frmRptManagementAll.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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 frmRptManagementAll : FrmBase
  21. {
  22. public frmRptManagementAll()
  23. {
  24. InitializeComponent();
  25. }
  26. private void frmRptManagementAll_Load(object sender, EventArgs e)
  27. {
  28. ForbidSort(ug1);
  29. Query();
  30. }
  31. public override void ToolBar_Click(object sender, string ToolbarKey)
  32. {
  33. base.ToolBar_Click(sender, ToolbarKey);
  34. switch (ToolbarKey)
  35. {
  36. case "Query":
  37. Query();
  38. break;
  39. case "Export":
  40. Export();
  41. break;
  42. case "Close":
  43. this.Close();
  44. break;
  45. }
  46. }
  47. private void Export()
  48. {
  49. if (ug1.Rows.Count == 0)
  50. {
  51. MessageUtil.ShowWarning("查询数据为空,无法导出!");
  52. }
  53. else
  54. {
  55. GridHelper.ulGridToExcel(ug1, "管理报表数据");
  56. }
  57. }
  58. private void Query()
  59. {
  60. string year = cb_year.Text;
  61. DataTable dtqry = ServerHelper.GetData("com.steering.pss.buybillet.Buybillet.get_Rpt_Management_All", new object[] { year }, this.ob);
  62. GridHelper.CopyDataToDatatable(ref dtqry, ref dt, true);
  63. SetStaticsInfo();
  64. CommonMethod.SetGridSumArea(this.ug1);
  65. }
  66. /// <summary>
  67. /// 禁止排序
  68. /// </summary>
  69. /// <param name="ugr"></param>
  70. public void ForbidSort(UltraGrid ugr)
  71. {
  72. foreach (UltraGridColumn ugc in ugr.DisplayLayout.Bands[0].Columns)
  73. {
  74. ugc.SortIndicator = SortIndicator.Disabled;
  75. ugc.AllowRowFiltering = DefaultableBoolean.False;
  76. }
  77. }
  78. /// <summary>
  79. /// 刷新Grid数据并根据数据调整Grid列宽
  80. /// </summary>
  81. /// <param name="ultraGrid">需要处理的Grid</param>
  82. public static void RefreshAndAutoSize(Infragistics.Win.UltraWinGrid.UltraGrid ultraGrid)
  83. {
  84. try
  85. {
  86. ultraGrid.DataBind();
  87. foreach (Infragistics.Win.UltraWinGrid.UltraGridBand band in ultraGrid.DisplayLayout.Bands)
  88. {
  89. foreach (Infragistics.Win.UltraWinGrid.UltraGridColumn column in band.Columns)
  90. {
  91. column.PerformAutoResize(Infragistics.Win.UltraWinGrid.PerformAutoSizeType.AllRowsInBand);
  92. }
  93. }
  94. ultraGrid.Refresh();
  95. }
  96. catch { }
  97. }
  98. private void SetStaticsInfo()
  99. {
  100. try
  101. {
  102. if (this.ug1.Rows.Count == 0)
  103. {
  104. this.ug1.DisplayLayout.Bands[0].Summaries.Clear();
  105. }
  106. else
  107. {
  108. ArrayList alist = new ArrayList();
  109. //半成品
  110. alist.Add("BCP");
  111. alist.Add("BCP_ZT");
  112. alist.Add("TOTAL_BCP");
  113. //管坯
  114. alist.Add("GP");
  115. alist.Add("GP_ZT");
  116. alist.Add("TOTAL_GP");
  117. //管坯加半成品合计
  118. alist.Add("TOTAL_GP_BCP");
  119. //外购坯量
  120. alist.Add("WGP_WEIGHT");
  121. CommonMethod.SetStaticsInfoSum(ref this.ug1, alist, true);
  122. }
  123. }
  124. catch { }
  125. }
  126. private void ug1_InitializeLayout(object sender, InitializeLayoutEventArgs e)
  127. {
  128. e.Layout.Override.CellAppearance.TextHAlign = HAlign.Right;
  129. e.Layout.Bands[0].Columns["RPT_YM"].CellAppearance.TextHAlign = HAlign.Left;
  130. e.Layout.Bands[0].Columns["WGP_RATE"].CellAppearance.TextHAlign = HAlign.Left;
  131. foreach (var col in e.Layout.Bands[0].Columns)
  132. {
  133. if (col.Key.ToLower() == "rpt_ym" || col.Key.ToLower() == "wgp_rate")
  134. {
  135. }
  136. else
  137. {
  138. col.MaskDisplayMode = Infragistics.Win.UltraWinMaskedEdit.MaskMode.IncludeLiterals;
  139. col.MaskInput = "{LOC}-nn,nnn,nnn.nnn";
  140. }
  141. }
  142. }
  143. }
  144. }