using JavaCode.cs;
|
using System;
|
using System.Collections.Generic;
|
using System.ComponentModel;
|
using System.Data;
|
using System.Drawing;
|
using System.IO;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
using System.Windows.Forms;
|
|
namespace JavaCode
|
{
|
public partial class FrmSEM : Form
|
{
|
public FrmSEM()
|
{
|
InitializeComponent();
|
}
|
|
private void btnCalc_Click(object sender, EventArgs e)
|
{
|
try
|
{
|
string xls = this.txtExcel.Text.Trim();
|
string path = Path.GetDirectoryName(xls);
|
if (string.IsNullOrWhiteSpace(xls) || !File.Exists(xls))
|
{
|
MessageBox.Show("Excel文件路径为空或文件不存在!");
|
return;
|
}
|
|
DataTable dt = ReadExcel.ReadXls(xls, 0);
|
if (null == dt || dt.Rows.Count == 0)
|
{
|
MessageBox.Show("Excel内容为空!");
|
return;
|
}
|
|
List<Coord> list = ModelHandler.FillModel<Coord>(dt);
|
if (null == list || list.Count == 0)
|
{
|
MessageBox.Show("读取Excel内容为空!");
|
return;
|
}
|
|
int count = 0;
|
foreach (Coord c in list)
|
{
|
string db = Path.Combine(path, c.Name + ".sem");
|
if (!File.Exists(db)) continue;
|
|
SQLiteHelper.ConnectionString = string.Format("Data Source={0};Integrated Security=True;Max Pool Size=64", db);
|
|
string sql = string.Format("insert into POSITION (id, x, y, height) values ((select count(*)+1 from POSITION), {0}, {1}, {2})", c.X, c.Y, c.Z);
|
int rows = SQLiteHelper.ExecuteNonQuery(sql, null);
|
if (rows > 0)
|
{
|
count++;
|
}
|
}
|
|
MessageBox.Show("共更新了 " + count + " 个.sem文件!");
|
}
|
catch (Exception ex)
|
{
|
MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
|
}
|
}
|
}
|
|
public class Coord
|
{
|
public string Name { set; get; }
|
|
public string X { set; get; }
|
|
public string Y { set; get; }
|
|
public string Z { set; get; }
|
}
|
}
|