Make_BoxLotBind.cs 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. using NPOI.SS.Formula.Functions;
  2. using System;
  3. using System.Data;
  4. using System.Drawing;
  5. using System.Windows.Forms;
  6. using UAS_MES_NEW.DataOperate;
  7. using UAS_MES_NEW.Entity;
  8. using UAS_MES_NEW.PublicMethod;
  9. namespace UAS_MES_NEW.Make
  10. {
  11. public partial class Make_BoxLotBind : Form
  12. {
  13. DataHelper dh;
  14. AutoSizeFormClass asc = new AutoSizeFormClass();
  15. LogStringBuilder sql = new LogStringBuilder();
  16. DataTable dt;
  17. public Make_BoxLotBind()
  18. {
  19. InitializeComponent();
  20. }
  21. private void Make_CollectNetCode_Load(object sender, EventArgs e)
  22. {
  23. asc.controllInitializeSize(this);
  24. sncode.Focus();
  25. dh = SystemInf.dh;
  26. ma_code.TableName = "make left join product on ma_prodcode=pr_code";
  27. ma_code.SelectField = "ma_code # 工单号,pr_code # 产品编号,pr_detail # 产品名称,ma_craftcode # 途程编号,ma_wccode # 工作中心";
  28. ma_code.FormName = Name;
  29. ma_code.SetValueField = new string[] { "ma_code", "pr_code", "pr_detail", "ma_craftcode", "ma_wccode" };
  30. ma_code.Condition = "ma_statuscode='STARTED'";
  31. ma_code.DbChange += Ma_code_DbChange;
  32. }
  33. DataTable Dbfind;
  34. private void Ma_code_DbChange(object sender, EventArgs e)
  35. {
  36. Dbfind = ma_code.ReturnData;
  37. BaseUtil.SetFormValue(this.Controls, Dbfind);
  38. //获取工单的其他信息
  39. }
  40. private void sncode_KeyDown(object sender, KeyEventArgs e)
  41. {
  42. if (e.KeyCode == Keys.Enter)
  43. {
  44. if (ma_code.Text == "")
  45. {
  46. OperateResult.AppendText(">>工单号不能为空\n", Color.Red);
  47. return;
  48. }
  49. sql.Clear();
  50. sql.Append("select cd_id from craft left join craftdetail on cd_crid=cr_id where cr_code='" + ma_craftcode.Text + "' ");
  51. sql.Append("and cr_prodcode='" + pr_code.Text + "' and nvl(cd_firststep,0)<>0 and cd_stepcode='" + User.CurrentStepCode + "'");
  52. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  53. if (dt.Rows.Count == 0)
  54. {
  55. OperateResult.AppendText(">>该岗位资源对应的工序不是当前工单途程中的第一道工序,请切换资源编号\n", Color.Red);
  56. return;
  57. }
  58. DataTable dt1 = (DataTable)dh.ExecuteSql("select mm_code from makematerial where mm_code='" + ma_code.Text + "' and mm_prodcode=(select BI_PRODUCTSPECNAME from boxinfo where BI_BOXNAME='" + boxcode.Text + "')", "select");
  59. if (dt1.Rows.Count == 0)
  60. {
  61. OperateResult.AppendText(">>箱号" + boxcode.Text + "不在用工单" + ma_code.Text + "用料清单中,不允许采集\n", Color.Red, boxcode);
  62. return;
  63. }
  64. //string boxprodcode = dh.getFieldDataByCondition("boxinfo", "BI_PRODUCTSPECNAME", "BI_BOXNAME='" + boxcode.Text + "'").ToString();
  65. //if (boxprodcode != pr_code.Text)
  66. //{
  67. // OperateResult.AppendText(">>箱号对应产品编号" + boxprodcode + "与工单对应产品编号" + pr_code.Text + "不一致\n", Color.Red);
  68. // return;
  69. //}
  70. string makecode = dh.getFieldDataByCondition("makeserial", "ms_makecode", "ms_boxcode='" + sncode.Text + "'").ToString();
  71. if (makecode != "")
  72. {
  73. OperateResult.AppendText(">>工装篮已使用到工单" + makecode + "\n", Color.Red);
  74. return;
  75. }
  76. string lotno = DateTime.Now.ToString("yyyyMMddHHmmss");
  77. sql.Clear();
  78. sql.Append("insert into MakeSerial(ms_id,ms_code,ms_sncode,ms_prodcode,ms_indate,ms_wccode");
  79. sql.Append(",ms_craftcode,ms_craftname,ms_nextstepcode,ms_status,ms_makecode,ms_linecode");
  80. sql.Append(",ms_sourcecode,ms_maid,ms_firstsn,ms_salecode,MS_LOTNO,ms_boxcode)select MakeSerial_seq.nextval,BI_PANELID,BI_PANELID,'" + pr_code.Text + "',");
  81. sql.Append("sysdate,'" + ma_wccode.Text + "','" + ma_craftcode.Text + "',ma_craftname,'" + User.CurrentStepCode + "',1,'" + ma_code.Text + "','" + User.UserLineCode + "'");
  82. sql.Append(",'" + User.UserSourceCode + "',ma_id,bi_panelid,ma_salecode,'" + lotno + "','" + sncode.Text + "' from boxinfo,make where BI_BOXNAME='" + boxcode.Text + "' and ma_code='" + ma_code.Text + "'");
  83. dh.ExecuteSql(sql.GetString(), "insert");
  84. OperateResult.AppendText(">>箱号" + boxcode.Text + "绑定工装篮" + sncode.Text + "成功\n", Color.Green);
  85. BaseUtil.CleanDGVData(LabelDataGridView);
  86. sncode.Text = "";
  87. boxcode.Text = "";
  88. boxcode.Focus();
  89. }
  90. }
  91. private void Make_CollectNetCode_SizeChanged(object sender, EventArgs e)
  92. {
  93. asc.controlAutoSize(this);
  94. }
  95. private void Make_CollectNetCode_Activated(object sender, EventArgs e)
  96. {
  97. sncode.Focus();
  98. }
  99. private void snCollectionBox1_KeyDown(object sender, KeyEventArgs e)
  100. {
  101. if (e.KeyCode == Keys.Enter)
  102. {
  103. DataTable dt = (DataTable)dh.ExecuteSql("select BI_ID, BI_GLASSID, BI_PANELID, BI_POSITION, BI_OWNER, BI_BOXNAME, BI_PRODUCTSPECNAME, BI_YULIU, BI_UPDATETIME" +
  104. " from boxinfo where bi_boxname='" + boxcode.Text + "'", "select");
  105. if (dt.Rows.Count == 0)
  106. {
  107. OperateResult.AppendText(">>箱号" + boxcode.Text + "不存在\n", Color.Red);
  108. return;
  109. }
  110. BaseUtil.FillDgvWithDataTable(LabelDataGridView, dt);
  111. agsum.Text = dt.Rows.Count.ToString();
  112. sncode.Focus();
  113. }
  114. }
  115. }
  116. }