Special_ChangeMakeCode.cs 5.8 KB

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