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 frmRptMeasureCg : FrmBase { public frmRptMeasureCg() { InitializeComponent(); } private void frmRptMeasureCg_Load(object sender, EventArgs e) { initial_cb_yearmonth(); ForbidSort(ug1); Query(); } private void initial_cb_yearmonth() { for (int i = 0; i < 6; i++) { cb_year_month.Items.Add(DateTime.Now.AddMonths(-i).ToString("yyyyMM")); cb_year_month.SelectedIndex = 0; } } 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_month.Text; DataTable dtqry = ServerHelper.GetData("com.steering.pss.buybillet.Buybillet.get_Rpt_Measure_Cg", new object[] { year }, this.ob); GridHelper.CopyDataToDatatable(ref dtqry, ref dt, true); SetStaticsInfo(); CommonMethod.SetStaticsInfoCustomization(ref this.ug1, "FGSTYLG", "TSYLG", "MATERIALOUTYLG", "GTLRATEYLG"); CommonMethod.SetStaticsInfoCustomization(ref this.ug1, "FGSTERLG", "TSERLG", "MATERIALOUTERLG", "GTLRATEERLG"); CommonMethod.SetStaticsInfoCustomization(ref this.ug1, "FGSTXH", "TSTOTAL", "MATERIALOUTTOTAL", "GTLRATETOTAL"); 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("FGCG"); alist.Add("FGHF"); alist.Add("FGTOTAL"); //废钢生铁消耗 alist.Add("FGSTXH"); //废钢生铁入库合计减消耗 alist.Add("FGSTTOTALJXH"); alist.Add("FGSTYLG"); alist.Add("FGSTERLG"); //铁水消耗 alist.Add("TSYLG"); alist.Add("TSERLG"); //生铁 alist.Add("STZC"); alist.Add("STCG"); alist.Add("STTOTAL"); //管坯加半成品合计 alist.Add("TSZC"); alist.Add("TSCG"); alist.Add("TSTOTAL"); alist.Add("TSXHTOTAL"); //出钢量 alist.Add("MATERIALOUTYLG"); alist.Add("MATERIALOUTERLG"); alist.Add("MATERIALOUTTOTAL"); //钢铁料比 //alist.Add("GTLRATEYLG"); 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_DATE"].CellAppearance.TextHAlign = HAlign.Left; //e.Layout.Bands[0].Columns["GTLRATEYLG"].CellAppearance.TextHAlign = HAlign.Left; } } }