Query_LoadMake.cs 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. using LabelManager2;
  2. using System;
  3. using System.Data;
  4. using System.Threading;
  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.Query
  10. {
  11. public partial class Query_LoadMake : Form
  12. {
  13. DataHelper dh = SystemInf.dh;
  14. ApplicationClass lbl;
  15. Document doc;
  16. DataTable Dbfind;
  17. Thread InitPrint;
  18. public Query_LoadMake()
  19. {
  20. InitializeComponent();
  21. try { UAS_MES_NEW.I18n.LanguageManager.Localize(this); } catch { }
  22. }
  23. private void Query_LoadMake_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 # 工单号,ma_prodcode # 产品编号,ma_qty # 工单数量,pr_detail # 产品名称,ma_softversion # 软件版本";
  27. ma_code.FormName = Name;
  28. ma_code.SetValueField = new string[] { "ma_code" };
  29. ma_code.Condition = "ma_statuscode='STARTED'";
  30. ma_code.DbChange += Ma_code_DbChange;
  31. li_code.TableName = "line";
  32. li_code.SelectField = "li_code # 线别编号,li_name # 线别名称";
  33. li_code.FormName = Name;
  34. li_code.SetValueField = new string[] { "li_code" };
  35. li_code.Condition = "li_statuscode='AUDITED'";
  36. li_code.DbChange += Ma_code_DbChange;
  37. LoadGridData();
  38. }
  39. private void Ma_code_DbChange(object sender, EventArgs e)
  40. {
  41. Dbfind = ma_code.ReturnData;
  42. BaseUtil.SetFormValue(this.Controls, Dbfind);
  43. }
  44. private void UpLoadMake_Click(object sender, EventArgs e)
  45. {
  46. if (ma_code.Text == "" || li_code.Text == "")
  47. {
  48. MessageBox.Show(UAS_MES_NEW.I18n.LanguageManager.T("工单和线别不允许为空"));
  49. return;
  50. }
  51. if (mancount.Value == 0)
  52. {
  53. MessageBox.Show(UAS_MES_NEW.I18n.LanguageManager.T("人数必须大于0"));
  54. return;
  55. }
  56. if (dh.CheckExist("loadmake", "lm_linecode='" + li_code.Text + "' and lm_stepcode='" + User.CurrentStepCode + "' and lm_downtime is null"))
  57. {
  58. MessageBox.Show(UAS_MES_NEW.I18n.LanguageManager.T("线别") + li_code.Text + UAS_MES_NEW.I18n.LanguageManager.T("存在在线工单,不允许上线"));
  59. return;
  60. }
  61. dh.ExecuteSql("insert into loadmake(lm_id,lm_makecode,lm_linecode,lm_uptime,lm_inman,lm_mannum,lm_stepcode)" +
  62. "values(loadmake_seq.nextval,'" + ma_code.Text + "','" + li_code.Text + "',sysdate,'" + User.UserName + "','" + mancount.Value + "','" + User.CurrentStepCode + "')", "insert");
  63. LoadGridData();
  64. }
  65. private void DownLoadMake_Click(object sender, EventArgs e)
  66. {
  67. if (!ifcheckrow())
  68. {
  69. MessageBox.Show(UAS_MES_NEW.I18n.LanguageManager.T("请勾选需要操作的行"));
  70. return;
  71. }
  72. for (int i = 0; i < DGV.Rows.Count; i++)
  73. {
  74. if (DGV.Rows[i].Cells["Choose"].Value != null && DGV.Rows[i].Cells["Choose"].FormattedValue.ToString() == "True")
  75. {
  76. dh.ExecuteSql("update loadmake set lm_downtime=sysdate where lm_id='" + DGV.Rows[i].Cells["lm_id"].Value.ToString() + "'", "update");
  77. }
  78. }
  79. LoadGridData();
  80. }
  81. private void LoadGridData()
  82. {
  83. DataTable dt = (DataTable)dh.ExecuteSql("select * from loadmake where lm_downtime is null and lm_stepcode='" + User.CurrentStepCode + "'", "select");
  84. BaseUtil.FillDgvWithDataTable(DGV, dt);
  85. }
  86. private void ChangeMan_Click(object sender, EventArgs e)
  87. {
  88. if (!ifcheckrow())
  89. {
  90. MessageBox.Show(UAS_MES_NEW.I18n.LanguageManager.T("请勾选需要操作的行"));
  91. return;
  92. }
  93. for (int i = 0; i < DGV.Rows.Count; i++)
  94. {
  95. if (DGV.Rows[i].Cells["Choose"].Value != null && DGV.Rows[i].Cells["Choose"].FormattedValue.ToString() == "True")
  96. {
  97. dh.ExecuteSql("update loadmake set lm_downtime=sysdate where lm_id='" + DGV.Rows[i].Cells["lm_id"].Value.ToString() + "'", "update");
  98. string makecode = DGV.Rows[i].Cells["lm_makecode"].Value.ToString();
  99. string licode = DGV.Rows[i].Cells["lm_linecode"].Value.ToString();
  100. string mannum = DGV.Rows[i].Cells["LM_MANNUM"].Value.ToString();
  101. dh.ExecuteSql("insert into loadmake(lm_id,lm_makecode,lm_linecode,lm_uptime,lm_inman,lm_mannum,lm_stepcode)" +
  102. "values(loadmake_seq.nextval,'" + makecode + "','" + licode + "',sysdate,'" + User.UserName + "','" + mannum + "','" + User.CurrentStepCode + "')", "insert");
  103. }
  104. }
  105. LoadGridData();
  106. }
  107. private bool ifcheckrow()
  108. {
  109. for (int i = 0; i < DGV.Rows.Count; i++)
  110. {
  111. if (DGV.Rows[i].Cells["Choose"].Value != null && DGV.Rows[i].Cells["Choose"].FormattedValue.ToString() == "True")
  112. {
  113. return true;
  114. }
  115. }
  116. return false;
  117. }
  118. }
  119. }