UIM020100.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  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 UIM020100 : FrmBase
  17. {
  18. private ZebraPrinter printer = new ZebraPrinter();
  19. public UIM020100()
  20. {
  21. InitializeComponent();
  22. }
  23. private void UIM020100_Load(object sender, EventArgs e)
  24. {
  25. try
  26. {
  27. string Current = Directory.GetCurrentDirectory();//获取当前根目录
  28. Ini ini = new Ini(Current + "/CoreFS.ini");
  29. // 读取ini
  30. string labPrinterAddr = ini.ReadValue("LABPRINTERADDR", "5");
  31. printer.Addr = labPrinterAddr;
  32. string version = ini.ReadValue("LABPRINTERADDR", "Version");
  33. printer.LableVersion = int.Parse(version);
  34. //MessageBox.Show(labPrinterAddr);
  35. }
  36. catch (Exception ej)
  37. {
  38. System.Diagnostics.Debug.WriteLine(ej.ToString());
  39. }
  40. }
  41. public override void ToolBar_Click(object sender, string ToolbarKey)
  42. {
  43. switch (ToolbarKey)
  44. {
  45. case "Query":
  46. this.DoQuery();
  47. break;
  48. //case "Export":
  49. // this.DoExport();
  50. // break;
  51. case "Print":
  52. this.DoPrint();
  53. break;
  54. }
  55. }
  56. //
  57. public void DoQuery() {
  58. try {
  59. this.dataSet1.Tables[0].Clear();
  60. string startTime = this.ultraDateTimeEditor1.Value != null ? this.ultraDateTimeEditor1.DateTime.ToString("yyyyMMdd") : "";//入库开始时间
  61. string entTime = this.ultraDateTimeEditor2.Value != null ? this.ultraDateTimeEditor2.DateTime.ToString("yyyyMMdd") : "";//入库结束时间
  62. string driveNum = this.ultraTextEditor1.Text.Trim();
  63. string ord = this.ultraTextEditor2.Text.Trim();
  64. CoreClientParam ccp = new CoreClientParam();
  65. ccp.ServerName = "UIM.UIM02.UIM020100";
  66. ccp.MethodName = "queryCoil";
  67. ccp.ServerParams = new object[] { startTime, entTime, driveNum, ord };
  68. ccp.SourceDataTable = this.dataSet1.Tables[0];
  69. this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
  70. //DataRowCollection drs = dataSet1.Tables[0].Rows;
  71. //for (int i = 0; i < drs.Count; i++)
  72. //{
  73. // if (drs[i]["PRINT_TP"].ToString().Equals("Y"))
  74. // {
  75. // if (!drs[i]["ORG_ORD_NO"].ToString().Equals(drs[i]["ORD_NO"].ToString())
  76. // && !drs[i]["ORG_ORD_SEQ"].ToString().Equals(drs[i]["ORD_SEQ"].ToString()))
  77. // ultraGrid1.Rows[i].Appearance.BackColor = Color.FromArgb(192, 255, 192);
  78. // }
  79. //}
  80. }catch(Exception e){
  81. System.Diagnostics.Debug.WriteLine(e.ToString());
  82. }
  83. }
  84. public void DoPrint() {
  85. try
  86. {
  87. ultraGrid1.UpdateData();
  88. Hashtable param = new Hashtable();
  89. string printid = this.UserInfo.GetUserID();
  90. foreach (Infragistics.Win.UltraWinGrid.UltraGridRow row in ultraGrid1.Rows)
  91. {
  92. if (Convert.ToBoolean(row.Cells["CHK"].Value))
  93. {
  94. param = new Hashtable();
  95. ColdCoilLable coilLabel = new ColdCoilLable();
  96. coilLabel.rollNo = row.Cells["OLD_SAMPL_NO"].Value.ToString().Substring(0, 9); //string.Empty;
  97. coilLabel.specification = row.Cells["SPEC_ABBSYM"].Text;
  98. coilLabel.steelGrade = row.Cells["SPEC_STL_GRD"].Text;
  99. coilLabel.dimension = row.Cells["INSTR_COIL_THK"].Text + "*" + row.Cells["INSTR_COIL_WTH"].Text;
  100. coilLabel.coilNo = row.Cells["OLD_SAMPL_NO"].Text;
  101. coilLabel.weight = row.Cells["ACT_WGT"].Text;
  102. coilLabel.heatNo = row.Cells["CHARGE_NO"].Text;
  103. coilLabel.prodDate = row.Cells["MILL_DTIME"].Text;
  104. coilLabel.contractNo = string.Empty;
  105. coilLabel.licenseNo = string.Empty;
  106. coilLabel.licenseMark = string.Empty;
  107. coilLabel.checker = string.Empty;
  108. coilLabel.barcode = coilLabel.coilNo;
  109. if (row.Cells["PRINT_TP"].Text == "Y")
  110. {
  111. if (MessageBox.Show(row.Cells["OLD_SAMPL_NO"].Value.ToString() + "已打印,需要再次打印?",
  112. "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
  113. {
  114. string coilno =row.Cells["OLD_SAMPL_NO"].Text;
  115. printer.printLable(coilLabel);
  116. //20140507
  117. printer.printLable(coilLabel);
  118. UpdateColor(coilno, "B");
  119. param.Add("i1", "L");
  120. param.Add("i2", coilno);
  121. param.Add("i3", printid);
  122. param.Add("i4", "标签打印");
  123. param.Add("i5", "UIM020100");
  124. param.Add("i6", "打印后");
  125. param.Add("o7", "");
  126. PrintHistory(param);
  127. }
  128. }
  129. else if (row.Cells["PRINT_TP"].Text == "N")
  130. {
  131. string coilno = row.Cells["OLD_SAMPL_NO"].Text;
  132. printer.printLable(coilLabel);
  133. //20140507
  134. printer.printLable(coilLabel);
  135. UpdateColor(coilno,"B");
  136. param.Add("i1","L");
  137. param.Add("i2", coilno);
  138. param.Add("i3", printid);
  139. param.Add("i4", "标签打印");
  140. param.Add("i5", "UIM020100");
  141. param.Add("i6", "打印后");
  142. param.Add("o7", "");
  143. PrintHistory(param);
  144. }
  145. }
  146. }
  147. this.DoQuery();
  148. }
  149. catch (Exception EX)
  150. {
  151. MessageBox.Show("连接打印机失败,请点击\"打印\"按钮重新打印!");
  152. }
  153. }
  154. private void UpdateColor(string coilno,string flag) {
  155. CoreClientParam ccp1 = new CoreClientParam();
  156. ccp1.ServerName = "UIL.UIL01.UIL010020";
  157. ccp1.MethodName = "dateColor";
  158. ccp1.ServerParams = new object[] { coilno ,flag};
  159. ccp1.SourceDataTable = this.dataSet1.Tables[0];
  160. this.ExecuteQueryToDataTable(ccp1, CoreInvokeType.Internal);
  161. }
  162. //标签打印记录增加
  163. private void PrintHistory(Hashtable param)
  164. {
  165. CoreClientParam ccp4 = new CoreClientParam();
  166. ccp4.ServerName = "UIB.COM.ComDBProcedure";
  167. ccp4.MethodName = "doXmlProcedure";
  168. ccp4.ServerParams = new Object[] { "UIL010020_02_CALL.CALL", param };
  169. this.ExecuteNonQuery(ccp4, CoreInvokeType.Internal);
  170. //提示
  171. ArrayList all = ccp4.ReturnObject as ArrayList;
  172. if (all[0].ToString() != "YY")//确认是否存在问题
  173. {
  174. MessageBox.Show(all[0].ToString(), "提示");
  175. return;
  176. }
  177. }
  178. private void ultraGrid1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
  179. {
  180. try
  181. {
  182. if (e.Cell.Column.Key == "CHK")
  183. {
  184. e.Cell.Row.Update();
  185. if (e.Cell.Value.ToString().ToUpper() == "TRUE")
  186. {
  187. string vDLIV_DIRNO = e.Cell.Row.Cells["DLIV_DIRNO"].Text;
  188. Infragistics.Win.UltraWinGrid.RowsCollection rs = this.ultraGrid1.Rows;
  189. for (int i = 0; i < rs.Count; i++)
  190. {
  191. if (rs[i].Cells["DLIV_DIRNO"].Text == vDLIV_DIRNO)
  192. {
  193. rs[i].Cells["CHK"].Value = true;
  194. }
  195. else
  196. {
  197. rs[i].Cells["CHK"].Value = false;
  198. }
  199. }
  200. }
  201. else
  202. {
  203. string vDLIV_DIRNO = e.Cell.Row.Cells["DLIV_DIRNO"].Text;
  204. Infragistics.Win.UltraWinGrid.RowsCollection rs = this.ultraGrid1.Rows;
  205. for (int i = 0; i < rs.Count; i++)
  206. {
  207. if (rs[i].Cells["DLIV_DIRNO"].Text == vDLIV_DIRNO)
  208. {
  209. rs[i].Cells["CHK"].Value = false;
  210. }
  211. }
  212. }
  213. }
  214. }
  215. catch (Exception ex)
  216. {
  217. System.Diagnostics.Debug.WriteLine(ex.ToString());
  218. }
  219. }
  220. }
  221. }