File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
using ClientLib;
using ClientLib.CommonService;
using DevExpress.XtraEditors;
using DevExpress.XtraGrid.Columns;
using DevExpress.XtraGrid.Views.BandedGrid;
using DevExpress.XtraTreeList;
using DevExpress.XtraTreeList.Nodes;
using PublicLib;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace HANMI_STD
{
public partial class CurrentMoneyManager : CommonMDI
{
DataView m_Group_View;
DataView m_Code_View;
DataView m_Code_Type;
string m_Item_CD = "";
string m_new_Grp_CD = "";
public CurrentMoneyManager()
{
InitializeComponent();
this.Shown += (sender, e) =>
{
SerializedSqlParam[] aParam = new SerializedSqlParam[] {
ClientClass.CreateSqlParameter("COMP_CD", SqlDbType.NVarChar, ConstClass._COMP_CD),
ClientClass.CreateSqlParameter("ITEM_CD", SqlDbType.NVarChar, "")
};
ResultData result = ClientClass.GetData("U3GetCurrentMoney", aParam);
if (result.isError)
{
throw new Exception(result.ResultValue);
}
gridControl_Main.DataSource = result.DataList.Tables[0];
DataRow row = bandedGridView_Main.GetFocusedDataRow();
m_Item_CD = row["ITEM_CD"].ToString();
searchProc();
};
bandedGridView_Main.FocusedRowChanged += (sender, e) =>
{
DataRow row = bandedGridView_Main.GetFocusedDataRow();
m_Item_CD = row["ITEM_CD"].ToString();
if (row != null)
{
searchProc();
}
};
gridControl_Main.DoubleClick += (sender, e) =>
{
DataRow row = bandedGridView_Main.GetFocusedDataRow();
m_Item_CD = row["ITEM_CD"].ToString();
if (row != null)
{
searchProc();
}
};
gridControl_Main.KeyPress += (sender, e) =>
{
DataRow row = bandedGridView_Main.GetFocusedDataRow();
m_Item_CD = row["ITEM_CD"].ToString();
if (e.KeyChar == '\r')
{
searchProc();
}
};
simpleButton_AddMoney.Click += (sender, e) =>
{
bandedGridView_Code.AddNewRow();
bandedGridView_Code.GetFocusedDataRow()["COMP_CD"] = ConstClass._COMP_CD;
bandedGridView_Code.GetFocusedDataRow()["ITEM_CD"] = m_Item_CD;
};
simpleButton_AddGroup.Click += (sender, e) =>
{
try
{
this.Cursor = Cursors.WaitCursor;
SerializedSqlParam[] aParam = new SerializedSqlParam[] {
ClientClass.CreateSqlParameter("COMP_CD", SqlDbType.NVarChar, ConstClass._COMP_CD),
ClientClass.CreateSqlParameter("ITEM_CD", SqlDbType.NVarChar, m_Item_CD),
ClientClass.CreateSqlParameter("RUN_RESULT", SqlDbType.NVarChar, "", ParameterDirection.Output, 1000)
};
ResultData result = ClientClass.GetData("U3GetMaxCurrentMoneyGroup", aParam);
if (result.isError)
{
throw new Exception(result.ResultValue);
}
if(result!=null && result.TableData.Rows.Count==1 && result.TableData.Rows[0].ItemArray.Length ==1 && m_new_Grp_CD != result.TableData.Rows[0].ItemArray[0].ToString())
{
bandedGridView_Group.AddNewRow();
bandedGridView_Group.GetFocusedDataRow()["COMP_CD"] = ConstClass._COMP_CD;
bandedGridView_Group.GetFocusedDataRow()["ITEM_CD"] = m_Item_CD;
bandedGridView_Group.GetFocusedDataRow()["GRP_CD"] = result.TableData.Rows[0].ItemArray[0].ToString();
m_new_Grp_CD = result.TableData.Rows[0].ItemArray[0].ToString();
bandedGridView_Group.Focus();
}
bandedGridView_Group.Focus();
this.Cursor = Cursors.Arrow;
}
catch (Exception ex)
{
this.Cursor = Cursors.Arrow;
XtraMessageBox.Show(ex.Message);
}
};
simpleButton_DeleteGroup.Click += (sender, e) =>
{
DataRow row = bandedGridView_Group.GetFocusedDataRow();
if (XtraMessageBox.Show(this,"[" + row["GRP_CD"].ToString() + "]\r\n삭제된 데이터는 완전히 지워집니다.\r\n 정말로 삭제하시겠습니까?","Delete", MessageBoxButtons.YesNo) != DialogResult.Yes)
{
return;
}
try
{
this.Cursor = Cursors.WaitCursor;
DataTable aData = new DataTable();
ResultData[] dataList = null;
ResultData data1 = new ResultData();
SerializedSqlParam[] aParam = new SerializedSqlParam[]
{
ClientClass.CreateSqlParameter("COMP_CD", SqlDbType.NVarChar, ConstClass._COMP_CD),
ClientClass.CreateSqlParameter("ITEM_CD", SqlDbType.NVarChar, m_Item_CD),
ClientClass.CreateSqlParameter("GRP_CD", SqlDbType.NVarChar, row["GRP_CD"].ToString()),
ClientClass.CreateSqlParameter("RUN_RESULT", SqlDbType.NVarChar, "", ParameterDirection.Output, 1000)
};
ResultData result = ClientClass.SetTableData("U3DeleteCurrentMoney", dataList, aParam);
if (result.isError || !UtilClass.isNull(result.ResultValue))
{
throw new Exception(result.ResultValue);
}
searchProc();
this.Cursor = Cursors.Arrow;
}
catch (Exception ex)
{
this.Cursor = Cursors.Arrow;
XtraMessageBox.Show(ex.Message);
}
};
repositoryItemButtonEdit1.ButtonClick += (sender, e) =>
{
DataRow row = bandedGridView_Group.GetFocusedDataRow();
if (row["ITEM_GRP"].ToString() == "")
{
XtraMessageBox.Show("그룹명이 입력되지 않았습니다.");
return;
}
SelectCurrentMoneyGroupForm scmgf = new SelectCurrentMoneyGroupForm("", row["GRP_CD"].ToString(), row["ITEM_CD"].ToString());
if(scmgf.ShowDialog() != DialogResult.No)
{
searchProc();
}
};
bandedGridView_Group.CellValueChanged += (sender, e) =>
{
DataRow row = bandedGridView_Group.GetFocusedDataRow();
try
{
if (row != null)
{
if (bandedGridView_Group.FocusedColumn.FieldName == "ITEM_GRP" && row["ITEM_GRP"].ToString() != "")
{
try
{
this.Cursor = Cursors.WaitCursor;
DataTable aData = new DataTable();
ResultData[] dataList = null;
ResultData data1 = new ResultData();
SerializedSqlParam[] aParam = new SerializedSqlParam[]
{
ClientClass.CreateSqlParameter("COMP_CD", SqlDbType.NVarChar, ConstClass._COMP_CD),
ClientClass.CreateSqlParameter("ITEM_CD", SqlDbType.NVarChar, m_Item_CD),
ClientClass.CreateSqlParameter("GRP_CD", SqlDbType.NVarChar, row["GRP_CD"].ToString()),
ClientClass.CreateSqlParameter("ITEM_GRP", SqlDbType.NVarChar,row["ITEM_GRP"].ToString()),
ClientClass.CreateSqlParameter("RUN_RESULT", SqlDbType.NVarChar, "", ParameterDirection.Output, 1000)
};
ResultData result = ClientClass.SetTableData("U3SaveCurrentMoneyGroup", dataList, aParam);
if (result.isError || !UtilClass.isNull(result.ResultValue))
{
throw new Exception(result.ResultValue);
}
this.Cursor = Cursors.Arrow;
}
catch (Exception ex)
{
this.Cursor = Cursors.Arrow;
XtraMessageBox.Show(ex.Message);
}
}
}
}
catch (Exception ex)
{
}
};
bandedGridView_Code.CellValueChanged += (sender, e) =>
{
DataRow row = bandedGridView_Code.GetFocusedDataRow();
try
{
if (row != null)
{
if (bandedGridView_Code.FocusedColumn.FieldName != "ITEM_QTY" && row["ITEM_QTY"]!= null && row["ITEM_QTY"].ToString() != "" && row["ITEM_QTY"].ToString() != "0")
{
try
{
this.Cursor = Cursors.WaitCursor;
DataTable aData = new DataTable();
ResultData[] dataList = null;
ResultData data1 = new ResultData();
string sfield = "";
if (bandedGridView_Code.FocusedColumn.FieldName == "STANDARD")
{
sfield = "";
}else
{
sfield = bandedGridView_Code.FocusedColumn.FieldName;
}
SerializedSqlParam[] aParam = new SerializedSqlParam[]
{
ClientClass.CreateSqlParameter("COMP_CD", SqlDbType.NVarChar, ConstClass._COMP_CD),
ClientClass.CreateSqlParameter("ITEM_CD", SqlDbType.NVarChar, m_Item_CD),
ClientClass.CreateSqlParameter("ITEM_GRP", SqlDbType.NVarChar, sfield),
ClientClass.CreateSqlParameter("ITEM_QTY", SqlDbType.Int, row["ITEM_QTY"].ToString()),
ClientClass.CreateSqlParameter("ITEM_MY", SqlDbType.Int, row[bandedGridView_Code.FocusedColumn.FieldName].ToString()),
ClientClass.CreateSqlParameter("RESULT_STR", SqlDbType.NVarChar, "", ParameterDirection.Output, 1000)
};
ResultData result = ClientClass.SetTableData("U3SaveCurrentmoney", dataList, aParam);
if (result.isError || !UtilClass.isNull(result.ResultValue))
{
throw new Exception(result.ResultValue);
}
this.Cursor = Cursors.Arrow;
}
catch (Exception ex)
{
this.Cursor = Cursors.Arrow;
XtraMessageBox.Show(ex.Message);
}
//MessageBox.Show(row[bandedGridView_Code.FocusedColumn.Caption].ToString());
}else if(bandedGridView_Code.FocusedColumn.FieldName == "ITEM_QTY" && row["ITEM_QTY"] != null && row["ITEM_QTY"].ToString() != "")
{
string[] Checker = new string[bandedGridView_Code.DataRowCount];
for (int i = 0; i < bandedGridView_Code.DataRowCount; i++)
{
Checker[i] = bandedGridView_Code.GetRowCellValue(i, bandedGridView_Code.Columns["ITEM_QTY"]).ToString();
}
Array.Sort(Checker);
if (row["PrevITEM_QTY"].ToString()=="")
{
foreach (string s in Checker)
{
if (row["ITEM_QTY"].ToString() == s)
{
MessageBox.Show("중복 수량수가 존재합니다.");
searchProc();
return;
}
}
}else
{
if (bandedGridView_Code.ActiveEditor.OldEditValue.ToString() == bandedGridView_Code.ActiveEditor.EditValue.ToString())
{
return;
}
string cs = "";
foreach (string s in Checker)
{
if (cs == s)
{
MessageBox.Show("중복 수량수가 존재합니다.");
searchProc();
return;
}
cs = s;
}
}
try
{
this.Cursor = Cursors.WaitCursor;
DataTable aData = new DataTable();
ResultData[] dataList = null;
ResultData data1 = new ResultData();
SerializedSqlParam[] aParam = new SerializedSqlParam[]
{
ClientClass.CreateSqlParameter("COMP_CD", SqlDbType.NVarChar, ConstClass._COMP_CD),
ClientClass.CreateSqlParameter("ITEM_CD", SqlDbType.NVarChar, m_Item_CD),
ClientClass.CreateSqlParameter("OLD_QTY", SqlDbType.NVarChar, bandedGridView_Code.ActiveEditor.OldEditValue.ToString()),
ClientClass.CreateSqlParameter("ITEM_QTY", SqlDbType.Int, row["ITEM_QTY"].ToString()),
ClientClass.CreateSqlParameter("RESULT_STR", SqlDbType.NVarChar, "", ParameterDirection.Output, 1000)
};
ResultData result = ClientClass.SetTableData("U3SaveCurrentmoneyQTY", dataList, aParam);
if (result.isError || !UtilClass.isNull(result.ResultValue))
{
throw new Exception(result.ResultValue);
}
this.Cursor = Cursors.Arrow;
}
catch (Exception ex)
{
this.Cursor = Cursors.Arrow;
XtraMessageBox.Show(ex.Message);
}
}
}
}
catch (Exception ex)
{
}
};
}
public override void searchProc()
{
try
{
this.Cursor = Cursors.WaitCursor;
m_new_Grp_CD = "";
SerializedSqlParam[] aParam = new SerializedSqlParam[] {
ClientClass.CreateSqlParameter("COMP_CD", SqlDbType.NVarChar, ConstClass._COMP_CD),
ClientClass.CreateSqlParameter("ITEM_CD", SqlDbType.NVarChar, m_Item_CD)
};
ResultData result = ClientClass.GetData("U3GetCurrentMoney", aParam);
if (result.isError)
{
throw new Exception(result.ResultValue);
}
//gridControl_Main.DataSource = result.DataList.Tables[0];
m_Group_View = new DataView(result.DataList.Tables[1]);
m_Code_Type = new DataView(result.DataList.Tables[2]);
m_Code_View = new DataView(result.DataList.Tables[3]);
if (result.DataList.Tables[0].Rows.Count > 0)
{
m_Group_View.RowFilter = " ITEM_CD like '%" + m_Item_CD + "%'";
}
gridControl_Group.DataSource = m_Group_View;
gridBand3.Columns.Clear();
bandedGridView_Code.Columns.Clear();
gridBand3.Columns.Add(GetGridColumn("grid_view_COMP_CD", "COMP_CD", "회사코드", false,true,100));
gridBand3.Columns.Add(GetGridColumn("grid_view_ITEM_CD", "ITEM_CD", "작업코드", false, true,100));
gridBand3.Columns.Add(GetGridColumn("grid_view_PrevITEM_QTY", "PrevITEM_QTY", "수량~", true,true,30));
gridBand3.Columns.Add(GetGridColumn("grid_view_ITEM_QTY", "ITEM_QTY", "~수량", true,false,30));
gridBand3.Columns.Add(GetGridColumn("grid_view_ITEM_STANDARD", "STANDARD", "기준값", true,false,50));
if (m_Code_Type != null && m_Code_Type.Count > 0)
{
for (int i = 0; i < m_Code_Type.Table.Rows.Count; i++)
{
gridBand3.Columns.Add(GetGridColumn("grid_view_"+ m_Code_Type.Table.Rows[i].ItemArray[0].ToString(), m_Code_Type.Table.Rows[i].ItemArray[0].ToString(), m_Code_Type.Table.Rows[i].ItemArray[0].ToString(), true,false,50));
}
}
gridControl_Code.DataSource = m_Code_View;
this.Cursor = Cursors.Arrow;
}
catch (Exception ex)
{
this.Cursor = Cursors.Arrow;
XtraMessageBox.Show(ex.Message);
}
}
private BandedGridColumn GetGridColumn(string name, string fieldName, string caption, bool visible, bool bReadonly, int width)
{
BandedGridColumn column = new BandedGridColumn();
column.Name = name;
column.FieldName = fieldName;
column.Caption = caption;
column.Visible = visible;
column.OptionsColumn.ReadOnly = bReadonly;
column.OptionsColumn.AllowEdit = !bReadonly;
column.Width = width;
column.OptionsColumn.AllowSort = DevExpress.Utils.DefaultBoolean.False;
column.OptionsFilter.AllowAutoFilter = false;
column.OptionsFilter.AllowFilter = false;
return column;
}
public override void newProc()
{
}
public override void deleteProc()
{
}
public override void saveProc()
{
}
}
}