Make_ColorBoxLabelPrint.cs 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. using System;
  2. using System.Data;
  3. using System.Drawing;
  4. using System.Text;
  5. using System.Windows.Forms;
  6. using UAS_MES.DataOperate;
  7. using UAS_MES.PublicMethod;
  8. using UAS_MES.Entity;
  9. using LabelManager2;
  10. namespace UAS_MES.Make
  11. {
  12. public partial class Make_ColorBoxLabelPrint : Form
  13. {
  14. DataHelper dh;
  15. DataTable dt;
  16. LogStringBuilder sql = new LogStringBuilder();
  17. AutoSizeFormClass asc = new AutoSizeFormClass();
  18. //保存StepProduct查询出来的数据
  19. DataTable ListA = new DataTable();
  20. //保存make left join makecraftdetail left join product的数据
  21. // DataTable ListB;
  22. //保存ProductLabel数据
  23. DataTable ListC;
  24. //工序编号
  25. string stepcode;
  26. //下一工序编号
  27. string nextstepcode;
  28. //工艺路线编号
  29. string craftcode;
  30. //制造单号
  31. string macode;
  32. //当前工单的序列号
  33. string sn_code;
  34. //当前提示的索引
  35. int RemainIndex = 0;
  36. //消息提示
  37. string ErrorMessage;
  38. ApplicationClass lbl;
  39. public Make_ColorBoxLabelPrint()
  40. {
  41. InitializeComponent();
  42. }
  43. private void Make_ColorBoxLabelPrint_Load(object sender, EventArgs e)
  44. {
  45. dh = new DataHelper();
  46. lbl = new ApplicationClass();
  47. sncode.Focus();
  48. asc.controllInitializeSize(this);
  49. }
  50. private void sn_code_KeyDown(object sender, KeyEventArgs e)
  51. {
  52. if (e.KeyCode == Keys.Enter)
  53. {
  54. if (sncode.Text == "")
  55. {
  56. OperateResult.AppendText(">>序列号不能为空\n", Color.Red);
  57. return;
  58. }
  59. string oMsID;
  60. string oMakeCode;
  61. // 获取工单归属工单下一工序是否正确
  62. if (LogicHandler.CheckStepSNAndMacode(ma_code.Text, User.UserSourceCode, sncode.Text, User.UserCode, out oMakeCode, out oMsID, out ErrorMessage))
  63. {
  64. //判断如果该序列号的归属工单和之前查询的是一致的话,就不进行重复数据的查询
  65. if (ma_code.Text != macode || macode == "")
  66. {
  67. //ma_code不为空的时候表示不是第一次加载,提示用户切换工单
  68. if (macode != "" && ma_code.Text != "")
  69. {
  70. OperateResult.AppendText(">>切换工单至工单号" + macode + "\n", Color.Red);
  71. }
  72. }
  73. sql.Clear();
  74. sql.Append("select ma_code,mcd_okqty,ma_qty,ma_qty-mcd_okqty as mcd_remainqty,pr_detail,pr_code ");
  75. sql.Append("from makeserial left join make on ms_makecode=ma_code left join product on ");
  76. sql.Append("ms_prodcode=pr_code left join makecraftdetail on ms_makecode=mcd_macode where ms_sncode=:sncode");
  77. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select", sncode.Text);
  78. if (dt.Rows.Count > 0)
  79. {
  80. BaseUtil.SetFormValue(this.Controls, dt);
  81. //提示用户“<< 序列号:XXXX”
  82. OperateResult.AppendText("<<序列号:" + sncode.Text + "\n", Color.Green);
  83. sn_code = sncode.Text;
  84. }
  85. else
  86. {
  87. OperateResult.AppendText(">>序列号" + sncode.Text + "没有对应工序\n", Color.Red);
  88. }
  89. string result = "";
  90. if (int.Parse(mcd_remainqty.Text) <= 0)
  91. {
  92. macode = ma_code.Text;
  93. BaseUtil.CleanForm(this);
  94. ErrorMessage = "工单" + macode + "打印完成>>>请输入SN";
  95. OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Green);
  96. return;
  97. }
  98. else
  99. {
  100. if (PrintLabel.SelectedValue != null && PrintNum.Text.Trim() != "")
  101. {
  102. Print.CodeSoft(lbl, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), Printer.Text, ma_code.Text, int.Parse(PrintNum.Text));
  103. if (LogicHandler.UpdateMakeMessage(sncode.Text, ma_code.Text, "彩盒打印", User.UserSourceCode, User.UserCode, "彩盒打印成功", out ErrorMessage))
  104. {
  105. OperateResult.AppendText(">>打印完成, 执行更新\n", Color.Green);
  106. mcd_okqty.Text = int.Parse(mcd_okqty.Text) + 1 + "";
  107. mcd_remainqty.Text = int.Parse(mcd_remainqty.Text) - 1 + "";
  108. sncode.Text = "";
  109. sncode.Focus();
  110. }
  111. else
  112. {
  113. OperateResult.AppendText(">>更新错误" + ErrorMessage + "\n", Color.Red);
  114. }
  115. }
  116. else
  117. {
  118. OperateResult.AppendText(">>该序列号对应的产品未维护(彩盒)标签模板或打印张数没有选择\n", Color.Red);
  119. }
  120. }
  121. }
  122. else
  123. {
  124. OperateResult.AppendText(ErrorMessage + "\n", Color.Red);
  125. }
  126. }
  127. }
  128. //根据产品编号获取打印模板
  129. private void pr_code_TextChanged(object sender, EventArgs e)
  130. {
  131. dt = (DataTable)dh.ExecuteSql("select pl_labelname,pl_labelcode from productlabel where pl_prodcode='" + pr_code.Text + "' and PL_LABELTYPE='彩盒标'", "select");
  132. PrintLabel.DataSource = dt;
  133. PrintLabel.DisplayMember = "pl_labelname";
  134. PrintLabel.ValueMember = "pl_labelcode";
  135. ftpOperater ftp = new ftpOperater();
  136. for (int i = 0; i < dt.Rows.Count; i++)
  137. {
  138. ftp.Download(dt.Rows[i]["pl_labelname"].ToString());
  139. }
  140. }
  141. private void Make_ColorBoxLabelPrint_Activated(object sender, EventArgs e)
  142. {
  143. sncode.Focus();
  144. }
  145. private void Make_ColorBoxLabelPrint_FormClosing(object sender, FormClosingEventArgs e)
  146. {
  147. lbl.Quit();
  148. }
  149. private void Make_ColorBoxLabelPrint_SizeChanged(object sender, EventArgs e)
  150. {
  151. asc.controlAutoSize(this);
  152. }
  153. }
  154. }