frmRptSalesAll.cs 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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 frmRptSalesAll : FrmBase
  21. {
  22. public frmRptSalesAll()
  23. {
  24. InitializeComponent();
  25. }
  26. private void frmRptSalesAll_Load(object sender, EventArgs e)
  27. {
  28. //this.ug1.DisplayLayout.Bands[0].Columns["GM1_SALES_WEIGHT"].AllowRowSummaries = AllowRowSummaries.True;
  29. //this.ug1.DisplayLayout.Bands[0].Summaries.Add(SummaryType.Minimum, null,
  30. //this.ug1.DisplayLayout.Bands[0].Columns["GM1_SALES_WEIGHT"], SummaryPosition.Left,
  31. //null);
  32. //this.ug1.DisplayLayout.Bands[0].SummaryFooterCaption = "My Sums";
  33. ForbidSort(ug1);
  34. Query();
  35. }
  36. public override void ToolBar_Click(object sender, string ToolbarKey)
  37. {
  38. base.ToolBar_Click(sender, ToolbarKey);
  39. switch (ToolbarKey)
  40. {
  41. case "Query":
  42. Query();
  43. break;
  44. case "Export":
  45. Export();
  46. break;
  47. case "Close":
  48. this.Close();
  49. break;
  50. }
  51. }
  52. private void Export()
  53. {
  54. if (ug1.Rows.Count == 0)
  55. {
  56. MessageUtil.ShowWarning("查询数据为空,无法导出!");
  57. }
  58. else
  59. {
  60. GridHelper.ulGridToExcel(ug1, "销售管理数据");
  61. }
  62. }
  63. private void Query()
  64. {
  65. string year = cb_year.Text;
  66. DataTable dtqry = ServerHelper.GetData("com.steering.pss.buybillet.Buybillet.get_Rpt_Sales_All", new object[] { year }, this.ob);
  67. GridHelper.CopyDataToDatatable(ref dtqry, ref dt, true);
  68. //ug1.DataSource = dt;
  69. //RefreshAndAutoSize(ug1);
  70. SetStaticsInfo();
  71. CommonMethod.SetGridSumArea(this.ug1);
  72. }
  73. /// <summary>
  74. /// 禁止排序
  75. /// </summary>
  76. /// <param name="ugr"></param>
  77. public void ForbidSort(UltraGrid ugr)
  78. {
  79. foreach (UltraGridColumn ugc in ugr.DisplayLayout.Bands[0].Columns)
  80. {
  81. ugc.SortIndicator = SortIndicator.Disabled;
  82. ugc.AllowRowFiltering = DefaultableBoolean.False;
  83. }
  84. }
  85. /// <summary>
  86. /// 刷新Grid数据并根据数据调整Grid列宽
  87. /// </summary>
  88. /// <param name="ultraGrid">需要处理的Grid</param>
  89. public static void RefreshAndAutoSize(Infragistics.Win.UltraWinGrid.UltraGrid ultraGrid)
  90. {
  91. try
  92. {
  93. ultraGrid.DataBind();
  94. foreach (Infragistics.Win.UltraWinGrid.UltraGridBand band in ultraGrid.DisplayLayout.Bands)
  95. {
  96. foreach (Infragistics.Win.UltraWinGrid.UltraGridColumn column in band.Columns)
  97. {
  98. column.PerformAutoResize(Infragistics.Win.UltraWinGrid.PerformAutoSizeType.AllRowsInBand);
  99. }
  100. }
  101. ultraGrid.Refresh();
  102. }
  103. catch { }
  104. }
  105. private void SetStaticsInfo()
  106. {
  107. try
  108. {
  109. if (this.ug1.Rows.Count == 0)
  110. {
  111. this.ug1.DisplayLayout.Bands[0].Summaries.Clear();
  112. }
  113. else
  114. {
  115. ArrayList alist = new ArrayList();
  116. //销售量
  117. alist.Add("GM1_SALES_WEIGHT");
  118. alist.Add("GM2_SALES_WEIGHT");
  119. alist.Add("XS_SALES_WEIGHT");
  120. alist.Add("TOTAL_SALES_WEIGHT");
  121. //排产量
  122. alist.Add("GM1_PC_WEIGHT");
  123. alist.Add("GM2_PC_WEIGHT");
  124. alist.Add("XS_PC_WEIGHT");
  125. alist.Add("TOTAL_PC_WEIGHT");
  126. //库存量
  127. alist.Add("GM1_STOCK_WEIGHT");
  128. alist.Add("GM2_STOCK_WEIGHT");
  129. alist.Add("XS_STOCK_WEIGHT");
  130. alist.Add("TOTAL_STOCK_WEIGHT");
  131. //入库量
  132. alist.Add("GM1_STOCKIN_WEIGHT");
  133. alist.Add("GM2_STOCKIN_WEIGHT");
  134. alist.Add("XS_STOCKIN_WEIGHT");
  135. alist.Add("TOTAL_STOCKIN_WEIGHT");
  136. //出库量(发运量)
  137. alist.Add("GM1_STOCKOUT_WEIGHT");
  138. alist.Add("GM2_STOCKOUT_WEIGHT");
  139. alist.Add("XS_STOCKOUT_WEIGHT");
  140. alist.Add("TOTAL_STOCKOUT_WEIGHT");
  141. //处理前期无合同库存
  142. alist.Add("GM1_QQ_STOCK");
  143. alist.Add("GM2_QQ_STOCK");
  144. alist.Add("XS_QQ_STOCK");
  145. alist.Add("TOTAL_QQ_STOCK");
  146. //无合同库存余额
  147. alist.Add("GM1_NODER_WEIGHT");
  148. alist.Add("GM2_NODER_WEIGHT");
  149. alist.Add("XS_NODER_WEIGHT");
  150. alist.Add("TOTAL_NODER_WEIGHT");
  151. CommonMethod.SetStaticsInfoSum(ref this.ug1, alist, true);
  152. }
  153. }
  154. catch { }
  155. }
  156. //设置单元格的对齐方向
  157. private void ug1_InitializeLayout(object sender, InitializeLayoutEventArgs e)
  158. {
  159. e.Layout.Override.CellAppearance.TextHAlign = HAlign.Right;
  160. e.Layout.Bands[0].Columns["RPT_YM"].CellAppearance.TextHAlign = HAlign.Left;
  161. e.Layout.Bands[0].Columns["GM1_STOCK_WEIGHT"].CellAppearance.TextHAlign = HAlign.Right;
  162. e.Layout.Bands[0].Columns["GM2_STOCK_WEIGHT"].CellAppearance.TextHAlign = HAlign.Right;
  163. e.Layout.Bands[0].Columns["XS_STOCK_WEIGHT"].CellAppearance.TextHAlign = HAlign.Right;
  164. e.Layout.Bands[0].Columns["TOTAL_STOCK_WEIGHT"].CellAppearance.TextHAlign = HAlign.Right;
  165. //e.Layout.AutoFitStyle = AutoFitStyle.ExtendLastColumn;
  166. foreach (var col in e.Layout.Bands[0].Columns)
  167. {
  168. if (col.Key.ToLower() == "rpt_ym")
  169. {
  170. }
  171. else
  172. {
  173. col.MaskDisplayMode = Infragistics.Win.UltraWinMaskedEdit.MaskMode.IncludeLiterals;
  174. col.MaskInput = "{LOC}-nn,nnn,nnn.nnn";
  175. }
  176. }
  177. }
  178. }
  179. }