Query_OnlineTraceBack.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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_OnlineTraceBack : Form
  15. {
  16. DataHelper dh;
  17. LogStringBuilder sql = new LogStringBuilder();
  18. AutoSizeFormClass asc = new AutoSizeFormClass();
  19. DataTable ComBoxData = new DataTable();
  20. DataTable Dbfind;
  21. public Query_OnlineTraceBack()
  22. {
  23. InitializeComponent();
  24. }
  25. private void Query_OnlineTraceBack_Load(object sender, EventArgs e)
  26. {
  27. asc.controllInitializeSize(this);
  28. dh = SystemInf.dh;
  29. DataColumn status = new DataColumn("status");
  30. DataColumn statuscode = new DataColumn("statuscode");
  31. ComBoxData.Columns.Add(status);
  32. ComBoxData.Columns.Add(statuscode);
  33. DataRow dr = ComBoxData.NewRow();
  34. dr[0] = "全部"; dr[1] = "ALL"; ComBoxData.Rows.Add(dr);
  35. dr = ComBoxData.NewRow();
  36. dr[0] = "未生产"; dr[1] = "null"; ComBoxData.Rows.Add(dr);
  37. dr = ComBoxData.NewRow();
  38. dr[0] = "已归属"; dr[1] = "0"; ComBoxData.Rows.Add(dr);
  39. dr = ComBoxData.NewRow();
  40. dr[0] = "在线"; dr[1] = "1"; ComBoxData.Rows.Add(dr);
  41. dr = ComBoxData.NewRow();
  42. dr[0] = "已完工"; dr[1] = "2"; ComBoxData.Rows.Add(dr);
  43. dr = ComBoxData.NewRow();
  44. dr[0] = "不良待维修"; dr[1] = "3"; ComBoxData.Rows.Add(dr);
  45. dr = ComBoxData.NewRow();
  46. dr[0] = "已报废"; dr[1] = "4"; ComBoxData.Rows.Add(dr);
  47. ms_status.DataSource = ComBoxData;
  48. ms_status.DisplayMember = "status";
  49. ms_status.ValueMember = "statuscode";
  50. //工单号放大镜配置
  51. ma_code.TableName = "make left join product on ma_prodcode=pr_code";
  52. ma_code.SelectField = "ma_code # 工单号,ma_prodcode # 产品编号,ma_qty # 工单数量,pr_detail # 产品名称,ma_softversion # 软件版本";
  53. ma_code.FormName = Name;
  54. ma_code.SetValueField = new string[] { "ma_code" };
  55. ma_code.Condition = "ma_statuscode='STARTED'";
  56. ma_code.DbChange += Ma_code_DbChange;
  57. }
  58. private void Ma_code_DbChange(object sender, EventArgs e)
  59. {
  60. Dbfind = ma_code.ReturnData;
  61. BaseUtil.SetFormValue(this.Controls, Dbfind);
  62. Query.PerformClick();
  63. }
  64. private void Query_OnlineTraceBack_SizeChanged(object sender, EventArgs e)
  65. {
  66. asc.controlAutoSize(this);
  67. }
  68. private void Query_Click(object sender, EventArgs e)
  69. {
  70. if (dh.CheckExist("make", "ma_code='" + ma_code.Text + "'"))
  71. {
  72. string condition = BaseUtil.GetScreenSqlCondition(ma_code, ms_stepcode, ms_nextstepcode);
  73. string statuscode = ms_status.SelectedValue.ToString();
  74. sql.Clear();
  75. sql.Append("select distinct sncode ms_sncode,ms_linecode,ms_stepcode,ms_nextstepcode,ms_craftcode,makecode ms_makecode, ");
  76. sql.Append("case when ms_status is null then '未生产' when ms_status=0 then '已归属' when ms_status=1 then '在线' when ms_status=2 ");
  77. sql.Append(" then '已完工' when ms_status=3 then '不良待维修' when ms_status=4 then '已报废' ");
  78. sql.Append("else 'null' end ms_status from((select msd_sncode sncode,msd_makecode makecode,msd_type type ");
  79. sql.Append("from makesnruledetail where msd_makecode='" + ma_code.Text + "') union (select msl_sncode sncode,msl_makecode ");
  80. sql.Append("makecode,msl_type type from makesnlist where msl_makecode='" + ma_code.Text + "') union (");
  81. sql.Append("select ms_sncode,ms_makecode,'' type from makeserial where ms_makecode='" + ma_code.Text + "'))");
  82. sql.Append("A left join makeserial on ms_sncode=sncode and ms_makecode=makecode ");
  83. sql.Append(condition);
  84. if (statuscode == "null")
  85. {
  86. sql.Append("and ms_status is null");
  87. }
  88. else if (statuscode == "ALL")
  89. {
  90. }
  91. else
  92. {
  93. sql.Append("and ms_status ='" + statuscode + "'");
  94. }
  95. sql.Append(" order by ms_sncode ");
  96. DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  97. BaseUtil.FillDgvWithDataTable(SnInf, dt);
  98. Count.Text = SnInf.Rows.Count.ToString();
  99. ma_qty.Text = dh.getFieldDataByCondition("make", "ma_qty", "ma_code='" + ma_code.Text + "'").ToString();
  100. }
  101. else
  102. {
  103. MessageBox.Show("工单号" + ma_code.Text + "不存在");
  104. BaseUtil.CleanDataGridView(SnInf);
  105. ma_code.Text = "";
  106. }
  107. }
  108. private void ms_status_SelectedIndexChanged(object sender, EventArgs e)
  109. {
  110. if (ma_code.Text != "")
  111. Query.PerformClick();
  112. }
  113. }
  114. }