frmRptMeasureCg.cs 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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 CoreFS.CA06;
  10. using Core.Mes.Client.Comm.Server;
  11. using Core.Mes.Client.Comm.Control;
  12. using Core.Mes.Client.Comm.Tool;
  13. using Infragistics.Win.UltraWinGrid;
  14. using Infragistics.Win;
  15. using System.Net;
  16. using System.Collections;
  17. using CoreFS.SA06;
  18. namespace Core.StlMes.Client.BuyBillet
  19. {
  20. public partial class frmRptMeasureCg : FrmBase
  21. {
  22. public frmRptMeasureCg()
  23. {
  24. InitializeComponent();
  25. }
  26. private void frmRptMeasureCg_Load(object sender, EventArgs e)
  27. {
  28. initial_cb_yearmonth();
  29. ForbidSort(ug1);
  30. Query();
  31. }
  32. private void initial_cb_yearmonth()
  33. {
  34. for (int i = 0; i < 6; i++)
  35. {
  36. cb_year_month.Items.Add(DateTime.Now.AddMonths(-i).ToString("yyyyMM"));
  37. cb_year_month.SelectedIndex = 0;
  38. }
  39. }
  40. public override void ToolBar_Click(object sender, string ToolbarKey)
  41. {
  42. base.ToolBar_Click(sender, ToolbarKey);
  43. switch (ToolbarKey)
  44. {
  45. case "Query":
  46. Query();
  47. break;
  48. case "Export":
  49. Export();
  50. break;
  51. case "Close":
  52. this.Close();
  53. break;
  54. }
  55. }
  56. private void Export()
  57. {
  58. if (ug1.Rows.Count == 0)
  59. {
  60. MessageUtil.ShowWarning("查询数据为空,无法导出!");
  61. }
  62. else
  63. {
  64. GridHelper.ulGridToExcel(ug1, "废钢生铁铁水计量数据");
  65. }
  66. }
  67. private void Query()
  68. {
  69. string year = cb_year_month.Text;
  70. DataTable dtqry = ServerHelper.GetData("com.steering.pss.buybillet.Buybillet.get_Rpt_Measure_Cg", new object[] { year }, this.ob);
  71. GridHelper.CopyDataToDatatable(ref dtqry, ref dt, true);
  72. SetStaticsInfo();
  73. CommonMethod.SetStaticsInfoCustomization(ref this.ug1, "FGSTYLG", "TSYLG", "MATERIALOUTYLG", "GTLRATEYLG");
  74. CommonMethod.SetStaticsInfoCustomization(ref this.ug1, "FGSTERLG", "TSERLG", "MATERIALOUTERLG", "GTLRATEERLG");
  75. CommonMethod.SetStaticsInfoCustomization(ref this.ug1, "FGSTXH", "TSTOTAL", "MATERIALOUTTOTAL", "GTLRATETOTAL");
  76. CommonMethod.SetGridSumArea(this.ug1);
  77. }
  78. /// <summary>
  79. /// 禁止排序
  80. /// </summary>
  81. /// <param name="ugr"></param>
  82. public void ForbidSort(UltraGrid ugr)
  83. {
  84. foreach (UltraGridColumn ugc in ugr.DisplayLayout.Bands[0].Columns)
  85. {
  86. ugc.SortIndicator = SortIndicator.Disabled;
  87. ugc.AllowRowFiltering = DefaultableBoolean.False;
  88. }
  89. }
  90. /// <summary>
  91. /// 刷新Grid数据并根据数据调整Grid列宽
  92. /// </summary>
  93. /// <param name="ultraGrid">需要处理的Grid</param>
  94. public static void RefreshAndAutoSize(Infragistics.Win.UltraWinGrid.UltraGrid ultraGrid)
  95. {
  96. try
  97. {
  98. ultraGrid.DataBind();
  99. foreach (Infragistics.Win.UltraWinGrid.UltraGridBand band in ultraGrid.DisplayLayout.Bands)
  100. {
  101. foreach (Infragistics.Win.UltraWinGrid.UltraGridColumn column in band.Columns)
  102. {
  103. column.PerformAutoResize(Infragistics.Win.UltraWinGrid.PerformAutoSizeType.AllRowsInBand);
  104. }
  105. }
  106. ultraGrid.Refresh();
  107. }
  108. catch { }
  109. }
  110. private void SetStaticsInfo()
  111. {
  112. try
  113. {
  114. if (this.ug1.Rows.Count == 0)
  115. {
  116. this.ug1.DisplayLayout.Bands[0].Summaries.Clear();
  117. }
  118. else
  119. {
  120. ArrayList alist = new ArrayList();
  121. //废钢
  122. alist.Add("FGCG");
  123. alist.Add("FGHF");
  124. alist.Add("FGTOTAL");
  125. //废钢生铁消耗
  126. alist.Add("FGSTXH");
  127. //废钢生铁入库合计减消耗
  128. alist.Add("FGSTTOTALJXH");
  129. alist.Add("FGSTYLG");
  130. alist.Add("FGSTERLG");
  131. //铁水消耗
  132. alist.Add("TSYLG");
  133. alist.Add("TSERLG");
  134. //生铁
  135. alist.Add("STZC");
  136. alist.Add("STCG");
  137. alist.Add("STTOTAL");
  138. //管坯加半成品合计
  139. alist.Add("TSZC");
  140. alist.Add("TSCG");
  141. alist.Add("TSTOTAL");
  142. alist.Add("TSXHTOTAL");
  143. //出钢量
  144. alist.Add("MATERIALOUTYLG");
  145. alist.Add("MATERIALOUTERLG");
  146. alist.Add("MATERIALOUTTOTAL");
  147. //钢铁料比
  148. //alist.Add("GTLRATEYLG");
  149. CommonMethod.SetStaticsInfoSum(ref this.ug1, alist, true);
  150. }
  151. }
  152. catch { }
  153. }
  154. private void ug1_InitializeLayout(object sender, InitializeLayoutEventArgs e)
  155. {
  156. e.Layout.Override.CellAppearance.TextHAlign = HAlign.Right;
  157. e.Layout.Bands[0].Columns["RPT_DATE"].CellAppearance.TextHAlign = HAlign.Left;
  158. //e.Layout.Bands[0].Columns["GTLRATEYLG"].CellAppearance.TextHAlign = HAlign.Left;
  159. }
  160. }
  161. }