using ClientLib; using ClientLib.CommonService; using DevExpress.XtraCharts; using DevExpress.XtraGrid; using DevExpress.XtraGrid.Columns; 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_J_SALE { public partial class TradeMoneyList : PublicLib.CommonMDI { private int m_CURR_MY, m_VAT_MY, m_ORDER_MY; private NewTradeControl m_NEW_LIST; public TradeMoneyList() { InitializeComponent(); gridControl_Main.LookAndFeel.Style = DevExpress.LookAndFeel.LookAndFeelStyle.Flat; gridControl_Main.LookAndFeel.UseDefaultLookAndFeel = false; gridView_Main.Appearance.HeaderPanel.BackColor = Color.FromArgb(170, 204, 255); m_CURR_MY = 0; m_VAT_MY = 0; m_ORDER_MY = 0; //dateEdit_SDATE.DateTime = dateEdit_FDATE.DateTime = DateTime.Now; buttonEdit_NORM.ButtonClick += (sender, e) => { selectNormProc(); }; buttonEdit_CUST_NM.ButtonClick += (sender, e) => { selectCustProc(); }; buttonEdit_CUST_NM.KeyPress += (sender, e) => { if (e.KeyChar == '\r') { selectCustProc(); } }; buttonEdit_CUST_NM.EditValueChanged += (sender, e) => { if (UtilClass.isNull(buttonEdit_CUST_NM.Text)) { labelControl_CUST_CD.Text = ""; } }; buttonEdit_RoutingNM.ButtonClick += (sender, e) => { selectRoutingProc(); }; //checkEdit_SpecToItemName.KeyPress += (sender, e) => //{ // if (e.KeyChar == '\r') // { // searchProc(); // } //}; GridGroupSummaryItem item; item = new GridGroupSummaryItem(DevExpress.Data.SummaryItemType.Sum, "CURR_MY", gridView_Main.Columns["CURR_MY"], "{0:#,##0}"); gridView_Main.GroupSummary.Add(item); item = new GridGroupSummaryItem(DevExpress.Data.SummaryItemType.Sum, "VAT_MY", gridView_Main.Columns["VAT_MY"], "{0:#,##0}"); gridView_Main.GroupSummary.Add(item); item = new GridGroupSummaryItem(DevExpress.Data.SummaryItemType.Sum, "ORDER_MY", gridView_Main.Columns["ORDER_MY"], "{0:#,##0}"); gridView_Main.GroupSummary.Add(item); gridView_Main.DoubleClick += (sender, e) => { Point aPT = gridControl_Main.PointToClient(Control.MousePosition); GridHitInfo aInfo = gridView_Main.CalcHitInfo(aPT); if (aInfo.InRowCell) { DataRow row = gridView_Main.GetFocusedDataRow(); if (m_NEW_LIST != null) m_NEW_LIST.Dispose(); m_NEW_LIST = new NewTradeControl(); m_NEW_LIST.selectNEWProc(row["COUNT"].ToString(), labelControl_CUST_CD.Text, labelControl_RoutingCD.Text, buttonEdit_NORM.Text, row["COUNT"].ToString()); m_NEW_LIST.SetBounds(chartControl_AVG.Location.X, chartControl_AVG.Location.Y, m_NEW_LIST.Width, m_NEW_LIST.Height); m_NEW_LIST.Visible = true; this.Controls.Add(m_NEW_LIST); m_NEW_LIST.BringToFront(); } }; gridView_Main.CustomDrawFooterCell += (sender, e) => { if (e.Column == gridView_Main.Columns["CURR_MY"]) { e.Info.DisplayText = m_CURR_MY.ToString("#,##0"); } else if (e.Column == gridView_Main.Columns["VAT_MY"]) { e.Info.DisplayText = m_VAT_MY.ToString("#,##0"); } else if (e.Column == gridView_Main.Columns["ORDER_MY"]) { e.Info.DisplayText = m_ORDER_MY.ToString("#,##0"); } }; //gridView_Main.CustomDrawCell += (sender, e) => //{ // DataRow row = gridView_Main.GetDataRow(e.RowHandle); // if (UtilClass.isEqual(e.Column.FieldName, "ORDER_DT") || UtilClass.isEqual(e.Column.FieldName, "CUST_NM") || // UtilClass.isEqual(e.Column.FieldName, "CURR_MY") || UtilClass.isEqual(e.Column.FieldName, "VAT_MY") || // UtilClass.isEqual(e.Column.FieldName, "ORDER_MY") || UtilClass.isEqual(e.Column.FieldName, "ORDER_QTY")) // { // if (UtilClass.isEqual(row["TAG_STR"], "C")) // { // e.Appearance.BackColor = Color.WhiteSmoke; // //e.Appearance.ForeColor = checkEdit_Color.Checked ? Color.Blue : e.Appearance.ForeColor; // } // else if (UtilClass.isEqual(row["TAG_STR"], "D")) // { // e.Appearance.BackColor = Color.LightCyan; // //e.Appearance.ForeColor = checkEdit_Color.Checked ? Color.Blue : e.Appearance.ForeColor; // } // else if (UtilClass.isEqual(row["TAG_STR"], "T")) // { // e.Appearance.BackColor = Color.LightGreen; // //e.Appearance.ForeColor = checkEdit_Color.Checked ? Color.Blue : e.Appearance.ForeColor; // } // else // { // e.Appearance.BackColor = Color.LightYellow; // } // } // else // { // if (UtilClass.isEqual(row["TAG_STR"], "C")) // { // e.Appearance.BackColor = Color.WhiteSmoke; // } // else if (UtilClass.isEqual(row["TAG_STR"], "D")) // { // e.Appearance.BackColor = Color.LightCyan; // } // else if (UtilClass.isEqual(row["TAG_STR"], "T")) // { // e.Appearance.BackColor = Color.LightGreen; // } // else // { // e.Appearance.BackColor = Color.Empty; // } // } //}; //gridView_Main.Appearance.HeaderPanel.ForeColor = // gridView_Main.Appearance.GroupFooter.ForeColor = // gridView_Main.Appearance.FooterPanel.ForeColor = // checkEdit_Color.Checked ? Color.Blue : Color.Empty; //for (int i = 0; i < gridView_Main.FormatConditions.Count; i++) //{ // gridView_Main.FormatConditions[i].Appearance.ForeColor = checkEdit_Color.Checked ? Color.Blue : Color.Empty; //} //checkEdit_Color.CheckedChanged += (sender, e) => //{ // gridView_Main.Appearance.HeaderPanel.ForeColor = // gridView_Main.Appearance.GroupFooter.ForeColor = // gridView_Main.Appearance.FooterPanel.ForeColor = // checkEdit_Color.Checked ? Color.Blue : Color.Empty; // for (int i = 0; i < gridView_Main.FormatConditions.Count; i++) // { // gridView_Main.FormatConditions[i].Appearance.ForeColor = checkEdit_Color.Checked ? Color.Blue : Color.Empty; // } //}; //checkEdit_SpecToItemName.CheckedChanged += (sender, e) => //{ // if (checkEdit_SpecToItemName.Checked) // { // gridColumn_ITEM_NM.FieldName = "ORDER_NORM"; // gridColumn_ORDER_NORM.Visible = false; // } // else // { // gridColumn_ITEM_NM.FieldName = "ITEM_NM"; // gridColumn_ORDER_NORM.Visible = true; // } //}; this.Shown += (sender, e) => { try { SerializedSqlParam[] aParam = new SerializedSqlParam[] { ClientClass.CreateSqlParameter("COMP_CD", SqlDbType.NVarChar, ConstClass._COMP_CD) }; ResultData resultData = ClientClass.GetData("U3GetSalesListForLookup", aParam); if (resultData.isError) { throw new Exception(resultData.ResultValue); } DataRow row; //row = resultData.DataList.Tables[0].NewRow(); //row["USR_ID"] = ""; //row["EMP_NO"] = ""; //row["USR_NM"] = "전체담당자"; //resultData.DataList.Tables[0].Rows.InsertAt(row, 0); //UtilClass.SetLookup(lookUpEdit_SALES_USER, resultData.DataList.Tables[0], "EMP_NO", "USR_NM", true); //row = resultData.DataList.Tables[1].NewRow(); //row["MST_DEPT_CD"] = ""; //row["DEPT_CD"] = ""; //row["DEPT_NM"] = "전체부서"; //resultData.DataList.Tables[1].Rows.InsertAt(row, 0); //UtilClass.SetLookup(lookUpEdit_DEPT, resultData.DataList.Tables[1], "MST_DEPT_CD", "DEPT_NM", true); //DataView c11 = new DataView(ConstClass._DATA); //c11.RowFilter = "CATE_CD = 'C' and GRP_CD = 'C11'"; //DataTable c11Data = c11.ToTable(); //row = c11Data.NewRow(); //row["NO_CD"] = ""; //row["NO_CD_NM"] = "전체창고"; //c11Data.Rows.InsertAt(row, 0); //UtilClass.SetLookup(lookUpEdit_STOCK, c11Data, "NO_CD", "NO_CD_NM", true); //DataView c12 = new DataView(ConstClass._DATA); //c12.RowFilter = "CATE_CD = 'C' and GRP_CD = 'C12'"; //DataTable c12Data = c12.ToTable(); //row = c12Data.NewRow(); //row["NO_CD"] = ""; //row["NO_CD_NM"] = "전체"; //c12Data.Rows.InsertAt(row, 0); //UtilClass.SetLookup(lookUpEdit_SIGN_GUBUN, c12Data, "NO_CD", "NO_CD_NM", true); } catch (Exception ex) { MessageBox.Show(ex.Message); this.Close(); } }; btnSelect.Click += (sender, e) => { selectAVGProc(); }; } private void selectCustProc() { SelectCustomerForm form = new SelectCustomerForm(buttonEdit_CUST_NM.Text, DateTime.Now); if (form.ShowDialog() != DialogResult.Yes) { return; } buttonEdit_CUST_NM.Text = form.m_CUST_NM; labelControl_CUST_CD.Text = form.m_CUST_CD; } private void selectNormProc() { SelectNormForm form = new SelectNormForm(""); if (form.ShowDialog() != DialogResult.Yes) { return; } buttonEdit_NORM.Text = form.m_NORM; } private void selectRoutingProc() { SelectRoutingForm form = new SelectRoutingForm(labelControl_RoutingCD.Text); if (form.ShowDialog() != DialogResult.Yes) { return; } buttonEdit_RoutingNM.Text = form.m_ITEM_NM; labelControl_RoutingCD.Text = form.m_ITEM_CD; } private void selectItemProc() { //SelectSalesItemForm form = new SelectSalesItemForm(buttonEdit_ITEM_NM.Text); //if (form.ShowDialog() != System.Windows.Forms.DialogResult.Yes) //{ // return; //} //labelControl_ITEM_CD.Text = form.m_ITEM_CD; //buttonEdit_ITEM_NM.Text = form.m_ITEM_NM; } public void selectAVGProc() { try { this.Cursor = Cursors.WaitCursor; gridControl_Main.DataSource = null; gridView_Main.Columns.Clear(); GridColumn gc = new GridColumn(); gc.Caption = "수량"; gc.FieldName = "COUNT"; gc.Name = "gridColumn_COUNT"; gc.Width = 70; gc.Visible = true; gridView_Main.Columns.Add(gc); gc = new GridColumn(); gc.Caption = "평균단가"; gc.FieldName = "TARGET_AVG"; gc.Name = "gridColumn_TARGET_AVG"; gc.Width = 100; gc.Visible = true; gridView_Main.Columns.Add(gc); gc = new GridColumn(); gc.Caption = "전체평균"; gc.FieldName = "TOTAL_AVG"; gc.Name = "gridColumn_TOTAL_AVG"; gc.Width = 100; gc.Visible = true; gridView_Main.Columns.Add(gc); System.Data.DataTable dt; dt = new DataTable(); dt.Columns.Add("COUNT", Type.GetType("System.String")); dt.Columns.Add("TARGET_AVG", Type.GetType("System.Int32")); dt.Columns.Add("TOTAL_AVG", Type.GetType("System.Int32")); GetAVGDataRow(ref dt); gridControl_Main.DataSource = dt; chartControl_AVG.Series.Clear(); Series chartSeries = new Series(buttonEdit_CUST_NM.Text, ViewType.Line); chartControl_AVG.Series.AddRange(new Series[] { chartSeries }); chartSeries.DataSource = dt; chartSeries.ArgumentDataMember = "COUNT"; chartSeries.ValueDataMembers.AddRange(new string[] { "TARGET_AVG" }); chartSeries = new Series("전체평균", ViewType.Line); chartControl_AVG.Series.AddRange(new Series[] { chartSeries }); chartSeries.DataSource = dt; chartSeries.ArgumentDataMember = "COUNT"; chartSeries.ValueDataMembers.AddRange(new string[] { "TOTAL_AVG" }); chartControl_AVG.Series.EndUpdate(); this.Cursor = Cursors.Arrow; } catch (Exception ex) { this.Cursor = Cursors.Arrow; MessageBox.Show(ex.Message); } } private void GetAVGDataRow(ref DataTable dt) { SerializedSqlParam[] aParam; ResultData resultData; DataTable aData; DataRow dr; try { aParam = new SerializedSqlParam[] { ClientClass.CreateSqlParameter("COMP_CD", SqlDbType.NVarChar, ConstClass._COMP_CD), ClientClass.CreateSqlParameter("CUST_CD", SqlDbType.NVarChar, labelControl_CUST_CD.Text), ClientClass.CreateSqlParameter("ITEM_CD", SqlDbType.NVarChar, labelControl_RoutingCD.Text), ClientClass.CreateSqlParameter("ORDER_NORM", SqlDbType.NVarChar, buttonEdit_NORM.Text) }; resultData = ClientClass.GetData("U3GetTradeMoneyListAVG", aParam); if (resultData.isError) { throw new Exception(resultData.ResultValue); } aData = resultData.TableData; if (resultData.TableData.Rows.Count > 0) { for (int i = 0; i < resultData.TableData.Rows.Count; i++) { dr = dt.NewRow(); dr[0] = ((UtilClass.toInt(aData.Rows[i]["QTY"]))*100) + "~" + ((UtilClass.toInt(aData.Rows[i]["QTY"])) * 100 + 99); dr[1] = UtilClass.toInt(aData.Rows[i]["TARGET_AVG"]); dr[2] = UtilClass.toInt(aData.Rows[i]["TOTAL_AVG"]); dt.Rows.Add(dr); } } else { gridControl_Main.DataSource = resultData.TableData; } } catch (Exception ex) { MessageBox.Show(ex.Message); } } 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("SDATE", SqlDbType.NVarChar, dateEdit_SDATE.DateTime.ToString("yyyy.MM.dd")), //ClientClass.CreateSqlParameter("FDATE", SqlDbType.NVarChar, dateEdit_FDATE.DateTime.ToString("yyyy.MM.dd")), ClientClass.CreateSqlParameter("CUST_CD", SqlDbType.NVarChar, labelControl_CUST_CD.Text), //ClientClass.CreateSqlParameter("SALE_USR_ID", SqlDbType.NVarChar, lookUpEdit_SALES_USER.EditValue), //ClientClass.CreateSqlParameter("DEPT_CD", SqlDbType.NVarChar, lookUpEdit_DEPT.EditValue), //ClientClass.CreateSqlParameter("STOCK_CD", SqlDbType.NVarChar, lookUpEdit_STOCK.EditValue), //ClientClass.CreateSqlParameter("SIGN_GUBUN_CD", SqlDbType.NVarChar, lookUpEdit_SIGN_GUBUN.EditValue), //ClientClass.CreateSqlParameter("ITEM_CD", SqlDbType.NVarChar, labelControl_ITEM_CD.Text), //ClientClass.CreateSqlParameter("ORDER_NORM", SqlDbType.NVarChar, buttonEdit_SPEC.Text), //ClientClass.CreateSqlParameter("SORT", SqlDbType.Int, checkEdit_SortAvg.Checked ? 0 : 1) }; ResultData resultData = ClientClass.GetData("U3GetSaleList", aParam); if (resultData.isError) { throw new Exception(resultData.ResultValue); } //if (checkEdit_SpecToItemName.Checked) //{ // gridColumn_ITEM_NM.FieldName = "ORDER_NORM"; //} //else //{ // gridColumn_ITEM_NM.FieldName = "ITEM_NM"; //} DataTable data = resultData.TableData.Clone(); DataTable aData = resultData.TableData; m_CURR_MY = 0; m_VAT_MY = 0; m_ORDER_MY = 0; int curr_my_day = 0, vat_my_day = 0, order_my_day = 0; int curr_my_cust = 0, vat_my_cust = 0, order_my_cust = 0, cnt_cust = 0; string order_dt = "", cust_cd = ""; DataRow row; for (int i = 0; i < aData.Rows.Count; i++) { row = data.NewRow(); row.ItemArray = aData.Rows[i].ItemArray; data.Rows.Add(row); order_dt = UtilClass.toStr(aData.Rows[i]["ORDER_DT"]); cust_cd = UtilClass.toStr(aData.Rows[i]["CUST_CD"]); curr_my_day += UtilClass.toInt(aData.Rows[i]["CURR_MY"]); vat_my_day += UtilClass.toInt(aData.Rows[i]["VAT_MY"]); order_my_day += UtilClass.toInt(aData.Rows[i]["ORDER_MY"]); curr_my_cust += UtilClass.toInt(aData.Rows[i]["CURR_MY"]); vat_my_cust += UtilClass.toInt(aData.Rows[i]["VAT_MY"]); order_my_cust += UtilClass.toInt(aData.Rows[i]["ORDER_MY"]); m_CURR_MY += UtilClass.toInt(aData.Rows[i]["CURR_MY"]); m_VAT_MY += UtilClass.toInt(aData.Rows[i]["VAT_MY"]); m_ORDER_MY += UtilClass.toInt(aData.Rows[i]["ORDER_MY"]); cnt_cust++; } DataRow sRow = data.NewRow(); sRow["ORDER_DT"] = "★"; sRow["CUST_NM"] = "▷합 계"; sRow["CURR_MY"] = m_CURR_MY; sRow["VAT_MY"] = m_VAT_MY; sRow["ORDER_MY"] = m_ORDER_MY; sRow["TAG_STR"] = "T"; data.Rows.Add(sRow); data.AcceptChanges(); gridControl_Main.DataSource = data; this.Cursor = Cursors.Arrow; } catch (Exception ex) { this.Cursor = Cursors.Arrow; MessageBox.Show(ex.Message); } } public override void newProc() { try { SaleRegistrationPopup form = new SaleRegistrationPopup(); form.ShowDialog(); if (form.m_Changed) { searchProc(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } public override void excelProc() { this.ExportExcelGrid(gridControl_Main); } } }