Query_DateRate.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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.PublicMethod;
  12. namespace UAS_MES_NEW.Query
  13. {
  14. public partial class Query_DateRate : Form
  15. {
  16. AutoSizeFormClass asc = new AutoSizeFormClass();
  17. string querysql = "";
  18. string condition;
  19. DataHelper dh = SystemInf.dh;
  20. DataTable Dbfind;
  21. public Query_DateRate()
  22. {
  23. InitializeComponent();
  24. }
  25. private void Query_SpecialReport_Load(object sender, EventArgs e)
  26. {
  27. asc.controllInitializeSize(this);
  28. //工单号放大镜配置
  29. pr_code.TableName = " product ";
  30. pr_code.SelectField = "pr_code # 产品编号,pr_detail # 产品名称,pr_orispeccode # 型号";
  31. pr_code.FormName = Name;
  32. pr_code.SetValueField = new string[] { "pr_code" };
  33. pr_code.Condition = "pr_statuscode='AUDITED'";
  34. pr_code.DbChange += pr_code_DbChange;
  35. wc_code.TableName = " workcenter ";
  36. wc_code.SelectField = "wc_code # 车间编号,wc_name # 车间名称";
  37. wc_code.FormName = Name;
  38. wc_code.SetValueField = new string[] { "wc_code" };
  39. wc_code.Condition = "wc_statuscode='AUDITED'";
  40. wc_code.DbChange += pr_code_DbChange;
  41. li_code.TableName = " line ";
  42. li_code.SelectField = "li_code # 车间编号,li_name # 车间名称";
  43. li_code.FormName = Name;
  44. li_code.SetValueField = new string[] { "li_code" };
  45. li_code.Condition = "li_statuscode='AUDITED'";
  46. li_code.DbChange += pr_code_DbChange;
  47. ma_code.TableName = " make left join product on ma_prodcode=pr_code left join workcenter on ma_wccode = wc_code";
  48. ma_code.SelectField = "ma_code # 工单编号,ma_prodcode # 产品编号,pr_spec # 型号,wc_code # 工作中心";
  49. ma_code.FormName = Name;
  50. ma_code.SetValueField = new string[] { "ma_code", "wc_code" };
  51. ma_code.Condition = "ma_statuscode='STARTED'";
  52. ma_code.DbChange += pr_code_DbChange;
  53. }
  54. private void Export_Click(object sender, EventArgs e)
  55. {
  56. if (wc_code.Text == "")
  57. {
  58. MessageBox.Show("请输入车间");
  59. return;
  60. }
  61. if (EndDate.Value < BeginDate.Value)
  62. {
  63. MessageBox.Show("结束日期不能小于起始日期");
  64. }
  65. condition = "";
  66. condition = " sp_date between to_date('" + BeginDate.Value.ToString("yyyy-MM-dd HH:mm:ss") + "', 'yyyy-mm-dd hh24:mi:ss') and to_date('" + EndDate.Value.ToString("yyyy-MM-dd HH:mm:ss") + "', 'yyyy-mm-dd hh24:mi:ss') ";
  67. if (wc_code.Text != "")
  68. {
  69. condition += " and sp_wccode = '" + wc_code.Text + "'";
  70. }
  71. if (pr_code.Text != "")
  72. {
  73. condition += " and sp_prodcode = '" + pr_code.Text + "'";
  74. }
  75. if (ma_code.Text != "")
  76. {
  77. condition += " and sp_makecode = '" + ma_code.Text + "'";
  78. }
  79. if (li_code.Text != "")
  80. {
  81. condition += " and sp_linecode = '" + li_code.Text + "'";
  82. }
  83. string v_sql = "";
  84. //string v_sql1 = "";
  85. LogicHandler.GetQuerySQL(condition, "直通率", out v_sql);
  86. DataTable dt = (DataTable)dh.ExecuteSql(v_sql, "select");
  87. DataRow dr = dt.NewRow();
  88. dr[3] = "ALL";
  89. dt.Rows.InsertAt(dr, dt.Rows.Count);
  90. BaseUtil.FillDgvWithDataTable(Data, dt);
  91. }
  92. private void pr_code_DbChange(object sender, EventArgs e)
  93. {
  94. Dbfind = pr_code.ReturnData;
  95. BaseUtil.SetFormValue(this.Controls, Dbfind);
  96. }
  97. private void Data_CellContentClick(object sender, DataGridViewCellEventArgs e)
  98. {
  99. try
  100. {
  101. if (Data.Columns[e.ColumnIndex].Name == "SNQTY")
  102. {
  103. Form baditem = new BadItem(li_code.Text, pr_code.Text, wc_code.Text, BeginDate.Value.ToString("yyyy-MM-dd HH:mm:ss"), EndDate.Value.ToString("yyyy-MM-dd HH:mm:ss"), Data.Rows[e.RowIndex].Cells["sp_stepcode"].Value.ToString());
  104. baditem.Show();
  105. }
  106. }
  107. catch (Exception ex)
  108. {
  109. MessageBox.Show(ex.Message);
  110. }
  111. }
  112. private void Query_DateRate_SizeChanged(object sender, EventArgs e)
  113. {
  114. asc.controlAutoSize(this);
  115. }
  116. }
  117. }