Make_Aging.cs 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. using System;
  2. using System.Data;
  3. using System.Drawing;
  4. using System.Windows.Forms;
  5. using UAS_MES_NEW.DataOperate;
  6. using UAS_MES_NEW.Entity;
  7. using UAS_MES_NEW.PublicMethod;
  8. namespace UAS_MES_NEW.Make
  9. {
  10. public partial class Make_Aging : Form
  11. {
  12. DataHelper dh;
  13. AutoSizeFormClass asc = new AutoSizeFormClass();
  14. LogStringBuilder sql = new LogStringBuilder();
  15. DataTable dt;
  16. //当前序列号记录
  17. string sn_code;
  18. //制造单号
  19. string macode;
  20. //采集网标号
  21. float net_code;
  22. //网标查询条件ms_id
  23. string oMsID;
  24. //打印计数
  25. int printcount = 0;
  26. int ma_unlimitin;
  27. string ErrorMessage = "";
  28. string LastSncode;
  29. public Make_Aging()
  30. {
  31. InitializeComponent();
  32. }
  33. private void Make_CollectNetCode_Load(object sender, EventArgs e)
  34. {
  35. asc.controllInitializeSize(this);
  36. sncode.Focus();
  37. dh = SystemInf.dh;
  38. }
  39. private void sncode_KeyDown(object sender, KeyEventArgs e)
  40. {
  41. if (e.KeyCode == Keys.Enter)
  42. {
  43. //采集序列号
  44. if (sncode.Text == "")
  45. {
  46. OperateResult.AppendText(">>箱号不能为空\n", Color.Red);
  47. return;
  48. }
  49. DataTable dt = (DataTable)dh.ExecuteSql("select ms_makecode,ms_prodcode,pr_detail from makeserial " +
  50. "left join product on pr_code=ms_prodcode where ms_outboxcode='" + sncode.Text + "' ", "select");
  51. if (dt.Rows.Count > 0)
  52. {
  53. BaseUtil.SetFormValue(this.Controls, dt);
  54. }
  55. dt = (DataTable)dh.ExecuteSql("select pa_makecode,pa_nextstep from package where pa_outboxcode='" + sncode.Text + "' and nvl(pa_status,0)=0 ", "select");
  56. if (dt.Rows.Count > 0)
  57. {
  58. string pa_nextstep = dt.Rows[0]["pa_nextstep"].ToString();
  59. if (pa_nextstep != User.CurrentStepCode)
  60. {
  61. OperateResult.AppendText(">>箱号" + sncode.Text + "当前工序不对应\n", Color.Red);
  62. return;
  63. }
  64. string pa_makecode = dt.Rows[0]["pa_makecode"].ToString();
  65. {
  66. dh.UpdateByCondition("package", "pa_status=1,pa_totalqty=pa_currentqty,pa_packageqty=pa_currentqty", "pa_outboxcode='" + sncode.Text + "'");
  67. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, pa_makecode, User.UserLineCode, User.UserSourceCode, "老化上架", "箱号" + sncode.Text + "上架成功", sncode.Text, "");
  68. string ms_makecode = dh.getFieldDataByCondition("packagedetail", "pd_makecode", "pd_outboxcode = '" + sncode.Text + "'").ToString();
  69. if (LogicHandler.OutBoxStepPass(sncode.Text, ms_makecode, User.UserSourceCode, User.UserCode, "卡通箱:" + sncode.Text + "整箱过站", "卡通箱整箱过站", out ErrorMessage))
  70. {
  71. dh.UpdateByCondition("package", "pa_nextstep='" + dh.getFieldDataByCondition("packagedetail left join makeserial on ms_sncode=pd_barcode and ms_makecode=pd_makecode", "max(ms_nextstepcode)", "pd_outboxcode='" + sncode.Text + "'").ToString() + "', PA_CURRENTSTEP = '' ", "pa_outboxcode='" + sncode.Text + "'");
  72. OperateResult.AppendText(">>箱号" + sncode.Text + "上架成功\n", Color.Green);
  73. }
  74. else
  75. {
  76. OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
  77. }
  78. //写入老化明细表
  79. dh.ExecuteSql("insert into AGEINGDETAIL(AGD_ID, AGD_AGCODE, AGD_MAKECODE, AGD_SNCODE, AGD_INDATE)" +
  80. "select AGEINGDETAIL_seq.nextval,'" + sncode.Text + "',pd_makecode,pd_barcode,sysdate from packagedetail " +
  81. "where pd_outboxcode='" + sncode.Text + "'", "insert");
  82. dh.ExecuteSql("insert into PACKAGEBACKUPDETAIL select * from PACKAGEDETAIL where pd_outboxcode='" + sncode.Text + "' and pd_barcode not in (select pbd_barcode from PACKAGEBACKUPDETAIL)", "insert");
  83. dh.ExecuteSql("delete from PACKAGEDETAIL where pd_outboxcode='" + sncode.Text + "'", "delete");
  84. dh.ExecuteSql("insert into PACKAGEBACKUP select * from PACKAGE where pa_outboxcode='" + sncode.Text + "' and pa_outboxcode not in (select pa_outboxcode from PACKAGEBACKUP)", "insert");
  85. dh.ExecuteSql("delete from PACKAGE where pa_outboxcode='" + sncode.Text + "'", "delete");
  86. dh.ExecuteSql("update makeserial set ms_outboxcode='' where ms_outboxcode='" + sncode.Text + "'", "update");
  87. //显示老化数据
  88. dt = (DataTable)dh.ExecuteSql("select AGD_AGCODE,AGD_MAKECODE,AGD_SNCODE,to_char(AGD_INDATE,'yyyy-mm-dd hh24:mi:ss')AGD_INDATE " +
  89. "from AGEINGDETAIL where AGD_AGCODE='" + sncode.Text + "'", "select");
  90. BaseUtil.FillDgvWithDataTable(LabelDataGridView, dt);
  91. }
  92. }
  93. else OperateResult.AppendText(">>箱号" + sncode.Text + "已经上架\n", Color.Red);
  94. }
  95. }
  96. private void Make_CollectNetCode_SizeChanged(object sender, EventArgs e)
  97. {
  98. asc.controlAutoSize(this);
  99. }
  100. private void Make_CollectNetCode_Activated(object sender, EventArgs e)
  101. {
  102. sncode.Focus();
  103. }
  104. void fildgv()
  105. {
  106. }
  107. private void snCollectionBox1_KeyDown(object sender, KeyEventArgs e)
  108. {
  109. if (e.KeyCode == Keys.Enter)
  110. {
  111. fildgv();
  112. sncode.Focus();
  113. sncode.SelectAll();
  114. }
  115. }
  116. }
  117. }