Special_Collertion.cs 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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 UAS_MES_NEW.DataOperate;
  10. using UAS_MES_NEW.Entity;
  11. using UAS_MES_NEW.PublicMethod;
  12. namespace UAS_MES_NEW.Special
  13. {
  14. public partial class Special_Collertion : Form
  15. {
  16. DataHelper dh;
  17. LogStringBuilder sql = new LogStringBuilder();
  18. AutoSizeFormClass asc = new AutoSizeFormClass();
  19. DataTable Dbfind;
  20. DataTable dt;
  21. List<String> sb = new List<string>();
  22. public Special_Collertion()
  23. {
  24. InitializeComponent();
  25. }
  26. private void Special_BoxSplit_Load(object sender, EventArgs e)
  27. {
  28. dh = SystemInf.dh;
  29. asc.controllInitializeSize(this);
  30. }
  31. private void Cd_stepcode_DbChange(object sender, EventArgs e)
  32. {
  33. BaseUtil.SetFormValue(this.Controls, Dbfind);
  34. }
  35. private void ReSN(string sncode)
  36. {
  37. sql.Clear();
  38. sql.Append("insert into RETURNSN select RETURNSN_seq.nextval,ms_sncode,ms_makecode,ms_prodcode,sysdate from makeserial where ms_sncode = '" + sncode + "'");
  39. dh.ExecuteSql(sql.GetString(), "insert");
  40. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ms_makecode.Text, User.UserLineCode, User.UserSourceCode, "返工采集", "返工采集", sncode, "");
  41. }
  42. private void Split_Click(object sender, EventArgs e)
  43. {
  44. string Delete = MessageBox.Show(this.ParentForm, "是否确认返工采集?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
  45. if (Delete == "Yes")
  46. {
  47. if (serBtn.Checked)
  48. {
  49. for (int i = 0; i < sb.Count; i++)
  50. {
  51. ReSN(sb[i].ToString());
  52. OperatResult.AppendText("SN:" + sb[i].ToString()+ "采集完成\n", Color.Green);
  53. }
  54. WeighRecord.Clear();
  55. sb.Clear();
  56. num.Text = WeighRecord.Items.Count + "";
  57. }
  58. else if(bigboxBtn.Checked)
  59. {
  60. for (int i = 0; i < sb.Count; i++)
  61. {
  62. DataTable dt2 = (DataTable)dh.ExecuteSql("select ms_sncode from makeserial where ms_outboxcode = '" + sb[i].ToString() + "'", "select");
  63. for (int k = 0; k < dt2.Rows.Count; k++)
  64. {
  65. ReSN(dt2.Rows[k]["ms_sncode"].ToString());
  66. }
  67. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ms_makecode.Text, User.UserLineCode, User.UserSourceCode, "返工采集", "返工采集", sb[i].ToString(), "");
  68. OperatResult.AppendText("卡通箱:" + sb[i].ToString() + "采集完成\n", Color.Green);
  69. }
  70. WeighRecord.Clear();
  71. sb.Clear();
  72. num.Text = WeighRecord.Items.Count + "";
  73. }
  74. }
  75. }
  76. private void bigboxBtn_Click(object sender, EventArgs e)
  77. {
  78. if (((RadioButton)sender).Checked == true)
  79. {
  80. if (WeighRecord.Items.Count > 0)
  81. {
  82. string logout_confirm = MessageBox.Show(this.ParentForm, "是否更换采集项(已录入信息会清空)?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
  83. if (logout_confirm == "Yes")
  84. {
  85. WeighRecord.Items.Clear();
  86. sb.Clear();
  87. ms_makecode.Text = "";
  88. ms_prodcode.Text = "";
  89. }
  90. else
  91. {
  92. serBtn.Checked = bigboxBtn.Checked;
  93. bigboxBtn.Checked = !serBtn.Checked;
  94. }
  95. }
  96. if (((RadioButton)sender).Name == "serBtn")
  97. {
  98. input.Focus();
  99. OperatResult.AppendText("请输入序列号进行采集\n", Color.Black, input);
  100. }
  101. else if (((RadioButton)sender).Name == "bigboxBtn")
  102. {
  103. input.Focus();
  104. OperatResult.AppendText("请输入箱号进行采集\n", Color.Black, input);
  105. }
  106. }
  107. }
  108. private void input_KeyDown(object sender, KeyEventArgs e)
  109. {
  110. if (e.KeyCode == Keys.Enter)
  111. {
  112. if (serBtn.Checked)
  113. {
  114. dt = (DataTable)dh.ExecuteSql("select ms_makecode,ms_prodcode,ms_sncode,ms_craftcode cr_code,ms_status,ms_outboxcode from makeserial where ms_sncode = '" + input.Text + "'", "select");
  115. if (dt.Rows.Count > 0)
  116. {
  117. //if (ms_makecode.Text != "" && dt.Rows[0]["ms_makecode"].ToString() != ms_makecode.Text)
  118. //{
  119. // OperatResult.AppendText("SN:" + input.Text + "所属工单" + dt.Rows[0]["ms_makecode"].ToString() + "与当前工单" + ms_makecode.Text + "不一致\n", Color.Red, input);
  120. // return;
  121. //}
  122. if (dt.Rows[0]["ms_status"].ToString() == "3")
  123. {
  124. OperatResult.AppendText("SN:" + input.Text + "为不良品,不允许采集\n", Color.Red, input);
  125. return;
  126. }
  127. if (dt.Rows[0]["ms_outboxcode"].ToString() != "")
  128. {
  129. OperatResult.AppendText("SN:" + input.Text + "已装箱" + dt.Rows[0]["ms_outboxcode"].ToString() + ",不允许采集\n", Color.Red, input);
  130. return;
  131. }
  132. BaseUtil.SetFormValue(this.Controls, dt);
  133. if (sb.Contains(dt.Rows[0]["ms_sncode"].ToString()))
  134. {
  135. OperatResult.AppendText("SN:" + input.Text + "已采集\n", Color.Red, input);
  136. return;
  137. }
  138. WeighRecord.Items.Add(dt.Rows[0]["ms_sncode"].ToString());
  139. sb.Add(dt.Rows[0]["ms_sncode"].ToString());
  140. OperatResult.AppendText("SN:" + input.Text + "采集\n", Color.Green, input);
  141. num.Text = WeighRecord.Items.Count+"";
  142. }
  143. else
  144. {
  145. OperatResult.AppendText("SN:" + input.Text + "不存在\n", Color.Red, input);
  146. return;
  147. }
  148. }
  149. else if (bigboxBtn.Checked)
  150. {
  151. dt = (DataTable)dh.ExecuteSql("select pa_makecode ms_makecode,pa_prodcode ms_prodcode,pa_outboxcode,pa_mothercode,ma_craftcode cr_code from package left join make on pa_makecode = ma_code where pa_outboxcode = '"+input.Text+"' and pa_type = '1'", "select");
  152. if (dt.Rows.Count > 0)
  153. {
  154. //if (ms_makecode.Text != "" && dt.Rows[0]["ms_makecode"].ToString() != ms_makecode.Text)
  155. //{
  156. // OperatResult.AppendText("SN:" + input.Text + "所属工单" + dt.Rows[0]["ms_makecode"].ToString() + "与当前工单" + ms_makecode.Text + "不一致\n", Color.Red, input);
  157. // return;
  158. //}
  159. if (dt.Rows[0]["pa_mothercode"].ToString() != "")
  160. {
  161. OperatResult.AppendText("卡通箱:" + input.Text + "已装栈板" + dt.Rows[0]["pa_mothercode"].ToString() + ",不允许采集\n", Color.Red, input);
  162. return;
  163. }
  164. BaseUtil.SetFormValue(this.Controls, dt);
  165. if (sb.Contains(dt.Rows[0]["pa_outboxcode"].ToString()))
  166. {
  167. OperatResult.AppendText("卡通箱:" + input.Text + "已采集\n", Color.Red, input);
  168. return;
  169. }
  170. WeighRecord.Items.Add(dt.Rows[0]["pa_outboxcode"].ToString());
  171. sb.Add(dt.Rows[0]["pa_outboxcode"].ToString());
  172. OperatResult.AppendText("卡通箱:" + input.Text + "采集\n", Color.Green, input);
  173. num.Text = WeighRecord.Items.Count + "";
  174. }
  175. else
  176. {
  177. OperatResult.AppendText("卡通箱:" + input.Text + "不存在\n", Color.Red, input);
  178. return;
  179. }
  180. }
  181. }
  182. }
  183. private void 数据清空_Click(object sender, EventArgs e)
  184. {
  185. BaseUtil.CleanControls(this.Controls);
  186. WeighRecord.Items.Clear();
  187. sb.Clear();
  188. num.Text = WeighRecord.Items.Count + "";
  189. }
  190. }
  191. }