frmOperateRule.cs 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.IO;
  5. using System.Diagnostics;
  6. using System.Data;
  7. using System.Drawing;
  8. using System.Text;
  9. using System.Windows.Forms;
  10. using CoreFS.CA06;
  11. using System.Collections;
  12. using Core.Mes.Client.Common;
  13. namespace Core.LgMes.Client.LgIntegrationQuery
  14. {
  15. public partial class frmOperateRule : Core.Mes.Client.Common.frmStyleBase
  16. {
  17. OpenFileDialog Ofd = new OpenFileDialog();
  18. string type = "";
  19. public frmOperateRule()
  20. {
  21. InitializeComponent();
  22. }
  23. private string directoryPath = "C:\\";//质保书临时存放
  24. string strErr = "";
  25. private void frmOperateRule_Load(object sender, EventArgs e)
  26. {
  27. type = this.CustomInfo.ToString();
  28. ultraComboEditor1.Visible = true;
  29. label7.Visible = true;
  30. if (type.Equals("MESSAGE"))
  31. {
  32. ultraComboEditor1.Visible = false;
  33. label7.Visible = false;
  34. this.ulGridMain.DisplayLayout.Bands[0].Columns["DOCTYPE"].Hidden = true;
  35. }
  36. this.ckbGX.Checked = true;
  37. Init();
  38. doQuery();
  39. SteelBind();
  40. /*try
  41. {
  42. InitCombox();
  43. }
  44. catch
  45. { }*/
  46. }
  47. void Init()
  48. {
  49. ArrayList arry = new ArrayList();
  50. arry.Add("GetProcessInfo1.Query");
  51. CommonClientToServer cctos = new CommonClientToServer();
  52. cctos.ob = this.ob;
  53. DataSet ds = cctos.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery",
  54. "doSimpleQuery", arry, out strErr);
  55. if (strErr == "" && ds.Tables[0].Rows.Count > 0)
  56. {
  57. urlCb_devNo.Items.Clear();
  58. Core.Mes.Client.Common.Globals.FillUltraComboItems(urlCb_devNo, ds);
  59. this.FillUltraComboItems(urlCb_BM,ds);
  60. }
  61. else
  62. MessageBox.Show("初使化失败!原因:" + strErr, "提示");
  63. ArrayList arry1 = new ArrayList();
  64. arry1.Add("GetProcessInfo2.Query");
  65. CommonClientToServer cctos1 = new CommonClientToServer();
  66. cctos1.ob = this.ob;
  67. DataSet ds1 = cctos.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery",
  68. "doSimpleQuery", arry1, out strErr);
  69. if (strErr == "" && ds.Tables[0].Rows.Count > 0)
  70. {
  71. ultraComboEditor1.Items.Clear();
  72. Core.Mes.Client.Common.Globals.FillUltraComboItems(ultraComboEditor1, ds1);
  73. }
  74. else
  75. MessageBox.Show("初使化失败!原因:" + strErr, "提示");
  76. try
  77. {
  78. Core.Mes.Client.Common.UltraGridMgt.SetGridRowFilter(ref this.ulGridMain, true);
  79. }
  80. catch
  81. { }
  82. }
  83. void SteelBind()
  84. {
  85. string strErr = "";
  86. //全部牌号
  87. ArrayList arrySteel = new ArrayList();
  88. arrySteel.Add("GetZLSteel.Query");
  89. CommonClientToServer cctos = new CommonClientToServer();
  90. cctos.ob = this.ob;
  91. DataSet dsSteel = cctos.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery",
  92. "doSimpleQuery", arrySteel, out strErr);
  93. //DataSet dsSteel = (DataSet)ClientCommon._RemotingHelp.ExecuteMethod("LGZL", "Core.XgMes.Server.Zlgl.Lg.CraftStandard", "getSteel", new object[] { }, out err);
  94. if (strErr == "")
  95. {
  96. Core.Mes.Client.Common.Globals.FillUltraComboItems(ulteSteel, dsSteel);
  97. }
  98. }
  99. void doRefresh()
  100. {
  101. try
  102. {
  103. this.txt_DocNo.Clear();
  104. this.txt_RuName.Clear();
  105. this.txt_RuNo.Clear();
  106. this.txt_RuScript.Clear();
  107. ulteSteel.Text = ulteSteelCode.Text = "";
  108. this.urlCb_devNo.Text = "";
  109. ArrayList arry = new ArrayList();
  110. arry.Add("RefreshData.Query");
  111. CommonClientToServer cctos = new CommonClientToServer();
  112. cctos.ob = this.ob;
  113. DataSet ds = cctos.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery",
  114. "doSimpleQuery", arry, out strErr);
  115. dataSet1.Clear();
  116. try
  117. {
  118. SetScmOperateRuleDs();
  119. }
  120. catch
  121. { }
  122. if (strErr == "" && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
  123. {
  124. foreach (DataRow Dr in ds.Tables[0].Rows)
  125. {
  126. DataRow dr1 = dataSet1.Tables[0].NewRow();
  127. dr1["RULEID"] = Dr["RULEID"].ToString();
  128. dr1["RULENAME"] = Dr["RULENAME"].ToString();
  129. dr1["DESCRIPTION"] = Dr["DESCRIPTION"].ToString();
  130. dr1["DEVICENO"] = Dr["DEVICENO"].ToString();
  131. dr1["STEELCODE"] = Dr["STEELCODE"].ToString();
  132. dr1["INPUTTIME"] = Dr["INPUTTIME"].ToString();
  133. dr1["POSITTION"] = Dr["POSITTION"].ToString();
  134. dr1["RECORDER"] = Dr["RECORDER"].ToString();
  135. dr1["DESCRIPTIONNAME"] = Dr["DESCRIPTIONNAME"].ToString();
  136. if (!this.isCorrectRuleId(Dr["RULEID"].ToString()))
  137. continue;
  138. dataSet1.Tables[0].Rows.Add(dr1);
  139. }
  140. }
  141. //if (strErr == "")
  142. // ulGridMain.DataSource = ds;
  143. }
  144. catch (Exception ex)
  145. {
  146. MessageBox.Show(ex.Message);
  147. }
  148. }
  149. private byte[] FileConvertByte(string filePath)
  150. {
  151. byte[] bytContent = null;
  152. System.IO.FileStream fs = null;
  153. System.IO.BinaryReader br = null;
  154. try
  155. {
  156. fs = new FileStream(filePath, System.IO.FileMode.Open);
  157. br = new BinaryReader(fs);
  158. bytContent = br.ReadBytes((Int32)fs.Length);
  159. }
  160. catch
  161. {
  162. fs.Close();
  163. fs.Dispose();
  164. }
  165. return bytContent;
  166. }
  167. private void ByteConvertFile(string filePath, byte[] data)
  168. {
  169. FileStream fs;
  170. if (System.IO.File.Exists(filePath))
  171. {
  172. fs = new FileStream(filePath, FileMode.Truncate);
  173. }
  174. else
  175. {
  176. fs = new FileStream(filePath, FileMode.CreateNew);
  177. }
  178. BinaryWriter br = new BinaryWriter(fs);
  179. br.Write(data, 0, data.Length);
  180. br.Close();
  181. fs.Close();
  182. }
  183. void doAdd()
  184. {
  185. try
  186. {
  187. string filePathName = this.txt_DocNo.Text.ToString();
  188. if (!File.Exists(filePathName))
  189. {
  190. MessageBox.Show("文件不存在");
  191. return;
  192. }
  193. if (string.IsNullOrEmpty(txt_RuNo.Text.Trim()))
  194. {
  195. MessageBox.Show("请输入文件编号");
  196. return;
  197. }
  198. //if (ulteSteelCode.Text == "")
  199. //{
  200. // MessageBox.Show(this, "请选择牌号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  201. // ulteSteel.Focus();
  202. // return;
  203. //}
  204. //if (urlCb_devNo.SelectedIndex == -1)
  205. //{
  206. // MessageBox.Show(this, "工序输入错误!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  207. // urlCb_devNo.Focus();
  208. // return;
  209. //}
  210. byte[] sByte;
  211. string strSqlID = "OperaterRule.add";
  212. object[] sArgs = new object[10];
  213. sArgs[0] = txt_RuNo.Text.ToString();
  214. sArgs[1] = txt_RuName.Text.ToString();
  215. sArgs[2] = txt_RuScript.Text.ToString();
  216. try
  217. {
  218. sArgs[3] = (urlCb_devNo.Text.Trim() != null) ? urlCb_devNo.Text.ToString() : "";
  219. }
  220. catch { }
  221. sArgs[4] = ulteSteel.Text;
  222. sArgs[5] = this.UserInfo.GetUserName();
  223. //byte[] bytes = File.ReadAllBytes(txt_DocNo.Text.ToString());
  224. //File.WriteAllBytes("c:\\123.txt", bytes);
  225. //StreamReader reader = new StreamReader(txt_DocNo.Text.ToString(), true);
  226. //string filePath = this.txt_DocNo.Text.ToString();
  227. //byte[] sByte = FileConvertByte(filePath);
  228. //ByteConvertFile("c:\\" + txt_RuScript.Text + ".doc", sByte);
  229. using (FileStream fsTream = new FileStream(txt_DocNo.Text.ToString(), FileMode.Open, FileAccess.Read))
  230. {
  231. if (fsTream.Length > 0)
  232. {
  233. sByte = new byte[fsTream.Length];
  234. fsTream.Read(sByte, 0, sByte.Length);
  235. fsTream.Close();
  236. }
  237. else
  238. {
  239. sByte = new byte[1];
  240. sByte[0] = 32;
  241. }
  242. }
  243. sArgs[6] = sByte;
  244. //sArgs[7] = Ofd.SafeFileName;
  245. sArgs[7] = Ofd.FileName.Substring(Ofd.FileName.LastIndexOf(@"\") + 1);
  246. sArgs[8] = ultraComboEditor1.Value == null ? "" : ultraComboEditor1.SelectedItem.ToString();
  247. sArgs[9] = type;
  248. Hashtable hashtb = new Hashtable();
  249. hashtb.Add("I1", sArgs[0]);
  250. hashtb.Add("I2", sArgs[1]);
  251. hashtb.Add("I3", sArgs[2]);
  252. hashtb.Add("I4", sArgs[3]);
  253. hashtb.Add("I5", sArgs[4]);
  254. hashtb.Add("I6", sArgs[5]);
  255. hashtb.Add("I7", sArgs[7]);
  256. //hashtb.Add("I7", sArgs[6]);
  257. hashtb.Add("I8",sArgs[8]);
  258. hashtb.Add("I9", sArgs[9]);
  259. hashtb.Add("O1", "");
  260. hashtb.Add("O2", "");
  261. CommonClientToServer ccTs = new CommonClientToServer();
  262. ccTs.ob = ob;
  263. string strRCode = ccTs.ExecuteProcedureFunctions("Core.LgMes.Server.lgIntegrationQuery.PerformanceLog",
  264. "BaseDataManage", strSqlID, hashtb, out strErr);
  265. CoreClientParam ccp = new CoreClientParam();
  266. ccp.ServerName = "Core.LgMes.Server.lgIntegrationQuery.PerformanceLog";
  267. ccp.MethodName = "UpdateBolob";
  268. ccp.ServerParams = new object[] { sByte, txt_RuNo.Text };
  269. this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  270. //ArrayList all = new ArrayList();
  271. //all.Add(sByte);
  272. //all.Add(txt_RuNo.Text);
  273. //ccTs.NoQueryFunctions("Core.LgMes.Server.lgIntegrationQuery.PerformanceLog", "UpdateBolob", all, out strErr);
  274. if (strErr == "")
  275. {
  276. //UpdateContextType();
  277. doQuery();
  278. activeRow(sArgs[0].ToString());
  279. }
  280. else
  281. {
  282. MessageBox.Show(strErr);
  283. }
  284. }
  285. catch (Exception ex)
  286. {
  287. MessageBox.Show(ex.Message);
  288. return;
  289. }
  290. }
  291. void doEdit()
  292. {
  293. try
  294. {
  295. string filePathName = this.txt_DocNo.Text.ToString();
  296. string rr = System.AppDomain.CurrentDomain.BaseDirectory;
  297. if (!File.Exists(filePathName))
  298. {
  299. MessageBox.Show("文件不存在");
  300. return;
  301. }
  302. if (ulteSteelCode.Text == "")
  303. {
  304. MessageBox.Show(this, "请选择牌号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  305. ulteSteel.Focus();
  306. return;
  307. }
  308. if (urlCb_devNo.SelectedIndex == -1)
  309. {
  310. MessageBox.Show(this, "工序输入错误!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  311. urlCb_devNo.Focus();
  312. return;
  313. }
  314. byte[] sByte;
  315. string strSqlID = "OperaterRule.Edit";
  316. object[] sArgs = new object[8];
  317. sArgs[0] = txt_RuNo.Text.ToString();
  318. sArgs[1] = txt_RuName.Text.ToString();
  319. sArgs[2] = txt_RuScript.Text.ToString();
  320. //sArgs[3] = "";
  321. sArgs[3] = (urlCb_devNo.Text.Trim() != null) ? urlCb_devNo.Text.ToString() : "";
  322. sArgs[4] = ulteSteelCode.Text;
  323. sArgs[5] = this.UserInfo.GetUserName();
  324. using (FileStream fsTream = new FileStream(txt_DocNo.Text.ToString(), FileMode.Open, FileAccess.Read))
  325. {
  326. if (fsTream.Length > 0)
  327. {
  328. sByte = new byte[fsTream.Length];
  329. fsTream.Read(sByte, 0, sByte.Length);
  330. fsTream.Close();
  331. }
  332. else
  333. {
  334. sByte = new byte[1];
  335. sByte[0] = 32;
  336. }
  337. }
  338. sArgs[6] = sByte;
  339. sArgs[7] = txt_DocNo.Text;
  340. string msg = "";
  341. Hashtable hashtb = new Hashtable();
  342. hashtb.Add("I1", sArgs[0]);
  343. hashtb.Add("I2", sArgs[1]);
  344. hashtb.Add("I3", sArgs[2]);
  345. hashtb.Add("I4", sArgs[3]);
  346. hashtb.Add("I5", sArgs[4]);
  347. hashtb.Add("I6", sArgs[5]);
  348. hashtb.Add("I7", sArgs[7]);
  349. hashtb.Add("O1", "");
  350. hashtb.Add("O2", "");
  351. CommonClientToServer ccTs = new CommonClientToServer();
  352. ccTs.ob = ob;
  353. string strRCode = ccTs.ExecuteProcedureFunctions("Core.LgMes.Server.lgblobIntegrationQuery.PerformanceLog",
  354. "BaseDataManage", strSqlID, hashtb, out strErr);
  355. if (strErr == "")
  356. {
  357. doQuery();
  358. activeRow(sArgs[0].ToString());
  359. UpdateContextType();
  360. }
  361. else
  362. MessageBox.Show(strErr);
  363. }
  364. catch (Exception ex)
  365. {
  366. MessageBox.Show(ex.Message);
  367. }
  368. }
  369. void doDelete()
  370. {
  371. try
  372. {
  373. if (ulGridMain.ActiveRow == null)
  374. return;
  375. if (MessageBox.Show(this, "是否删除本记录?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
  376. return;
  377. string strSqlID = "OperaterRule.Del";
  378. string[] sArgs = new string[1];
  379. string rr = "";
  380. sArgs[0] = this.ulGridMain.ActiveRow.Cells["RULEID"].Value.ToString();
  381. Hashtable hashtb = new Hashtable();
  382. hashtb.Add("I1", sArgs[0]);
  383. hashtb.Add("O1", "");
  384. hashtb.Add("O2", "");
  385. CommonClientToServer ccTs = new CommonClientToServer();
  386. ccTs.ob = ob;
  387. string strRCode = ccTs.ExecuteProcedureFunctions("Core.LgMes.Server.lgIntegrationQuery.PerformanceLog",
  388. "BaseDataManage", strSqlID, hashtb, out strErr);
  389. if (strErr == "")
  390. {
  391. doQuery();
  392. }
  393. else
  394. MessageBox.Show(strErr);
  395. }
  396. catch (Exception ex)
  397. {
  398. MessageBox.Show(ex.Message);
  399. }
  400. }
  401. //打开文件
  402. private void ulGridMain_DoubleClickCell(object sender, Infragistics.Win.UltraWinGrid.DoubleClickCellEventArgs e)
  403. {
  404. doDownLoad();
  405. }
  406. void doDownLoad()
  407. {
  408. try
  409. {
  410. if (ulGridMain.ActiveRow == null)
  411. return;
  412. CoreClientParam ccp = new CoreClientParam();
  413. ccp.ServerName = "Core.LgMes.Server.lgIntegrationQuery.PerformanceLog";
  414. ccp.MethodName = "downLoadFile";
  415. ccp.ServerParams = new object[] { ulGridMain.ActiveRow.Cells["RULEID"].Text };
  416. this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  417. byte[] sBytes = (byte[])ccp.ReturnObject;
  418. if (strErr == "")
  419. {
  420. SaveFileDialog sFile = new SaveFileDialog();
  421. sFile.Title = "操作规程文件保存";
  422. sFile.AddExtension = true;
  423. sFile.CheckPathExists = true;
  424. sFile.CreatePrompt = true;
  425. sFile.FileName = ulGridMain.ActiveRow.Cells["DESCRIPTIONNAME"].Text;
  426. //sFile.FileName = ds.Tables[0].Rows[0]["DESCRIPTIONNAME"].ToString();
  427. sFile.Filter = "Word文件(*.doc)|*.doc";
  428. sFile.DefaultExt = ".doc";
  429. System.DateTime dt = System.DateTime.Now;
  430. string TimeNow = string.Format("{0:yyyyMMddHHmmssffff}", dt);
  431. string sFile1 = "", strTemplateName="";
  432. //strTemplateName= Application.StartupPath + "\\Report\\" + strTemplateName + ".xls";
  433. if (ulGridMain.ActiveRow.Cells["DESCRIPTIONNAME"].Text.Contains(".xls"))
  434. {
  435. sFile1 = Application.StartupPath + "\\Report\\" + ulGridMain.ActiveRow.Cells["DESCRIPTION"].Text + ".xls";
  436. }
  437. else if (ulGridMain.ActiveRow.Cells["DESCRIPTIONNAME"].Text.Contains(".pdf"))
  438. {
  439. sFile1 = Application.StartupPath + "\\Report\\" + ulGridMain.ActiveRow.Cells["DESCRIPTION"].Text + ".pdf";
  440. }
  441. else if (ulGridMain.ActiveRow.Cells["DESCRIPTIONNAME"].Text.Contains(".et"))
  442. {
  443. sFile1 = Application.StartupPath + "\\Report\\" + ulGridMain.ActiveRow.Cells["DESCRIPTION"].Text + ".et";
  444. }
  445. else if (ulGridMain.ActiveRow.Cells["DESCRIPTIONNAME"].Text.Contains(".wps"))
  446. {
  447. sFile1 = Application.StartupPath + "\\Report\\" + ulGridMain.ActiveRow.Cells["DESCRIPTION"].Text + ".wps";
  448. }
  449. else
  450. sFile1 = Application.StartupPath + "\\Report\\" + ulGridMain.ActiveRow.Cells["DESCRIPTION"].Text + ".doc";
  451. if (!File.Exists(strTemplateName))
  452. {
  453. System.IO.Directory.CreateDirectory(Application.StartupPath + "\\Report\\");
  454. }
  455. FileStream fs = new FileStream(sFile1, FileMode.OpenOrCreate, FileAccess.Write);
  456. fs.Write(sBytes, 0, sBytes.Length);
  457. fs.Close();
  458. ProcessStartInfo p = new ProcessStartInfo(sFile1);
  459. p.WorkingDirectory = Path.GetDirectoryName(sFile1);
  460. Process.Start(p);
  461. }
  462. else
  463. MessageBox.Show(strErr, "提示");
  464. }
  465. catch (Exception ex)
  466. {
  467. MessageBox.Show(ex.Message);
  468. }
  469. }
  470. void activeRow(string strRuID)
  471. {
  472. try
  473. {
  474. for (int i = 0; i < ulGridMain.Rows.Count; i++)
  475. {
  476. if (ulGridMain.Rows[i].Cells["RULEID"].Text == strRuID)
  477. {
  478. ulGridMain.Rows[i].Activated = true;
  479. ulGridMain.Rows[i].Selected = true;
  480. break;
  481. }
  482. }
  483. }
  484. catch (Exception ex)
  485. {
  486. MessageBox.Show(ex.Message);
  487. }
  488. }
  489. /// <summary>根据条件查询信息
  490. /// 根据条件查询信息
  491. /// </summary>
  492. private void doQuery()
  493. {
  494. string strPostion = "";
  495. string description = "";
  496. this.txt_DocNo.Clear();
  497. this.txt_RuName.Clear();
  498. this.txt_RuNo.Clear();
  499. this.txt_RuScript.Clear();
  500. ulteSteel.Text = ulteSteelCode.Text = "";
  501. this.urlCb_devNo.Text = "";
  502. if (ckbGX.Checked )
  503. {
  504. strPostion = Convert.ToString(urlCb_BM.Text.Trim());
  505. }
  506. if (ckbGCMS.Checked)
  507. {
  508. description = Convert.ToString(textBox1.Text.Trim());
  509. }
  510. /*if (strPostion == "" && description == "")
  511. {
  512. this.doQuery();
  513. return;
  514. }*/
  515. DataSet ds = new DataSet();
  516. ArrayList arry = new ArrayList();
  517. if (strPostion != "" && description == "")
  518. {
  519. arry.Add("GetGywjByPosittion.Query");
  520. arry.Add("%" + strPostion + "%");
  521. arry.Add(type);
  522. //arry.Add(strPostion);
  523. CommonClientToServer cctos = new CommonClientToServer();
  524. cctos.ob = this.ob;
  525. ds = cctos.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery",
  526. "doSimpleQuery", arry, out strErr);
  527. }
  528. if (strPostion == "" && description != "")
  529. {
  530. arry.Add("GetGywjByPosittion2.Query");
  531. arry.Add("%" + description + "%");
  532. arry.Add(type);
  533. //arry.Add(strPostion);
  534. CommonClientToServer cctos = new CommonClientToServer();
  535. cctos.ob = this.ob;
  536. ds = cctos.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery",
  537. "doSimpleQuery", arry, out strErr);
  538. }
  539. if (strPostion != "" && description != "")
  540. {
  541. arry.Add("GetGywjByPosittion3.Query");
  542. arry.Add("%" + strPostion + "%");
  543. arry.Add("%" + description + "%");
  544. arry.Add(type);
  545. //arry.Add(strPostion);
  546. CommonClientToServer cctos = new CommonClientToServer();
  547. cctos.ob = this.ob;
  548. ds = cctos.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery",
  549. "doSimpleQuery", arry, out strErr);
  550. }
  551. if (strPostion == "" && description == "")
  552. {
  553. arry.Add("GetGywjByPosittion4.Query");
  554. arry.Add(type);
  555. //arry.Add(strPostion);
  556. CommonClientToServer cctos = new CommonClientToServer();
  557. cctos.ob = this.ob;
  558. ds = cctos.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery",
  559. "doSimpleQuery", arry, out strErr);
  560. }
  561. dataSet1.Clear();
  562. if (strErr == "" && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
  563. {
  564. foreach (DataRow Dr in ds.Tables[0].Rows)
  565. {
  566. DataRow dr1 = dataSet1.Tables[0].NewRow();
  567. dr1["RULEID"] = Dr["RULEID"].ToString();
  568. dr1["RULENAME"] = Dr["RULENAME"].ToString();
  569. dr1["DESCRIPTION"] = Dr["DESCRIPTION"].ToString();
  570. dr1["DEVICENO"] = Dr["DEVICENO"].ToString();
  571. dr1["STEELCODE"] = Dr["STEELCODE"].ToString();
  572. dr1["INPUTTIME"] = Dr["INPUTTIME"].ToString();
  573. dr1["POSITTION"] = Dr["POSITTION"].ToString();
  574. dr1["RECORDER"] = Dr["RECORDER"].ToString();
  575. dr1["DESCRIPTIONNAME"] = Dr["DESCRIPTIONNAME"].ToString();
  576. dr1["DOCTYPE"] = Dr["DOCTYPE"].ToString();
  577. dataSet1.Tables[0].Rows.Add(dr1);
  578. }
  579. }
  580. //if (strErr == "")
  581. // ulGridMain.DataSource = ds;
  582. }
  583. public override void ToolBar_Click(object sender, string ToolbarKey)
  584. {
  585. switch (ToolbarKey)
  586. {
  587. case "Query":
  588. doQuery();
  589. break;
  590. case "Update":
  591. doEdit();
  592. break;
  593. case "Add":
  594. doAdd();
  595. break;
  596. case "Delete":
  597. doDelete();
  598. break;
  599. case "Exit":
  600. Close();
  601. break;
  602. }
  603. }
  604. private void button1_Click(object sender, EventArgs e)
  605. {
  606. try
  607. {
  608. Ofd.Title = "打开文件";
  609. Ofd.Filter = "文件 (*.doc;*.xls;*.rtf;*.htm;*.txt;*.wps;*.pdf;)|*.doc;*.xls;*.rtf;*.htm;*.txt;*.wps;*.pdf;";
  610. if (type.Equals("MESSAGE"))
  611. {
  612. ArrayList arry = new ArrayList();
  613. arry.Add("GetMaxRULEID.Query");
  614. CommonClientToServer cctos = new CommonClientToServer();
  615. cctos.ob = this.ob;
  616. DataSet ds = cctos.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery",
  617. "doSimpleQuery", arry, out strErr);
  618. this.txt_RuNo.Text = ds.Tables[0].Rows[0][0].ToString();
  619. }
  620. else
  621. this.txt_RuNo.Text = "";
  622. if (Ofd.ShowDialog() == DialogResult.OK)
  623. {
  624. //this.txt_DocNo.Text = Ofd.FileNames ;
  625. this.txt_DocNo.Text = Ofd.FileName;
  626. char Flag = '.';
  627. //string[] sArgs = Ofd.SafeFileName.Split(Flag);
  628. string[] sArgs = Ofd.FileName.Substring(Ofd.FileName.LastIndexOf(@"\") + 1).Split(Flag);
  629. txt_RuScript.Text = sArgs[0];
  630. txt_RuName.Text = sArgs[0];
  631. }
  632. }
  633. catch { }
  634. }
  635. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  636. {
  637. if (ulGridMain.ActiveRow != null)
  638. {
  639. this.txt_RuNo.Text = ulGridMain.ActiveRow.Cells[0].Value.ToString();
  640. this.txt_RuName.Text = ulGridMain.ActiveRow.Cells[1].Value.ToString();
  641. this.txt_RuScript.Text = ulGridMain.ActiveRow.Cells[2].Value.ToString();
  642. this.txt_DocNo.Text = "";
  643. ulteSteelCode.Text = ulGridMain.ActiveRow.Cells["STEELCODE"].Value.ToString();
  644. ulteSteel.Text = ulGridMain.ActiveRow.Cells["STEELCODE"].Value.ToString();
  645. this.urlCb_devNo.Value = ulGridMain.ActiveRow.Cells["DEVICENO"].Value.ToString();
  646. }
  647. }
  648. private void ulteSteel_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
  649. {
  650. }
  651. private void ckbGX_CheckedChanged(object sender, EventArgs e)
  652. {
  653. urlCb_BM.Enabled = ckbGX.Checked;
  654. this.checkBox1.Checked = !this.ckbGX.Checked;
  655. //doQuery();
  656. }
  657. private void InitCombox()
  658. {
  659. this.ultraComboEditor1.DataSource = this.GetDocType();
  660. this.ultraComboEditor1.DisplayMember = "name_";
  661. this.ultraComboEditor1.ValueMember = "id_";
  662. this.ultraComboEditor1.SelectedIndex = 0;
  663. }
  664. private DataTable GetDocType()
  665. {
  666. DataTable dt = new DataTable();
  667. DataColumn dcId = new DataColumn("id_",System.Type.GetType("System.String"));
  668. DataColumn dcName = new DataColumn("name_", System.Type.GetType("System.String"));
  669. dt.Columns.AddRange(new DataColumn[] { dcId, dcName });
  670. dt.Rows.Add(new object[] { "0", "工艺文件" });
  671. dt.Rows.Add(new object[] { "1", "工艺考核通报" });
  672. return dt;
  673. }
  674. private void UpdateContextType()
  675. {
  676. try
  677. {
  678. ClientParamWithSqlConditionAndOpenBase param = new ClientParamWithSqlConditionAndOpenBase();
  679. string str = this.ultraComboEditor1.Value.ToString();
  680. object[] obj = new object[] { str, this.txt_RuNo.Text.ToString().Trim() };
  681. param.ob = this.ob;
  682. param.param = obj;
  683. Core.LgMes.Client.lgBll.LgScmOpeateRuleMgt.LgScmOpeateRuleMgt.UpdateScmOperateRuleContextType(param);
  684. }
  685. catch
  686. {
  687. }
  688. }
  689. private Boolean isCorrectRuleId(string ruleId)
  690. {
  691. try
  692. {
  693. DataRow[] drs = this._ds.Tables[0].Select(string.Format("RULEID = '{0}'",ruleId));
  694. if (drs.Length == 0)
  695. return true;
  696. if (this.checkBox1.Checked)
  697. {
  698. return drs[0]["DOCTYPE"].ToString() == "1";
  699. }
  700. if (this.ckbGX.Checked)
  701. {
  702. return drs[0]["DOCTYPE"].ToString() == "0";
  703. }
  704. }
  705. catch
  706. {
  707. }
  708. return true;
  709. }
  710. private void checkBox1_CheckedChanged(object sender, EventArgs e)
  711. {
  712. this.ckbGX.Checked = !this.checkBox1.Checked;
  713. this.ckbGCMS.Checked = !this.checkBox1.Checked;
  714. }
  715. private void SetScmOperateRuleDs()
  716. {
  717. this._ds = Core.LgMes.Client.lgBll.LgScmOpeateRuleMgt.LgScmOpeateRuleMgt.GetScmOperateRuleDs(new ClientParamWithSqlConditionAndOpenBase("",this.ob));
  718. }
  719. public void FillUltraComboItems(Infragistics.Win.UltraWinEditors.UltraComboEditor ulcme, DataSet dset)
  720. {
  721. if (dset.Tables.Count > 0 && dset.Tables[0].Columns.Count > 1)
  722. {
  723. for (int i = 0; i < dset.Tables[0].Rows.Count; i++)
  724. if (i == 0)
  725. ulcme.Items.Add(null, null);
  726. else
  727. ulcme.Items.Add(dset.Tables[0].Rows[i][0].ToString(), dset.Tables[0].Rows[i][1].ToString());
  728. }
  729. }
  730. private DataSet _ds = null;
  731. private void ckbGCMS_CheckedChanged(object sender, EventArgs e)
  732. {
  733. textBox1.Enabled = ckbGCMS.Checked;
  734. //doQuery();
  735. }
  736. }
  737. }