using ClientLib; using ClientLib.CommonService; using DevExpress.XtraEditors; 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.Reflection; using System.Text; using System.Threading; using System.Windows.Forms; namespace HM_WORK { partial class OutBarCodeForm : XtraForm { private DataTable m_ORDER; private string m_OUT_USR_ID; public OutBarCodeForm() { InitializeComponent(); m_OUT_USR_ID = ""; textEdit_BARCODE.Text = ""; m_ORDER = new DataTable(); m_ORDER.Columns.Add("ORDER_NO", typeof(string)); m_ORDER.Columns.Add("CUST_NM", typeof(string)); m_ORDER.Columns.Add("FILE_NM", typeof(string)); m_ORDER.Columns.Add("PRINT_POS", typeof(string)); m_ORDER.Columns.Add("OUT_POS", typeof(string)); gridControl_Main.DataSource = m_ORDER; this.Shown += (sender, e) => { textEdit_BARCODE.Focus(); }; textEdit_BARCODE.KeyPress += (sender, e) => { if (e.KeyChar == '\r') { searchProc(); } }; simpleButton_OK.Click += (sender, e) => { saveProc(); }; simpleButton_Cancel.Click += (sender, e) => { this.DialogResult = DialogResult.Cancel; this.Close(); }; checkButton2.Click += checkButton1_CheckedChanged; checkButton3.Click += checkButton1_CheckedChanged; checkButton4.Click += checkButton1_CheckedChanged; checkButton5.Click += checkButton1_CheckedChanged; checkButton6.Click += checkButton1_CheckedChanged; checkButton7.Click += checkButton1_CheckedChanged; checkButton8.Click += checkButton1_CheckedChanged; checkButton9.Click += checkButton1_CheckedChanged; checkButton10.Click += checkButton1_CheckedChanged; } public void searchProc() { try { this.Cursor = Cursors.WaitCursor; SerializedSqlParam[] aParam = new SerializedSqlParam[] { ClientClass.CreateSqlParameter("COMP_CD", SqlDbType.NVarChar, ConstClass._COMP_CD), ClientClass.CreateSqlParameter("ORDER_NO", SqlDbType.NVarChar, textEdit_BARCODE.Text) }; ResultData resultData = ClientClass.GetData("GetOutOrderInfo", aParam); if (resultData.isError) { throw new Exception(resultData.ResultValue); } DataTable aData = resultData.DataList.Tables[0]; DataTable bData = resultData.DataList.Tables[1]; if (aData.Rows.Count > 0) { DataRow row = m_ORDER.NewRow(); row["ORDER_NO"] = aData.Rows[0]["ORDER_NO"]; row["CUST_NM"] = aData.Rows[0]["CUST_NM"]; row["FILE_NM"] = aData.Rows[0]["FILE_NM"]; row["PRINT_POS"] = aData.Rows[0]["PRINT_POS"]; row["OUT_POS"] = aData.Rows[0]["OUT_POS"]; m_ORDER.Rows.Add(row); } else { throw new Exception("관리번호가 존재하지 않습니다."); } textEdit_BARCODE.Text = ""; textEdit_BARCODE.Focus(); var parent = this.FindForm(); for (int i = 0; i <= 9; i++) { var button = parent.Controls.Find("checkButton" + UtilClass.toStr(i+1), true).FirstOrDefault(); if (button != null) { if (i < bData.Rows.Count) { (button as CheckButton).Tag = UtilClass.toStr(bData.Rows[i]["NO_CD"]); (button as CheckButton).Text = UtilClass.toStr(bData.Rows[i]["NO_CD_NM"]); } else { (button as CheckButton).Enabled = false; } } } this.Cursor = Cursors.Arrow; } catch (Exception ex) { this.Cursor = Cursors.Arrow; XtraMessageBox.Show(ex.Message); } } private void saveProc() { try { this.Cursor = Cursors.WaitCursor; if (m_ORDER.Rows.Count <= 0) { throw new Exception("바코드를 스캔하세요."); } if (m_OUT_USR_ID == "") { throw new Exception("출고자를 선택하세요."); } DataTable dtData = UtilClass.GetDataTable(m_ORDER, false, "ORDER_NO"); ResultData[] dataList = null; ResultData data1 = new ResultData(); dtData.TableName = "ADATA"; data1.TableData = dtData; dataList = new ResultData[] { data1}; SerializedSqlParam[] aParam = new SerializedSqlParam[] { ClientClass.CreateSqlParameter("COMP_CD", SqlDbType.NVarChar, ConstClass._COMP_CD), ClientClass.CreateSqlParameter("OUT_USR_ID", SqlDbType.NVarChar, m_OUT_USR_ID) }; ResultData resultData = ClientClass.SetTableData("SaveOutOrderInfo", dataList, aParam); if (resultData.isError) { throw new Exception(resultData.ResultValue); } XtraMessageBox.Show("정상적으로 출고하였습니다"); this.DialogResult = DialogResult.Yes; this.Close(); this.Cursor = Cursors.Arrow; } catch (Exception ex) { this.Cursor = Cursors.Arrow; XtraMessageBox.Show(ex.Message); } } private void checkButton1_CheckedChanged(object sender, EventArgs e) { //if ((sender as CheckButton).Checked) { m_OUT_USR_ID = UtilClass.toStr((sender as SimpleButton).Tag); } } } }