Make_MakeDown.cs 7.1 KB

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