using ClientLib; using ClientLib.CommonService; using DevExpress.XtraEditors; using DevExpress.XtraGrid.Views.Grid.ViewInfo; using DevExpress.XtraReports.UI; 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 HM_WORK { partial class WorkManagerPopup : XtraForm { private string m_ORDER_NO; private int m_LN_SEQ; public WorkManagerPopup() { InitializeComponent(); m_ORDER_NO = ""; m_LN_SEQ = 0; DataView out_gbn = new DataView(ConstClass._DATA); out_gbn.RowFilter = "CATE_CD = 'D' and GRP_CD = 'D01'"; UtilClass.SetLookup(lookUpEdit_OUT_GBN, out_gbn, "NO_CD", "NO_CD_NM", true); DataView out_car_no = new DataView(ConstClass._DATA); out_car_no.RowFilter = "CATE_CD = 'D' and GRP_CD = 'D02'"; UtilClass.SetLookup(lookUpEdit_OUT_CAR_NO, out_car_no, "NO_CD", "NO_CD_NM", true); DataView in_user = new DataView(ConstClass._DATA); in_user.RowFilter = "CATE_CD = 'L' and GRP_CD = 'L01'"; UtilClass.SetLookup(lookUpEdit_IN_USR_ID, in_user, "NO_CD", "NO_CD_NM", true); DataView work_user = new DataView(ConstClass._DATA); work_user.RowFilter = "CATE_CD = 'L' and GRP_CD = 'L02'"; UtilClass.SetLookup(lookUpEdit_WORK_USR_ID, work_user, "NO_CD", "NO_CD_NM", true); DataView out_user = new DataView(ConstClass._DATA); out_user.RowFilter = "CATE_CD = 'D' and GRP_CD = 'D04'"; UtilClass.SetLookup(lookUpEdit_OUT_USR_ID, in_user, "NO_CD", "NO_CD_NM", true); simpleButton_BACK.Click += (sender, e) => { if (this.ActiveControl is TextBoxMaskBox) { SendKeys.Send("{BACKSPACE}"); } }; simpleButton_POINT.Click += (sender, e) => { if (this.ActiveControl is TextBoxMaskBox) { SendKeys.Send("."); } }; simpleButton_DASH.Click += (sender, e) => { if (this.ActiveControl is TextBoxMaskBox) { SendKeys.Send("-"); } }; lookUpEdit_OUT_GBN.EditValueChanged += (sender, e) => { if (UtilClass.isEqual(lookUpEdit_OUT_GBN.EditValue, "01")) { lookUpEdit_OUT_CAR_NO.Enabled = true; lookUpEdit_OUT_USR_ID.Enabled = true; textEdit_OUT_DRV_NO.Enabled = false; textEdit_OUT_TEL_NO.Enabled = false; textEdit_OUT_GISA.Enabled = false; } else { lookUpEdit_OUT_CAR_NO.Enabled = false; lookUpEdit_OUT_USR_ID.Enabled = false; textEdit_OUT_DRV_NO.Enabled = true; textEdit_OUT_TEL_NO.Enabled = true; textEdit_OUT_GISA.Enabled = true; } }; simpleButton_INPUT_OK.Click += (sender, e) => { if (checkEdit_IN_ING_YN.Checked && !checkEdit_IN_FIN_YN.Checked) { if (MessageBox.Show("입고진행 처리를 하시겠습니까?", "확인", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { saveInputIngProc("M"); this.DialogResult = DialogResult.Yes; this.Close(); } } else if (!checkEdit_IN_ING_YN.Checked && checkEdit_IN_FIN_YN.Checked) { MessageBox.Show("입고 진행후 작업하시기 바랍니다."); return; } else if (checkEdit_IN_ING_YN.Checked && checkEdit_IN_FIN_YN.Checked) { if (MessageBox.Show("입고확인 처리를 하시겠습니까?", "확인", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { saveInputProc("M"); this.DialogResult = DialogResult.Yes; this.Close(); } } else { this.DialogResult = DialogResult.Yes; this.Close(); } }; simpleButton_INPUT_CANCEL.Click += (sender, e) => { if (checkEdit_IN_ING_YN.Checked && !checkEdit_IN_FIN_YN.Checked) { if (MessageBox.Show("입고진행 처리를 취소하시겠습니까?", "취소", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { saveInputIngProc("C"); this.DialogResult = DialogResult.Yes; this.Close(); } } else if (checkEdit_IN_ING_YN.Checked && checkEdit_IN_FIN_YN.Checked) { if (MessageBox.Show("입고확인 처리를 하시겠습니까?", "취소", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { saveInputProc("C"); this.DialogResult = DialogResult.Yes; this.Close(); } } }; simpleButton_OUT_OK.Click += (sender, e) => { if (MessageBox.Show("출고확인 처리를 하시겠습니까?", "확인", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { checkEdit_OUT_YN.Checked = true; saveOutputProc("M"); this.DialogResult = DialogResult.Yes; this.Close(); } }; simpleButton_OUT_CANCEL.Click += (sender, e) => { if (MessageBox.Show("출고취소 처리를 하시겠습니까?", "확인", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { checkEdit_OUT_YN.Checked = false; saveOutputProc("C"); this.DialogResult = DialogResult.Yes; this.Close(); } }; simpleButton_WORK_OK.Click += (sender, e) => { if (MessageBox.Show("작업진행 처리를 하시겠습니까?", "확인", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { saveWorkExecuteProc("M"); this.DialogResult = DialogResult.Yes; this.Close(); } }; simpleButton_WORK_CANCEL.Click += (sender, e) => { if (MessageBox.Show("작업진행 취소 처리를 하시겠습니까?", "취소", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { saveWorkExecuteProc("C"); this.DialogResult = DialogResult.Yes; this.Close(); } }; simpleButton_WORK_STA_INPUT.Click += (sender, e) => { if (UtilClass.isNull(textEdit_WORK_STA_DATE.Text)) { textEdit_WORK_STA_DATE.Text = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"); } else { textEdit_WORK_STA_DATE.Text = ""; } }; simpleButton_WORK_FIN_INPUT.Click += (sender, e) => { if (UtilClass.isNull(textEdit_WORK_FIN_DATE.Text)) { textEdit_WORK_FIN_DATE.Text = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"); } else { textEdit_WORK_FIN_DATE.Text = ""; } }; simpleButton_0.Click += number_Click; simpleButton_1.Click += number_Click; simpleButton_2.Click += number_Click; simpleButton_3.Click += number_Click; simpleButton_4.Click += number_Click; simpleButton_5.Click += number_Click; simpleButton_6.Click += number_Click; simpleButton_7.Click += number_Click; simpleButton_8.Click += number_Click; simpleButton_9.Click += number_Click; simpleButton_PRINT.Click += (sender, e) => { printProc(); }; gridView_Main.FocusedRowChanged += (sender, e) => { DataRow row = gridView_Main.GetFocusedDataRow(); if (row == null) { return; } m_LN_SEQ = UtilClass.toInt(row["LN_SEQ"]); 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"]); textEdit_MACH_NM.EditValue = UtilClass.toStr(row["MACH_NM"]); textEdit_ORDER_UNIT_NM.EditValue = UtilClass.toStr(row["ORDER_UNIT_NM"]); textEdit_ORDER_QTY.Text = UtilClass.toInt(row["ORDER_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_WORK_STA_DATE.Text = UtilClass.toStr(row["WORK_STA_DATE"]); textEdit_WORK_FIN_DATE.Text = UtilClass.toStr(row["WORK_FIN_DATE"]); textEdit_WORK_QTY.Text = UtilClass.toInt(row["FIN_QTY"]).ToString("n0"); if (UtilClass.isNull(row["WORK_USR_ID"])) { lookUpEdit_WORK_USR_ID.EditValue = "01"; } else { lookUpEdit_WORK_USR_ID.EditValue = UtilClass.toStr(row["WORK_USR_ID"]); } }; simpleButton_CLOSE.Click += (sender, e) => { this.DialogResult = DialogResult.Yes; this.Close(); }; this.Shown += (sender, e) => { if (!checkEdit_IN_ING_YN.Checked) { simpleButton_INPUT_CANCEL.Enabled = false; panelControl_WORK.Enabled = false; panelControl_WORK_BUTTON.Enabled = false; panelControl_OUT.Enabled = false; } else if (checkEdit_IN_ING_YN.Checked && !checkEdit_IN_FIN_YN.Checked) { simpleButton_INPUT_CANCEL.Enabled = true; panelControl_WORK.Enabled = false; panelControl_WORK_BUTTON.Enabled = false; panelControl_OUT.Enabled = false; } if (checkEdit_IN_ING_YN.Checked && checkEdit_IN_FIN_YN.Checked) { simpleButton_INPUT_OK.Enabled = false; simpleButton_INPUT_CANCEL.Enabled = true; panelControl_WORK.Enabled = true; panelControl_WORK_BUTTON.Enabled = true; panelControl_OUT.Enabled = true; } }; } private void saveInputIngProc(string mode) { try { this.Cursor = Cursors.WaitCursor; SerializedSqlParam[] aParam = new SerializedSqlParam[] { ClientClass.CreateSqlParameter("MODE", SqlDbType.NVarChar, mode), ClientClass.CreateSqlParameter("COMP_CD", SqlDbType.NVarChar, ConstClass._COMP_CD), ClientClass.CreateSqlParameter("ORDER_NO", SqlDbType.NVarChar, m_ORDER_NO), ClientClass.CreateSqlParameter("IN_ING_YN", SqlDbType.NVarChar, checkEdit_IN_ING_YN.Checked ? 'Y':'N'), ClientClass.CreateSqlParameter("IN_USR_ID", SqlDbType.NVarChar, lookUpEdit_IN_USR_ID.EditValue), ClientClass.CreateSqlParameter("REG_ID", SqlDbType.NVarChar, ConstClass._USR_ID) }; ResultData resultData = ClientClass.SetData("SaveWorkInputIng", aParam); if (resultData.isError) { throw new Exception(resultData.ResultValue); } this.Cursor = Cursors.Arrow; } catch (Exception ex) { this.Cursor = Cursors.Arrow; MessageBox.Show(ex.Message); } } private void saveInputProc(string mode) { try { this.Cursor = Cursors.WaitCursor; SerializedSqlParam[] aParam = new SerializedSqlParam[] { ClientClass.CreateSqlParameter("MODE", SqlDbType.NVarChar, mode), ClientClass.CreateSqlParameter("COMP_CD", SqlDbType.NVarChar, ConstClass._COMP_CD), ClientClass.CreateSqlParameter("ORDER_NO", SqlDbType.NVarChar, m_ORDER_NO), ClientClass.CreateSqlParameter("IN_ING_YN", SqlDbType.NVarChar, checkEdit_IN_ING_YN.Checked ? 'Y':'N'), ClientClass.CreateSqlParameter("IN_FIN_YN", SqlDbType.NVarChar, checkEdit_IN_FIN_YN.Checked ? 'Y':'N'), ClientClass.CreateSqlParameter("IN_USR_ID", SqlDbType.NVarChar, lookUpEdit_IN_USR_ID.EditValue), ClientClass.CreateSqlParameter("REG_ID", SqlDbType.NVarChar, ConstClass._USR_ID) }; ResultData resultData = ClientClass.SetData("SaveWorkInput", aParam); if (resultData.isError) { throw new Exception(resultData.ResultValue); } this.Cursor = Cursors.Arrow; } catch (Exception ex) { this.Cursor = Cursors.Arrow; MessageBox.Show(ex.Message); } } private void saveOutputProc(string mode) { try { this.Cursor = Cursors.WaitCursor; SerializedSqlParam[] aParam = new SerializedSqlParam[] { ClientClass.CreateSqlParameter("MODE", SqlDbType.NVarChar, mode), ClientClass.CreateSqlParameter("COMP_CD", SqlDbType.NVarChar, ConstClass._COMP_CD), ClientClass.CreateSqlParameter("ORDER_NO", SqlDbType.NVarChar, m_ORDER_NO), ClientClass.CreateSqlParameter("OUT_YN", SqlDbType.NVarChar, checkEdit_OUT_YN.Checked ? 'Y':'N'), ClientClass.CreateSqlParameter("OUT_GBN", SqlDbType.NVarChar, lookUpEdit_OUT_GBN.EditValue), ClientClass.CreateSqlParameter("OUT_CAR_NO", SqlDbType.NVarChar, lookUpEdit_OUT_CAR_NO.EditValue), ClientClass.CreateSqlParameter("OUT_USR_ID", SqlDbType.NVarChar, lookUpEdit_OUT_USR_ID.EditValue), ClientClass.CreateSqlParameter("OUT_DRV_NO", SqlDbType.NVarChar, textEdit_OUT_DRV_NO.Text), ClientClass.CreateSqlParameter("OUT_TEL_NO", SqlDbType.NVarChar, textEdit_OUT_TEL_NO.Text), ClientClass.CreateSqlParameter("OUT_GISA", SqlDbType.NVarChar, textEdit_OUT_GISA.Text), ClientClass.CreateSqlParameter("REG_ID", SqlDbType.NVarChar, ConstClass._USR_ID) }; ResultData resultData = ClientClass.SetData("SaveWorkOutput", aParam); if (resultData.isError) { throw new Exception(resultData.ResultValue); } this.Cursor = Cursors.Arrow; } catch (Exception ex) { this.Cursor = Cursors.Arrow; MessageBox.Show(ex.Message); } } private void saveWorkExecuteProc(string mode) { try { this.Cursor = Cursors.WaitCursor; SerializedSqlParam[] aParam = new SerializedSqlParam[] { ClientClass.CreateSqlParameter("MODE", SqlDbType.NVarChar, mode), ClientClass.CreateSqlParameter("COMP_CD", SqlDbType.NVarChar, ConstClass._COMP_CD), ClientClass.CreateSqlParameter("ORDER_NO", SqlDbType.NVarChar, m_ORDER_NO), ClientClass.CreateSqlParameter("LN_SEQ", SqlDbType.NVarChar, m_LN_SEQ), ClientClass.CreateSqlParameter("FIN_YN", SqlDbType.NVarChar, UtilClass.isNull(textEdit_WORK_FIN_DATE.Text) ? 'N':'Y'), ClientClass.CreateSqlParameter("FIN_QTY", SqlDbType.Int, UtilClass.toInt(textEdit_WORK_QTY.Text)), ClientClass.CreateSqlParameter("WORK_USR_ID", SqlDbType.NVarChar, lookUpEdit_WORK_USR_ID.EditValue), ClientClass.CreateSqlParameter("WORK_STA_DATE", SqlDbType.NVarChar, textEdit_WORK_STA_DATE.Text), ClientClass.CreateSqlParameter("WORK_FIN_DATE", SqlDbType.NVarChar, textEdit_WORK_FIN_DATE.Text), ClientClass.CreateSqlParameter("REG_ID", SqlDbType.NVarChar, ConstClass._USR_ID) }; ResultData resultData = ClientClass.SetData("SaveWorkExecute", aParam); if (resultData.isError) { throw new Exception(resultData.ResultValue); } this.Cursor = Cursors.Arrow; } catch (Exception ex) { this.Cursor = Cursors.Arrow; MessageBox.Show(ex.Message); } } 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) { DataRow row = resultData.DataList.Tables[0].Rows[0]; m_ORDER_NO = UtilClass.toStr(row["ORDER_NO"]); textEdit_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"]); textEdit_INPUT_DATE.Text = UtilClass.toStr(row["INPUT_DATE"]); 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_TIME.Text = UtilClass.toStr(row["INPUT_TIME"]); checkEdit_IN_ING_YN.Checked = UtilClass.isEqual(row["IN_ING_YN"], "Y"); checkEdit_IN_FIN_YN.Checked = UtilClass.isEqual(row["IN_FIN_YN"], "Y"); if (UtilClass.isNull(row["IN_USR_ID"])) { lookUpEdit_IN_USR_ID.EditValue = "01"; } else { lookUpEdit_IN_USR_ID.EditValue = UtilClass.toStr(row["IN_USR_ID"]); } textEdit_IN_DATE.Text = UtilClass.toStr(row["IN_DATE"]); textEdit_IN_TIME.Text = UtilClass.toStr(row["IN_TIME"]); checkEdit_OUT_YN.Checked = UtilClass.isEqual(row["OUT_YN"], "Y"); if (!UtilClass.isNull(row["OUT_GBN"])) { lookUpEdit_OUT_GBN.EditValue = UtilClass.toStr(row["OUT_GBN"]); } else { lookUpEdit_OUT_GBN.EditValue = "01"; } if (!UtilClass.isNull(row["OUT_CAR_NO"])) { lookUpEdit_OUT_CAR_NO.EditValue = UtilClass.toStr(row["OUT_CAR_NO"]); } else { lookUpEdit_OUT_CAR_NO.EditValue = "01"; } if (UtilClass.isNull(row["OUT_USR_ID"])) { lookUpEdit_OUT_USR_ID.EditValue = "01"; } else { lookUpEdit_OUT_USR_ID.EditValue = UtilClass.toStr(row["OUT_USR_ID"]); } textEdit_OUT_DRV_NO.Text = UtilClass.toStr(row["OUT_DRV_NO"]); textEdit_OUT_TEL_NO.Text = UtilClass.toStr(row["OUT_TEL_NO"]); textEdit_OUT_GISA.Text = UtilClass.toStr(row["OUT_GISA"]); 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 number_Click(object sender, EventArgs e) { if (this.ActiveControl is TextBoxMaskBox) { SendKeys.Send((sender as SimpleButton).Text); } } private DateTime dtPrint = DateTime.MinValue; private void printProc() { if ((DateTime.Now - dtPrint).TotalSeconds <= 5) return; DataTable data = gridControl_Main.DataSource as DataTable; WorkOrderReport report = new WorkOrderReport(); report.SetData(data, m_ORDER_NO, textEdit_ORDER_DATE.Text, textEdit_ORDER_SEQ.Text, textEdit_CUST_NM.Text, textEdit_FILE_NM.Text, textEdit_PRINT_POS.Text, textEdit_OUT_POS.Text ); report.Print(); dtPrint = DateTime.Now; } protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { if (keyData == (Keys.P | Keys.Alt)) { printProc(); return true; } else if (keyData == (Keys.X | Keys.Alt)) { simpleButton_CLOSE.PerformClick(); return true; } return base.ProcessCmdKey(ref msg, keyData); } } }