using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using CoreFS.CA06; using Core.Mes.Client.Comm.Server; using Core.Mes.Client.Comm.Control; using Core.Mes.Client.Comm.Tool; using Infragistics.Win.UltraWinGrid; using Infragistics.Win; using System.Net; using System.Collections; using CoreFS.SA06; namespace Core.StlMes.Client.BuyBillet { public partial class frmRptSalesAll : FrmBase { public frmRptSalesAll() { InitializeComponent(); } private void frmRptSalesAll_Load(object sender, EventArgs e) { //this.ug1.DisplayLayout.Bands[0].Columns["GM1_SALES_WEIGHT"].AllowRowSummaries = AllowRowSummaries.True; //this.ug1.DisplayLayout.Bands[0].Summaries.Add(SummaryType.Minimum, null, //this.ug1.DisplayLayout.Bands[0].Columns["GM1_SALES_WEIGHT"], SummaryPosition.Left, //null); //this.ug1.DisplayLayout.Bands[0].SummaryFooterCaption = "My Sums"; ForbidSort(ug1); Query(); } public override void ToolBar_Click(object sender, string ToolbarKey) { base.ToolBar_Click(sender, ToolbarKey); switch (ToolbarKey) { case "Query": Query(); break; case "Export": Export(); break; case "Close": this.Close(); break; } } private void Export() { if (ug1.Rows.Count == 0) { MessageUtil.ShowWarning("查询数据为空,无法导出!"); } else { GridHelper.ulGridToExcel(ug1, "销售管理数据"); } } private void Query() { string year = cb_year.Text; DataTable dtqry = ServerHelper.GetData("com.steering.pss.buybillet.Buybillet.get_Rpt_Sales_All", new object[] { year }, this.ob); GridHelper.CopyDataToDatatable(ref dtqry, ref dt, true); //ug1.DataSource = dt; //RefreshAndAutoSize(ug1); SetStaticsInfo(); CommonMethod.SetGridSumArea(this.ug1); } /// /// 禁止排序 /// /// public void ForbidSort(UltraGrid ugr) { foreach (UltraGridColumn ugc in ugr.DisplayLayout.Bands[0].Columns) { ugc.SortIndicator = SortIndicator.Disabled; ugc.AllowRowFiltering = DefaultableBoolean.False; } } /// /// 刷新Grid数据并根据数据调整Grid列宽 /// /// 需要处理的Grid public static void RefreshAndAutoSize(Infragistics.Win.UltraWinGrid.UltraGrid ultraGrid) { try { ultraGrid.DataBind(); foreach (Infragistics.Win.UltraWinGrid.UltraGridBand band in ultraGrid.DisplayLayout.Bands) { foreach (Infragistics.Win.UltraWinGrid.UltraGridColumn column in band.Columns) { column.PerformAutoResize(Infragistics.Win.UltraWinGrid.PerformAutoSizeType.AllRowsInBand); } } ultraGrid.Refresh(); } catch { } } private void SetStaticsInfo() { try { if (this.ug1.Rows.Count == 0) { this.ug1.DisplayLayout.Bands[0].Summaries.Clear(); } else { ArrayList alist = new ArrayList(); //销售量 alist.Add("GM1_SALES_WEIGHT"); alist.Add("GM2_SALES_WEIGHT"); alist.Add("XS_SALES_WEIGHT"); alist.Add("TOTAL_SALES_WEIGHT"); //排产量 alist.Add("GM1_PC_WEIGHT"); alist.Add("GM2_PC_WEIGHT"); alist.Add("XS_PC_WEIGHT"); alist.Add("TOTAL_PC_WEIGHT"); //库存量 alist.Add("GM1_STOCK_WEIGHT"); alist.Add("GM2_STOCK_WEIGHT"); alist.Add("XS_STOCK_WEIGHT"); alist.Add("TOTAL_STOCK_WEIGHT"); //入库量 alist.Add("GM1_STOCKIN_WEIGHT"); alist.Add("GM2_STOCKIN_WEIGHT"); alist.Add("XS_STOCKIN_WEIGHT"); alist.Add("TOTAL_STOCKIN_WEIGHT"); //出库量(发运量) alist.Add("GM1_STOCKOUT_WEIGHT"); alist.Add("GM2_STOCKOUT_WEIGHT"); alist.Add("XS_STOCKOUT_WEIGHT"); alist.Add("TOTAL_STOCKOUT_WEIGHT"); //处理前期无合同库存 alist.Add("GM1_QQ_STOCK"); alist.Add("GM2_QQ_STOCK"); alist.Add("XS_QQ_STOCK"); alist.Add("TOTAL_QQ_STOCK"); //无合同库存余额 alist.Add("GM1_NODER_WEIGHT"); alist.Add("GM2_NODER_WEIGHT"); alist.Add("XS_NODER_WEIGHT"); alist.Add("TOTAL_NODER_WEIGHT"); CommonMethod.SetStaticsInfoSum(ref this.ug1, alist, true); } } catch { } } //设置单元格的对齐方向 private void ug1_InitializeLayout(object sender, InitializeLayoutEventArgs e) { e.Layout.Override.CellAppearance.TextHAlign = HAlign.Right; e.Layout.Bands[0].Columns["RPT_YM"].CellAppearance.TextHAlign = HAlign.Left; e.Layout.Bands[0].Columns["GM1_STOCK_WEIGHT"].CellAppearance.TextHAlign = HAlign.Right; e.Layout.Bands[0].Columns["GM2_STOCK_WEIGHT"].CellAppearance.TextHAlign = HAlign.Right; e.Layout.Bands[0].Columns["XS_STOCK_WEIGHT"].CellAppearance.TextHAlign = HAlign.Right; e.Layout.Bands[0].Columns["TOTAL_STOCK_WEIGHT"].CellAppearance.TextHAlign = HAlign.Right; //e.Layout.AutoFitStyle = AutoFitStyle.ExtendLastColumn; foreach (var col in e.Layout.Bands[0].Columns) { if (col.Key.ToLower() == "rpt_ym") { } else { col.MaskDisplayMode = Infragistics.Win.UltraWinMaskedEdit.MaskMode.IncludeLiterals; col.MaskInput = "{LOC}-nn,nnn,nnn.nnn"; } } } } }