File name
Commit message
Commit date
File name
Commit message
Commit date
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 CreditLongSalesList : PublicLib.CommonMDI
{
public CreditLongSalesList()
{
InitializeComponent();
gridControl_Main.LookAndFeel.Style = DevExpress.LookAndFeel.LookAndFeelStyle.Flat;
gridControl_Main.LookAndFeel.UseDefaultLookAndFeel = false;
gridView_Main.Appearance.HeaderPanel.BackColor = Color.FromArgb(170, 204, 255);
spinEdit_YY.Value = DateTime.Now.Year;
spinEdit_MM.Value = DateTime.Now.Month;
spinEdit_MM.Spin += (sender, e) =>
{
if (e.IsSpinUp)
{
if (spinEdit_MM.Value >= 12)
{
spinEdit_YY.Value++;
spinEdit_MM.Value = 1;
e.Handled = true;
}
}
else
{
if (spinEdit_MM.Value <= 1)
{
spinEdit_YY.Value--;
spinEdit_MM.Value = 12;
e.Handled = true;
}
}
};
buttonEdit_CUST_NM.ButtonClick += (sender, e) =>
{
selectCustProc();
};
buttonEdit_CUST_NM.KeyPress += (sender, e) =>
{
if (e.KeyChar == '\r')
{
selectCustProc();
}
};
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;
lookUpEdit_SALES_USER.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("YYMM", SqlDbType.NVarChar, spinEdit_YY.Value.ToString("0000") + "." + spinEdit_MM.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("ONLY_4_OVER", SqlDbType.NVarChar, checkEdit_ONLY_4_OVER.Checked ? "Y" : "N"),
ClientClass.CreateSqlParameter("CURRENT_REMAIN_ONLY", SqlDbType.NVarChar, checkEdit_CurrentRemainOnly.Checked ? "Y" : "N")
};
// GetCreditLongSalesList2 함수로 변경
ResultData resultData = ClientClass.GetData("GetCreditLongSalesList2", aParam);
if (resultData.isError)
{
throw new Exception(resultData.ResultValue);
}
DataTable aData = resultData.TableData;
foreach (DataRow inrow in aData.Rows)
{
//decimal col_my_c1 = UtilClass.toDecimal(inrow["COL_MY_C1"]);
decimal not_my_2 = UtilClass.toDecimal(inrow["NOT_MY_2"]);
decimal not_my_3 = UtilClass.toDecimal(inrow["NOT_MY_3"]);
decimal not_my_4 = UtilClass.toDecimal(inrow["NOT_MY_4"]);
decimal not_my_5 = UtilClass.toDecimal(inrow["NOT_MY_5"]);
decimal not_my_6 = UtilClass.toDecimal(inrow["NOT_MY_6"]);
decimal not_my_7 = UtilClass.toDecimal(inrow["NOT_MY_7"]);
decimal base_my = UtilClass.toDecimal(inrow["BASE_MY"]);
//decimal prev_my = UtilClass.toDecimal(inrow["PREV_REMAIN_MY"]);
decimal col_my_total = UtilClass.toDecimal(inrow["COL_MY_TOTAL"]);
not_my_7 += base_my;
if (not_my_7 < 0)
{
col_my_total = col_my_total + (-not_my_7);
inrow["NOT_MY_7"] = 0;
}
if (col_my_total > 0 && not_my_7 > 0)
{
inrow["NOT_MY_7"] = (col_my_total >= not_my_7) ? 0 : (not_my_7 - col_my_total);
col_my_total -= not_my_7;
}
if (col_my_total > 0 && not_my_6 > 0)
{
inrow["NOT_MY_6"] = (col_my_total >= not_my_6) ? 0 : (not_my_6 - col_my_total);
col_my_total -= not_my_6;
}
if (col_my_total > 0 && not_my_5 > 0)
{
inrow["NOT_MY_5"] = (col_my_total >= not_my_5) ? 0 : (not_my_5 - col_my_total);
col_my_total -= not_my_5;
}
if (col_my_total > 0 && not_my_4 > 0)
{
inrow["NOT_MY_4"] = (col_my_total >= not_my_4) ? 0 : (not_my_4 - col_my_total);
col_my_total -= not_my_4;
}
if (col_my_total > 0 && not_my_3 > 0)
{
inrow["NOT_MY_3"] = (col_my_total >= not_my_3) ? 0 : (not_my_3 - col_my_total);
col_my_total -= not_my_3;
}
if (col_my_total > 0 && not_my_2 > 0)
{
inrow["NOT_MY_2"] = (col_my_total >= not_my_2) ? 0 : (not_my_2 - col_my_total);
col_my_total -= not_my_2;
}
//if (col_my_total > 0 && prev_my > 0)
//{
// inrow["PREV_REMAIN_MY"] = (col_my_total >= prev_my) ? 0 : (prev_my - col_my_total);
// col_my_total -= prev_my;
//}
//if (col_my_c1 > 0) //당월수금이 있을시
//{
// if (not_my_6 > 0)
// {
// inrow["NOT_MY_6"] = not_my_6 - col_my_c1;
// }
// else if (not_my_5 > 0)
// {
// inrow["NOT_MY_5"] = not_my_5 - col_my_c1;
// }
// else if (not_my_4 > 0)
// {
// inrow["NOT_MY_4"] = not_my_4 - col_my_c1;
// }
// else if (not_my_3 > 0)
// {
// inrow["NOT_MY_3"] = not_my_3 - col_my_c1;
// }
// else if (not_my_2 > 0)
// {
// inrow["NOT_MY_2"] = not_my_2 - col_my_c1;
// }
//}
}
aData.AcceptChanges();
gridControl_Main.DataSource = aData;
this.Cursor = Cursors.Arrow;
}
catch (Exception ex)
{
this.Cursor = Cursors.Arrow;
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("YYMM", SqlDbType.NVarChar, spinEdit_YY.Value.ToString("0000") + "." + spinEdit_MM.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("ONLY_4_OVER", SqlDbType.NVarChar, checkEdit_ONLY_4_OVER.Checked ? "Y" : "N"),
// ClientClass.CreateSqlParameter("CURRENT_REMAIN_ONLY", SqlDbType.NVarChar, checkEdit_CurrentRemainOnly.Checked ? "Y" : "N")
// };
// ResultData resultData = ClientClass.GetData("GetCreditLongSalesList", aParam);
// if (resultData.isError)
// {
// throw new Exception(resultData.ResultValue);
// }
// DataTable aData = resultData.TableData;
// foreach (DataRow inrow in aData.Rows)
// {
// decimal col_my_c1 = UtilClass.toDecimal(inrow["COL_MY_C1"]);
// decimal not_my_2 = UtilClass.toDecimal(inrow["NOT_MY_2"]);
// decimal not_my_3 = UtilClass.toDecimal(inrow["NOT_MY_3"]);
// decimal not_my_4 = UtilClass.toDecimal(inrow["NOT_MY_4"]);
// decimal not_my_5 = UtilClass.toDecimal(inrow["NOT_MY_5"]);
// decimal not_my_6 = UtilClass.toDecimal(inrow["NOT_MY_6"]);
// if (col_my_c1 > 0) //당월수금이 있을시
// {
// if (not_my_6 > 0)
// {
// inrow["NOT_MY_6"] = not_my_6 - col_my_c1;
// }
// else if (not_my_5 > 0)
// {
// inrow["NOT_MY_5"] = not_my_5 - col_my_c1;
// }
// else if (not_my_4 > 0)
// {
// inrow["NOT_MY_4"] = not_my_4 - col_my_c1;
// }
// else if (not_my_3 > 0)
// {
// inrow["NOT_MY_3"] = not_my_3 - col_my_c1;
// }
// else if (not_my_2 > 0)
// {
// inrow["NOT_MY_2"] = not_my_2 - col_my_c1;
// }
// }
// }
// aData.AcceptChanges();
// gridControl_Main.DataSource = aData;
// 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);
}
}
}