using ClientLib; using ClientLib.CommonService; using DevExpress.XtraEditors; 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.Net; using System.Text; using System.Windows.Forms; using System.Xml; namespace HANMI_SALE { partial class OrderManagerPopup : XtraForm { private string m_Type; private string m_ROUT_CD; private string m_ORDER_NO; private bool m_Change_Date; private CommonMDI m_Parent; ResultData m_CurrentMoney; public OrderManagerPopup(CommonMDI parent) { InitializeComponent(); m_Parent = parent; this.Icon = ConstClass._MAIN.Icon; textEdit_CUST_NM.ImeMode = System.Windows.Forms.ImeMode.Hangul; textEdit_FILE_NM.ImeMode = System.Windows.Forms.ImeMode.Hangul; textEdit_PRINT_POS.ImeMode = System.Windows.Forms.ImeMode.Hangul; textEdit_OUT_POS.ImeMode = System.Windows.Forms.ImeMode.Hangul; textEdit_ITEM_NM.ImeMode = System.Windows.Forms.ImeMode.Hangul; textEdit_ORDER_NORM.ImeMode = System.Windows.Forms.ImeMode.Hangul; m_Type = "I"; m_ROUT_CD = ""; m_ORDER_NO = ""; m_Change_Date = false; simpleButton_DELETE.Enabled = false; simpleButton_UPDATE.Enabled = false; dateEdit_ORDER_DATE.DateTime = DateTime.Now; DataView orderUnitCD = new DataView(ConstClass._DATA); orderUnitCD.RowFilter = "CATE_CD = 'C' and GRP_CD = 'C03'"; UtilClass.SetLookup(lookUpEdit_ORDER_UNIT_CD, orderUnitCD, "NO_CD", "NO_CD_NM", true); getLookup(); textEdit_LN_RMK.KeyPress += (sender, e) => { if (e.KeyChar == '\r') { simpleButton_ADD.Focus(); } }; textEdit_CUST_CD.EditValueChanged += (sender, e) => { GetCurrentmoney(); }; textEdit_ITEM_CD.EditValueChanged += (sender, e) => { GetCurrentmoney(); }; textEdit_FIN_QTY.KeyPress += (sender, e) => { if (e.KeyChar == '\r') { if (m_Type == "M") { textEdit_CURR_MY.Focus(); } else { textEdit_LN_RMK.Focus(); } } }; textEdit_VAT_MY.KeyPress += (sender, e) => { if (e.KeyChar == '\r') { if (gridView_Main.RowCount > 0) { simpleButton_MOD.Focus(); } else { simpleButton_ADD.Focus(); } } }; textEdit_CUST_NM.KeyPress += (sender, e) => { if (e.KeyChar == '\r') { selectCustProc(); } }; dateEdit_ORDER_DATE.EditValueChanged += (sender, e) => { if (m_Type == "M") { m_Change_Date = true; } }; textEdit_PRINT_POS.KeyPress += (sender, e) => { if (e.KeyChar == '\r') { if (UtilClass.isNull(textEdit_PRINT_POS.Text)) { textEdit_PRINT_POS.Text = textEdit_CUST_NM.Text; } } }; textEdit_ITEM_NM.KeyPress += (sender, e) => { if (e.KeyChar == '\r') { selectItemProc(); } }; textEdit_ORDER_NORM.KeyPress += (sender, e) => { if (e.KeyChar == '\r') { selectNormProc(); } }; textEdit_CURR_UNIT_MY.EditValueChanged += (sender, e) => { int order_qty = UtilClass.toInt(textEdit_ORDER_QTY.Text); int curr_unit_my = UtilClass.toInt(textEdit_CURR_UNIT_MY.Text); int curr_my = order_qty * curr_unit_my; textEdit_CURR_MY.Text = curr_my.ToString("n0"); textEdit_VAT_MY.Text = Math.Truncate(curr_my * 0.1).ToString("n0"); textEdit_ORDER_MY.Text = Math.Truncate(curr_my * 1.1).ToString("n0"); }; textEdit_CURR_MY.EditValueChanged += (sender, e) => { int curr_my = UtilClass.toInt(textEdit_CURR_MY.Text); textEdit_VAT_MY.Text = Math.Truncate(curr_my * 0.1).ToString("n0"); textEdit_ORDER_MY.Text = Math.Truncate(curr_my * 1.1).ToString("n0"); }; textEdit_VAT_MY.EditValueChanged += (sender, e) => { int curr_my = UtilClass.toInt(textEdit_CURR_MY.Text); int vat_my = UtilClass.toInt(textEdit_VAT_MY.Text); textEdit_ORDER_MY.Text = (curr_my + vat_my).ToString("n0"); }; textEdit_ORDER_QTY.EditValueChanged += (sender, e) => { SetCurrentmoney(); }; textEdit_FIN_QTY.EditValueChanged += (sender, e) => { int order_qty = UtilClass.toInt(textEdit_ORDER_QTY.Text); int fin_qty = UtilClass.toInt(textEdit_FIN_QTY.Text); if (fin_qty > 0) { textEdit_ORDER_ADD_QTY.Text = (fin_qty - order_qty).ToString("n0"); } else { textEdit_ORDER_ADD_QTY.Text = "0"; } }; simpleButton_Cust_Search.Click += (sender, e) => { selectCustProc(); }; simpleButton_PRINT_POS_Search.Click += (sender, e) => { selectPrintPosProc(); }; simpleButton_OUT_POS_Search.Click += (sender, e) => { selectOutPosProc(); }; simpleButton_ITEM_Search.Click += (sender, e) => { selectItemProc(); }; simpleButton_NORM_Search.Click += (sender, e) => { selectNormProc(); }; simpleButton_PRINT.Click += (sender, e) => { printProc(); }; textEdit_ORDER_QTY.Properties.Mask.UseMaskAsDisplayFormat = true; textEdit_FIN_QTY.Properties.Mask.UseMaskAsDisplayFormat = true; textEdit_CURR_UNIT_MY.Properties.Mask.UseMaskAsDisplayFormat = true; textEdit_CURR_MY.Properties.Mask.UseMaskAsDisplayFormat = true; textEdit_VAT_MY.Properties.Mask.UseMaskAsDisplayFormat = true; textEdit_ORDER_QTY.MouseUp += textEditMouseUp; textEdit_FIN_QTY.MouseUp += textEditMouseUp; textEdit_CURR_UNIT_MY.MouseUp += textEditMouseUp; textEdit_CURR_MY.MouseUp += textEditMouseUp; textEdit_VAT_MY.MouseUp += textEditMouseUp; gridView_Main.FocusedRowChanged += (sender, e) => { DataRow row = gridView_Main.GetFocusedDataRow(); if (row == null) { return; } textEdit_LN_SEQ.Text = UtilClass.toInt(row["LN_SEQ"]).ToString("00"); textEdit_ITEM_CD.Text = UtilClass.toStr(row["ITEM_CD"]); textEdit_ITEM_NM.Text = UtilClass.toStr(row["ITEM_NM"]); textEdit_ORDER_NORM.Text = UtilClass.toStr(row["ORDER_NORM"]); lookUpEdit_MACH_CD.EditValue = UtilClass.toStr(row["MACH_CD"]); lookUpEdit_ORDER_UNIT_CD.EditValue = UtilClass.toStr(row["ORDER_UNIT_CD"]); textEdit_ORDER_QTY.Text = UtilClass.toInt(row["ORDER_QTY"]).ToString("n0"); textEdit_FIN_QTY.Text = UtilClass.toInt(row["FIN_QTY"]).ToString("n0"); textEdit_FIN_QTY.Text = UtilClass.toInt(row["FIN_QTY"]).ToString("n0"); textEdit_ORDER_ADD_QTY.Text = UtilClass.toInt(row["ORDER_ADD_QTY"]).ToString("n0"); textEdit_LN_RMK.Text = UtilClass.toStr(row["LN_RMK"]); textEdit_CURR_UNIT_MY.Text = UtilClass.toInt(row["CURR_UNIT_MY"]).ToString("n0"); textEdit_CURR_MY.Text = UtilClass.toInt(row["CURR_MY"]).ToString("n0"); textEdit_VAT_MY.Text = UtilClass.toInt(row["VAT_MY"]).ToString("n0"); textEdit_ORDER_MY.Text = UtilClass.toInt(row["ORDER_MY"]).ToString("n0"); textEdit_WORK_STA_DATE.Text = UtilClass.toStr(row["WORK_STA_DATE"]); textEdit_WORK_FIN_DATE.Text = UtilClass.toStr(row["WORK_FIN_DATE"]); }; simpleButton_ADD.Click += (sender, e) => { if (UtilClass.isNull(textEdit_ITEM_CD.Text)) { XtraMessageBox.Show("[필수입력]상품코드를 입력하세요."); return; } DataTable aData = gridControl_Main.DataSource as DataTable; DataRow row = aData.NewRow(); row["COMP_CD"] = ConstClass._COMP_CD; row["ORDER_NO"] = textEdit_ORDER_SEQ.Text; row["LN_SEQ"] = (aData.Rows.Count + 1).ToString("00"); row["ROUT_CD"] = m_ROUT_CD; row["ITEM_CD"] = textEdit_ITEM_CD.Text; row["ITEM_NM"] = textEdit_ITEM_NM.Text; row["ORDER_NORM"] = textEdit_ORDER_NORM.Text; row["MACH_CD"] = UtilClass.toStr(lookUpEdit_MACH_CD.EditValue); row["MACH_NM"] = lookUpEdit_MACH_CD.Text; row["ORDER_UNIT_CD"] = UtilClass.toStr(lookUpEdit_ORDER_UNIT_CD.EditValue); row["ORDER_UNIT_NM"] = lookUpEdit_ORDER_UNIT_CD.Text; row["ORDER_QTY"] = UtilClass.toInt(textEdit_ORDER_QTY.Text); row["CURR_UNIT_MY"] = UtilClass.toInt(textEdit_CURR_UNIT_MY.Text); row["CURR_MY"] = UtilClass.toInt(textEdit_CURR_MY.Text); row["VAT_MY"] = UtilClass.toInt(textEdit_VAT_MY.Text); row["ORDER_MY"] = UtilClass.toInt(textEdit_ORDER_MY.Text); row["LN_RMK"] = textEdit_LN_RMK.Text; row["FIN_QTY"] = UtilClass.toInt(textEdit_FIN_QTY.Text); row["FIN_YN"] = "N"; row["SCM_YN"] = "N"; row["SCM_ACCEPT_YN"] = "Y"; aData.Rows.Add(row); }; simpleButton_MOD.Click += (sender, e) => { DataRow row = gridView_Main.GetFocusedDataRow(); if (row == null) { return; } row["ROUT_CD"] = m_ROUT_CD; row["ITEM_CD"] = textEdit_ITEM_CD.Text; row["ITEM_NM"] = textEdit_ITEM_NM.Text; row["ORDER_NORM"] = textEdit_ORDER_NORM.Text; row["MACH_CD"] = UtilClass.toStr(lookUpEdit_MACH_CD.EditValue); row["MACH_NM"] = lookUpEdit_MACH_CD.Text; row["ORDER_UNIT_CD"] = UtilClass.toStr(lookUpEdit_ORDER_UNIT_CD.EditValue); row["ORDER_UNIT_NM"] = lookUpEdit_ORDER_UNIT_CD.Text; row["ORDER_QTY"] = UtilClass.toInt(textEdit_ORDER_QTY.Text); row["CURR_UNIT_MY"] = UtilClass.toInt(textEdit_CURR_UNIT_MY.Text); row["CURR_MY"] = UtilClass.toInt(textEdit_CURR_MY.Text); row["VAT_MY"] = UtilClass.toInt(textEdit_VAT_MY.Text); row["ORDER_MY"] = UtilClass.toInt(textEdit_ORDER_MY.Text); row["LN_RMK"] = textEdit_LN_RMK.Text; row["FIN_QTY"] = UtilClass.toInt(textEdit_FIN_QTY.Text); }; simpleButton_DEL.Click += (sender, e) => { DataRow row = gridView_Main.GetFocusedDataRow(); if (row == null) { return; } if (XtraMessageBox.Show("삭제하시겠습니까?", "삭제", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.Yes) { return; } row.Delete(); }; simpleButton_CLEAR.Click += (sender, e) => { m_ROUT_CD = ""; textEdit_ITEM_CD.Text = ""; textEdit_ITEM_NM.Text = ""; textEdit_ORDER_NORM.Text = ""; lookUpEdit_MACH_CD.EditValue = ""; lookUpEdit_ORDER_UNIT_CD.EditValue = "01"; textEdit_ORDER_QTY.Text = "0"; textEdit_FIN_QTY.Text = "0"; textEdit_ORDER_ADD_QTY.Text = "0"; textEdit_LN_RMK.Text = ""; textEdit_CURR_UNIT_MY.Text = "0"; textEdit_CURR_MY.Text = "0"; textEdit_VAT_MY.Text = "0"; textEdit_ORDER_MY.Text = "0"; textEdit_WORK_STA_DATE.Text = ""; textEdit_WORK_FIN_DATE.Text = ""; }; simpleButton_CLOSE.Click += (sender, e) => { this.Close(); m_Parent.searchProc(); }; simpleButton_CANCEL.Click += (sender, e) => { textEdit_ORDER_SEQ.Text = ""; textEdit_LN_SEQ.Text = ""; textEdit_CUST_NM.Text = ""; textEdit_CUST_CD.Text = ""; textEdit_FILE_NM.Text = ""; textEdit_PRINT_POS.Text = ""; textEdit_OUT_POS.Text = ""; }; simpleButton_INPUT.Click += (sender, e) => { m_Type = "I"; string order_seq = getMaxOrderno(); if (XtraMessageBox.Show("[" + order_seq +"] 작업을 등록하시겠습니까?", "등록", MessageBoxButtons.YesNo, MessageBoxIcon.Information) != DialogResult.Yes) { return; } saveProc(); }; simpleButton_UPDATE.Click += (sender, e) => { m_Type = "M"; string order_seq = ""; if (m_Change_Date) { order_seq = getMaxOrderno(); } else { order_seq = textEdit_ORDER_SEQ.Text; } if (XtraMessageBox.Show("[" + order_seq + "] 번호 자료를 수정하시겠습니까?", "등록", MessageBoxButtons.YesNo, MessageBoxIcon.Information) != DialogResult.Yes) { return; } updateProc(); }; simpleButton_DELETE.Click += (sender, e) => { if (XtraMessageBox.Show("[" + textEdit_ORDER_SEQ.Text + "] 번호 자료를 삭제하시겠습니까?", "삭제", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.Yes) { return; } deleteProc(); }; this.FormClosed += (sender, e) => { bool isFind = false; for (int i = 0; i < Application.OpenForms.Count; i++) { if (Application.OpenForms[i] is OrderManagerPopup) { isFind = true; Application.OpenForms[i].BringToFront(); Application.OpenForms[i].Focus(); (Application.OpenForms[i] as OrderManagerPopup).textEdit_CUST_NM.Focus(); break; } } if (!isFind) { if (m_Parent != null) { m_Parent.Activate(); m_Parent.Focus(); (m_Parent as OrderManager).textEdit_CUST_NM.Focus(); } } }; this.Shown += (sender, e) => { m_Change_Date = false; searchProc(); }; GetCurrentmoney(); } private void textEditMouseUp(object sender, MouseEventArgs e) { TextEdit edit = sender as TextEdit; BeginInvoke(new Action(() => edit.SelectAll())); } private void getLookup() { try { SerializedSqlParam[] aParam = new SerializedSqlParam[] { ClientClass.CreateSqlParameter("COMP_CD", SqlDbType.NVarChar, ConstClass._COMP_CD) }; ResultData resultData = ClientClass.GetData("GetMachineLookup", aParam); if (resultData.isError) { throw new Exception(resultData.ResultValue); } DataRow row = resultData.TableData.NewRow(); row["COMP_CD"] = ConstClass._COMP_CD; row["MACH_CD"] = ""; row["MACH_NM"] = ""; resultData.TableData.Rows.InsertAt(row, 0); UtilClass.SetLookup(lookUpEdit_MACH_CD, resultData.TableData, "MACH_CD", "MACH_NM", true); } catch (Exception ex) { this.Cursor = Cursors.Arrow; XtraMessageBox.Show(ex.Message); } } private string getMaxOrderno() { try { SerializedSqlParam[] aParam = new SerializedSqlParam[] { ClientClass.CreateSqlParameter("COMP_CD", SqlDbType.NVarChar, ConstClass._COMP_CD), ClientClass.CreateSqlParameter("ORDER_DT", SqlDbType.NVarChar, dateEdit_ORDER_DATE.DateTime.ToString("yyyy.MM.dd")), ClientClass.CreateSqlParameter("RESULT_STR", SqlDbType.NVarChar, "", ParameterDirection.Output, 1000) }; ResultData resultData = ClientClass.GetData("GetMaxOrderno", aParam); if (resultData.isError) { throw new Exception(resultData.ResultValue); } string returnvalue = ""; if (resultData.TableData.Rows.Count > 0) { returnvalue = UtilClass.toStr(resultData.TableData.Rows[0]["ORDER_SEQ"]); } else { returnvalue = "0000"; } return returnvalue; } catch (Exception ex) { this.Cursor = Cursors.Arrow; XtraMessageBox.Show(ex.Message); return "0000"; } } private void selectCustProc() { SelectCustomerForm form = new SelectCustomerForm(textEdit_CUST_NM.Text); form.TopMost = true; if (form.ShowDialog() != System.Windows.Forms.DialogResult.Yes) { return; } textEdit_CUST_NM.Text = form.m_CUST_NN; textEdit_CUST_CD.Text = form.m_CUST_CD; textEdit_TEL_NO.Text = form.m_TEL_NO; textEdit_OWNER_TEL_NO.Text = form.m_OWNER_TEL_NO; textEdit_MGR_TEL_NO.Text = form.m_MGR_TEL_NO; GetCurrentmoney(); } private void selectPrintPosProc() { SelectOutPosForm form = new SelectOutPosForm(textEdit_CUST_CD.Text, textEdit_CUST_NM.Text); form.TopMost = true; if (form.ShowDialog() != System.Windows.Forms.DialogResult.Yes) { return; } textEdit_PRINT_POS.Text = form.m_LOCATION_NM; textEdit_OUT_POS.Focus(); } private void selectOutPosProc() { SelectOutPosForm form = new SelectOutPosForm(textEdit_CUST_CD.Text, textEdit_CUST_NM.Text); form.TopMost = true; if (form.ShowDialog() != System.Windows.Forms.DialogResult.Yes) { return; } textEdit_OUT_POS.Text = form.m_LOCATION_NM; textEdit_ITEM_NM.Focus(); } private void selectItemProc() { SelectItemForm form = new SelectItemForm(textEdit_ITEM_NM.Text); form.TopMost = true; if (form.ShowDialog() != System.Windows.Forms.DialogResult.Yes) { return; } m_ROUT_CD = form.m_ROUT_CD; textEdit_ITEM_CD.Text = form.m_ITEM_CD; textEdit_ITEM_NM.Text = form.m_ITEM_NM; textEdit_ORDER_NORM.Focus(); GetCurrentmoney(); } private void selectNormProc() { SelectNormForm form = new SelectNormForm(textEdit_ITEM_CD.Text); form.TopMost = true; if (form.ShowDialog() != System.Windows.Forms.DialogResult.Yes) { return; } textEdit_ORDER_NORM.Text = form.m_NORM; lookUpEdit_MACH_CD.Focus(); } public string initProc(string order_no) { string result = ""; try { SerializedSqlParam[] aParam = new SerializedSqlParam[] { ClientClass.CreateSqlParameter("COMP_CD", SqlDbType.NVarChar, ConstClass._COMP_CD), ClientClass.CreateSqlParameter("ORDER_NO", SqlDbType.NVarChar, order_no) }; ResultData resultData = ClientClass.GetData("GetOrderManagerPopup", aParam); if (resultData.isError) { throw new Exception(resultData.ResultValue); } if (resultData.DataList.Tables[0].Rows.Count > 0) { m_Type = "M"; simpleButton_INPUT.Enabled = true; simpleButton_DELETE.Enabled = true; simpleButton_UPDATE.Enabled = true; DataRow row = resultData.DataList.Tables[0].Rows[0]; m_ORDER_NO = UtilClass.toStr(row["ORDER_NO"]); dateEdit_ORDER_DATE.Text = UtilClass.toStr(row["ORDER_DATE"]); textEdit_ORDER_SEQ.Text = UtilClass.toInt(row["ORDER_SEQ"]).ToString("0000"); textEdit_CUST_NM.Text = UtilClass.toStr(row["CUST_NM"]); textEdit_CUST_CD.Text = UtilClass.toStr(row["CUST_CD"]); textEdit_FILE_NM.Text = UtilClass.toStr(row["FILE_NM"]); textEdit_PRINT_POS.Text = UtilClass.toStr(row["PRINT_POS"]); textEdit_OUT_POS.Text = UtilClass.toStr(row["OUT_POS"]); checkEdit_IN_FIN_YN.Checked = UtilClass.isEqual(row["IN_FIN_YN"], "Y"); checkEdit_OUT_YN.Checked = UtilClass.isEqual(row["OUT_YN"], "Y"); textEdit_IN_USR_NM.Text = UtilClass.toStr(row["IN_USR_NM"]); textEdit_OUT_DRV_NO.Text = UtilClass.toStr(row["OUT_DRV_NO"]); textEdit_OUT_USR_NM.Text = UtilClass.toStr(row["OUT_USR_NM"]); textEdit_TEL_NO.Text = UtilClass.toStr(row["TEL_NO"]); textEdit_OWNER_TEL_NO.Text = UtilClass.toStr(row["OWNER_TEL_NO"]); textEdit_MGR_TEL_NO.Text = UtilClass.toStr(row["MGR_TEL_NO"]); textEdit_INPUT_DATE.Text = UtilClass.toStr(row["INPUT_DATE"]); textEdit_INPUT_TIME.Text = UtilClass.toStr(row["INPUT_TIME"]); textEdit_IN_DATE.Text = UtilClass.toStr(row["IN_DATE"]); textEdit_IN_TIME.Text = UtilClass.toStr(row["IN_TIME"]); textEdit_OUT_DATE.Text = UtilClass.toStr(row["OUT_DATE"]); textEdit_OUT_TIME.Text = UtilClass.toStr(row["OUT_TIME"]); } gridControl_Main.DataSource = resultData.DataList.Tables[1]; } catch (Exception ex) { result = ex.Message; } return result; } private void searchProc() { try { } catch (Exception ex) { this.Cursor = Cursors.Arrow; XtraMessageBox.Show(ex.Message); } } private void saveProc() { try { this.Cursor = Cursors.WaitCursor; gridView_Main.PostEditor(); gridView_Main.UpdateCurrentRow(); Application.DoEvents(); if (UtilClass.isNull(dateEdit_ORDER_DATE.EditValue)) { dateEdit_ORDER_DATE.Focus(); throw new Exception("주문일을 선택하십시오."); } if (UtilClass.isNull(textEdit_CUST_CD.EditValue)) { textEdit_FILE_NM.Focus(); throw new Exception("거래선이 등록되어있지 않습니다."); } if (UtilClass.isNull(textEdit_FILE_NM.EditValue)) { textEdit_FILE_NM.Focus(); throw new Exception("파일이름을 입력하십시오."); } DataTable aData = gridControl_Main.DataSource as DataTable; foreach(DataRow inrow in aData.Rows) { if (inrow.RowState == DataRowState.Deleted) { continue; } inrow["REG_ID"] = "MOD"; } DataTable dtData = UtilClass.GetDataTable(aData, true, "LN_SEQ", "ROUT_CD", "ITEM_CD", "ORDER_NORM", "MACH_CD", "ORDER_UNIT_CD", "ORDER_QTY", "FIN_QTY", "CURR_UNIT_MY", "CURR_MY", "VAT_MY", "ORDER_MY", "LN_RMK" ); if (dtData.Rows.Count < 1 && m_Type == "I") { throw new Exception("작업내역이 없습니다. 작업명을 추가하세요."); } dtData.TableName = "ADATA"; ResultData data1 = new ResultData(); data1.TableData = dtData; ResultData[] dataList = new ResultData[] { data1 }; SerializedSqlParam[] aParam = new SerializedSqlParam[] { ClientClass.CreateSqlParameter("COMP_CD", SqlDbType.NVarChar, ConstClass._COMP_CD), ClientClass.CreateSqlParameter("CUST_CD", SqlDbType.NVarChar, textEdit_CUST_CD.Text), ClientClass.CreateSqlParameter("ORDER_DATE", SqlDbType.NVarChar, dateEdit_ORDER_DATE.DateTime.ToString("yyyy-MM-dd")), ClientClass.CreateSqlParameter("FILE_NM", SqlDbType.NVarChar, textEdit_FILE_NM.Text), ClientClass.CreateSqlParameter("PRINT_POS", SqlDbType.NVarChar, textEdit_PRINT_POS.Text), ClientClass.CreateSqlParameter("OUT_POS", SqlDbType.NVarChar, textEdit_OUT_POS.Text), ClientClass.CreateSqlParameter("REG_ID", SqlDbType.NVarChar, ConstClass._USR_ID) }; ResultData resultData = ClientClass.SetTableData("SaveOrderManagerPopup2", dataList, aParam); if (resultData.isError) { throw new Exception(resultData.ResultValue); } this.Cursor = Cursors.Arrow; this.Close(); m_Parent.searchProc(); } catch (Exception ex) { this.Cursor = Cursors.Arrow; XtraMessageBox.Show(ex.Message); } } private void updateProc() { try { this.Cursor = Cursors.WaitCursor; gridView_Main.PostEditor(); gridView_Main.UpdateCurrentRow(); Application.DoEvents(); if (UtilClass.isNull(dateEdit_ORDER_DATE.EditValue)) { dateEdit_ORDER_DATE.Focus(); throw new Exception("주문일을 선택하십시오."); } if (UtilClass.isNull(textEdit_CUST_CD.EditValue)) { textEdit_FILE_NM.Focus(); throw new Exception("거래선이 등록되어있지 않습니다."); } if (UtilClass.isNull(textEdit_FILE_NM.EditValue)) { textEdit_FILE_NM.Focus(); throw new Exception("파일이름을 입력하십시오."); } DataTable aData = gridControl_Main.DataSource as DataTable; DataTable dtData = UtilClass.GetDataTable(aData, true, "LN_SEQ", "ROUT_CD", "ITEM_CD", "ORDER_NORM", "MACH_CD", "ORDER_UNIT_CD", "ORDER_QTY", "FIN_QTY", "CURR_UNIT_MY", "CURR_MY", "VAT_MY", "ORDER_MY", "LN_RMK" ); dtData.TableName = "ADATA"; ResultData data1 = new ResultData(); data1.TableData = dtData; ResultData[] dataList = new ResultData[] { data1 }; SerializedSqlParam[] aParam = new SerializedSqlParam[] { ClientClass.CreateSqlParameter("COMP_CD", SqlDbType.NVarChar, ConstClass._COMP_CD), ClientClass.CreateSqlParameter("ORDER_NO", SqlDbType.NVarChar, m_ORDER_NO), ClientClass.CreateSqlParameter("CUST_CD", SqlDbType.NVarChar, textEdit_CUST_CD.Text), ClientClass.CreateSqlParameter("ORDER_DT", SqlDbType.NVarChar, dateEdit_ORDER_DATE.DateTime.ToString("yyyy.MM.dd")), ClientClass.CreateSqlParameter("FILE_NM", SqlDbType.NVarChar, textEdit_FILE_NM.Text), ClientClass.CreateSqlParameter("PRINT_POS", SqlDbType.NVarChar, textEdit_PRINT_POS.Text), ClientClass.CreateSqlParameter("OUT_POS", SqlDbType.NVarChar, textEdit_OUT_POS.Text), ClientClass.CreateSqlParameter("REG_ID", SqlDbType.NVarChar, ConstClass._USR_ID) }; ResultData resultData = ClientClass.SetTableData("UpdateOrderManagerPopup", dataList, aParam); if (resultData.isError) { throw new Exception(resultData.ResultValue); } this.Cursor = Cursors.Arrow; this.Close(); m_Parent.searchProc(); } catch (Exception ex) { this.Cursor = Cursors.Arrow; XtraMessageBox.Show(ex.Message); } } private void deleteProc() { try { this.Cursor = Cursors.WaitCursor; gridView_Main.PostEditor(); gridView_Main.UpdateCurrentRow(); Application.DoEvents(); SerializedSqlParam[] aParam = new SerializedSqlParam[] { ClientClass.CreateSqlParameter("COMP_CD", SqlDbType.NVarChar, ConstClass._COMP_CD), ClientClass.CreateSqlParameter("ORDER_NO", SqlDbType.NVarChar, m_ORDER_NO), ClientClass.CreateSqlParameter("RESULT_STR", SqlDbType.NVarChar, "", ParameterDirection.Output, 1000) }; ResultData resultData = ClientClass.SetData("DeleteOrderManager", aParam); if (resultData.isError) { throw new Exception(resultData.ResultValue); } if (!UtilClass.isNull(resultData.ResultValue)) { throw new Exception(resultData.ResultValue); } this.Cursor = Cursors.Arrow; this.Close(); m_Parent.searchProc(); } catch (Exception ex) { this.Cursor = Cursors.Arrow; XtraMessageBox.Show(ex.Message); } } private void GetCurrentmoney() { if (textEdit_CUST_CD.Text != "" && textEdit_ITEM_CD.Text != "") { try { this.Cursor = Cursors.WaitCursor; ResultData[] dataList = null; SerializedSqlParam[] aParam = new SerializedSqlParam[] { ClientClass.CreateSqlParameter("COMP_CD", SqlDbType.NVarChar, ConstClass._COMP_CD), ClientClass.CreateSqlParameter("CUST_CD", SqlDbType.NVarChar, textEdit_CUST_CD.Text), ClientClass.CreateSqlParameter("ITEM_CD", SqlDbType.NVarChar, textEdit_ITEM_CD.Text), ClientClass.CreateSqlParameter("ITEM_QTY", SqlDbType.Int, UtilClass.toInt(textEdit_ORDER_QTY.Text)) }; m_CurrentMoney = ClientClass.GetDataByTable("U3GetSaleCurrentMoneyPopup", dataList, aParam); if (m_CurrentMoney.isError) { throw new Exception(m_CurrentMoney.ResultValue); } DataTable aData; aData = m_CurrentMoney.DataList.Tables[0]; labelWarning.Text = ""; SetCurrentmoney(); this.Cursor = Cursors.Arrow; } catch (Exception ex) { this.Cursor = Cursors.Arrow; MessageBox.Show(ex.Message); } } } private void SetCurrentmoney() { if (textEdit_CUST_CD.Text != "" && textEdit_ITEM_CD.Text != "") { try { if (m_CurrentMoney != null ) { if(m_CurrentMoney.DataList.Tables[0].Rows.Count <= 0) { labelWarning.Text = "단가등록이 되어있지 않습니다."; return; } if (UtilClass.toStr(m_CurrentMoney.DataList.Tables[2].Rows[0]["ITEM_TYPE"]) != "고정가") { textEdit_CURR_UNIT_MY.Tag = "단가"; } else { textEdit_CURR_UNIT_MY.Tag = "고정가"; } int rowCheck = 0; for(int i = 0; i < m_CurrentMoney.DataList.Tables[0].Rows.Count; i++) { if((UtilClass.toInt(textEdit_ORDER_QTY.Text) <= UtilClass.toInt(m_CurrentMoney.DataList.Tables[0].Rows[i]["PostITEM_QTY"])) && (UtilClass.toInt(textEdit_ORDER_QTY.Text) > UtilClass.toInt(m_CurrentMoney.DataList.Tables[0].Rows[i]["PrevITEM_QTY"]))) { rowCheck = i; labelWarning.Text = ""; break; } if(i>= (m_CurrentMoney.DataList.Tables[0].Rows.Count-1) && UtilClass.toInt(textEdit_ORDER_QTY.Text)!=0) { labelWarning.Text = "등록된 범위를 초과했습니다."; textEdit_CURR_UNIT_MY.EditValue = 0; textEdit_CURR_MY.EditValue = 0; textEdit_VAT_MY.EditValue = 0; textEdit_ORDER_MY.EditValue = 0; return; } } if (UtilClass.toStr(m_CurrentMoney.DataList.Tables[1].Rows[0]["SPECIAL"]) != "None") { if (textEdit_CURR_UNIT_MY.Tag == "고정가") { textEdit_CURR_MY.Text = UtilClass.toStr(m_CurrentMoney.DataList.Tables[0].Rows[rowCheck]["SPECIAL"]); refreshCostBind(); } else { textEdit_CURR_UNIT_MY.Text = UtilClass.toStr(m_CurrentMoney.DataList.Tables[0].Rows[rowCheck]["SPECIAL"]); refreshCost(); } } else { if (textEdit_CURR_UNIT_MY.Tag == "고정가") { textEdit_CURR_MY.Text = UtilClass.toStr(m_CurrentMoney.DataList.Tables[0].Rows[rowCheck]["STANDARD"]); refreshCostBind(); } else { textEdit_CURR_UNIT_MY.Text = UtilClass.toStr(m_CurrentMoney.DataList.Tables[0].Rows[rowCheck]["STANDARD"]); refreshCost(); } } } } catch (Exception ex) { this.Cursor = Cursors.Arrow; MessageBox.Show(ex.Message); } } } private void refreshCost() { int qty = UtilClass.toInt(textEdit_ORDER_QTY.EditValue); int unit_my = UtilClass.toInt(textEdit_CURR_UNIT_MY.EditValue); textEdit_CURR_UNIT_MY.EditValue = unit_my; textEdit_CURR_MY.EditValue = qty * unit_my; textEdit_VAT_MY.EditValue = (qty * unit_my) * 0.1; textEdit_ORDER_MY.EditValue = (qty * unit_my) + (qty * unit_my) * 0.1; } private void refreshCostBind() { int qty = UtilClass.toInt(textEdit_ORDER_QTY.EditValue); int my = UtilClass.toInt(textEdit_CURR_MY.EditValue); textEdit_CURR_MY.EditValue = my; textEdit_VAT_MY.EditValue = my * 0.1; textEdit_ORDER_MY.EditValue = my + my * 0.1; } private void printProc() { DataTable data = gridControl_Main.DataSource as DataTable; this.TopMost = false; try { WorkOrderReport report = new WorkOrderReport(); report.SetData(data, m_ORDER_NO, dateEdit_ORDER_DATE.Text, textEdit_ORDER_SEQ.Text, textEdit_CUST_NM.Text, textEdit_FILE_NM.Text, textEdit_PRINT_POS.Text, textEdit_OUT_POS.Text ); } finally { this.TopMost = true; } } protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { if (keyData == (Keys.P | Keys.Alt)) { printProc(); return true; } else if (keyData == (Keys.A | Keys.Alt)) { simpleButton_CANCEL.PerformClick(); return true; } else if (keyData == (Keys.I | Keys.Alt)) { simpleButton_INPUT.PerformClick(); return true; } else if (keyData == (Keys.M | Keys.Alt)) { simpleButton_UPDATE.PerformClick(); return true; } else if (keyData == (Keys.D | Keys.Alt)) { simpleButton_DELETE.PerformClick(); return true; } else if (keyData == (Keys.X | Keys.Alt)) { simpleButton_CLOSE.PerformClick(); return true; } else if (keyData == (Keys.F5)) { simpleButton_ADD.PerformClick(); return true; } else if (keyData == (Keys.F6)) { simpleButton_MOD.PerformClick(); return true; } else if (keyData == (Keys.F7)) { simpleButton_DEL.PerformClick(); return true; } else if (keyData == (Keys.F8)) { return true; } return base.ProcessCmdKey(ref msg, keyData); } } }