32dfa38f17b5323ceb3a0a0beaf50b6847cb9f7b.svn-base 23 KB

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