using ClientLib; using ClientLib.CommonService2; using DevExpress.XtraGrid; using DevExpress.XtraGrid.Columns; using DevExpress.XtraGrid.Views.BandedGrid; using DevExpress.XtraGrid.Views.Grid.ViewInfo; using PublicLib; 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; namespace HANMI_WORK { public partial class ProcessRunReport : PublicLib.CommonMDI { public ProcessRunReport() { InitializeComponent(); gridView_Main.CustomDrawCell += (sender, e) => { if (!e.Column.FieldName.StartsWith("C_")) { return; } string value = UtilClass.toStr(e.CellValue); if (UtilClass.isEqual(value, "0/0")) { e.Appearance.BackColor = Color.Red; e.Appearance.ForeColor = Color.White; } else if (UtilClass.isNull(value)) { e.Appearance.BackColor = Color.Empty; } else { int inx = value.IndexOf("/"); string v = value.Substring(0, inx); if (UtilClass.toInt(v) == 0) { e.Appearance.BackColor = Color.Red; } else { e.Appearance.BackColor = Color.LightGreen; } } }; dateEdit_SDATE.DateTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM") + "-01"); dateEdit_FDATE.DateTime = DateTime.Now; dateEdit_FDATE.KeyPress += (sender, e) => { if (e.KeyChar == '\r') { searchProc(); } }; this.Shown += (sender, e) => { }; } public override void searchProc() { try { this.Cursor = Cursors.WaitCursor; gridControl_Main.DataSource = null; SerializedSqlParam[] aParam = new SerializedSqlParam[] { ClientClass.CreateSqlParameter("COMP_CD", SqlDbType.NVarChar, ConstClass._COMP_CD), ClientClass.CreateSqlParameter("CUST_NM", SqlDbType.NVarChar, textEdit_CUST_NM.Text), ClientClass.CreateSqlParameter("SDATE", SqlDbType.NVarChar, checkEdit_ORDER_DT.Checked ? dateEdit_SDATE.DateTime.ToString("yyyy-MM-dd") : ""), ClientClass.CreateSqlParameter("FDATE", SqlDbType.NVarChar, dateEdit_FDATE.DateTime.ToString("yyyy-MM-dd")) }; ResultData resultData = ClientClass.GetData("GetProcessRunReport", aParam); if (resultData.isError) { throw new Exception(resultData.ResultValue); } while (gridView_Main.Columns.Count > 4) { gridView_Main.Columns.RemoveAt(4); } BandedGridColumn column; DataTable aData = resultData.DataList.Tables[0]; for (int i = 1; i < aData.Columns.Count; i++) { column = new BandedGridColumn(); gridView_Main.Columns.Add(column); column.OwnerBand = gridBand_PROC; column.Visible = true; column.OptionsColumn.FixedWidth = true; column.Caption = aData.Columns[i].Caption; column.FieldName = "C_" + UtilClass.toStr(aData.Rows[0][i]); column.Width = 95; column.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric; column.DisplayFormat.FormatString = "{0:#,##0}"; column.AppearanceCell.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; column.AppearanceCell.Options.UseTextOptions = true; column.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; column.AppearanceHeader.Options.UseTextOptions = true; } gridBand_PROC.Visible = true; gridControl_Main.DataSource = resultData.DataList.Tables[1]; this.Cursor = Cursors.Arrow; } catch (Exception ex) { this.Cursor = Cursors.Arrow; MessageBox.Show(ex.Message); } } public override void excelProc() { this.ExportExcelGrid(gridControl_Main); } } }