CNAS取数仪器端升级
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

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