File name
Commit message
Commit date
File name
Commit message
Commit date
using ClientLib;
using ClientLib.CommonService2;
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.Text;
using System.Windows.Forms;
namespace HANMI_J_SALE
{
public partial class SalesList : PublicLib.CommonMDI
{
private int m_CURR_MY, m_VAT_MY, m_ORDER_MY;
public SalesList()
{
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_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 = "";
}
};
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();
SaleRegistrationPopupV2 form = new SaleRegistrationPopupV2();
form.setData(Convert.ToDateTime(row["ORDER_DT"]), UtilClass.toStr(row["ORDER_SEQ"]));
form.ShowDialog();
if (form.m_Changed)
{
searchProc();
}
}
};
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("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);
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();
}
};
}
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();
}
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;
buttonEdit_SPEC.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("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("PROC_CD", SqlDbType.NVarChar, (comboBoxEdit_PROC.SelectedIndex + 1).ToString()),
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_CustSort.Checked ? 0 : 1)
};
ResultData resultData = ClientClass.GetData("GetSaleList", 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);
if (checkEdit_CustSort.Checked)
{
if (checkEdit_CustSum.Checked)
{
if (!UtilClass.isNull(cust_cd) && !UtilClass.isEqual(cust_cd, aData.Rows[i]["CUST_CD"]))
{
if (cnt_cust > 1)
{
row = data.NewRow();
row["ORDER_DT"] = " ";
row["CUST_NM"] = "▷거래선계";
row["CURR_MY"] = curr_my_cust;
row["VAT_MY"] = vat_my_cust;
row["ORDER_MY"] = order_my_cust;
row["TAG_STR"] = "C";
data.Rows.InsertAt(row, data.Rows.Count - 1);
}
curr_my_cust = 0;
vat_my_cust = 0;
order_my_cust = 0;
cnt_cust = 0;
}
}
if (checkEdit_DaySum.Checked)
{
if (!UtilClass.isNull(order_dt) && !UtilClass.isEqual(order_dt, aData.Rows[i]["ORDER_DT"]))
{
row = data.NewRow();
row["ORDER_DT"] = " ";
row["CUST_NM"] = "▷일 자 계";
row["CURR_MY"] = curr_my_day;
row["VAT_MY"] = vat_my_day;
row["ORDER_MY"] = order_my_day;
row["TAG_STR"] = "D";
data.Rows.InsertAt(row, data.Rows.Count - 1);
curr_my_day = 0;
vat_my_day = 0;
order_my_day = 0;
//cnt_cust = 0;
}
}
}
else
{
if (checkEdit_DaySum.Checked)
{
if (!UtilClass.isNull(order_dt) && !UtilClass.isEqual(order_dt, aData.Rows[i]["ORDER_DT"]))
{
row = data.NewRow();
row["ORDER_DT"] = " ";
row["CUST_NM"] = "▷일 자 계";
row["CURR_MY"] = curr_my_day;
row["VAT_MY"] = vat_my_day;
row["ORDER_MY"] = order_my_day;
row["TAG_STR"] = "D";
data.Rows.InsertAt(row, data.Rows.Count - 1);
curr_my_day = 0;
vat_my_day = 0;
order_my_day = 0;
//cnt_cust = 0;
}
}
if (checkEdit_CustSum.Checked)
{
if (!UtilClass.isNull(cust_cd) && !UtilClass.isEqual(cust_cd, aData.Rows[i]["CUST_CD"]))
{
if (cnt_cust > 1)
{
row = data.NewRow();
row["ORDER_DT"] = " ";
row["CUST_NM"] = "▷거래선계";
row["CURR_MY"] = curr_my_cust;
row["VAT_MY"] = vat_my_cust;
row["ORDER_MY"] = order_my_cust;
row["TAG_STR"] = "C";
data.Rows.InsertAt(row, data.Rows.Count - 1);
}
curr_my_cust = 0;
vat_my_cust = 0;
order_my_cust = 0;
cnt_cust = 0;
}
}
}
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++;
}
if (checkEdit_CustSum.Checked && cnt_cust > 1)
{
DataRow cRow = data.NewRow();
cRow["ORDER_DT"] = " ";
cRow["CUST_NM"] = "▷거래선계";
cRow["CURR_MY"] = curr_my_cust;
cRow["VAT_MY"] = vat_my_cust;
cRow["ORDER_MY"] = order_my_cust;
cRow["TAG_STR"] = "C";
data.Rows.Add(cRow);
}
if (checkEdit_DaySum.Checked)
{
DataRow dRow = data.NewRow();
dRow["ORDER_DT"] = " ";
dRow["CUST_NM"] = "▷일 자 계";
dRow["CURR_MY"] = curr_my_day;
dRow["VAT_MY"] = vat_my_day;
dRow["ORDER_MY"] = order_my_day;
dRow["TAG_STR"] = "D";
data.Rows.Add(dRow);
}
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
{
SaleRegistrationPopupV2 form = new SaleRegistrationPopupV2();
form.ShowDialog();
if (form.m_Changed)
{
searchProc();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
public override void excelProc()
{
this.ExportExcelGrid(gridControl_Main);
}
}
}