UIM020103.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using CoreFS.CA06;
  10. using PrintSolution.LabelPrinter;
  11. using INI;
  12. using System.IO;
  13. using System.Collections;
  14. namespace Core.LZMes.Client.UIM.UIM02
  15. {
  16. public partial class UIM020103 : FrmBase
  17. {
  18. private ZebraPrinter printer = new ZebraPrinter();
  19. public UIM020103()
  20. {
  21. InitializeComponent();
  22. }
  23. public override void ToolBar_Click(object sender, string ToolbarKey)
  24. {
  25. switch (ToolbarKey)
  26. {
  27. case "Query":
  28. this.DoQuery();
  29. break;
  30. //case "Export":
  31. // this.DoExport();
  32. // break;
  33. case "Print":
  34. this.DoPrint();
  35. break;
  36. }
  37. }
  38. //
  39. public void DoQuery() {
  40. try {
  41. ArrayList al = new ArrayList();
  42. string startTime = this.ultraDateTimeEditor1.Value != null ? this.ultraDateTimeEditor1.DateTime.ToString("yyyyMMdd") : "";//入库开始时间
  43. string entTime = this.ultraDateTimeEditor2.Value != null ? this.ultraDateTimeEditor2.DateTime.ToString("yyyyMMdd") : "";//入库结束时间
  44. string driveNum = this.ultraTextEditor1.Text.Trim();
  45. string ord = this.ultraTextEditor2.Text.Trim();
  46. //钢卷号查询
  47. string coilNo = this.ultraTextEditor3_coilNo.Text.Trim();
  48. if (CustomInfo == "2")
  49. {
  50. if (Convert.ToBoolean(this.checkBox3.Checked))
  51. {
  52. if (coilNo == "")
  53. coilNo = "***";
  54. al.Add("UIM020103_01_CP_ALL_SUANXI.SELECT");
  55. al.Add(coilNo);
  56. }
  57. else
  58. {
  59. al.Add("UIM020103_01_CP_SUANXI.SELECT");
  60. al.Add(startTime);
  61. al.Add(entTime);
  62. al.Add(driveNum);
  63. al.Add(ord);
  64. }
  65. }
  66. else
  67. {
  68. if (Convert.ToBoolean(this.checkBox3.Checked))
  69. {
  70. if (coilNo == "")
  71. coilNo = "***";
  72. al.Add("UIM020103_01_CP_ALL.SELECT");
  73. al.Add(coilNo);
  74. }
  75. else
  76. {
  77. al.Add("UIM020103_01_CP.SELECT");
  78. al.Add(startTime);
  79. al.Add(entTime);
  80. al.Add(driveNum);
  81. al.Add(ord);
  82. }
  83. }
  84. this.dataSet1.Tables[0].Clear();
  85. CoreClientParam ccp = new CoreClientParam();
  86. ccp.ServerName = "UIB.COM.ComDBQuery";
  87. ccp.MethodName = "doSimpleQuery";
  88. ccp.ServerParams = new object[] { al };
  89. ccp.SourceDataTable = this.dataSet1.Tables[0];
  90. this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
  91. foreach (Infragistics.Win.UltraWinGrid.UltraGridRow ugr in ultraGrid1.Rows)
  92. {
  93. string wth = ugr.Cells["COIL_WTH"].Text.Trim();
  94. string thk = ugr.Cells["COIL_THK"].Text.Trim();
  95. double b = double.Parse(ugr.Cells["C_ORD_THK_MAX"].Text.Trim());
  96. double c = double.Parse(ugr.Cells["C_ORD_THK_MIN"].Text.Trim());
  97. double d = double.Parse(ugr.Cells["C_ORD_WTH_MIN"].Text.Trim());
  98. double f = double.Parse(ugr.Cells["C_ORD_WTH_MAX"].Text.Trim());
  99. if (double.Parse(thk) > b || double.Parse(thk) < c || double.Parse(wth) < d || double.Parse(wth) > f)
  100. {
  101. ugr.Appearance.BackColor = Color.Yellow;
  102. }
  103. if (ugr.Cells["IS_CUT"].Text.Trim().Equals("N"))
  104. {
  105. ugr.Appearance.BackColor = Color.Orange;//LimeGreen
  106. }
  107. this.ultraGrid1.DisplayLayout.Override.ActiveRowAppearance = null;
  108. }
  109. ClearControlValue();
  110. }catch(Exception e){
  111. System.Diagnostics.Debug.WriteLine(e.ToString());
  112. }
  113. }
  114. public void DoPrint() {
  115. try
  116. {
  117. ultraGrid1.UpdateData();
  118. Hashtable param = new Hashtable();
  119. string printid = this.UserInfo.GetUserID();
  120. //若钢卷号查询条件不为空,则打印编辑区域信息,否则打印勾选的钢卷信息
  121. string coil_No = this.ultraTextEditor3_coilNo.Text.Trim();
  122. if (Convert.ToBoolean(this.checkBox3.Checked) && coil_No != null && coil_No != "")
  123. {
  124. foreach (Infragistics.Win.UltraWinGrid.UltraGridRow row in ultraGrid1.Rows)
  125. {
  126. if (Convert.ToBoolean(row.Cells["CHK"].Value))
  127. {
  128. param = new Hashtable();
  129. ColdCoilLable coilLabel = new ColdCoilLable();
  130. coilLabel.rollNo = this.textBox9.Text.Substring(0, 9); //string.Empty;
  131. coilLabel.specification = this.textBox8.Text;
  132. coilLabel.steelGrade = this.textBox3.Text;//this.textBox3.Text为客户牌号
  133. coilLabel.dimension = this.textBox15.Text + "*" + this.textBox14.Text;
  134. coilLabel.coilNo = this.textBox9.Text;
  135. coilLabel.weight = this.textBox10.Text;
  136. coilLabel.heatNo = this.textBox13.Text;
  137. coilLabel.prodDate = this.textBox12.Text;
  138. coilLabel.contractNo = this.textBox11.Text;
  139. coilLabel.licenseNo = string.Empty;
  140. coilLabel.licenseMark = string.Empty;
  141. coilLabel.checker = this.textBox30.Text;
  142. coilLabel.barcode = coilLabel.coilNo;
  143. coilLabel.custName = this.textBox2.Text;
  144. coilLabel.prodName = this.textBox1.Text;
  145. if (this.textBox1_printYN.Text == "Y")
  146. {
  147. if (MessageBox.Show(this.textBox9.Text + "已打印,需要再次打印?",
  148. "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
  149. {
  150. string coilno = this.textBox9.Text;
  151. //打印两份20170117
  152. printer.printLable(coilLabel);
  153. printer.printLable(coilLabel); //20190304
  154. UpdateColor(coilno, "B");
  155. param.Add("i1", "L");
  156. param.Add("i2", coilno);
  157. param.Add("i3", printid);
  158. param.Add("i4", "标签打印");
  159. param.Add("i5", "UIM020102");
  160. param.Add("i6", "打印后");
  161. param.Add("o7", "");
  162. PrintHistory(param);
  163. }
  164. }
  165. else if (this.textBox1_printYN.Text == "N")
  166. {
  167. string coilno = this.textBox9.Text;
  168. printer.printLable(coilLabel);
  169. //20140507
  170. printer.printLable(coilLabel);
  171. UpdateColor(coilno, "B");
  172. param.Add("i1", "L");
  173. param.Add("i2", coilno);
  174. param.Add("i3", printid);
  175. param.Add("i4", "标签打印");
  176. param.Add("i5", "UIM020102");
  177. param.Add("i6", "打印后");
  178. param.Add("o7", "");
  179. PrintHistory(param);
  180. }
  181. }
  182. }
  183. }
  184. else
  185. {
  186. foreach (Infragistics.Win.UltraWinGrid.UltraGridRow row in ultraGrid1.Rows)
  187. {
  188. if (Convert.ToBoolean(row.Cells["CHK"].Value))
  189. {
  190. param = new Hashtable();
  191. ColdCoilLable coilLabel = new ColdCoilLable();
  192. coilLabel.rollNo = row.Cells["OLD_SAMPL_NO"].Value.ToString().Substring(0, 9); //string.Empty;
  193. coilLabel.specification = row.Cells["SPEC_ABBSYM"].Text;
  194. coilLabel.steelGrade = row.Cells["DDC_STL_GRD"].Text;//row.Cells["SPEC_STL_GRD"].Text;
  195. coilLabel.dimension = row.Cells["INSTR_COIL_THK"].Text + "*" + row.Cells["INSTR_COIL_WTH"].Text;//打印成品规格 20170109
  196. coilLabel.coilNo = row.Cells["OLD_SAMPL_NO"].Text;
  197. coilLabel.weight = row.Cells["ACT_WGT"].Text;
  198. coilLabel.heatNo = row.Cells["CHARGE_NO"].Text;
  199. coilLabel.prodDate = row.Cells["MILL_DTIME"].Text;
  200. coilLabel.contractNo = row.Cells["ORD_NO"].Text;
  201. coilLabel.licenseNo = string.Empty;
  202. coilLabel.licenseMark = string.Empty;
  203. //coilLabel.checker = string.Empty;
  204. coilLabel.checker = row.Cells["FAC_STL_GRD"].Text; //销售备注
  205. coilLabel.barcode = coilLabel.coilNo;
  206. coilLabel.custName = row.Cells["ORDCUST_CD"].Text;
  207. coilLabel.prodName = row.Cells["C_ORD_USE_TP"].Text;
  208. if (row.Cells["PRINT_TP"].Text == "Y")
  209. {
  210. if (MessageBox.Show(row.Cells["OLD_SAMPL_NO"].Value.ToString() + "已打印,需要再次打印?",
  211. "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
  212. {
  213. string coilno = row.Cells["OLD_SAMPL_NO"].Text;
  214. //打印两份 20170117
  215. printer.printLable(coilLabel);
  216. printer.printLable(coilLabel);
  217. UpdateColor(coilno, "B");
  218. param.Add("i1", "L");
  219. param.Add("i2", coilno);
  220. param.Add("i3", printid);
  221. param.Add("i4", "标签打印");
  222. param.Add("i5", "UIM020102");
  223. param.Add("i6", "打印后");
  224. param.Add("o7", "");
  225. PrintHistory(param);
  226. }
  227. }
  228. else if (row.Cells["PRINT_TP"].Text == "N")
  229. {
  230. string coilno = row.Cells["OLD_SAMPL_NO"].Text;
  231. printer.printLable(coilLabel);
  232. //20140507
  233. printer.printLable(coilLabel);
  234. UpdateColor(coilno, "B");
  235. param.Add("i1", "L");
  236. param.Add("i2", coilno);
  237. param.Add("i3", printid);
  238. param.Add("i4", "标签打印");
  239. param.Add("i5", "UIM020102");
  240. param.Add("i6", "打印后");
  241. param.Add("o7", "");
  242. PrintHistory(param);
  243. }
  244. }
  245. }
  246. }
  247. ClearControlValue();
  248. this.DoQuery();
  249. }
  250. catch (Exception EX)
  251. {
  252. MessageBox.Show("连接打印机失败,请点击\"打印\"按钮重新打印!");
  253. }
  254. }
  255. private void UpdateColor(string coilno,string flag) {
  256. CoreClientParam ccp1 = new CoreClientParam();
  257. ccp1.ServerName = "UIL.UIL01.UIL010020";
  258. ccp1.MethodName = "dateColor";
  259. ccp1.ServerParams = new object[] { coilno ,flag};
  260. ccp1.SourceDataTable = this.dataSet1.Tables[0];
  261. this.ExecuteQueryToDataTable(ccp1, CoreInvokeType.Internal);
  262. }
  263. //标签打印记录增加
  264. private void PrintHistory(Hashtable param)
  265. {
  266. CoreClientParam ccp4 = new CoreClientParam();
  267. ccp4.ServerName = "UIB.COM.ComDBProcedure";
  268. ccp4.MethodName = "doXmlProcedure";
  269. ccp4.ServerParams = new Object[] { "UIL010020_02_CALL.CALL", param };
  270. this.ExecuteNonQuery(ccp4, CoreInvokeType.Internal);
  271. //提示
  272. ArrayList all = ccp4.ReturnObject as ArrayList;
  273. if (all[0].ToString() != "YY")//确认是否存在问题
  274. {
  275. MessageBox.Show(all[0].ToString(), "提示");
  276. return;
  277. }
  278. }
  279. private void UIM020103_Load(object sender, EventArgs e)
  280. {
  281. try
  282. {
  283. string Current = Directory.GetCurrentDirectory();//获取当前根目录
  284. Ini ini = new Ini(Current + "/CoreFS.ini");
  285. // ini.Writue("LABPRINTERADDR", "5", "10.10.76.211");
  286. // 读取ini
  287. // string labPrinterAddr = ini.ReadValue("LABPRINTERADDR", "5");
  288. string labPrinterAddr = "10.10.76.219";
  289. if (CustomInfo == "2")
  290. {
  291. labPrinterAddr = "10.10.76.220";
  292. }
  293. // labPrinterAddr = "172.16.50.200";//测试代码20161014
  294. printer.Addr = labPrinterAddr;
  295. string version = ini.ReadValue("LABPRINTERADDR", "Version");
  296. version = "5";//测试代码 20161014
  297. printer.LableVersion = int.Parse(version);
  298. //MessageBox.Show(labPrinterAddr);
  299. }
  300. catch (Exception ej)
  301. {
  302. System.Diagnostics.Debug.WriteLine(ej.ToString());
  303. }
  304. }
  305. private void ultraGrid1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
  306. {
  307. try
  308. {
  309. if (e.Cell.Column.Key == "CHK")
  310. {
  311. //若钢卷号查询条件为空勾选时默认同发运号的钢卷都会勾选,否则只勾选当前钢卷并把钢卷信息填入编辑区域
  312. string coil_No = this.ultraTextEditor3_coilNo.Text.Trim();
  313. if (Convert.ToBoolean(this.checkBox3.Checked) && coil_No != null && coil_No != "")
  314. {
  315. string coilNo = string.Empty;
  316. string weight = string.Empty;
  317. string ordNo = string.Empty;
  318. string ordSeq = string.Empty;
  319. string ordThk = string.Empty;
  320. string ordWth = string.Empty;
  321. string heatNo = string.Empty;
  322. string steelCode = string.Empty;
  323. string standardNo = string.Empty;
  324. string millTime = string.Empty;
  325. string printTP = string.Empty;
  326. string prodname = string.Empty;
  327. string custname = string.Empty;
  328. string custspecstl = string.Empty;
  329. string beizhu = string.Empty;
  330. if (!Convert.ToBoolean(e.Cell.Value))
  331. {
  332. for (int i = 0; i < ultraGrid1.Rows.Count; i++)
  333. {
  334. ultraGrid1.Rows[i].Cells["CHK"].Value = false;
  335. }
  336. coilNo = e.Cell.Row.Cells["OLD_SAMPL_NO"].Text;
  337. weight = e.Cell.Row.Cells["ACT_WGT"].Text;
  338. ordNo = e.Cell.Row.Cells["ORD_NO"].Text;
  339. ordSeq = e.Cell.Row.Cells["ORD_SEQ"].Text;
  340. ordThk = e.Cell.Row.Cells["INSTR_COIL_THK"].Text;//打印成品规格 20170109
  341. ordWth = e.Cell.Row.Cells["INSTR_COIL_WTH"].Text;
  342. heatNo = e.Cell.Row.Cells["CHARGE_NO"].Text;
  343. steelCode = e.Cell.Row.Cells["SPEC_STL_GRD"].Text;
  344. standardNo = e.Cell.Row.Cells["SPEC_ABBSYM"].Text;
  345. millTime = e.Cell.Row.Cells["MILL_DTIME"].Text;
  346. printTP = e.Cell.Row.Cells["PRINT_TP"].Text;
  347. prodname = e.Cell.Row.Cells["C_ORD_USE_TP"].Text;
  348. custname = e.Cell.Row.Cells["ORDCUST_CD"].Text;
  349. custspecstl = e.Cell.Row.Cells["DDC_STL_GRD"].Text;
  350. beizhu = e.Cell.Row.Cells["FAC_STL_GRD"].Text;
  351. }
  352. SetControlValue(coilNo, weight, ordNo, ordSeq, ordThk, ordWth, heatNo, steelCode, standardNo, millTime, printTP, prodname, custname, custspecstl, beizhu);
  353. e.Cell.Value = !Convert.ToBoolean(e.Cell.Value);
  354. }
  355. else
  356. {
  357. e.Cell.Row.Update();
  358. if (e.Cell.Value.ToString().ToUpper() == "TRUE")
  359. {
  360. string vDLIV_DIRNO = e.Cell.Row.Cells["DLIV_DIRNO"].Text;
  361. Infragistics.Win.UltraWinGrid.RowsCollection rs = this.ultraGrid1.Rows;
  362. for (int i = 0; i < rs.Count; i++)
  363. {
  364. if (rs[i].Cells["DLIV_DIRNO"].Text == vDLIV_DIRNO)
  365. {
  366. rs[i].Cells["CHK"].Value = true;
  367. }
  368. else
  369. {
  370. rs[i].Cells["CHK"].Value = false;
  371. }
  372. }
  373. }
  374. else
  375. {
  376. string vDLIV_DIRNO = e.Cell.Row.Cells["DLIV_DIRNO"].Text;
  377. Infragistics.Win.UltraWinGrid.RowsCollection rs = this.ultraGrid1.Rows;
  378. for (int i = 0; i < rs.Count; i++)
  379. {
  380. if (rs[i].Cells["DLIV_DIRNO"].Text == vDLIV_DIRNO)
  381. {
  382. rs[i].Cells["CHK"].Value = false;
  383. }
  384. }
  385. }
  386. }
  387. }
  388. }
  389. catch (Exception ex)
  390. {
  391. System.Diagnostics.Debug.WriteLine(ex.ToString());
  392. }
  393. }
  394. private void SetControlValue(string coilNo, string weight, string ordNo, string ordSeq, string ordThk, string ordWth, string heatNo, string steelCode, string standardNo, string millTime, string printTP, string prodname, string custname, string custspecstl, string beizhu)
  395. {
  396. textBox9.Text = coilNo;
  397. textBox10.Text = weight;
  398. textBox12.Text = millTime;
  399. textBox11.Text = ordNo;
  400. textBox7.Text = ordSeq;
  401. textBox15.Text = ordThk;
  402. textBox14.Text = ordWth;
  403. textBox5.Text = steelCode;
  404. textBox8.Text = standardNo;
  405. textBox13.Text = heatNo;
  406. textBox1_printYN.Text = printTP;
  407. textBox1.Text = prodname;
  408. textBox2.Text = custname;
  409. textBox3.Text = custspecstl;
  410. textBox30.Text = beizhu;
  411. }
  412. private void ClearControlValue()
  413. {
  414. textBox9.Text = "";
  415. textBox10.Text = "";
  416. textBox12.Text = "";
  417. textBox11.Text = "";
  418. textBox7.Text = "";
  419. textBox15.Text = "";
  420. textBox14.Text = "";
  421. textBox5.Text = "";
  422. textBox8.Text = "";
  423. textBox13.Text = "";
  424. textBox1_printYN.Text = "";
  425. textBox1.Text = "";
  426. textBox2.Text = "";
  427. textBox3.Text = "";
  428. textBox30.Text = "";
  429. }
  430. private void checkBoxORD_Click(object sender, EventArgs e)
  431. {
  432. try
  433. {
  434. this.textBox11.Enabled = this.checkBoxORD.Checked;
  435. this.textBox7.Enabled = this.checkBoxORD.Checked;
  436. }
  437. catch (Exception ex)
  438. {
  439. System.Diagnostics.Debug.WriteLine(ex.ToString());
  440. }
  441. }
  442. private void checkBox3_Click(object sender, EventArgs e)
  443. {
  444. try
  445. {
  446. this.ultraTextEditor3_coilNo.Enabled = this.checkBox3.Checked;
  447. ClearControlValue();
  448. this.DoQuery();
  449. }
  450. catch (Exception ex)
  451. {
  452. System.Diagnostics.Debug.WriteLine(ex.ToString());
  453. }
  454. }
  455. }
  456. }