Make_MakeDown.cs 6.2 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. ma_code.TableName = " make left join product on ma_prodcode=pr_code";
  47. ma_code.SelectField = "ma_code # 工单编号,ma_prodcode # 产品编号,pr_spec # 型号";
  48. ma_code.FormName = Name;
  49. ma_code.SetValueField = new string[] { "ma_code" };
  50. ma_code.Condition = "ma_statuscode='STARTED'";
  51. ma_code.DbChange += pr_code_DbChange;
  52. st_code.FormName = Name;
  53. st_code.TableName = "step";
  54. st_code.SetValueField = new string[] { "st_code", "st_name" };
  55. st_code.SelectField = "st_code # 工序编号 ,st_name # 工序名称";
  56. st_code.DBTitle = "执行工序";
  57. st_code.DbChange += pr_code_DbChange;
  58. }
  59. DataTable Dbfind;
  60. private void pr_code_DbChange(object sender, EventArgs e)
  61. {
  62. Dbfind = ma_code.ReturnData;
  63. BaseUtil.SetFormValue(this.Controls, Dbfind);
  64. }
  65. private void Make_MakeDown_SizeChanged(object sender, EventArgs e)
  66. {
  67. asc.controlAutoSize(this);
  68. }
  69. private void sn_code_KeyDown(object sender, KeyEventArgs e)
  70. {
  71. if (e.KeyCode == Keys.Enter)
  72. {
  73. if (inputreson.Text.Trim() != "")
  74. {
  75. //进行下地操作,插入下地记录
  76. sql.Clear();
  77. sql.Append("INSERT INTO MAKEDOWN (MD_ID,MD_LINECODE,MD_SCCODE,MD_STEPCODE,");
  78. sql.Append("MD_SNCODE,MD_PRODCODE,MD_MACODE, MD_DOWNREASON, MD_CODE,");
  79. sql.Append("MD_DOWNDATE,MD_DOWNMAN,MD_STATUS) values (MAKEDOWN_seq.nextval,'" + User.UserLineCode + "','" + User.UserSourceCode + "',");
  80. sql.Append("'" + User.CurrentStepCode + "','" + sn_code.Text + "','" + pr_code.Text + "','" + ms_makecode.Text + "','" + inputreson.Text + "','" + mdcode.Text + "',sysdate,'" + User.UserCode + "','-1')");
  81. //执行
  82. dh.ExecuteSql(sql.GetString(), "insert");
  83. //更新序列号状态为下地
  84. dh.UpdateByCondition("makeserial", "ms_downstatus='-1'", "ms_sncode='" + sn_code.Text + "'");
  85. OperateResult.AppendText(">>>序列号" + sn_code.Text + "下地成功\n", Color.Green);
  86. //更新数量
  87. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ms_makecode.Text, User.UserLineCode, User.UserSourceCode, "下地操作", "序列号" + sn_code.Text + "下地成功", sn_code.Text, "");
  88. count++;
  89. make_count.Text = count + "";
  90. sn_code.Text = "";
  91. loadGrid();
  92. }
  93. else
  94. {
  95. OperateResult.AppendText(">>>序列号" + sn_code.Text + "未输入下地原因\n", Color.Red, sn_code);
  96. sn_code.Focus();
  97. return;
  98. }
  99. }
  100. }
  101. private void loadGrid()
  102. {
  103. sql.Clear();
  104. 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 + "'");
  105. dt1 = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  106. BaseUtil.FillDgvWithDataTable(LabelDataGridView, dt1);
  107. }
  108. private void BatchFreeze_Click(object sender, EventArgs e)
  109. {
  110. string condition = "1=1";
  111. if (stcode.Checked)
  112. {
  113. if (!macode.Checked && !date.Checked)
  114. {
  115. MessageBox.Show("勾选工序条件时必须勾选工单或者时间范围");
  116. return;
  117. }
  118. condition += " and sp_stepcode='" + st_code.Text + "' ";
  119. }
  120. if (macode.Checked)
  121. {
  122. condition += " and sp_makecode='" + ma_code.Text + "'";
  123. }
  124. if (date.Checked)
  125. {
  126. condition += " and sp_date between to_date('" + BeginDate.Value.ToString("yyyy-MM-dd HH:mm:ss") + "', 'yyyy-mm-dd hh24:mi:ss') and to_date('" + EndDate.Value.ToString("yyyy-MM-dd HH:mm:ss") + "', 'yyyy-mm-dd hh24:mi:ss')";
  127. }
  128. sql.Clear();
  129. sql.Append("INSERT INTO MAKEDOWN (MD_ID,MD_LINECODE,MD_SCCODE,MD_STEPCODE,");
  130. sql.Append("MD_SNCODE,MD_PRODCODE,MD_MACODE, MD_DOWNREASON, MD_CODE,");
  131. sql.Append("MD_DOWNDATE,MD_DOWNMAN,MD_STATUS) select MAKEDOWN_seq.nextval,'" + User.UserLineCode + "','" + User.UserSourceCode + "',");
  132. sql.Append("'" + st_code.Text + "',sp_sncode,sp_prodcode,sp_makecode,'" + inputreson.Text + "','" + mdcode.Text + "',sysdate,'" + User.UserCode + "','-1' ");
  133. sql.Append(" from steppassed where " + condition);
  134. dh.ExecuteSql(sql.GetString(), "insert");
  135. loadGrid();
  136. }
  137. }
  138. }