Query_LoadMake.cs 5.0 KB

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