-
Notifications
You must be signed in to change notification settings - Fork 0
/
ImportDataFrm.cs
162 lines (127 loc) · 4.86 KB
/
ImportDataFrm.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Data.OleDb;
using HR.Data;
using System.Configuration;
using System.Threading;
using Autodesk.AutoCAD.Interop.Common;
using Autodesk.AutoCAD.Interop;
using System.Reflection;
namespace CHXQ.XMManager
{
public partial class ImportDataFrm : Form
{
public ImportDataFrm()
{
InitializeComponent();
TxbLableMin.Text = CIni.ReadINI("DrawCAD", "LableMin");
TxbArrowMin.Text = CIni.ReadINI("DrawCAD", "ArrowMin");
//this.FormClosing += ImportDataFrm_FormClosing;
//AcadApp = (AcadApplication)System.Runtime.InteropServices.Marshal.GetActiveObject("AutoCAD.Application");
//AcadApp.Application.Visible = false;
//AcadDoc = AcadApp.ActiveDocument;
//AcadDoc.Close(false);
}
/* private void ImportDataFrm_FormClosing(object sender, FormClosingEventArgs e)
{
if (pWork != null)
{
if (pWork.IsBusy)
{
pWork.CancelAsync();
}
}
}
*/
//delegate void tabControldelegate(bool value);
private void BtnOpenExcel_Click(object sender, EventArgs e)
{
OpenFileDialog pDialog = new OpenFileDialog();
pDialog.Filter = "Excel文件|*.xls;*.xlsx|所有文件(*.*)|*.*";
pDialog.Title = "选择入库文件";
if (pDialog.ShowDialog() == DialogResult.OK)
{
txbExcelPath.Text = pDialog.FileName;
DataTable CurTable = ExcelClass.ReadExcelFile(pDialog.FileName, 0, 0, 0, true, 1);
if (!CurTable.Columns.Contains("起点点号") || !CurTable.Columns.Contains("终点点号"))
{
MessageBox.Show("选择的表格不符合格式要求","错误", MessageBoxButtons.OK, MessageBoxIcon.Stop);
txbExcelPath.Clear();
}
}
}
private void BtnSave_Click(object sender, EventArgs e)
{
//FolderBrowserDialog pDialog = new FolderBrowserDialog();
SaveFileDialog pDialog = new SaveFileDialog();
pDialog.Filter = "CAD文件|*.dwg";
pDialog.Title = "选择保存路径";
if (pDialog.ShowDialog() == DialogResult.OK)
{
TxbSaveDir.Text = pDialog.FileName;
}
}
public WorkArgument pWorkArgument;
private void BtnStart_Click(object sender, EventArgs e)
{
if (txbExcelPath.Text == string.Empty)
{
MessageBox.Show("请选择普查数据表格");
return;
}
if (TxbCoordFile.Text == string.Empty)
{
MessageBox.Show("请选择坐标数据表格");
return;
}
CIni.WriterINI("DrawCAD", "LableMin",TxbLableMin.Text);
CIni.WriterINI("DrawCAD", "ArrowMin", TxbArrowMin.Text);
pWorkArgument = new WorkArgument();
pWorkArgument.ExcelPath = txbExcelPath.Text;
pWorkArgument.DwgSavePath = TxbSaveDir.Text;
pWorkArgument.CoordExcelpath = TxbCoordFile.Text;
//pWorkArgument.ProjectName = txbProject.Text;
this.DialogResult = System.Windows.Forms.DialogResult.OK;
}
/* private void PWork_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
Progressup(e.ProgressPercentage);
}
*/
private void BtnCancle_Click(object sender, EventArgs e)
{
this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
}
private void BtnOpenCoordExcel_Click(object sender, EventArgs e)
{
OpenFileDialog pDialog = new OpenFileDialog();
pDialog.Filter = "Excel文件|*.xls;*.xlsx|所有文件(*.*)|*.*";
pDialog.Title = "选择入库文件";
if (pDialog.ShowDialog() == DialogResult.OK)
{
TxbCoordFile.Text = pDialog.FileName;
}
}
private void BtnOnline_Click(object sender, EventArgs e)
{
OnlineTable pOnlineTable = new OnlineTable();
pOnlineTable.Show();
}
}
public class WorkArgument
{
public string ExcelPath;
public string DwgSavePath;
public string CoordExcelpath;
//public string ProjectName;
//public string[] ImportTableNames;
//public string FieldYSFile;
}
}