Special_Reset.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  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_Reset : 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_Reset()
  23. {
  24. InitializeComponent();
  25. }
  26. private void Special_BoxSplit_Load(object sender, EventArgs e)
  27. {
  28. dh = SystemInf.dh;
  29. asc.controllInitializeSize(this);
  30. cd_stepcode.FormName = Name;
  31. cd_stepcode.TableName = "craftdetail left join step on st_code=cd_stepcode left join craft on cd_crid=cr_id";
  32. cd_stepcode.SetValueField = new string[] { "cd_stepcode", "cd_stepno" };
  33. cd_stepcode.SelectField = "cd_stepname # 工序名称 ,cd_stepcode # 工序编号,cd_stepno # 执行顺序";
  34. cd_stepcode.Condition = "ST_STATUSCODE='AUDITED' and cr_code='" + cr_code.Text + "' and cr_prodcode='" + ms_prodcode.Text + "' order by cd_stepno";
  35. cd_stepcode.DBTitle = "回流工序";
  36. cd_stepcode.DbChange += Cd_stepcode_DbChange;
  37. }
  38. private void Cd_stepcode_DbChange(object sender, EventArgs e)
  39. {
  40. Dbfind = cd_stepcode.ReturnData;
  41. BaseUtil.SetFormValue(this.Controls, Dbfind);
  42. }
  43. private void ReSN(string sncode, string stepcode)
  44. {
  45. string stname = dh.getFieldDataByCondition("step", "st_name", "st_code = '" + stepcode + "'").ToString();
  46. dh.ExecuteSql("update makeserial set ms_status=1,ms_outboxcode='',ms_nextstepcode= '"+ stepcode + "' where ms_sncode='" + sncode + "'", "update");
  47. dh.ExecuteSql("delete makebad where mb_sncode = '" + sncode + "' and mb_status = 0", "delete");
  48. sql.Clear();
  49. sql.Append("update craftmaterial set cm_status=-1,cm_lastdeco=-1,cm_dropman='" + User.UserCode + "',");
  50. sql.Append("cm_dropdate =sysdate,CM_REMARK = '重置站点拆解',cm_dropstep='" + User.CurrentStepCode + "',");
  51. sql.Append("cm_dropsccode='" + User.UserSourceCode + "' where cm_sncode = '" + sncode + "' and cm_stepcode in (select cd_stepcode from craftdetail left join step on st_code=cd_stepcode left join craft on cd_crid=cr_id where ST_STATUSCODE='AUDITED' and cr_code='" + cr_code.Text + "' and cr_prodcode='" + ms_prodcode.Text + "' and cd_detno >=" + cd_stepno.Text + " )");
  52. dh.ExecuteSql(sql.GetString(), "update");
  53. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ms_makecode.Text, User.UserLineCode, User.UserSourceCode, "站点重置", "站点重置至" + stname, sncode, "");
  54. }
  55. private void Split_Click(object sender, EventArgs e)
  56. {
  57. if (sb.Count == 0|| cd_stepcode.Text == "")
  58. {
  59. OperatResult.AppendText(">>采集数与回流工位不能为空\n", Color.Red);
  60. return;
  61. }
  62. string Delete = MessageBox.Show(this.ParentForm, "是否确认重置站点?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
  63. if (Delete == "Yes")
  64. {
  65. if (serBtn.Checked)
  66. {
  67. for (int i = 0; i < sb.Count; i++)
  68. {
  69. ReSN(sb[i].ToString(), cd_stepcode.Text);
  70. OperatResult.AppendText("SN:" + sb[i].ToString()+ "回流至"+ cd_stepcode.Text + "完成\n", Color.Green);
  71. }
  72. WeighRecord.Clear();
  73. sb.Clear();
  74. }
  75. else if(bigboxBtn.Checked)
  76. {
  77. string stname = dh.getFieldDataByCondition("step", "st_name", "st_code = '" + cd_stepcode.Text + "'").ToString();
  78. for (int i = 0; i < sb.Count; i++)
  79. {
  80. DataTable dt2 = (DataTable)dh.ExecuteSql("select ms_sncode from makeserial where ms_outboxcode = '" + sb[i].ToString() + "'", "select");
  81. for (int k = 0; k < dt2.Rows.Count; k++)
  82. {
  83. ReSN(dt2.Rows[k]["ms_sncode"].ToString(), cd_stepcode.Text);
  84. }
  85. dh.ExecuteSql("insert into PACKAGEBACKUP select * from package where pa_outboxcode='" + sb[i].ToString() + "'", "insert");
  86. dh.ExecuteSql("insert into PACKAGEBACKUPDETAIL select * from packagedetail where pd_outboxcode='" + sb[i].ToString() + "'", "insert");
  87. dh.ExecuteSql("delete from package where pa_outboxcode = '" + sb[i].ToString() + "'", "delete");
  88. //删除箱的明细
  89. dh.ExecuteSql("delete from packagedetail where pd_outboxcode='" + sb[i].ToString() + "'", "delete");
  90. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ms_makecode.Text, User.UserLineCode, User.UserSourceCode, "站点重置", "站点重置至" + stname, sb[i].ToString(), "");
  91. OperatResult.AppendText("卡通箱:" + sb[i].ToString() + "回流至" + cd_stepcode.Text + "完成\n", Color.Green);
  92. }
  93. WeighRecord.Clear();
  94. sb.Clear();
  95. }
  96. }
  97. }
  98. private void bigboxBtn_Click(object sender, EventArgs e)
  99. {
  100. if (((RadioButton)sender).Checked == true)
  101. {
  102. if (WeighRecord.Items.Count > 0)
  103. {
  104. string logout_confirm = MessageBox.Show(this.ParentForm, "是否更换采集项(已录入信息会清空)?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
  105. if (logout_confirm == "Yes")
  106. {
  107. WeighRecord.Items.Clear();
  108. sb.Clear();
  109. ms_makecode.Text = "";
  110. ms_prodcode.Text = "";
  111. cr_code.Text = "";
  112. cd_stepcode.Text = "";
  113. }
  114. else
  115. {
  116. serBtn.Checked = bigboxBtn.Checked;
  117. bigboxBtn.Checked = !serBtn.Checked;
  118. }
  119. }
  120. if (((RadioButton)sender).Name == "serBtn")
  121. {
  122. input.Focus();
  123. OperatResult.AppendText("请输入序列号进行采集\n", Color.Black, input);
  124. }
  125. else if (((RadioButton)sender).Name == "bigboxBtn")
  126. {
  127. input.Focus();
  128. OperatResult.AppendText("请输入箱号进行采集\n", Color.Black, input);
  129. }
  130. }
  131. }
  132. private void cr_code_TextChanged(object sender, EventArgs e)
  133. {
  134. cd_stepcode.Condition = "ST_STATUSCODE='AUDITED' and cr_code='" + cr_code.Text + "' and cr_prodcode='" + ms_prodcode.Text + "' order by cd_stepno";
  135. }
  136. private void input_KeyDown(object sender, KeyEventArgs e)
  137. {
  138. if (e.KeyCode == Keys.Enter)
  139. {
  140. if (serBtn.Checked)
  141. {
  142. 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");
  143. if (dt.Rows.Count > 0)
  144. {
  145. if (ms_makecode.Text != "" && dt.Rows[0]["ms_makecode"].ToString() != ms_makecode.Text)
  146. {
  147. OperatResult.AppendText("SN:" + input.Text + "所属工单" + dt.Rows[0]["ms_makecode"].ToString() + "与当前工单" + ms_makecode.Text + "不一致\n", Color.Red, input);
  148. return;
  149. }
  150. if (dt.Rows[0]["ms_status"].ToString() == "3")
  151. {
  152. OperatResult.AppendText("SN:" + input.Text + "为不良品,不允许采集\n", Color.Red, input);
  153. return;
  154. }
  155. if (dt.Rows[0]["ms_outboxcode"].ToString() != "")
  156. {
  157. OperatResult.AppendText("SN:" + input.Text + "已装箱" + dt.Rows[0]["ms_outboxcode"].ToString() + ",不允许采集\n", Color.Red, input);
  158. return;
  159. }
  160. BaseUtil.SetFormValue(this.Controls, dt);
  161. if (sb.Contains(dt.Rows[0]["ms_sncode"].ToString()))
  162. {
  163. OperatResult.AppendText("SN:" + input.Text + "已采集\n", Color.Red, input);
  164. return;
  165. }
  166. WeighRecord.Items.Add(dt.Rows[0]["ms_sncode"].ToString());
  167. sb.Add(dt.Rows[0]["ms_sncode"].ToString());
  168. OperatResult.AppendText("SN:" + input.Text + "采集\n", Color.Green, input);
  169. cd_stepcode.Condition = "ST_STATUSCODE='AUDITED' and cr_code='" + cr_code.Text + "' and cr_prodcode='" + ms_prodcode.Text + "' order by cd_stepno";
  170. }
  171. else
  172. {
  173. OperatResult.AppendText("SN:" + input.Text + "不存在\n", Color.Red, input);
  174. return;
  175. }
  176. }
  177. else if (bigboxBtn.Checked)
  178. {
  179. 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");
  180. if (dt.Rows.Count > 0)
  181. {
  182. if (ms_makecode.Text != "" && dt.Rows[0]["ms_makecode"].ToString() != ms_makecode.Text)
  183. {
  184. OperatResult.AppendText("SN:" + input.Text + "所属工单" + dt.Rows[0]["ms_makecode"].ToString() + "与当前工单" + ms_makecode.Text + "不一致\n", Color.Red, input);
  185. return;
  186. }
  187. if (dt.Rows[0]["pa_mothercode"].ToString() != "")
  188. {
  189. OperatResult.AppendText("卡通箱:" + input.Text + "已装栈板" + dt.Rows[0]["pa_mothercode"].ToString() + ",不允许采集\n", Color.Red, input);
  190. return;
  191. }
  192. BaseUtil.SetFormValue(this.Controls, dt);
  193. if (sb.Contains(dt.Rows[0]["pa_outboxcode"].ToString()))
  194. {
  195. OperatResult.AppendText("卡通箱:" + input.Text + "已采集\n", Color.Red, input);
  196. return;
  197. }
  198. WeighRecord.Items.Add(dt.Rows[0]["pa_outboxcode"].ToString());
  199. sb.Add(dt.Rows[0]["pa_outboxcode"].ToString());
  200. OperatResult.AppendText("卡通箱:" + input.Text + "采集\n", Color.Green, input);
  201. cd_stepcode.Condition = "ST_STATUSCODE='AUDITED' and cr_code='" + cr_code.Text + "' and cr_prodcode='" + ms_prodcode.Text + "' order by cd_stepno";
  202. }
  203. else
  204. {
  205. OperatResult.AppendText("卡通箱:" + input.Text + "不存在\n", Color.Red, input);
  206. return;
  207. }
  208. }
  209. }
  210. }
  211. private void 数据清空_Click(object sender, EventArgs e)
  212. {
  213. BaseUtil.CleanControls(this.Controls);
  214. WeighRecord.Clear();
  215. sb.Clear();
  216. }
  217. }
  218. }