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 Core.Mes.Client.Comm.Control; using Core.Mes.Client.Comm.Tool; using Core.StlMes.Client.YdmPipeManage.Tool; using Core.StlMes.Client.YdmPipeReport.Entity; using CoreFS.CA06; using Infragistics.Win.UltraWinGrid; using Infragistics.Win.UltraWinMaskedEdit; namespace Core.StlMes.Client.YdmPipeReport { public partial class FrmOutFactory : FrmBase { public FrmOutFactory() { IsLoadUserView = true; InitializeComponent(); } private void ChcBillNo_CheckedChanged(object sender, EventArgs e) { if (ChcBillNo.Checked) { TxtBillNo.ReadOnly = false; } else { TxtBillNo.ReadOnly = true; } if (ChcTime.Checked) { BeginTime.Enabled = true; //EndTime.Enabled = true; } else { BeginTime.Enabled = false; //EndTime.Enabled = false; } } public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Query": DoQuery(); break; case "Export": GridHelper.ulGridToExcel(GridOutFactory, "出库审核信息"); break; case "Close": this.Close(); break; default: break; } } /// /// 初始化时间 /// private void InitTime() { BeginTime.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM")); //EndTime.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")).AddDays(1).AddSeconds(-1); } private void FrmOutFactory_Load(object sender, EventArgs e) { EntityHelper.ShowGridCaption(GridOutFactory.DisplayLayout.Bands[0]); InitTime(); BaseMethod.setOtherColumnReadOnly(GridOutFactory,new string[]{""}); setUltraGridColumnMaxInput(GridOutFactory, new string[] { "PlanWeight", "ActWeight" }); //GridColumnSum(GridOutFactory, new string[] { "PlanWeight", "ActWeight","CarNumber" }); InitCellPosition(GridOutFactory, new string[] { "PlanWeight", "ActWeight", "CarNumber" }); } /// /// 查询 /// private void DoQuery() { string billNo = ""; if (ChcBillNo.Checked) { billNo = TxtBillNo.Text.Trim(); } string beginTime = ""; string endTime = ""; if (ChcTime.Checked) { beginTime = BeginTime.Value.ToString("yyyyMM"); //endTime = EndTime.Value.ToString(); } string supplyUnit = this.CustomInfo; List listSource = EntityHelper.GetData( "com.steering.pss.ydm.Report.FrmOutFactory.getOutFactory", new object[] { billNo, beginTime, this.ValidDataPurviewIds , supplyUnit }, this.ob); outFactoryEntityBindingSource.DataSource = listSource; } /// /// 设置列字段显示位置在右 /// /// UltraGrid /// 要设置的列 private void InitCellPosition(UltraGrid ug, string[] columnsKeys) { columnsKeys.ToArray(); foreach (UltraGridColumn ugc in ug.DisplayLayout.Bands[0].Columns) { if (columnsKeys.Contains(ugc.Key.ToString())) { ugc.CellAppearance.TextHAlign = Infragistics.Win.HAlign.Right; } } } /// /// 设置列显示位数 /// /// /// private void setUltraGridColumnMaxInput(UltraGrid ug, string[] arr) { if (ug == null || arr == null || arr.Length == 0) { return; } arr.ToArray(); foreach (UltraGridColumn ugc in ug.DisplayLayout.Bands[0].Columns) { if (arr.Contains(ugc.Key.ToString())) { ugc.MaskDisplayMode = MaskMode.IncludeLiterals; ugc.MaskInput = "{LOC}n,nnn,nnn.nnn"; } } } /// /// 列求和 /// /// UltraGrid /// 列数组 private void GridColumnSum(UltraGrid ug, string[] columnKeys) { if (columnKeys.Length == 0) { return; } for (int i = 0; i < columnKeys.Length; i++) { SummarySettings summary = ug.DisplayLayout.Bands[0].Summaries.Add(SummaryType.Sum, ug.DisplayLayout.Bands[0].Columns[columnKeys[i]], SummaryPosition.UseSummaryPositionColumn); summary.DisplayFormat = "{0}"; summary.Appearance.TextHAlign = Infragistics.Win.HAlign.Right; } } } }