Special_GetBad.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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.Make;
  12. using UAS_MES_NEW.PublicMethod;
  13. namespace UAS_MES_NEW.Special
  14. {
  15. public partial class Special_GetBad : Form
  16. {
  17. DataHelper dh;
  18. LogStringBuilder sql = new LogStringBuilder();
  19. DataTable dt;
  20. public Special_GetBad()
  21. {
  22. InitializeComponent();
  23. }
  24. private void Special_BoxSplit_Load(object sender, EventArgs e)
  25. {
  26. dh = SystemInf.dh;
  27. }
  28. private void Split_Click(object sender, EventArgs e)
  29. {
  30. if (SN.Text == "" || makecode.Text == null || makecode.Text == "")
  31. {
  32. OperatResult.AppendText(">>序列号和工单号不允许为空\n", Color.Red);
  33. }
  34. else
  35. {
  36. //如果存在送检批号则进行删除
  37. if (dh.CheckExist("oqcbatchdetail", "obd_sncode='" + SN.Text + "'"))
  38. {
  39. string checkno = dh.getFieldDataByCondition("oqcbatchdetail", "obd_checkno", "obd_sncode='" + SN.Text + "'").ToString();
  40. string ifng = dh.getFieldDataByCondition("oqcbatchdetail", "obd_ifng", "obd_sncode='" + SN.Text + "'").ToString();
  41. if (ifng == "-1")
  42. {
  43. dh.ExecuteSql("delete OQCITEMSAMPLES where ois_sncode = '" + SN.Text + "'", "select");
  44. dh.ExecuteSql("update oqcbatch set ob_nowcheckqty=ob_nowcheckqty-1,ob_ngqty = ob_ngqty -1 where ob_checkno='" + checkno + "'", "update");
  45. }
  46. dh.ExecuteSql("delete from oqcbatchdetail where obd_sncode='" + SN.Text + "'", "delete");
  47. }
  48. //之前保存的不良就不再调用
  49. DataTable dt = dh.getFieldsDataByCondition("makeserial", new string[] { "ms_stepcode", "nvl(ms_ifrework,0)ms_ifrework", "ms_status" }, "ms_sncode='" + SN.Text + "' and ms_makecode='" + makecode.Text + "'");
  50. if (dt.Rows.Count > 0)
  51. {
  52. string ifrework = dt.Rows[0]["ms_ifrework"].ToString();
  53. string ms_stepcode = dt.Rows[0]["ms_stepcode"].ToString();
  54. string ms_status = dt.Rows[0]["ms_status"].ToString();
  55. if (ms_status == "2")
  56. {
  57. dh.UpdateByCondition("make", "ma_madeqty=nvl(ma_madeqty,0)-1", "ma_code='" + makecode.Text + "'");
  58. }
  59. dh.UpdateByCondition("makeserial", "ms_nextstepcode='',ms_status=3", "ms_sncode='" + SN.Text + "' and ms_makecode='" + makecode.Text + "' ");
  60. }
  61. LogicHandler.InsertMakeProcess(SN.Text, makecode.Text, User.UserSourceCode, "采集成不良", "特殊测试不良", User.UserCode);
  62. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, makecode.Text, User.UserLineCode, User.UserSourceCode, "采集成不良", "特殊采集不良", SN.Text,"");
  63. OperatResult.AppendText(">>序列号:" + SN.Text + "不良采集成功\n", Color.Green);
  64. BaseUtil.CleanControls(this.Controls);
  65. }
  66. }
  67. private void SN_KeyDown(object sender, KeyEventArgs e)
  68. {
  69. if (e.KeyCode == Keys.Enter)
  70. {
  71. sql.Clear();
  72. sql.Append("select ms_makecode makecode from makeserial left join make ");
  73. sql.Append("on ms_makecode=ma_code where ms_sncode = '" + SN.Text + "' order by ms_id desc");
  74. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  75. BaseUtil.SetFormValue(this.Controls, dt);
  76. string ms_paststep = "";
  77. if (!(dt.Rows.Count > 0))
  78. {
  79. OperatResult.AppendText(">>序列号:" + SN.Text + "不存在\n", Color.Red);
  80. BaseUtil.CleanForm(this);
  81. return;
  82. }
  83. }
  84. }
  85. private void NewBadCode_Click(object sender, EventArgs e)
  86. {
  87. if (SN.Text == "" || makecode.Text == null || makecode.Text == "")
  88. {
  89. OperatResult.AppendText(">>序列号和工单号不允许为空\n", Color.Red);
  90. }
  91. else
  92. {
  93. Make_NewBadCode badcode = new Make_NewBadCode(SN.Text, makecode.Text);
  94. // badcode.FormClosed += LoadBadInfTree;
  95. BaseUtil.SetFormCenter(badcode);
  96. badcode.ShowDialog();
  97. }
  98. }
  99. }
  100. }