Make_MakeDown.cs 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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.Make
  13. {
  14. public partial class Make_MakeDown : Form
  15. {
  16. AutoSizeFormClass asc = new AutoSizeFormClass();
  17. DataTable dt;
  18. DataTable dt1;
  19. DataTable dtbar;
  20. LogStringBuilder sql = new LogStringBuilder();
  21. DataHelper dh;
  22. //页面Caller
  23. string caller;
  24. //事件号变量
  25. string _macode;
  26. //数量记录
  27. int count;
  28. //记录当前序列号ms_id
  29. string ms_id;
  30. public Make_MakeDown()
  31. {
  32. InitializeComponent();
  33. caller = "MakeDown";
  34. count = 0;
  35. _macode = "";
  36. }
  37. private void Make_MakeDown_Load(object sender, EventArgs e)
  38. {
  39. asc.controllInitializeSize(this);
  40. dh = SystemInf.dh;
  41. sn_code.Focus();
  42. make_count.Text = count.ToString();
  43. string[] param = new string[] { caller, make_count.Text, _macode };
  44. dh.CallProcedure("SP_GETMAXNUMBER", ref param);
  45. mdcode.Text = param[2];
  46. }
  47. private void Make_MakeDown_SizeChanged(object sender, EventArgs e)
  48. {
  49. asc.controlAutoSize(this);
  50. }
  51. private void sn_code_KeyDown(object sender, KeyEventArgs e)
  52. {
  53. if (e.KeyCode == Keys.Enter)
  54. {
  55. if (inputreson.Text.Trim() != "")
  56. {
  57. sql.Clear();
  58. sql.Append("select max(ms_id) from makeserial where ms_sncode='" + sn_code.Text + "'");
  59. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  60. ms_id = dt.Rows[0][0].ToString();
  61. if (ms_id != "")
  62. {
  63. //界面赋值
  64. dtbar = (DataTable)dh.ExecuteSql("select ms_makecode,pr_code,pr_detail from makeserial left join product on MS_PRODCODE=pr_code where ms_id='" + ms_id + "'", "select");
  65. BaseUtil.SetFormValue(this.Controls, dtbar);
  66. sql.Clear();
  67. sql.Append("select ms_outboxcode, ms_downstatus,ms_outno,nvl(ms_iostatus,0) ms_iostatus,ms_prodcode from makeserial where ms_id ='" + ms_id + "' ");
  68. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  69. string ms_downstatus = dt.Rows[0]["ms_downstatus"].ToString();
  70. string ms_outboxcode = dt.Rows[0]["ms_outboxcode"].ToString();
  71. string ms_iostatus = dt.Rows[0]["ms_iostatus"].ToString();
  72. string ms_outno = dt.Rows[0]["ms_outno"].ToString();
  73. if (ms_downstatus == "0")
  74. {
  75. if (ms_outno == ""&& ms_iostatus =="0")
  76. {
  77. if (ms_outboxcode == null || ms_outboxcode == "")
  78. {
  79. //进行下地操作,插入下地记录
  80. sql.Clear();
  81. sql.Append("INSERT INTO MAKEDOWN (MD_ID,MD_LINECODE,MD_SCCODE,MD_STEPCODE,");
  82. sql.Append("MD_SNCODE,MD_PRODCODE,MD_MACODE, MD_DOWNREASON, MD_CODE,");
  83. sql.Append("MD_DOWNDATE,MD_DOWNMAN,MD_STATUS) values (MAKEDOWN_seq.nextval,'" + User.UserLineCode + "','" + User.UserSourceCode + "',");
  84. sql.Append("'" + User.CurrentStepCode + "','" + sn_code.Text + "','" + pr_code.Text + "','" + ms_makecode.Text + "','" + inputreson.Text + "','" + mdcode.Text + "',sysdate,'" + User.UserCode + "','-1')");
  85. //执行
  86. dh.ExecuteSql(sql.GetString(), "insert");
  87. //更新序列号状态为下地
  88. dh.UpdateByCondition("makeserial", "ms_downstatus='-1'", "ms_id='" + ms_id + "'");
  89. OperateResult.AppendText(">>>序列号" + sn_code.Text + "下地成功\n", Color.Green);
  90. //更新数量
  91. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ms_makecode.Text, User.UserLineCode, User.UserSourceCode, "下地操作", "序列号" + sn_code.Text + "下地成功", sn_code.Text, "");
  92. count++;
  93. make_count.Text = count + "";
  94. sn_code.Text = "";
  95. loadGrid();
  96. }
  97. else
  98. {
  99. OperateResult.AppendText(">>>序列号" + sn_code.Text + "已装箱:" + ms_outboxcode + ",不允许下地,如需下地请先解除装箱\n", Color.Red, sn_code);
  100. sn_code.Focus();
  101. return;
  102. }
  103. }
  104. else
  105. {
  106. OperateResult.AppendText(">>>序列号" + sn_code.Text + "已进行出入库操作,不允许下地\n", Color.Red, sn_code);
  107. sn_code.Focus();
  108. return;
  109. }
  110. }
  111. else
  112. {
  113. OperateResult.AppendText(">>>序列号" + sn_code.Text + "目前已经是下地状态,无需重复下地\n", Color.Red, sn_code);
  114. sn_code.Focus();
  115. return;
  116. }
  117. }
  118. else
  119. {
  120. ms_id = null;
  121. OperateResult.AppendText(">>>序列号" + sn_code.Text + "不存在\n", Color.Red, sn_code);
  122. sn_code.Focus();
  123. }
  124. }
  125. else
  126. {
  127. OperateResult.AppendText(">>>序列号" + sn_code.Text + "未输入下地原因\n", Color.Red, sn_code);
  128. sn_code.Focus();
  129. return;
  130. }
  131. }
  132. }
  133. private void loadGrid()
  134. {
  135. sql.Clear();
  136. sql.Append("select md_macode,md_sncode,md_prodcode,pr_detail from makedown left join product on pr_code = md_prodcode where md_code = '" + mdcode.Text + "'");
  137. dt1 = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  138. BaseUtil.FillDgvWithDataTable(LabelDataGridView, dt1);
  139. }
  140. }
  141. }