RolledTubePhyFailQueryFrm.cs 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. using Core.Mes.Client.Comm.Control;
  2. using Core.StlMes.Client.Judge.Commons;
  3. using CoreFS.CA06;
  4. using Infragistics.Win.UltraWinGrid;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Data;
  8. using System.Linq;
  9. using System.Windows.Forms;
  10. namespace Core.StlMes.Client.Judge.Forms
  11. {
  12. public partial class RolledTubePhyFailQueryFrm : FrmBase
  13. {
  14. private Dal _d;
  15. public RolledTubePhyFailQueryFrm()
  16. {
  17. InitializeComponent();
  18. }
  19. public override void ToolBar_Click(object sender, string ToolbarKey)
  20. {
  21. base.ToolBar_Click(sender, ToolbarKey);
  22. switch (ToolbarKey)
  23. {
  24. case "Query":
  25. Query();
  26. break;
  27. case "Export":
  28. Export();
  29. break;
  30. case "Close":
  31. this.Close();
  32. break;
  33. }
  34. }
  35. private void Export()
  36. {
  37. GridHelper.ulGridToExcel(ultraGrid1, "理化不合信息");
  38. }
  39. private void RolledTubePhyFailQueryFrm_Load(object sender, EventArgs e)
  40. {
  41. _d = new Dal(ob);
  42. for (int i = DateTime.Now.Year - 10; i <= DateTime.Now.Year + 10; i++)
  43. {
  44. ultraComboEditor1.Items.Add(i);
  45. ultraComboEditor3.Items.Add(i);
  46. }
  47. ultraComboEditor1.Value = DateTime.Now.Year;
  48. ultraComboEditor2.Value = DateTime.Now.Month.ToString().PadLeft(2, '0');
  49. ultraComboEditor3.Value = DateTime.Now.Year;
  50. ultraComboEditor4.Value = DateTime.Now.Month.ToString().PadLeft(2, '0');
  51. JudgeBaseInfo.LoadPlineName(labelComboBox1.ComboBox, ob, false, CustomInfo);
  52. labelComboBox1.ComboBox.DropDownListWidth = -1;
  53. foreach (var item in labelComboBox1.ComboBox.Items)
  54. {
  55. item.CheckState = CheckState.Checked;
  56. }
  57. labelComboBox1.Checked = true;
  58. }
  59. private void Query()
  60. {
  61. string[] plines;
  62. if (!labelComboBox1.Checked)
  63. {
  64. plines = new string[labelComboBox1.ComboBox.Items.Count];
  65. for (int i = 0; i < labelComboBox1.ComboBox.Items.Count; i++)
  66. {
  67. plines[i] = labelComboBox1.ComboBox.Items[i].DataValue.ToString2();
  68. }
  69. if (plines.Length == 0)
  70. {
  71. plines = new string[] { "1" };
  72. }
  73. }
  74. else if (labelComboBox1.ComboBox.Value == null)
  75. {
  76. plines = new string[] { "1" };
  77. }
  78. else
  79. {
  80. plines = ((List<object>)labelComboBox1.ComboBox.Value).Select(a => a.ToString()).ToArray();
  81. }
  82. string yearMonth = ultraComboEditor1.Value.ToString2() + ultraComboEditor2.Value.ToString2();
  83. string yearMonth2 = ultraComboEditor3.Value.ToString2() + ultraComboEditor4.Value.ToString2();
  84. DataTable dt1 = _d.GetTableByXmlId("QcmZgJugdeApplyDAL.PhyFailQuery1", plines.Length, plines, yearMonth, yearMonth2);
  85. DataTable dt2 = _d.GetTableByXmlId("QcmZgJugdeApplyDAL.PhyFailQuery2", plines.Length, plines, yearMonth, yearMonth2);
  86. DataTable dt3 = _d.GetTableByXmlId("QcmZgJugdeApplyDAL.PhyFailQuery3", plines.Length, plines, yearMonth, yearMonth2);
  87. DataTable dt4 = _d.GetTableByXmlId("QcmZgJugdeApplyDAL.PhyFailQuery4", plines.Length, plines, yearMonth, yearMonth2);
  88. DataTable dt5 = _d.GetTableByXmlId("QcmZgJugdeApplyDAL.PhyFailQuery5", plines.Length, plines, yearMonth, yearMonth2);
  89. DataTable dt = dt1.Clone();
  90. foreach (DataColumn dc in dt2.Columns)
  91. {
  92. if (dt.Columns.Contains(dc.ColumnName)) continue;
  93. dt.Columns.Add(new DataColumn() { ColumnName = dc.ColumnName });
  94. }
  95. foreach (DataColumn dc in dt3.Columns)
  96. {
  97. if (dt.Columns.Contains(dc.ColumnName)) continue;
  98. dt.Columns.Add(new DataColumn() { ColumnName = dc.ColumnName });
  99. }
  100. foreach (DataColumn dc in dt4.Columns)
  101. {
  102. if (dt.Columns.Contains(dc.ColumnName)) continue;
  103. dt.Columns.Add(new DataColumn() { ColumnName = dc.ColumnName });
  104. }
  105. foreach (DataColumn dc in dt5.Columns)
  106. {
  107. if (dt.Columns.Contains(dc.ColumnName)) continue;
  108. dt.Columns.Add(new DataColumn() { ColumnName = dc.ColumnName });
  109. }
  110. foreach (DataRow dr1 in dt1.Rows)
  111. {
  112. DataRow drNew = dt.NewRow();
  113. DataRow[] aryDr2 = dt2.Select("判定炉号='" + dr1["判定炉号"].ToString() + "' AND 性能批号='" + dr1["性能批号"].ToString() + "'");
  114. DataRow dr2 = aryDr2.Length > 0 ? aryDr2[0] : null;
  115. DataRow[] aryDr3 = dt3.Select("判定炉号='" + dr1["判定炉号"].ToString() + "' AND 性能批号='" + dr1["性能批号"].ToString() + "'");
  116. DataRow dr3 = aryDr3.Length > 0 ? aryDr3[0] : null;
  117. DataRow[] aryDr4 = dt4.Select("判定炉号='" + dr1["判定炉号"].ToString() + "' AND 性能批号='" + dr1["性能批号"].ToString() + "'");
  118. DataRow dr4 = aryDr4.Length > 0 ? aryDr4[0] : null;
  119. DataRow[] aryDr5 = dt5.Select("判定炉号='" + dr1["判定炉号"].ToString() + "' AND 性能批号='" + dr1["性能批号"].ToString() + "'");
  120. DataRow dr5 = aryDr5.Length > 0 ? aryDr5[0] : null;
  121. if (dr2 == null && dr3 == null && dr4 == null && dr5 == null)
  122. continue;
  123. foreach (DataColumn dc in dt.Columns)
  124. {
  125. if (dt1.Columns.Contains(dc.ColumnName))
  126. {
  127. drNew[dc.ColumnName] = dr1[dc.ColumnName].ToString();
  128. }
  129. else if (dt2.Columns.Contains(dc.ColumnName))
  130. {
  131. if (dr2 == null) continue;
  132. drNew[dc.ColumnName] = dr2[dc.ColumnName].ToString();
  133. }
  134. else if (dt3.Columns.Contains(dc.ColumnName))
  135. {
  136. if (dr3 == null) continue;
  137. drNew[dc.ColumnName] = dr3[dc.ColumnName].ToString();
  138. }
  139. else if (dt4.Columns.Contains(dc.ColumnName))
  140. {
  141. if (dr4 == null) continue;
  142. drNew[dc.ColumnName] = dr4[dc.ColumnName].ToString();
  143. }
  144. else if (dt5.Columns.Contains(dc.ColumnName))
  145. {
  146. if (dr5 == null) continue;
  147. drNew[dc.ColumnName] = dr5[dc.ColumnName].ToString();
  148. }
  149. }
  150. dt.Rows.Add(drNew);
  151. }
  152. ultraGrid1.DataSource = dt;
  153. foreach (UltraGridColumn cl in ultraGrid1.DisplayLayout.Bands[0].Columns)
  154. {
  155. bool existsData = false;
  156. foreach (UltraGridRow row in ultraGrid1.Rows)
  157. {
  158. if (row.Cells[cl.Key].Value.ToString() != "")
  159. {
  160. existsData = true;
  161. }
  162. }
  163. if (!existsData)
  164. {
  165. cl.Hidden = true;
  166. }
  167. else
  168. {
  169. cl.Hidden = false;
  170. }
  171. }
  172. ultraGrid1.DisplayLayout.Bands[0].Override.SummaryDisplayArea = SummaryDisplayAreas.BottomFixed;
  173. ultraGrid1.DisplayLayout.Bands[0].Override.AllowDelete = Infragistics.Win.DefaultableBoolean.False;
  174. ultraGrid1.DisplayLayout.Bands[0].Override.AllowUpdate = Infragistics.Win.DefaultableBoolean.False;
  175. if (ultraGrid1.DisplayLayout.Bands[0].Summaries.Count == 0)
  176. {
  177. SummarySettings set = ultraGrid1.DisplayLayout.Bands[0].Summaries.Add(SummaryType.Sum, ultraGrid1.DisplayLayout.Bands[0].Columns["判定吨"]);
  178. set.SummaryType = SummaryType.Sum;
  179. set.SummaryPositionColumn = ultraGrid1.DisplayLayout.Bands[0].Columns["判定吨"];
  180. set.DisplayFormat = "总吨数:{0}";
  181. SummarySettings set2 = ultraGrid1.DisplayLayout.Bands[0].Summaries.Add(SummaryType.Sum, ultraGrid1.DisplayLayout.Bands[0].Columns["判定支"]);
  182. set2.SummaryType = SummaryType.Sum;
  183. set2.SummaryPositionColumn = ultraGrid1.DisplayLayout.Bands[0].Columns["判定支"];
  184. set2.DisplayFormat = "总支数:{0}";
  185. }
  186. GridHelper.RefreshAndAutoSize(ultraGrid1);
  187. }
  188. }
  189. }