CNAS取数仪器端升级
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

frmDatabaseParams.cs 48KB

4 ay önce
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057
  1. using CnasSynchronusClient;
  2. using CnasSynchrousModel;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.ComponentModel;
  6. using System.Data;
  7. using System.Drawing;
  8. using System.IO;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Windows.Forms;
  12. using System.Xml.Serialization;
  13. namespace CNAS_DBSync
  14. {
  15. public delegate void InstrumentItemDataHanlder(Dictionary<string,DataTable> dictInstrument);
  16. public partial class frmDatabaseParams : Form
  17. {
  18. public SyncInstrumentItemInfo syncInstrumentItem = new SyncInstrumentItemInfo(); //仪器信息项
  19. public Dictionary<string, DataTable> dictInstrument = new Dictionary<string, DataTable>();
  20. public InstumentCodeHanlder InstrumentDelegate; //传递仪器编码委托
  21. public InstrumentItemDataHanlder InstrumentItemData; //传递仪器项委托
  22. private string strReadExcelMode = ""; //读取Excel数据模式
  23. private string strReadFoxproMode = ""; //读取Foxpro数据模式
  24. private string strReadTxtMode = "";//读取Txt数据模式
  25. private string strReadSqliteMode = ""; //读取sqlite数据模式
  26. private string strReadAccessMode = ""; //读取Access数据模式
  27. public DataBaseInfo targetDataBaseInfo = new DataBaseInfo(); //数据库
  28. public SqlServerFormatConfig sqlServerFormat { get; set; }
  29. public frmDatabaseParams(SyncInstrumentItemInfo syncInstrumentItem)
  30. {
  31. InitializeComponent();
  32. this.syncInstrumentItem = syncInstrumentItem;
  33. //读取Excel和FoxPro的模式
  34. strReadExcelMode = FileOperation.GetFormatConfigData<ExcelFormatConfig>("ExcelFormatConfig.xml").ReadExcelFileMode;
  35. strReadFoxproMode = FileOperation.GetFormatConfigData<FoxProFormatConfig>("FoxProFormatConfig.xml").ReadFoxProFileMode;
  36. strReadTxtMode = FileOperation.GetFormatConfigData<NormalFileFormatConfig>("NormalFileFormatConfig.xml").ReadNormalFileMode;
  37. strReadSqliteMode = FileOperation.GetFormatConfigData<SqliteFormatConfig>("SqliteFormatConfig.xml").ReadSqliteFileMode;
  38. strReadAccessMode = FileOperation.GetFormatConfigData<AccessFormatConfig>("AccessFormatConfig.xml").ReadAccessFileMode;
  39. sqlServerFormat = FileOperation.GetFormatConfigData<SqlServerFormatConfig>("SqlServerFormatConfig.xml");
  40. if (GlobalCommonOperation.strStartWebApi == "1")
  41. {
  42. this.txtDBHost.Enabled = false;
  43. this.txtDBName.Enabled = false;
  44. this.txtDBUser.Enabled = false;
  45. this.txtDBPwd.Enabled = false;
  46. this.txtPort.Enabled = false;
  47. btnCNASTestLink.Enabled = false;
  48. }
  49. }
  50. private void frmDatabaseParams_Load(object sender, EventArgs e)
  51. {
  52. tabExcel.Text = strReadExcelMode == "0" ? "Excel(文件)" : "Excel(文件夹)";
  53. tabFoxPro.Text = strReadFoxproMode == "0" ? "Foxpro(文件)" : "Foxpro(文件夹)";
  54. tabTxt.Text = strReadTxtMode == "0" ? "TXT(文件)" : "TXT(文件夹)";
  55. tabSQLite.Text = strReadSqliteMode == "0" ? "Sqlite(文件)" : "Sqlite(文件夹)";
  56. tabAccess.Text = strReadAccessMode == "0" ? "Access(文件)" : "Access(文件夹)";
  57. //if(sqlServerFormat)
  58. if (syncInstrumentItem.SyncInstrumentDSInfo == null)
  59. syncInstrumentItem.SyncInstrumentDSInfo = new InstrumentDataSourceInfo();
  60. //如果有旧值,加载旧的值
  61. switch (syncInstrumentItem.SyncInstrumentDSInfo.InstrumentDataSourceType)
  62. {
  63. case DataSourceType.Excel:
  64. this.tabcDS.SelectedIndex = 0;
  65. this.txtInportExcel.Text = syncInstrumentItem.SyncInstrumentDSInfo.Path;
  66. this.cbxExcelRemote.Checked= syncInstrumentItem.SyncInstrumentDSInfo.DsPathType == PathType.Local ? false : true;
  67. this.txtRemoteExcelUser.Text = syncInstrumentItem.SyncInstrumentDSInfo.RemoteUser;
  68. this.txtRemoteExcelPwd.Text = syncInstrumentItem.SyncInstrumentDSInfo.RemotePwd;
  69. break;
  70. case DataSourceType.FoxPro:
  71. this.tabcDS.SelectedIndex = 1;
  72. this.txtFoxProFolder.Text = syncInstrumentItem.SyncInstrumentDSInfo.Path;
  73. this.txtFoxProUserId.Text = syncInstrumentItem.SyncInstrumentDSInfo.UserId;
  74. this.txtFoxProPwd.Text = syncInstrumentItem.SyncInstrumentDSInfo.UserPwd;
  75. this.cbxFoxProRemote.Checked = syncInstrumentItem.SyncInstrumentDSInfo.DsPathType == PathType.Local ? false : true;
  76. this.txtRemoteFoxProUserId.Text = syncInstrumentItem.SyncInstrumentDSInfo.RemoteUser;
  77. this.txtRemoteFoxProPwd.Text = syncInstrumentItem.SyncInstrumentDSInfo.RemotePwd;
  78. break;
  79. case DataSourceType.Access:
  80. this.tabcDS.SelectedIndex = 2;
  81. this.txtAccessPath.Text = syncInstrumentItem.SyncInstrumentDSInfo.Path;
  82. this.txtAccessUser.Text = syncInstrumentItem.SyncInstrumentDSInfo.UserId;
  83. this.txtAceessPwd.Text = syncInstrumentItem.SyncInstrumentDSInfo.UserPwd;
  84. this.cbxAccessRemote.Checked = syncInstrumentItem.SyncInstrumentDSInfo.DsPathType == PathType.Local ? false : true;
  85. this.txtAccessRemoteUser.Text = syncInstrumentItem.SyncInstrumentDSInfo.RemoteUser;
  86. this.txtAccessRemotePwd.Text = syncInstrumentItem.SyncInstrumentDSInfo.RemotePwd;
  87. break;
  88. case DataSourceType.SQLLite:
  89. this.tabcDS.SelectedIndex = 3;
  90. this.txtSqlitePath.Text= syncInstrumentItem.SyncInstrumentDSInfo.Path;
  91. this.txtSqliteUser.Text = syncInstrumentItem.SyncInstrumentDSInfo.UserId;
  92. this.txtSqlitePwd.Text = syncInstrumentItem.SyncInstrumentDSInfo.UserPwd;
  93. this.cbxSqliteRemote.Checked = syncInstrumentItem.SyncInstrumentDSInfo.DsPathType == PathType.Local ? false : true;
  94. this.txtSqliteRemoteUser.Text = syncInstrumentItem.SyncInstrumentDSInfo.RemoteUser;
  95. this.txtSqliteRemotePwd.Text = syncInstrumentItem.SyncInstrumentDSInfo.RemotePwd;
  96. break;
  97. case DataSourceType.SQL:
  98. this.tabcDS.SelectedIndex = 4;
  99. this.txtSqlServerHost.Text = syncInstrumentItem.SyncInstrumentDSInfo.Host;
  100. this.txtSqlServerName.Text = syncInstrumentItem.SyncInstrumentDSInfo.ServerName;
  101. this.txtSqlServerUser.Text = syncInstrumentItem.SyncInstrumentDSInfo.UserId;
  102. this.txtSqlServerPwd.Text = syncInstrumentItem.SyncInstrumentDSInfo.UserPwd;
  103. //this.txtSqlServerConnect.Text = sqlServerFormat.SqlServerConnection;
  104. break;
  105. case DataSourceType.MySQL:
  106. this.tabcDS.SelectedIndex = 5;
  107. this.txtMySqlHost.Text= syncInstrumentItem.SyncInstrumentDSInfo.Host;
  108. this.txtMySqlServer.Text = syncInstrumentItem.SyncInstrumentDSInfo.ServerName;
  109. this.txtMySqlUser.Text = syncInstrumentItem.SyncInstrumentDSInfo.UserId;
  110. this.txtMySqlPwd.Text = syncInstrumentItem.SyncInstrumentDSInfo.UserPwd;
  111. this.txtMySqlPort.Text = syncInstrumentItem.SyncInstrumentDSInfo.Port ;
  112. break;
  113. case DataSourceType.Oracle:
  114. this.tabcDS.SelectedIndex = 6;
  115. this.txtOracleHost.Text = syncInstrumentItem.SyncInstrumentDSInfo.Host ;
  116. this.txtOracleSource.Text = syncInstrumentItem.SyncInstrumentDSInfo.ServerName;
  117. this.txtOracleUserId.Text = syncInstrumentItem.SyncInstrumentDSInfo.UserId;
  118. this.txtOraclePwd.Text = syncInstrumentItem.SyncInstrumentDSInfo.UserPwd;
  119. this.txtOraclePort.Text = syncInstrumentItem.SyncInstrumentDSInfo.Port;
  120. break;
  121. case DataSourceType.TXT:
  122. this.tabcDS.SelectedIndex = 7;
  123. this.txtInportTxt.Text = syncInstrumentItem.SyncInstrumentDSInfo.Path;
  124. this.cbxRemoteTxt.Checked = syncInstrumentItem.SyncInstrumentDSInfo.DsPathType == PathType.Local ? false : true;
  125. this.txtRemoteTxtUserId.Text = syncInstrumentItem.SyncInstrumentDSInfo.RemoteUser;
  126. this.txtRemoteTxtPwd.Text = syncInstrumentItem.SyncInstrumentDSInfo.RemotePwd;
  127. break;
  128. default:
  129. break;
  130. }
  131. //加载旧的CNAS数据库信息
  132. if (syncInstrumentItem.SyncTargetDBInfo != null)
  133. {
  134. targetDataBaseInfo = syncInstrumentItem.SyncTargetDBInfo;
  135. }
  136. else
  137. syncInstrumentItem.SyncTargetDBInfo = new DataBaseInfo();
  138. this.txtDBHost.Text = targetDataBaseInfo.DBHost;
  139. this.txtDBName.Text = targetDataBaseInfo.DBName;
  140. this.txtDBUser.Text = targetDataBaseInfo.DBUser;
  141. this.txtDBPwd.Text = targetDataBaseInfo.DBPwd;
  142. this.txtPort.Text= targetDataBaseInfo.DBPort;
  143. }
  144. private void btnOK_Click(object sender, EventArgs e)
  145. {
  146. //点击确定按钮
  147. //InstrumentData instrumentData = null;
  148. switch (syncInstrumentItem.SyncInstrumentDSInfo.InstrumentDataSourceType)
  149. {
  150. case DataSourceType.Access:
  151. syncInstrumentItem.SyncInstrumentDSInfo.Path = this.txtAccessPath.Text.Trim();
  152. syncInstrumentItem.SyncInstrumentDSInfo.Host = "";
  153. syncInstrumentItem.SyncInstrumentDSInfo.ServerName = "";
  154. syncInstrumentItem.SyncInstrumentDSInfo.UserId = this.txtAccessUser.Text.Trim();
  155. syncInstrumentItem.SyncInstrumentDSInfo.UserPwd = this.txtAceessPwd.Text.Trim();
  156. syncInstrumentItem.SyncInstrumentDSInfo.DsPathType = this.cbxAccessRemote.Checked ? PathType.Remote : PathType.Local;
  157. syncInstrumentItem.SyncInstrumentDSInfo.RemoteUser = this.txtAccessRemoteUser.Text.Trim();
  158. syncInstrumentItem.SyncInstrumentDSInfo.RemotePwd = this.txtAccessRemotePwd.Text.Trim();
  159. break;
  160. case DataSourceType.SQLLite:
  161. syncInstrumentItem.SyncInstrumentDSInfo.Path = this.txtSqlitePath.Text.Trim();
  162. syncInstrumentItem.SyncInstrumentDSInfo.Host = "";
  163. syncInstrumentItem.SyncInstrumentDSInfo.ServerName = "";
  164. syncInstrumentItem.SyncInstrumentDSInfo.UserId = this.txtSqliteUser.Text.Trim();
  165. syncInstrumentItem.SyncInstrumentDSInfo.UserPwd = this.txtSqlitePwd.Text.Trim();
  166. syncInstrumentItem.SyncInstrumentDSInfo.DsPathType = this.cbxSqliteRemote.Checked ? PathType.Remote : PathType.Local;
  167. syncInstrumentItem.SyncInstrumentDSInfo.RemoteUser = this.txtSqliteRemoteUser.Text.Trim();
  168. syncInstrumentItem.SyncInstrumentDSInfo.RemotePwd = this.txtSqliteRemotePwd.Text.Trim();
  169. break;
  170. case DataSourceType.SQL:
  171. syncInstrumentItem.SyncInstrumentDSInfo.Host = this.txtSqlServerHost.Text.Trim();
  172. syncInstrumentItem.SyncInstrumentDSInfo.ServerName = this.txtSqlServerName.Text.Trim();
  173. syncInstrumentItem.SyncInstrumentDSInfo.UserId = this.txtSqlServerUser.Text.Trim();
  174. syncInstrumentItem.SyncInstrumentDSInfo.UserPwd = this.txtSqlServerPwd.Text.Trim();
  175. break;
  176. case DataSourceType.MySQL:
  177. syncInstrumentItem.SyncInstrumentDSInfo.Host = this.txtMySqlHost.Text.Trim();
  178. syncInstrumentItem.SyncInstrumentDSInfo.ServerName = this.txtMySqlServer.Text.Trim();
  179. syncInstrumentItem.SyncInstrumentDSInfo.UserId = this.txtMySqlUser.Text.Trim();
  180. syncInstrumentItem.SyncInstrumentDSInfo.UserPwd = this.txtMySqlPwd.Text.Trim();
  181. syncInstrumentItem.SyncInstrumentDSInfo.Port = this.txtMySqlPort.Text.Trim();
  182. break;
  183. case DataSourceType.Oracle:
  184. syncInstrumentItem.SyncInstrumentDSInfo.Host = this.txtOracleHost.Text.Trim();
  185. syncInstrumentItem.SyncInstrumentDSInfo.ServerName = this.txtOracleSource.Text.Trim();
  186. syncInstrumentItem.SyncInstrumentDSInfo.UserId = this.txtOracleUserId.Text.Trim();
  187. syncInstrumentItem.SyncInstrumentDSInfo.UserPwd = this.txtOraclePwd.Text.Trim();
  188. syncInstrumentItem.SyncInstrumentDSInfo.Port = this.txtOraclePort.Text.Trim();
  189. break;
  190. case DataSourceType.FoxPro:
  191. syncInstrumentItem.SyncInstrumentDSInfo.Path = this.txtFoxProFolder.Text.Trim();
  192. syncInstrumentItem.SyncInstrumentDSInfo.Host = "";
  193. syncInstrumentItem.SyncInstrumentDSInfo.ServerName = "";
  194. syncInstrumentItem.SyncInstrumentDSInfo.UserId = this.txtFoxProUserId.Text.Trim();
  195. syncInstrumentItem.SyncInstrumentDSInfo.UserPwd = this.txtFoxProPwd.Text.Trim();
  196. syncInstrumentItem.SyncInstrumentDSInfo.DsPathType = this.cbxFoxProRemote.Checked ? PathType.Remote : PathType.Local;
  197. syncInstrumentItem.SyncInstrumentDSInfo.RemoteUser = this.txtRemoteFoxProUserId.Text.Trim();
  198. syncInstrumentItem.SyncInstrumentDSInfo.RemotePwd = this.txtRemoteFoxProPwd.Text.Trim();
  199. break;
  200. case DataSourceType.TXT:
  201. syncInstrumentItem.SyncInstrumentDSInfo.Path = this.txtInportTxt.Text.Trim();
  202. syncInstrumentItem.SyncInstrumentDSInfo.Host = "";
  203. syncInstrumentItem.SyncInstrumentDSInfo.ServerName = "";
  204. syncInstrumentItem.SyncInstrumentDSInfo.UserId = "";
  205. syncInstrumentItem.SyncInstrumentDSInfo.UserPwd = "";
  206. syncInstrumentItem.SyncInstrumentDSInfo.DsPathType = this.cbxRemoteTxt.Checked ? PathType.Remote : PathType.Local;
  207. syncInstrumentItem.SyncInstrumentDSInfo.RemoteUser = this.txtRemoteTxtUserId.Text.Trim();
  208. syncInstrumentItem.SyncInstrumentDSInfo.RemotePwd = this.txtRemoteTxtPwd.Text.Trim();
  209. break;
  210. case DataSourceType.Excel:
  211. default:
  212. syncInstrumentItem.SyncInstrumentDSInfo.Path = this.txtInportExcel.Text.Trim();
  213. syncInstrumentItem.SyncInstrumentDSInfo.Host = "";
  214. syncInstrumentItem.SyncInstrumentDSInfo.ServerName = "";
  215. syncInstrumentItem.SyncInstrumentDSInfo.UserId = "";
  216. syncInstrumentItem.SyncInstrumentDSInfo.UserPwd = "";
  217. syncInstrumentItem.SyncInstrumentDSInfo.DsPathType = this.cbxExcelRemote.Checked ? PathType.Remote : PathType.Local;
  218. syncInstrumentItem.SyncInstrumentDSInfo.RemoteUser = this.txtRemoteExcelUser.Text.Trim();
  219. syncInstrumentItem.SyncInstrumentDSInfo.RemotePwd = this.txtRemoteExcelPwd.Text.Trim();
  220. break;
  221. }
  222. object[] obj = new object[] { "", "", "" };
  223. //instrumentData = InstrumentDataFact.CreateInstrumentDataSource(syncInstrumentItem.SyncInstrumentDSInfo, obj);
  224. //dictInstrument = instrumentData.GetInstrumentData();
  225. //目标库的信息
  226. if (GlobalCommonOperation.strStartWebApi != "1")
  227. {
  228. syncInstrumentItem.SyncTargetDBInfo.DBHost = this.txtDBHost.Text.Trim();
  229. syncInstrumentItem.SyncTargetDBInfo.DBName = this.txtDBName.Text.Trim();
  230. syncInstrumentItem.SyncTargetDBInfo.DBUser = this.txtDBUser.Text.Trim();
  231. syncInstrumentItem.SyncTargetDBInfo.DBPwd = this.txtDBPwd.Text.Trim();
  232. syncInstrumentItem.SyncTargetDBInfo.DBPort = this.txtPort.Text.Trim();
  233. }
  234. else
  235. syncInstrumentItem.SyncTargetDBInfo = targetDataBaseInfo;
  236. this.InstrumentDelegate(syncInstrumentItem);
  237. //this.InstrumentItemData(dictInstrument);
  238. this.Close();
  239. }
  240. private void btnOpenFileExcel_Click(object sender, EventArgs e)
  241. {
  242. if (syncInstrumentItem.Code == null) return;
  243. if (syncInstrumentItem.SyncInstrumentDSInfo == null)
  244. syncInstrumentItem.SyncInstrumentDSInfo = new InstrumentDataSourceInfo();
  245. syncInstrumentItem.SyncInstrumentDSInfo.InstrumentDataSourceType = DataSourceType.Excel;
  246. if (strReadExcelMode == "0")
  247. {
  248. OpenFileDialog openFile = new OpenFileDialog
  249. {
  250. Filter = "Excel(*.xlsx)|*.xlsx|Excel(*.xls)|*.xls",
  251. InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop),
  252. Multiselect = false
  253. };
  254. if (openFile.ShowDialog() == DialogResult.Cancel) return;
  255. this.txtInportExcel.Text = syncInstrumentItem.SyncInstrumentDSInfo.Path = openFile.FileName;
  256. string fileType = System.IO.Path.GetExtension(openFile.FileName);
  257. if (string.IsNullOrEmpty(fileType)) return;
  258. }
  259. else
  260. {
  261. FolderBrowserDialog dialog = new FolderBrowserDialog();
  262. dialog.Description = "请选择文件路径";
  263. if (dialog.ShowDialog() == DialogResult.Cancel) return;
  264. this.txtInportExcel.Text = syncInstrumentItem.SyncInstrumentDSInfo.Path = dialog.SelectedPath;
  265. }
  266. }
  267. private void tabcDS_Selected(object sender, TabControlEventArgs e)
  268. {
  269. //切换的时候,检查其他类型数据源是否有值,如果有值,将提示删除旧值才能配置新值
  270. if (e.TabPage == tabExcel)
  271. {
  272. //检查tabAccess页面是否为空 //检查tabSQLite页面是否为空
  273. if (!CheckAccessControl() || !CheckSQLiteControl()|| !CheckSQLServerControl()||!CheckMySqlControl() || !CheckOracleControl()||!CheckFoxproControl()||!CheckTxtControl())
  274. {
  275. if (MessageBox.Show("其他数据源存在已保存数据,继续将删除这些值,是否继续", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
  276. {
  277. ClearAccessControl();
  278. ClearSqliteControl();
  279. ClearSQLServerControl();
  280. ClearMySQLControl();
  281. ClearOracleControl();
  282. ClearFoxproControl();
  283. ClearTxtControl();
  284. ClearObjectValue();
  285. }
  286. else
  287. {
  288. ChangeSelectTabPageByType();
  289. return;
  290. }
  291. }
  292. syncInstrumentItem.SyncInstrumentDSInfo.InstrumentDataSourceType = DataSourceType.Excel;
  293. }
  294. if (e.TabPage == tabAccess)
  295. {
  296. //检查tabAccess页面是否为空 //检查tabSQLite页面是否为空
  297. if (!CheckExcelControl() || !CheckSQLiteControl() || !CheckSQLServerControl() || !CheckMySqlControl() || !CheckOracleControl() || !CheckFoxproControl() || !CheckTxtControl())
  298. {
  299. if (MessageBox.Show("其他数据源存在已保存数据,继续将删除这些值,是否继续", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
  300. {
  301. ClearExcelControl();
  302. ClearSqliteControl();
  303. ClearSQLServerControl();
  304. ClearMySQLControl();
  305. ClearOracleControl();
  306. ClearFoxproControl();
  307. ClearTxtControl();
  308. ClearObjectValue();
  309. }
  310. else
  311. {
  312. ChangeSelectTabPageByType();
  313. return;
  314. }
  315. }
  316. syncInstrumentItem.SyncInstrumentDSInfo.InstrumentDataSourceType = DataSourceType.Access;
  317. }
  318. if (e.TabPage == tabSQLite)
  319. {
  320. //检查tabAccess页面是否为空 //检查tabSQLite页面是否为空
  321. if (!CheckExcelControl() || !CheckAccessControl() || !CheckSQLServerControl() || !CheckMySqlControl() || !CheckOracleControl() || !CheckFoxproControl() || !CheckTxtControl())
  322. {
  323. if (MessageBox.Show("其他数据源存在已保存数据,继续将删除这些值,是否继续", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
  324. {
  325. ClearAccessControl();
  326. ClearExcelControl();
  327. ClearSQLServerControl();
  328. ClearMySQLControl();
  329. ClearOracleControl();
  330. ClearFoxproControl();
  331. ClearTxtControl();
  332. ClearObjectValue();
  333. }
  334. else
  335. {
  336. ChangeSelectTabPageByType();
  337. return;
  338. }
  339. }
  340. syncInstrumentItem.SyncInstrumentDSInfo.InstrumentDataSourceType = DataSourceType.SQLLite;
  341. }
  342. if (e.TabPage == tabSQLServer)
  343. {
  344. //检查tabAccess页面是否为空 //检查tabSQLite页面是否为空
  345. if (!CheckExcelControl() || !CheckAccessControl() || !CheckSQLiteControl() || !CheckMySqlControl() || !CheckOracleControl() || !CheckFoxproControl() || !CheckTxtControl())
  346. {
  347. if (MessageBox.Show("其他数据源存在已保存数据,继续将删除这些值,是否继续", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
  348. {
  349. ClearAccessControl();
  350. ClearExcelControl();
  351. ClearSqliteControl();
  352. ClearMySQLControl();
  353. ClearOracleControl();
  354. ClearFoxproControl();
  355. ClearTxtControl();
  356. ClearObjectValue();
  357. }
  358. else
  359. {
  360. ChangeSelectTabPageByType();
  361. return;
  362. }
  363. }
  364. syncInstrumentItem.SyncInstrumentDSInfo.InstrumentDataSourceType = DataSourceType.SQL;
  365. }
  366. if (e.TabPage == tabMySql)
  367. {
  368. //检查tabAccess页面是否为空 //检查tabSQLite页面是否为空
  369. if (!CheckExcelControl() || !CheckAccessControl() || !CheckSQLiteControl() || !CheckSQLServerControl()||!CheckOracleControl() || !CheckFoxproControl() || !CheckTxtControl())
  370. {
  371. if (MessageBox.Show("其他数据源存在已保存数据,继续将删除这些值,是否继续", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
  372. {
  373. ClearAccessControl();
  374. ClearExcelControl();
  375. ClearSqliteControl();
  376. ClearSQLServerControl();
  377. ClearOracleControl();
  378. ClearFoxproControl();
  379. ClearTxtControl();
  380. ClearObjectValue();
  381. }
  382. else
  383. {
  384. ChangeSelectTabPageByType();
  385. return;
  386. }
  387. }
  388. syncInstrumentItem.SyncInstrumentDSInfo.InstrumentDataSourceType = DataSourceType.MySQL;
  389. }
  390. if (e.TabPage == tabOracle)
  391. {
  392. //检查tabAccess页面是否为空 //检查tabSQLite页面是否为空
  393. if (!CheckExcelControl() || !CheckAccessControl() || !CheckSQLiteControl() || !CheckSQLServerControl()||!CheckMySqlControl() || !CheckFoxproControl() || !CheckTxtControl())
  394. {
  395. if (MessageBox.Show("其他数据源存在已保存数据,继续将删除这些值,是否继续", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
  396. {
  397. ClearAccessControl();
  398. ClearExcelControl();
  399. ClearSqliteControl();
  400. ClearSQLServerControl();
  401. ClearMySQLControl();
  402. ClearFoxproControl();
  403. ClearTxtControl();
  404. ClearObjectValue();
  405. }
  406. else
  407. {
  408. ChangeSelectTabPageByType();
  409. return;
  410. }
  411. }
  412. syncInstrumentItem.SyncInstrumentDSInfo.InstrumentDataSourceType = DataSourceType.Oracle;
  413. }
  414. if (e.TabPage == tabFoxPro)
  415. {
  416. if (!CheckExcelControl() || !CheckAccessControl() || !CheckSQLiteControl() || !CheckSQLServerControl() || !CheckMySqlControl() || !CheckOracleControl() || !CheckTxtControl())
  417. {
  418. if (MessageBox.Show("其他数据源存在已保存数据,继续将删除这些值,是否继续", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
  419. {
  420. ClearAccessControl();
  421. ClearExcelControl();
  422. ClearSqliteControl();
  423. ClearSQLServerControl();
  424. ClearMySQLControl();
  425. ClearOracleControl();
  426. ClearTxtControl();
  427. ClearObjectValue();
  428. }
  429. else
  430. {
  431. ChangeSelectTabPageByType();
  432. return;
  433. }
  434. }
  435. syncInstrumentItem.SyncInstrumentDSInfo.InstrumentDataSourceType = DataSourceType.FoxPro;
  436. }
  437. if (e.TabPage == tabTxt)
  438. {
  439. if (!CheckExcelControl() || !CheckAccessControl() || !CheckSQLiteControl() || !CheckSQLServerControl() || !CheckMySqlControl() || !CheckOracleControl() || !CheckFoxproControl())
  440. {
  441. if (MessageBox.Show("其他数据源存在已保存数据,继续将删除这些值,是否继续", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
  442. {
  443. ClearAccessControl();
  444. ClearExcelControl();
  445. ClearSqliteControl();
  446. ClearSQLServerControl();
  447. ClearMySQLControl();
  448. ClearOracleControl();
  449. ClearFoxproControl();
  450. ClearObjectValue();
  451. }
  452. else
  453. {
  454. ChangeSelectTabPageByType();
  455. return;
  456. }
  457. }
  458. syncInstrumentItem.SyncInstrumentDSInfo.InstrumentDataSourceType = DataSourceType.TXT;
  459. }
  460. }
  461. //根据数据源类型切换Tab页
  462. private void ChangeSelectTabPageByType()
  463. {
  464. switch (syncInstrumentItem.SyncInstrumentDSInfo.InstrumentDataSourceType)
  465. {
  466. case DataSourceType.SQLLite:
  467. tabcDS.SelectedTab = tabSQLite;
  468. break;
  469. case DataSourceType.Access:
  470. tabcDS.SelectedTab = tabAccess;
  471. break;
  472. case DataSourceType.SQL:
  473. tabcDS.SelectedTab = tabSQLServer;
  474. break;
  475. case DataSourceType.Oracle:
  476. tabcDS.SelectedTab=tabOracle;
  477. break;
  478. case DataSourceType.FoxPro:
  479. tabcDS.SelectedTab = tabFoxPro;
  480. break;
  481. case DataSourceType.TXT:
  482. tabcDS.SelectedTab = tabTxt;
  483. break;
  484. case DataSourceType.Excel:
  485. default:
  486. tabcDS.SelectedTab = tabExcel;
  487. break;
  488. }
  489. }
  490. private bool CheckExcelControl()
  491. {
  492. if (this.txtInportExcel.Text != "")
  493. return false;
  494. else
  495. return true;
  496. }
  497. private bool CheckAccessControl()
  498. {
  499. if (this.txtAccessPath.Text != "" || this.txtAccessUser.Text != "" || this.txtAceessPwd.Text != "")
  500. return false;
  501. else
  502. return true;
  503. }
  504. private bool CheckSQLiteControl()
  505. {
  506. if (this.txtSqlitePath.Text != "" || this.txtSqliteUser.Text != "" || this.txtSqlitePwd.Text != "")
  507. return false;
  508. else
  509. return true;
  510. }
  511. private bool CheckSQLServerControl()
  512. {
  513. if (this.txtSqlServerHost.Text.Trim() != "" || this.txtSqlServerName.Text.Trim() != "" || this.txtSqlServerPwd.Text.Trim() != "" || this.txtSqlServerUser.Text.Trim() != "")
  514. return false;
  515. else
  516. return true;
  517. }
  518. private bool CheckMySqlControl()
  519. {
  520. if (this.txtMySqlHost.Text.Trim() != "" || this.txtMySqlServer.Text.Trim() != "" || this.txtMySqlUser.Text.Trim() != "" || this.txtMySqlPwd.Text.Trim() != ""|| this.txtMySqlPort.Text.Trim()!="")
  521. return false;
  522. else
  523. return true;
  524. }
  525. private bool CheckOracleControl()
  526. {
  527. if (this.txtOraclePort.Text.Trim() != "" || this.txtOraclePwd.Text.Trim() != ""||this.txtOracleHost.Text.Trim()!="" || this.txtOracleSource.Text.Trim() != "" || this.txtOracleUserId.Text.Trim() != "")
  528. return false;
  529. else
  530. return true;
  531. }
  532. private bool CheckFoxproControl()
  533. {
  534. if (this.txtFoxProFolder.Text.Trim() != "" || this.txtFoxProUserId.Text.Trim() != "" || this.txtFoxProPwd.Text.Trim() != "" || this.txtRemoteFoxProUserId.Text.Trim() != "" || this.txtRemoteFoxProPwd.Text.Trim() != "")
  535. {
  536. return false;
  537. }
  538. else
  539. return true;
  540. }
  541. private bool CheckTxtControl()
  542. {
  543. if (this.txtInportTxt.Text.Trim() != "" || this.txtRemoteTxtUserId.Text.Trim() != "" || this.txtRemoteTxtPwd.Text.Trim() != "")
  544. return false;
  545. else
  546. return true;
  547. }
  548. private void btnCNASTestLink_Click(object sender, EventArgs e)
  549. {
  550. //this.txtDBHost.Text.Trim(), this.txtDBName.Text.Trim(), this.txtDBUser.Text.Trim(), this.txtDBPwd.Text.Trim(),this.txtPort.Text.Trim()
  551. if (CnasDataOperationFact.CnasDataOperation().TestConnect(new DataBaseInfo()
  552. {
  553. DBHost= this.txtDBHost.Text.Trim(),
  554. DBName= this.txtDBName.Text.Trim(),
  555. DBUser= this.txtDBUser.Text.Trim(),
  556. DBPwd= this.txtDBPwd.Text.Trim(),
  557. DBPort= this.txtPort.Text.Trim()
  558. }))
  559. MessageBox.Show("连接成功!");
  560. else
  561. MessageBox.Show("连接失败!");
  562. }
  563. private void ClearExcelControl()
  564. {
  565. this.txtInportExcel.Text = "";
  566. this.txtRemoteExcelUser.Text = "";
  567. this.txtRemoteExcelPwd.Text = "";
  568. }
  569. private void ClearAccessControl()
  570. {
  571. this.txtAccessPath.Text = "";
  572. this.txtAccessUser.Text = "";
  573. this.txtAceessPwd.Text = "";
  574. this.txtAccessRemoteUser.Text = "";
  575. this.txtAccessRemotePwd.Text = "";
  576. }
  577. private void ClearSqliteControl()
  578. {
  579. this.txtSqliteUser.Text = "";
  580. this.txtSqlitePath.Text = "";
  581. this.txtSqlitePwd.Text = "";
  582. this.txtSqliteRemoteUser.Text = "";
  583. this.txtSqliteRemotePwd.Text = "";
  584. }
  585. private void ClearSQLServerControl()
  586. {
  587. this.txtSqlServerHost.Text = "";
  588. this.txtSqlServerName.Text = "";
  589. this.txtSqlServerUser.Text = "";
  590. this.txtSqlServerPwd.Text = "";
  591. }
  592. private void ClearMySQLControl()
  593. {
  594. this.txtMySqlHost.Text = "";
  595. this.txtMySqlServer.Text = "";
  596. this.txtMySqlUser.Text = "";
  597. this.txtMySqlPwd.Text = "";
  598. this.txtMySqlPort.Text = "";
  599. }
  600. private void ClearOracleControl()
  601. {
  602. this.txtOracleHost.Text = "";
  603. this.txtOracleSource.Text = "";
  604. this.txtOracleUserId.Text = "";
  605. this.txtOraclePwd.Text = "";
  606. this.txtOraclePort.Text = "";
  607. }
  608. private void ClearFoxproControl()
  609. {
  610. this.txtFoxProFolder.Text = "";
  611. this.txtFoxProUserId.Text = "";
  612. this.txtFoxProPwd.Text = "";
  613. this.txtRemoteFoxProUserId.Text = "";
  614. this.txtRemoteFoxProPwd.Text = "";
  615. }
  616. private void ClearTxtControl()
  617. {
  618. this.txtInportTxt.Text = "";
  619. this.txtRemoteTxtUserId.Text = "";
  620. this.txtRemoteTxtPwd.Text = "";
  621. }
  622. /// <summary>
  623. /// 清空对象中存储的值
  624. /// </summary>
  625. private void ClearObjectValue()
  626. {
  627. syncInstrumentItem.SyncInstrumentDSInfo.Host = "";
  628. syncInstrumentItem.SyncInstrumentDSInfo.ServerName = "";
  629. syncInstrumentItem.SyncInstrumentDSInfo.Path = "";
  630. syncInstrumentItem.SyncInstrumentDSInfo.UserId = "";
  631. syncInstrumentItem.SyncInstrumentDSInfo.UserPwd = "";
  632. syncInstrumentItem.SyncInstrumentDSInfo.Port = "";
  633. syncInstrumentItem.SyncInstrumentDSInfo.DsPathType = PathType.Local;
  634. syncInstrumentItem.SyncInstrumentDSInfo.RemoteUser = "";
  635. syncInstrumentItem.SyncInstrumentDSInfo.RemotePwd = "";
  636. }
  637. private void btnOpenFileAccess_Click(object sender, EventArgs e)
  638. {
  639. if (syncInstrumentItem.Code == null) return;
  640. if (syncInstrumentItem.SyncInstrumentDSInfo == null)
  641. syncInstrumentItem.SyncInstrumentDSInfo = new InstrumentDataSourceInfo();
  642. syncInstrumentItem.SyncInstrumentDSInfo.InstrumentDataSourceType = DataSourceType.Access;
  643. if (strReadAccessMode == "0")
  644. {
  645. OpenFileDialog openFile = new OpenFileDialog
  646. {
  647. Filter = "Microsoft Access(*.mdb)|*.mdb|Microsoft Access(*.accdb)|*.accdb",
  648. InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop),
  649. Multiselect = false
  650. };
  651. if (openFile.ShowDialog() == DialogResult.Cancel) return;
  652. this.txtAccessPath.Text = syncInstrumentItem.SyncInstrumentDSInfo.Path = openFile.FileName;
  653. string fileType = System.IO.Path.GetExtension(openFile.FileName);
  654. if (string.IsNullOrEmpty(fileType)) return;
  655. }
  656. else
  657. {
  658. FolderBrowserDialog dialog = new FolderBrowserDialog();
  659. dialog.Description = "请选择文件路径";
  660. if (dialog.ShowDialog() == DialogResult.Cancel) return;
  661. this.txtAccessPath.Text = syncInstrumentItem.SyncInstrumentDSInfo.Path = dialog.SelectedPath;
  662. }
  663. }
  664. private void btnOpenFileSQLite_Click(object sender, EventArgs e)
  665. {
  666. if (syncInstrumentItem.Code == null) return;
  667. if (syncInstrumentItem.SyncInstrumentDSInfo == null)
  668. syncInstrumentItem.SyncInstrumentDSInfo = new InstrumentDataSourceInfo();
  669. syncInstrumentItem.SyncInstrumentDSInfo.InstrumentDataSourceType = DataSourceType.SQLLite;
  670. if (strReadSqliteMode == "0")
  671. {
  672. OpenFileDialog openFile = new OpenFileDialog
  673. {
  674. Filter = "SQLite(*.db)|*.db",
  675. InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop),
  676. Multiselect = false
  677. };
  678. if (openFile.ShowDialog() == DialogResult.Cancel) return;
  679. this.txtSqlitePath.Text = syncInstrumentItem.SyncInstrumentDSInfo.Path = openFile.FileName;
  680. string fileType = System.IO.Path.GetExtension(openFile.FileName);
  681. if (string.IsNullOrEmpty(fileType)) return;
  682. }
  683. else
  684. {
  685. FolderBrowserDialog dialog = new FolderBrowserDialog();
  686. dialog.Description = "请选择文件路径";
  687. if (dialog.ShowDialog() == DialogResult.Cancel) return;
  688. this.txtSqlitePath.Text = syncInstrumentItem.SyncInstrumentDSInfo.Path = dialog.SelectedPath;
  689. }
  690. }
  691. private void btnTestSQLLink_Click(object sender, EventArgs e)
  692. {
  693. if (this.txtSqlServerHost.Text.Trim() == "" || this.txtSqlServerName.Text.Trim() == "" || this.txtSqlServerUser.Text.Trim() == "")
  694. {
  695. MessageBox.Show("请填写相关连接信息。");
  696. return;
  697. }
  698. InstrumentDataSourceInfo dbinfo = new InstrumentDataSourceInfo();
  699. dbinfo.Host = this.txtSqlServerHost.Text.Trim();
  700. dbinfo.ServerName = this.txtSqlServerName.Text.Trim();
  701. dbinfo.UserId = this.txtSqlServerUser.Text.Trim();
  702. dbinfo.UserPwd = this.txtSqlServerPwd.Text.Trim();
  703. dbinfo.Port = this.txtSqlServerPort.Text.Trim();
  704. if (new SQLServerInstrumentData(dbinfo, new object[] {
  705. "",
  706. "",
  707. ""
  708. }).TestSQLServerLink())
  709. MessageBox.Show("连接成功!");
  710. else
  711. MessageBox.Show("连接失败!");
  712. }
  713. private void cbxExcelRemote_CheckedChanged(object sender, EventArgs e)
  714. {
  715. if (!cbxExcelRemote.Checked)
  716. {
  717. this.btnOpenFileExcel.Visible = true;
  718. lblExcelRemotePwd.Visible = false;
  719. lblExcelRemoteUser.Visible = false;
  720. txtRemoteExcelUser.Visible = false;
  721. txtRemoteExcelPwd.Visible = false;
  722. }
  723. else
  724. {
  725. this.btnOpenFileExcel.Visible = false;
  726. lblExcelRemotePwd.Visible = true;
  727. lblExcelRemoteUser.Visible = true;
  728. txtRemoteExcelUser.Visible = true;
  729. txtRemoteExcelPwd.Visible = true;
  730. }
  731. }
  732. private void cbxAccessRemote_CheckedChanged(object sender, EventArgs e)
  733. {
  734. if (cbxAccessRemote.Checked)
  735. {
  736. btnOpenFileAccess.Visible = false;
  737. lblAccessRemoteUser.Visible = true;
  738. lblAccessRemotePwd.Visible = true;
  739. txtAccessRemoteUser.Visible = true;
  740. txtAccessRemotePwd.Visible = true;
  741. }
  742. else
  743. {
  744. btnOpenFileAccess.Visible = true;
  745. lblAccessRemoteUser.Visible = false;
  746. lblAccessRemotePwd.Visible = false;
  747. txtAccessRemoteUser.Visible = false;
  748. txtAccessRemotePwd.Visible = false;
  749. }
  750. }
  751. private void cbxSqliteRemote_CheckedChanged(object sender, EventArgs e)
  752. {
  753. if (cbxSqliteRemote.Checked)
  754. {
  755. btnOpenFileSQLite.Visible = false;
  756. lblSqliteRemoteUser.Visible = true;
  757. lblSqliteRemotePwd.Visible = true;
  758. txtSqliteRemoteUser.Visible = true;
  759. txtSqliteRemotePwd.Visible = true;
  760. }
  761. else
  762. {
  763. btnOpenFileSQLite.Visible = true;
  764. lblSqliteRemoteUser.Visible = false;
  765. lblSqliteRemotePwd.Visible = false;
  766. txtSqliteRemoteUser.Visible = false;
  767. txtSqliteRemotePwd.Visible = false;
  768. }
  769. }
  770. private void btnMySqlTest_Click(object sender, EventArgs e)
  771. {
  772. if (CnasDataOperationFact.CnasDataOperation().TestConnect(new DataBaseInfo()
  773. {
  774. DBHost = this.txtMySqlHost.Text.Trim(),
  775. DBName = this.txtMySqlServer.Text.Trim(),
  776. DBUser = this.txtMySqlUser.Text.Trim(),
  777. DBPwd = this.txtMySqlPwd.Text.Trim(),
  778. DBPort = this.txtMySqlPort.Text.Trim()
  779. }))
  780. MessageBox.Show("连接成功!");
  781. else
  782. MessageBox.Show("连接失败!");
  783. }
  784. private void btnOracleTestLink_Click(object sender, EventArgs e)
  785. {
  786. if (this.txtOracleHost.Text.Trim()==""||this.txtOracleSource.Text.Trim() == "" || this.txtOracleUserId.Text.Trim() == ""|| this.txtOraclePort.Text.Trim() == "")
  787. {
  788. MessageBox.Show("请填写相关连接信息。");
  789. return;
  790. }
  791. InstrumentDataSourceInfo dbinfo = new InstrumentDataSourceInfo();
  792. dbinfo.Host = this.txtOracleHost.Text.Trim();
  793. dbinfo.ServerName = this.txtOracleSource.Text.Trim();
  794. dbinfo.UserId = this.txtOracleUserId.Text.Trim();
  795. dbinfo.UserPwd = this.txtOraclePwd.Text.Trim();
  796. dbinfo.Port = this.txtOraclePort.Text.Trim();
  797. if (new OracleInstrumentData(dbinfo, new object[] {
  798. "",
  799. "",
  800. ""
  801. }).TestSQLServerLink())
  802. MessageBox.Show("连接成功!");
  803. else
  804. MessageBox.Show("连接失败!");
  805. }
  806. private void txtFileOpenFoxPro_Click(object sender, EventArgs e)
  807. {
  808. if (syncInstrumentItem.Code == null) return;
  809. if (syncInstrumentItem.SyncInstrumentDSInfo == null)
  810. syncInstrumentItem.SyncInstrumentDSInfo = new InstrumentDataSourceInfo();
  811. syncInstrumentItem.SyncInstrumentDSInfo.InstrumentDataSourceType = DataSourceType.FoxPro;
  812. if (strReadFoxproMode == "0")
  813. {
  814. OpenFileDialog openFile = new OpenFileDialog
  815. {
  816. Filter = "Foxpro文件(*.dbf)|*.dbf",
  817. InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop),
  818. Multiselect = false
  819. };
  820. if (openFile.ShowDialog() == DialogResult.Cancel) return;
  821. this.txtFoxProFolder.Text = syncInstrumentItem.SyncInstrumentDSInfo.Path = openFile.FileName;
  822. string fileType = System.IO.Path.GetExtension(openFile.FileName);
  823. if (string.IsNullOrEmpty(fileType)) return;
  824. }
  825. else
  826. {
  827. FolderBrowserDialog dialog = new FolderBrowserDialog();
  828. dialog.Description = "请选择文件路径";
  829. if (dialog.ShowDialog() == DialogResult.Cancel) return;
  830. this.txtFoxProFolder.Text = syncInstrumentItem.SyncInstrumentDSInfo.Path = dialog.SelectedPath;
  831. }
  832. }
  833. private void cbxFoxProRemote_CheckedChanged(object sender, EventArgs e)
  834. {
  835. if (!cbxFoxProRemote.Checked)
  836. {
  837. this.btnFileOpenFoxPro.Visible = true;
  838. lblFoxproRemoteUserId.Visible = false;
  839. lblFoxproRemotePwd.Visible = false;
  840. txtRemoteFoxProUserId.Visible = false;
  841. txtRemoteFoxProPwd.Visible = false;
  842. }
  843. else
  844. {
  845. this.btnFileOpenFoxPro.Visible = false;
  846. lblFoxproRemoteUserId.Visible = true;
  847. lblFoxproRemotePwd.Visible = true;
  848. txtRemoteFoxProUserId.Visible = true;
  849. txtRemoteFoxProPwd.Visible = true;
  850. }
  851. }
  852. private void btnOpenFileTxt_Click(object sender, EventArgs e)
  853. {
  854. if (syncInstrumentItem.Code == null) return;
  855. if (syncInstrumentItem.SyncInstrumentDSInfo == null)
  856. syncInstrumentItem.SyncInstrumentDSInfo = new InstrumentDataSourceInfo();
  857. syncInstrumentItem.SyncInstrumentDSInfo.InstrumentDataSourceType = DataSourceType.TXT;
  858. if (strReadTxtMode == "0")
  859. {
  860. OpenFileDialog openFile = new OpenFileDialog
  861. {
  862. Filter = "文本文件(*.txt)|*.txt|所有文件(*.*)|*.*",
  863. InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop),
  864. Multiselect = false
  865. };
  866. if (openFile.ShowDialog() == DialogResult.Cancel) return;
  867. this.txtInportTxt.Text = syncInstrumentItem.SyncInstrumentDSInfo.Path = openFile.FileName;
  868. string fileType = System.IO.Path.GetExtension(openFile.FileName);
  869. if (string.IsNullOrEmpty(fileType)) return;
  870. }
  871. else
  872. {
  873. FolderBrowserDialog dialog = new FolderBrowserDialog();
  874. dialog.Description = "请选择文件路径";
  875. if (dialog.ShowDialog() == DialogResult.Cancel) return;
  876. this.txtInportTxt.Text = syncInstrumentItem.SyncInstrumentDSInfo.Path = dialog.SelectedPath;
  877. }
  878. }
  879. private void cbxRemoteTxt_CheckedChanged(object sender, EventArgs e)
  880. {
  881. if (!cbxRemoteTxt.Checked)
  882. {
  883. this.btnOpenFileTxt.Visible = true;
  884. lblTxtRemoteUserId.Visible = false;
  885. lblTxtRemoteUserPwd.Visible = false;
  886. txtRemoteTxtUserId.Visible = false;
  887. txtRemoteTxtPwd.Visible = false;
  888. }
  889. else
  890. {
  891. this.btnOpenFileTxt.Visible = false;
  892. lblTxtRemoteUserId.Visible = true;
  893. lblTxtRemoteUserPwd.Visible = true;
  894. txtRemoteTxtUserId.Visible = true;
  895. txtRemoteTxtPwd.Visible = true;
  896. }
  897. }
  898. private void cbxTargetDBSelect_SelectedIndexChanged(object sender, EventArgs e)
  899. {
  900. if (cbxTargetDBSelect.SelectedIndex == 0)
  901. {
  902. if (GlobalCommonOperation.strStartWebApi == "1")
  903. {
  904. targetDataBaseInfo = new DataBaseInfo() {
  905. DataBaseCode = "cnas"
  906. };
  907. }
  908. else
  909. {
  910. DataBaseInfo CNASDataBase = FileOperation.GetLocalCnasDB();
  911. if (CNASDataBase != null)
  912. {
  913. this.txtDBHost.Text = CNASDataBase.DBHost;
  914. this.txtDBName.Text = CNASDataBase.DBName;
  915. this.txtDBUser.Text = CNASDataBase.DBUser;
  916. this.txtDBPwd.Text = CNASDataBase.DBPwd;
  917. this.txtPort.Text = CNASDataBase.DBPort;
  918. }
  919. }
  920. }
  921. else if (cbxTargetDBSelect.SelectedIndex == 1)
  922. {
  923. if (GlobalCommonOperation.strStartWebApi == "1")
  924. {
  925. targetDataBaseInfo = new DataBaseInfo()
  926. {
  927. DataBaseCode = "platform"
  928. };
  929. }
  930. else
  931. {
  932. DataBaseInfo PlatDataBase = FileOperation.GetLocalPlatFormDB();
  933. if (PlatDataBase != null)
  934. {
  935. this.txtDBHost.Text = PlatDataBase.DBHost;
  936. this.txtDBName.Text = PlatDataBase.DBName;
  937. this.txtDBUser.Text = PlatDataBase.DBUser;
  938. this.txtDBPwd.Text = PlatDataBase.DBPwd;
  939. this.txtPort.Text = PlatDataBase.DBPort;
  940. }
  941. }
  942. }
  943. }
  944. }
  945. }