Special_ChangeMakeCode.cs 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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_ChangeMakeCode : Form
  12. {
  13. DataHelper dh = SystemInf.dh;
  14. LogStringBuilder sql = new LogStringBuilder();
  15. public Special_ChangeMakeCode()
  16. {
  17. InitializeComponent();
  18. }
  19. private void Clean_Click(object sender, EventArgs e)
  20. {
  21. OperateResult.Clear();
  22. }
  23. private void Special_CancelCollection_Load(object sender, EventArgs e)
  24. {
  25. ma_code.TableName = " make left join product on ma_prodcode=pr_code";
  26. ma_code.SelectField = "ma_code # 工单编号,pr_code # 产品编号,pr_spec # 型号";
  27. ma_code.FormName = Name;
  28. ma_code.SetValueField = new string[] { "ma_code" };
  29. ma_code.Condition = "ma_statuscode='STARTED'";
  30. ma_code.DbChange += pr_code_DbChange;
  31. ma_code1.TableName = " make left join product on ma_prodcode=pr_code";
  32. ma_code1.SelectField = "ma_code # 工单编号,pr_code # 产品编号,pr_spec # 型号";
  33. ma_code1.FormName = Name;
  34. ma_code1.SetValueField = new string[] { "ma_code1" };
  35. ma_code1.Condition = "ma_statuscode='STARTED'";
  36. ma_code1.DbChange += pr_code_DbChange1;
  37. }
  38. DataTable Dbfind;
  39. private void pr_code_DbChange(object sender, EventArgs e)
  40. {
  41. Dbfind = ma_code.ReturnData;
  42. BaseUtil.SetFormValue(this.Controls, Dbfind);
  43. DataTable dt = (DataTable)dh.ExecuteSql("select ma_qty,ma_prodcode,pr_detail,ma_printnum from make left join product on ma_prodcode=pr_code left join (select count(1)ma_printnum,mil_makecode from makeimeilist where mil_printstatus=-1 group by mil_makecode) on mil_makecode=ma_code where ma_code='" + ma_code.Text + "'", "select");
  44. if (dt.Rows.Count > 0)
  45. {
  46. pr_code.Text = dt.Rows[0]["ma_prodcode"].ToString();
  47. pr_detail.Text = dt.Rows[0]["pr_detail"].ToString();
  48. }
  49. }
  50. private void pr_code_DbChange1(object sender, EventArgs e)
  51. {
  52. Dbfind = ma_code.ReturnData;
  53. BaseUtil.SetFormValue(this.Controls, Dbfind);
  54. DataTable dt = (DataTable)dh.ExecuteSql("select ma_qty,ma_prodcode,pr_detail,ma_printnum from make left join product on ma_prodcode=pr_code left join (select count(1)ma_printnum,mil_makecode from makeimeilist where mil_printstatus=-1 group by mil_makecode) on mil_makecode=ma_code where ma_code='" + ma_code.Text + "'", "select");
  55. if (dt.Rows.Count > 0)
  56. {
  57. pr_code1.Text = dt.Rows[0]["ma_prodcode"].ToString();
  58. pr_detail1.Text = dt.Rows[0]["pr_detail"].ToString();
  59. }
  60. }
  61. private void Confirm_Click(object sender, EventArgs e)
  62. {
  63. if (ma_code.Text == "" || ma_code1.Text == "")
  64. {
  65. OperateResult.AppendText("工单号不允许为空\n");
  66. return;
  67. }
  68. if (!dh.CheckExist("make", "ma_code='" + ma_code.Text + "'"))
  69. {
  70. OperateResult.AppendText("工单号" + ma_code.Text + "不存在\n");
  71. return;
  72. }
  73. if (!dh.CheckExist("make", "ma_code='" + ma_code1.Text + "'"))
  74. {
  75. OperateResult.AppendText("工单号" + ma_code1.Text + "不存在\n");
  76. return;
  77. }
  78. //if (dh.getFieldDataByCondition("make", "ma_prodcode", "ma_code='" + ma_code.Text + "'").ToString() != dh.getFieldDataByCondition("make", "ma_prodcode", "ma_code='" + ma_code1.Text + "'").ToString())
  79. //{
  80. // OperateResult.AppendText("工单号产品编号不对应,不允许切换\n");
  81. // return;
  82. //}
  83. List<string> sqls = new List<string>();
  84. sqls.Add("update CRAFTMATERIAL set cm_makecode='" + ma_code1.Text + "' where cm_makecode= '" + ma_code.Text + "'");
  85. sqls.Add("update steppassed set sp_makecode='" + ma_code1.Text + "' where sp_makecode= '" + ma_code.Text + "'");
  86. sqls.Add("update makeserial set ms_makecode='" + ma_code1.Text + "' where ms_makecode= '" + ma_code.Text + "'");
  87. sqls.Add("update makeprocess set mp_makecode='" + ma_code1.Text + "' where mp_makecode= '" + ma_code.Text + "'");
  88. sqls.Add("update commandlog set cl_makecode='" + ma_code1.Text + "' where cl_makecode= '" + ma_code.Text + "'");
  89. sqls.Add("update makebad set mb_makecode='" + ma_code1.Text + "' where mb_makecode= '" + ma_code.Text + "'");
  90. sqls.Add("update labelprintlog set lpl_makecode='" + ma_code1.Text + "' where lpl_makecode= '" + ma_code.Text + "'");
  91. sqls.Add("update package set pa_makecode='" + ma_code1.Text + "' where pa_makecode= '" + ma_code.Text + "'");
  92. sqls.Add("update packagedetail set pd_makecode='" + ma_code1.Text + "' where pd_makecode= '" + ma_code.Text + "'");
  93. sqls.Add("update make set ma_inqty=(select count(1) from makeserial where ms_makecode='"+ma_code1.Text+"') and ma_code='"+ma_code1.Text+"'");
  94. sqls.Add("update make set ma_endqty=(select count(1) from makeserial where ms_makecode='" + ma_code1.Text+"' and ms_status=2) and ma_code='"+ma_code1.Text+"'");
  95. dh.ExecuteSQLTran(sqls.ToArray());
  96. OperateResult.AppendText("工单号切换成功\n");
  97. LogicHandler.DoCommandLog("", User.UserName, ma_code.Text, User.UserLineCode, User.UserSourceCode, "工单变更", "工单变更" + ma_code.Text + "切换到" + ma_code1.Text, "", "");
  98. }
  99. }
  100. }