Special_Oksn.cs 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Drawing;
  5. using System.Windows.Forms;
  6. using UAS_MES_NEW.DataOperate;
  7. using UAS_MES_NEW.Entity;
  8. using UAS_MES_NEW.PublicMethod;
  9. namespace UAS_MES_NEW.Special
  10. {
  11. public partial class Special_Oksn : Form
  12. {
  13. DataHelper dh;
  14. LogStringBuilder sql = new LogStringBuilder();
  15. AutoSizeFormClass asc = new AutoSizeFormClass();
  16. DataTable Dbfind;
  17. public Special_Oksn()
  18. {
  19. InitializeComponent();
  20. }
  21. private void Confirm_Click(object sender, EventArgs e)
  22. {
  23. }
  24. private void Clean_Click(object sender, EventArgs e)
  25. {
  26. OperateResult.Clear();
  27. }
  28. private void Special_CancelCollection_Load(object sender, EventArgs e)
  29. {
  30. dh = SystemInf.dh;
  31. // asc.controllInitializeSize(this);
  32. ma_code.TableName = "make left join product on ma_prodcode=pr_code";
  33. ma_code.SelectField = "ma_code # 工单号,ma_prodcode # 产品编号,ma_qty # 工单数量, pr_orispeccode # 型号, ma_wccode # 车间,ma_inqty # 投入数,pr_spec # 产品规格";
  34. ma_code.FormName = Name;
  35. ma_code.SetValueField = new string[] { "ma_code", "ma_prodcode", "ma_qty", "pr_orispeccode" };
  36. ma_code.Condition = "ma_statuscode='STARTED' order by ma_auditdate desc";
  37. ma_code.DbChange += Ma_code_DbChange;
  38. ma_code.SetLockCheckBox(Lock);
  39. Lock.GetMakeCodeCtl(ma_code);
  40. }
  41. private void Ma_code_DbChange(object sender, EventArgs e)
  42. {
  43. Dbfind = ma_code.ReturnData;
  44. BaseUtil.SetFormValue(this.Controls, Dbfind);
  45. getqty.Text = dh.getFieldDataByCondition("makeserial", "count(1) cn ", "MS_LASTSTEP is not null and ms_makecode = '"+ma_code.Text+"' ").ToString();
  46. }
  47. private void sn_code_KeyDown(object sender, KeyEventArgs e)
  48. {
  49. if (e.KeyCode == Keys.Enter)
  50. {
  51. if (!checkBox1.Checked)
  52. {
  53. //获取序列号的途程
  54. DataTable dt = (DataTable)dh.ExecuteSql("select ms_id,ms_nextstepcode,ms_outboxcode,ms_makecode,ms_status,ms_laststep,ms_craftcode,ms_prodcode,ms_stepcode from makeserial where ms_sncode='" + sn_code.Text + "' and ms_makecode = '"+ma_code.Text+"' order by ms_id desc", "select");
  55. if (dt.Rows.Count > 0)
  56. {
  57. string pr_code = dt.Rows[0]["ms_prodcode"].ToString();
  58. string cr_code = dt.Rows[0]["ms_craftcode"].ToString();
  59. string ms_nextstepcode = dt.Rows[0]["ms_nextstepcode"].ToString();
  60. string ms_makecode = dt.Rows[0]["ms_makecode"].ToString();
  61. string ms_stepcode = dt.Rows[0]["ms_stepcode"].ToString();
  62. string ms_laststep = dt.Rows[0]["ms_laststep"].ToString();
  63. string ms_status = dt.Rows[0]["ms_status"].ToString();
  64. string ms_outboxcode = dt.Rows[0]["ms_outboxcode"].ToString();
  65. string ms_id = dt.Rows[0]["ms_id"].ToString();
  66. if (ms_nextstepcode == "")
  67. {
  68. OperateResult.AppendText(">>序列号" + sn_code.Text + "非在制状态,无法采集\n", Color.Red, sn_code);
  69. return;
  70. }
  71. if (ms_outboxcode != "")
  72. {
  73. OperateResult.AppendText(">>序列号" + sn_code.Text + "已装箱"+ms_outboxcode+",无法采集\n", Color.Red, sn_code);
  74. return;
  75. }
  76. if (dh.CheckExist("step", "st_code = '" + ms_nextstepcode + "' and nvl(st_ifoqc,0) <> -1 and nvl(st_ifover,0) = -1 "))
  77. {
  78. if (dh.CheckExist("makedown", "md_msid = " + ms_id + " and md_status = 0"))
  79. {
  80. OperateResult.AppendText(">>序列号" + sn_code.Text + "被锁定,无法采集\n", Color.Red, sn_code);
  81. return;
  82. }
  83. dh.ExecuteSql("update makeserial set ms_status = 2,ms_laststep = ms_nextstepcode,ms_nextstepcode = '' where ms_id = " + ms_id + " ", "update");
  84. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ms_makecode, User.UserLineCode, User.UserSourceCode, "完工采集", "完工采集成功", sn_code.Text, "");
  85. OperateResult.AppendText(">>序列号" + sn_code.Text + "采集成完工\n", Color.Green, sn_code);
  86. getqty.Text = dh.getFieldDataByCondition("makeserial", "count(1) cn ", "MS_LASTSTEP is not null and ms_makecode = '" + ma_code.Text + "' ").ToString();
  87. }
  88. else
  89. {
  90. OperateResult.AppendText(">>序列号" + sn_code.Text + "所处工序" + ms_nextstepcode + ",无法采集\n", Color.Red, sn_code);
  91. return;
  92. }
  93. }
  94. else OperateResult.AppendText(">>序列号" + sn_code.Text + "不存在\n", Color.Red, sn_code);
  95. }
  96. else
  97. {
  98. //获取序列号的途程
  99. DataTable dt = (DataTable)dh.ExecuteSql("select ms_id,ms_nextstepcode,ms_currentstepcode,ms_makecode,ms_status,ms_laststep,ms_craftcode,ms_prodcode,ms_stepcode from makeserial where ms_sncode='" + sn_code.Text + "' and ms_makecode = '"+ma_code.Text+"' order by ms_id desc", "select");
  100. if (dt.Rows.Count > 0)
  101. {
  102. string pr_code = dt.Rows[0]["ms_prodcode"].ToString();
  103. string cr_code = dt.Rows[0]["ms_craftcode"].ToString();
  104. string ms_nextstepcode = dt.Rows[0]["ms_nextstepcode"].ToString();
  105. string ms_makecode = dt.Rows[0]["ms_makecode"].ToString();
  106. string ms_stepcode = dt.Rows[0]["ms_stepcode"].ToString();
  107. string ms_laststep = dt.Rows[0]["ms_laststep"].ToString();
  108. string ms_status = dt.Rows[0]["ms_status"].ToString();
  109. string ms_currentstepcode = dt.Rows[0]["ms_currentstepcode"].ToString();
  110. string ms_id = dt.Rows[0]["ms_id"].ToString();
  111. if (ms_status != "2")
  112. {
  113. OperateResult.AppendText(">>序列号" + sn_code.Text + "非完工,无法撤销\n", Color.Red, sn_code);
  114. return;
  115. }
  116. if (ms_laststep == "")
  117. {
  118. OperateResult.AppendText(">>序列号" + sn_code.Text + "未采集过,无法撤销\n", Color.Red, sn_code);
  119. return;
  120. }
  121. dh.ExecuteSql("update makeserial set ms_status = 1,ms_nextstepcode = ms_laststep,ms_laststep = '' where ms_id = " + ms_id + "", "update");
  122. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ms_makecode, User.UserLineCode, User.UserSourceCode, "撤销完工采集", "撤销完工采集成功", sn_code.Text, "");
  123. OperateResult.AppendText(">>序列号" + sn_code.Text + "撤销完工\n", Color.Green, sn_code);
  124. getqty.Text = dh.getFieldDataByCondition("makeserial", "count(1) cn ", "MS_LASTSTEP is not null and ms_makecode = '" + ma_code.Text + "' ").ToString();
  125. }
  126. else OperateResult.AppendText(">>序列号" + sn_code.Text + "不存在\n", Color.Red, sn_code);
  127. }
  128. }
  129. }
  130. private void Special_Oksn_SizeChanged(object sender, EventArgs e)
  131. {
  132. // asc.controlAutoSize(this);
  133. }
  134. }
  135. }