FrmUnLoadReport.cs 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Windows.Forms;
  5. using Core.Mes.Client.Comm.Control;
  6. using Core.Mes.Client.Comm.Tool;
  7. using Core.StlMes.Client.Mcp.Control.Entity;
  8. using CoreFS.CA06;
  9. using Infragistics.Win;
  10. using Infragistics.Win.UltraWinGrid;
  11. namespace Core.StlMes.Client.Mcp.Mch.Report
  12. {
  13. public partial class FrmUnLoadReport : FrmBase
  14. {
  15. private string[] _plineCodes = {};
  16. public FrmUnLoadReport()
  17. {
  18. InitializeComponent();
  19. IsLoadUserView = true;
  20. }
  21. /// <summary>
  22. /// 合同信息
  23. /// </summary>
  24. protected List<string> ViewList = new List<string>
  25. {
  26. "JudgeStoveNo",
  27. "BatchNo",
  28. "PlineName",
  29. "Producname",
  30. "Steelname",
  31. "Gradename",
  32. "Outdiameter",
  33. "Wallthick",
  34. "ModelDesc",
  35. "OrderNoSeq",
  36. "PlanIndoubleNum",
  37. "PlanIndoubleWt",
  38. "ProCount",
  39. "ProWeight",
  40. "ActCount",
  41. "ActWeight"
  42. };
  43. public override void ToolBar_Click(object sender, string ToolbarKey)
  44. {
  45. switch (ToolbarKey)
  46. {
  47. case "DoQuery":
  48. Query();
  49. break;
  50. case "Export":
  51. Export();
  52. break;
  53. case "DoClose":
  54. Close();
  55. break;
  56. }
  57. }
  58. /// <summary>
  59. /// 导出
  60. /// </summary>
  61. protected virtual void Export()
  62. {
  63. GridHelper.ulGridToExcel(CrackDetectGrid, Text);
  64. }
  65. /// <summary>
  66. /// 查询
  67. /// </summary>
  68. private void Query()
  69. {
  70. var Message = "";
  71. var wf = new WaitingForm2("正在查询,请稍候....");
  72. try
  73. {
  74. Cursor = Cursors.WaitCursor;
  75. DataBindingSource.DataSource = EntityHelper.GetData<PlnZyJgxCEntity>(
  76. "com.steering.mes.mcp.Mch.FrmJgxReport.doQueryUnLoadReport",
  77. GetQueryCondition(),
  78. ob);
  79. GridHelper.RefreshAndAutoSizeExceptColumns(CrackDetectGrid, "ReportPath");
  80. }
  81. catch (Exception ex)
  82. {
  83. if (ex.Message.ToString2() != "")
  84. MessageBox.Show(ex.Message);
  85. }
  86. finally
  87. {
  88. wf.Close();
  89. Cursor = Cursors.Default;
  90. }
  91. }
  92. /// <summary>
  93. /// 按照区域重新排序
  94. /// </summary>
  95. private void Resort()
  96. {
  97. SortBand(ViewList, CrackDetectGrid.DisplayLayout.Bands[0]);
  98. }
  99. /// <summary>
  100. /// Band重新排序
  101. /// </summary>
  102. /// <param name="ColumnSeq"></param>
  103. /// <param name="band"></param>
  104. private void SortBand(List<string> ColumnSeq, UltraGridBand band)
  105. {
  106. foreach (var Columns in band.Columns)
  107. ResetColumns(Columns);
  108. var ColumnX = 0;
  109. for (var i = 0; i < ColumnSeq.Count; i++)
  110. {
  111. var Key = ColumnSeq[i];
  112. if (band.Columns.Exists(Key))
  113. {
  114. band.Columns[Key].Hidden = false;
  115. band.Columns[Key].RowLayoutColumnInfo.OriginX = 2 * ColumnX++;
  116. band.Columns[Key].RowLayoutColumnInfo.OriginY = 0;
  117. }
  118. }
  119. }
  120. /// <summary>
  121. /// 重置字段属性,或绑定
  122. /// </summary>
  123. /// <param name="Columns"></param>
  124. protected virtual void ResetColumns(UltraGridColumn Columns)
  125. {
  126. Columns.Hidden = true;
  127. Columns.CellActivation = Activation.ActivateOnly;
  128. }
  129. /// <summary>
  130. /// 获取查询区域参数
  131. /// </summary>
  132. /// <returns></returns>
  133. protected object[] GetQueryCondition()
  134. {
  135. var OrderNo = "";
  136. var JudgeStoveNo = "";
  137. var BatchNo = "";
  138. if (chkOrderNo.Checked)
  139. OrderNo = txtOrderNo.Text;
  140. if (chkJudgeStove.Checked)
  141. JudgeStoveNo = txtJudgeStove.Text;
  142. if (chkBatchNo.Checked)
  143. BatchNo = txtBatchNo.Text;
  144. return new object[]
  145. {
  146. chkPlineCode.Checked && (cboPline.CheckedItems.Count > 0)
  147. ? cboPline.CheckedItems.Select(p => p.DataValue.ToString()).ToArray()
  148. : _plineCodes,OrderNo, JudgeStoveNo, BatchNo,chkExitsC.Checked?"1":"0",chkExitsL.Checked?"1":"0"
  149. };
  150. }
  151. protected override void OnLoad(EventArgs e)
  152. {
  153. base.OnLoad(e);
  154. EntityHelper.ShowGridCaption<PlnZyJgxCEntity>(CrackDetectGrid.DisplayLayout.Bands[0]);
  155. Resort();
  156. SetStaticsInfoSum( ref CrackDetectGrid, new List<string>()
  157. {
  158. "PlanIndoubleNum",
  159. "PlanIndoubleWt",
  160. "ProCount",
  161. "ProWeight",
  162. "ActCount",
  163. "ActWeight"
  164. }, true, true);
  165. if (ob == null) return;
  166. _plineCodes = comm.InitDropPlineCodePower("G", cboPline, ValidDataPurviewIds, ob);
  167. Query();
  168. }
  169. private void chkStarts_CheckedChanged(object sender, EventArgs e)
  170. {
  171. txtOrderNo.Enabled = chkOrderNo.Checked;
  172. txtJudgeStove.Enabled = chkJudgeStove.Checked;
  173. txtBatchNo.Enabled = chkBatchNo.Checked;
  174. txtOrderNo.Visible = chkOrderNo.Checked;
  175. txtJudgeStove.Visible = chkJudgeStove.Checked;
  176. txtBatchNo.Visible = chkBatchNo.Checked;
  177. cboPline.Visible = chkPlineCode.Checked;
  178. }
  179. /// <summary>
  180. /// 汇总方法
  181. /// </summary>
  182. /// <param name="myGrid1"></param>
  183. /// <param name="alistColumns"></param>
  184. /// <param name="clearExists"></param>
  185. protected void SetStaticsInfoSum(ref UltraGrid myGrid1, List<string> alistColumns, bool clearExists,bool ShowCount)
  186. {
  187. try
  188. {
  189. var band = myGrid1.DisplayLayout.Bands[0];
  190. if (clearExists)
  191. band.Summaries.Clear();
  192. band.Override.SummaryFooterCaptionVisible = DefaultableBoolean.False;
  193. for (var i = 0; i < alistColumns.Count; i++)
  194. {
  195. try
  196. {
  197. if (!band.Columns.Exists(alistColumns[i])) continue;
  198. var summary = band.Summaries.Add(SummaryType.Sum, band.Columns[alistColumns[i]]);
  199. summary.SummaryDisplayArea = SummaryDisplayAreas.BottomFixed;
  200. summary.SummaryPosition = SummaryPosition.UseSummaryPositionColumn;
  201. summary.DisplayFormat = "{0}";
  202. summary.Appearance.TextHAlign = HAlign.Right;
  203. summary.Appearance.TextVAlign = VAlign.Middle;
  204. summary.Appearance.FontData.Bold = DefaultableBoolean.True;
  205. }
  206. catch
  207. {
  208. // ignored
  209. }
  210. }
  211. if (ShowCount )
  212. {
  213. var summary = band.Summaries.Add(SummaryType.Count, band.Columns[0]);
  214. summary.SummaryDisplayArea = SummaryDisplayAreas.BottomFixed;
  215. summary.SummaryPosition = SummaryPosition.UseSummaryPositionColumn;
  216. summary.DisplayFormat = "共{0}条记录";
  217. summary.Appearance.TextHAlign = HAlign.Left;
  218. summary.Appearance.TextVAlign = VAlign.Middle;
  219. summary.Appearance.FontData.Bold = DefaultableBoolean.True;
  220. }
  221. }
  222. catch
  223. {
  224. }
  225. }
  226. }
  227. }