using ClientLib; using ClientLib.CommonService; using DevExpress.XtraGrid; 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.Reflection; using System.Text; using System.Windows.Forms; namespace HANMI_J_SALE { public partial class DurationCustCreditList : PublicLib.CommonMDI { private string m_SYYMM, m_FYYMM; public DurationCustCreditList() { InitializeComponent(); m_SYYMM = ""; m_FYYMM = ""; spinEdit_SYY.Value = 2018; spinEdit_SMM.Value = 12; spinEdit_FYY.Value = DateTime.Now.Year; spinEdit_FMM.Value = DateTime.Now.Month; spinEdit_SMM.Spin += (sender, e) => { if (e.IsSpinUp) { if (spinEdit_SMM.Value >= 12) { spinEdit_SYY.Value++; spinEdit_SMM.Value = 1; e.Handled = true; } } else { if (spinEdit_SMM.Value <= 1) { spinEdit_SYY.Value--; spinEdit_SMM.Value = 12; e.Handled = true; } } }; spinEdit_FMM.Spin += (sender, e) => { if (e.IsSpinUp) { if (spinEdit_FMM.Value >= 12) { spinEdit_FYY.Value++; spinEdit_FMM.Value = 1; e.Handled = true; } } else { if (spinEdit_FMM.Value <= 1) { spinEdit_FYY.Value--; spinEdit_FMM.Value = 12; e.Handled = true; } } }; buttonEdit_CUST_NM.EditValueChanged += (sender, e) => { labelControl_CUST_CD.Text = ""; }; buttonEdit_CUST_NM.ButtonClick += (sender, e) => { selectCustProc(); }; buttonEdit_CUST_NM.KeyPress += (sender, e) => { if (e.KeyChar == '\r') { selectCustProc(); } }; gridView_Main.FocusedRowChanged += (sender, e) => { ShowDetail(); }; gridControl_Main.LookAndFeel.Style = DevExpress.LookAndFeel.LookAndFeelStyle.Flat; gridControl_Main.LookAndFeel.UseDefaultLookAndFeel = false; gridView_Main.Appearance.HeaderPanel.BackColor = Color.FromArgb(170, 204, 255); gridControl_Det.LookAndFeel.Style = DevExpress.LookAndFeel.LookAndFeelStyle.Flat; gridControl_Det.LookAndFeel.UseDefaultLookAndFeel = false; gridView_Det.Appearance.HeaderPanel.BackColor = Color.FromArgb(170, 204, 255); this.Shown += (sender, e) => { try { comboBoxEdit_SEARCH_CONDITION.SelectedIndex = 1; SerializedSqlParam[] aParam = new SerializedSqlParam[] { ClientClass.CreateSqlParameter("COMP_CD", SqlDbType.NVarChar, ConstClass._COMP_CD) }; ResultData resultData = ClientClass.GetData("GetSalesListForLookup", 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); } catch (Exception ex) { MessageBox.Show(ex.Message); this.Close(); } }; } 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; searchProc(); gridControl_Main.Focus(); } 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("SYYMM", SqlDbType.NVarChar, spinEdit_SYY.Value.ToString("0000") + "." + spinEdit_SMM.Value.ToString("00")), ClientClass.CreateSqlParameter("FYYMM", SqlDbType.NVarChar, spinEdit_FYY.Value.ToString("0000") + "." + spinEdit_FMM.Value.ToString("00")), ClientClass.CreateSqlParameter("SEARCH_CONDITION", SqlDbType.Int, comboBoxEdit_SEARCH_CONDITION.SelectedIndex), ClientClass.CreateSqlParameter("REMARK_CONDITION", SqlDbType.Int, comboBoxEdit_REMARK_CONDITION.SelectedIndex), ClientClass.CreateSqlParameter("MST_DEPT_CD", SqlDbType.NVarChar, lookUpEdit_DEPT.EditValue), ClientClass.CreateSqlParameter("SALES_USR_ID", SqlDbType.NVarChar, lookUpEdit_SALES_USER.EditValue), ClientClass.CreateSqlParameter("CUST_CD", SqlDbType.NVarChar, labelControl_CUST_CD.Text), ClientClass.CreateSqlParameter("CURRENT_REMAIN_ONLY", SqlDbType.NVarChar, checkEdit_CurrentRemainOnly.Checked ? "Y" : "N") }; ResultData resultData = ClientClass.GetData("GetDurationCustCreditList", aParam); if (resultData.isError) { throw new Exception(resultData.ResultValue); } m_SYYMM = spinEdit_SYY.Value.ToString("0000") + "." + spinEdit_SMM.Value.ToString("00"); m_FYYMM = spinEdit_FYY.Value.ToString("0000") + "." + spinEdit_FMM.Value.ToString("00"); gridControl_Main.DataSource = resultData.TableData; this.Cursor = Cursors.Arrow; } catch (Exception ex) { this.Cursor = Cursors.Arrow; MessageBox.Show(ex.Message); } } private void ShowDetail() { try { gridControl_Det.DataSource = null; DataRow row = gridView_Main.GetFocusedDataRow(); if (row == null) { return; } this.Cursor = Cursors.WaitCursor; SerializedSqlParam[] aParam = new SerializedSqlParam[] { ClientClass.CreateSqlParameter("COMP_CD", SqlDbType.NVarChar, ConstClass._COMP_CD), ClientClass.CreateSqlParameter("CUST_CD", SqlDbType.NVarChar, row["CUST_CD"]), ClientClass.CreateSqlParameter("SYYMM", SqlDbType.NVarChar, m_SYYMM), ClientClass.CreateSqlParameter("FYYMM", SqlDbType.NVarChar, m_FYYMM) }; ResultData resultData = ClientClass.GetData("GetDurationCustCreditListDetail", aParam); if (resultData.isError) { throw new Exception(resultData.ResultValue); } decimal prev_remain_my = UtilClass.toDecimal(row["PREV_REMAIN_MY"]); for (int i = 0; i < resultData.TableData.Rows.Count; i++) { resultData.TableData.Rows[i]["PREV_REMAIN_MY"] = prev_remain_my; prev_remain_my = (prev_remain_my + UtilClass.toInt(resultData.TableData.Rows[i]["ORDER_MY"])) - UtilClass.toInt(resultData.TableData.Rows[i]["COL_MY"]); resultData.TableData.Rows[i]["CURR_REMAIN_MY"] = prev_remain_my; } resultData.TableData.AcceptChanges(); gridControl_Det.DataSource = resultData.TableData; this.Cursor = Cursors.Arrow; } catch (Exception ex) { this.Cursor = Cursors.Arrow; MessageBox.Show(ex.Message); } } public override void printProc() { try { if (gridControl_Main.DataSource == null) { return; } CommonPreview.showPreview(gridControl_Main, "장기 외상매출현황(6개월)", true); } catch (Exception ex) { MessageBox.Show(ex.Message); } } public override void excelProc() { this.ExportExcelGrid(gridControl_Main); } } }