Make_Aging.cs 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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. try { UAS_MES_NEW.I18n.LanguageManager.Localize(this); } catch { }
  33. }
  34. private void Make_CollectNetCode_Load(object sender, EventArgs e)
  35. {
  36. asc.controllInitializeSize(this);
  37. sncode.Focus();
  38. dh = SystemInf.dh;
  39. }
  40. private void sncode_KeyDown(object sender, KeyEventArgs e)
  41. {
  42. if (e.KeyCode == Keys.Enter)
  43. {
  44. //采集序列号
  45. if (sncode.Text == "")
  46. {
  47. OperateResult.AppendText(">>箱号不能为空\n", Color.Red);
  48. return;
  49. }
  50. DataTable dt = (DataTable)dh.ExecuteSql("select ms_makecode,ms_prodcode,pr_detail from makeserial " +
  51. "left join product on pr_code=ms_prodcode where ms_outboxcode='" + sncode.Text + "' ", "select");
  52. if (dt.Rows.Count > 0)
  53. {
  54. BaseUtil.SetFormValue(this.Controls, dt);
  55. }
  56. dt = (DataTable)dh.ExecuteSql("select pa_makecode,pa_nextstep from package where pa_outboxcode='" + sncode.Text + "' and nvl(pa_status,0)=0 ", "select");
  57. if (dt.Rows.Count > 0)
  58. {
  59. string pa_nextstep = dt.Rows[0]["pa_nextstep"].ToString();
  60. if (pa_nextstep != User.CurrentStepCode)
  61. {
  62. OperateResult.AppendText(">>箱号" + sncode.Text + "当前工序不对应\n", Color.Red);
  63. return;
  64. }
  65. string pa_makecode = dt.Rows[0]["pa_makecode"].ToString();
  66. {
  67. dh.UpdateByCondition("package", "pa_status=1,pa_totalqty=pa_currentqty,pa_packageqty=pa_currentqty", "pa_outboxcode='" + sncode.Text + "'");
  68. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, pa_makecode, User.UserLineCode, User.UserSourceCode, "老化上架", "箱号" + sncode.Text + "上架成功", sncode.Text, "");
  69. string ms_makecode = dh.getFieldDataByCondition("packagedetail", "pd_makecode", "pd_outboxcode = '" + sncode.Text + "'").ToString();
  70. if (LogicHandler.OutBoxStepPass(sncode.Text, ms_makecode, User.UserSourceCode, User.UserCode, "卡通箱:" + sncode.Text + "整箱过站", "卡通箱整箱过站", out ErrorMessage))
  71. {
  72. 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 + "'");
  73. OperateResult.AppendText(">>箱号" + sncode.Text + "上架成功\n", Color.Green);
  74. }
  75. else
  76. {
  77. OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
  78. }
  79. //写入老化明细表
  80. dh.ExecuteSql("insert into AGEINGDETAIL(AGD_ID, AGD_AGCODE, AGD_MAKECODE, AGD_SNCODE, AGD_INDATE)" +
  81. "select AGEINGDETAIL_seq.nextval,'" + sncode.Text + "',pd_makecode,pd_barcode,sysdate from packagedetail " +
  82. "where pd_outboxcode='" + sncode.Text + "'", "insert");
  83. dh.ExecuteSql("insert into PACKAGEBACKUPDETAIL select * from PACKAGEDETAIL where pd_outboxcode='" + sncode.Text + "' and pd_barcode not in (select pbd_barcode from PACKAGEBACKUPDETAIL)", "insert");
  84. dh.ExecuteSql("delete from PACKAGEDETAIL where pd_outboxcode='" + sncode.Text + "'", "delete");
  85. dh.ExecuteSql("insert into PACKAGEBACKUP select * from PACKAGE where pa_outboxcode='" + sncode.Text + "' and pa_outboxcode not in (select pa_outboxcode from PACKAGEBACKUP)", "insert");
  86. dh.ExecuteSql("delete from PACKAGE where pa_outboxcode='" + sncode.Text + "'", "delete");
  87. dh.ExecuteSql("update makeserial set ms_outboxcode='' where ms_outboxcode='" + sncode.Text + "'", "update");
  88. //显示老化数据
  89. dt = (DataTable)dh.ExecuteSql("select AGD_AGCODE,AGD_MAKECODE,AGD_SNCODE,to_char(AGD_INDATE,'yyyy-mm-dd hh24:mi:ss')AGD_INDATE " +
  90. "from AGEINGDETAIL where AGD_AGCODE='" + sncode.Text + "'", "select");
  91. BaseUtil.FillDgvWithDataTable(LabelDataGridView, dt);
  92. }
  93. }
  94. else OperateResult.AppendText(">>箱号" + sncode.Text + "已经上架\n", Color.Red);
  95. }
  96. }
  97. private void Make_CollectNetCode_SizeChanged(object sender, EventArgs e)
  98. {
  99. asc.controlAutoSize(this);
  100. }
  101. private void Make_CollectNetCode_Activated(object sender, EventArgs e)
  102. {
  103. sncode.Focus();
  104. }
  105. void fildgv()
  106. {
  107. }
  108. private void snCollectionBox1_KeyDown(object sender, KeyEventArgs e)
  109. {
  110. if (e.KeyCode == Keys.Enter)
  111. {
  112. fildgv();
  113. sncode.Focus();
  114. sncode.SelectAll();
  115. }
  116. }
  117. }
  118. }