using System; using System.Collections; using System.Windows.Forms; using Cosmos.UserFrame; using Cosmos.BaseFrame; using Cosmos.ServiceProvider; using Cosmos.Common; using Cosmos.CommonManager; using System.Data; using System.Drawing; using System.Text.RegularExpressions; namespace Cosmos.Win { public partial class frmReservedCustInfo : Form { #region Variable private SManager sManager = new SManager(); // 이 객체를 통해 업무 Service 호출 private StateServer StateObject = (StateServer)StateServer.GetInstance(); // StateObject : StateServer Object (객체) private PosStatus m_cPosStatus = new PosStatus(); // 기본정보 참조 private TranStatus m_cTrnStatus = new TranStatus(); // 거래정보 참조 private IDataCommonUs m_cDataCommon = null; // POS 공통함수 인터페이스 private string m_sPosMenuKeyIn; public string PosMenuKeyIn { set { m_sPosMenuKeyIn = value; } get { return m_sPosMenuKeyIn; } } private string m_sPosMenuKeyOut; public string PosMenuKeyOut { set { m_sPosMenuKeyOut = value; } get { return m_sPosMenuKeyOut; } } private bool m_bShift = false; private object ActiveTxtBox = null; #endregion #region 생성자 & 소멸자 public frmReservedCustInfo() { InitializeComponent(); base.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw, true); //this.UpdateStyles(); m_cPosStatus = (PosStatus)StateObject.POS; m_cTrnStatus = (TranStatus)StateObject.TRAN; m_cDataCommon = (IDataCommonUs)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.DATA_COMMON); } /// /// 폼로드 /// /// /// private void frmReservedCustInfo_Load(object sender, EventArgs e) { UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ""); InitControl(); ReservNoCheck(); } /// /// 폼 클로즈 /// /// /// private void frmReservedCustInfo_FormClosing(object sender, FormClosingEventArgs e) { UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", lblTitle.Text); } #endregion #region 폼 컨트롤 초기화 /// /// 폼 컨트롤 초기화 /// private void InitControl() { try { if (m_cPosStatus.Mst.CntryDiv == ItemConst.CNTRY_DIV.US) //미국 { picBack.Image = ImageManager.GetImage(Cosmos.BaseFrame.BaseCom.NxImgPath, ImageManager.POP_SIZE_800X600); picBack.Size = new Size(800, 600); this.Size = new Size(800, 600); pnlKeyBoard.Visible = true; } else { picBack.Image = ImageManager.GetImage(Cosmos.BaseFrame.BaseCom.NxImgPath, ImageManager.POP_SIZE_800X320); picBack.Size = new Size(800, 320); this.Size = new Size(800, 320); pnlKeyBoard.Visible = false; } FormManager.MovePopUpForm(this, false, m_cPosStatus.Sale.ScreenSizeUser); //this.Location = new Point(216, 173); FormManager.SetFormAllControlFont(this, m_cPosStatus.Base.FONT); FormManager.SetTextBoxGlobalInfo(this, m_cPosStatus.Global.m_stCultureMaster.nGroupingDigits, m_cPosStatus.Global.m_stCultureMaster.strGroupingSymbol , m_cPosStatus.Global.m_stCultureMaster.nDecimalDigits, m_cPosStatus.Global.m_stCultureMaster.strDecimalSymbol); //테마색상 적용! btnSave.BackColor = CmUtil.GetColorToString(m_cPosStatus.ScnMst.ThemeColor); //padInPut.ClearBtnText = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0817); btnExit.Image = ImageManager.GetImage(Cosmos.BaseFrame.BaseCom.NxImgPath, ImageManager.BTN_CLOSE); if (btnExit.Image != null) btnExit.Text = ""; btnDate.Image = ImageManager.GetImage(BaseCom.NxImgPath, ImageManager.ICON_DATE_BASIC); if (btnDate.Image != null) btnDate.Text = ""; lblTitle.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0077); //예약등록 lblReservNo.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0188); //예약번호 lblReservCustNm.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0278); //고객명 lblReservCustNo.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0279); //전화번호 lblReservDate.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0189); //예약일자 lblReservTime.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0190); //예약시간 lblReservMemo.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0280); //주소메모 lblReservOnOff.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0494); //주문구분 btnSave.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0225); //저장 ckbOn.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0495); //온라인 ckbOff.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0496); //오프라인 txtSaleDate.InputTypeFormat = m_cPosStatus.Global.m_stCultureMaster.strDatePattern; txtSaleDate.Text = m_cPosStatus.Global.DateToCulture(m_cPosStatus.Base.SaleDate); ckbOn.Checked = true; ckbOff.Checked = false; txtReservNo.Text = ""; txtReservCustNm.Text = ""; txtReservCustNo.Text = ""; txtReservMemo.Text = ""; txtReservTimeHH.Text = "00"; txtReservTimeMM.Text = "00"; //padInPut.BtnDotEnable = true; btnExit.Enabled = true; ComboxInit(); if (pnlKeyBoard.Visible == true) { m_bShift = false; SetKeyboardText(); } txtReservCustNm.Select(); } catch (Exception ex) { WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message); } } private void ComboxNowTimeCheck() { try { } catch (Exception ex) { WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message); } } /// /// 콤보박스 초기화 /// private void ComboxInit() { try { cbTimeHH.Items.Clear(); cbTimeMM.Items.Clear(); DataTable dt = null; //시간 dt = m_cDataCommon.SeletCommonCode(PosConst.COMMON_CODE_GROUP.Z0005, ""); if (dt != null && dt.Rows.Count > 0) { int iRow = 0; int iRowSelect = 0; foreach(DataRow dr in dt.Rows) { string sValue = CmUtil.GetDataRowStr(dr, PosMst.MST_COMMON.DATA.CHAR_VAL_TITLE_VAL_01); cbTimeHH.Items.Add(sValue); //현재 시간 체크 string sNowHH = DateTime.Now.ToString("HH"); iRow++; //23시면 if (sNowHH == "23") { iRowSelect = 0; } else if (sNowHH == sValue.Trim()) { iRowSelect = iRow; } } cbTimeHH.SelectedIndex = iRowSelect; txtReservTimeHH.Text = cbTimeHH.Text.Trim(); } //분 dt = m_cDataCommon.SeletCommonCode(PosConst.COMMON_CODE_GROUP.Z0006, ""); if (dt != null && dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { cbTimeMM.Items.Add(CmUtil.GetDataRowStr(dr, PosMst.MST_COMMON.DATA.CHAR_VAL_TITLE_VAL_01)); } cbTimeMM.SelectedIndex = 0; } } catch (Exception ex) { WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message); } } #endregion #region Control Event /// /// 입력박스 이벤트 /// /// /// private void txtEditBox_EditBoxKeyDownEvent(object sender, string sFuncValue) { try { if (sFuncValue == PosKey.MENU_KEY.ENTER) { if (((Cosmos.UI.CsmPosEditBox)sender) == txtReservCustNm) //이름 { txtReservCustNo.Select(); } else if (((Cosmos.UI.CsmPosEditBox)sender) == txtReservCustNo) { txtReservMemo.Select(); //txtReservTimeHH.Select(); } //else if (((Cosmos.UI.CsmPosEditBox)sender) == txtReservTimeHH) //{ // txtReservTimeMM.Select(); //} //else if (((Cosmos.UI.CsmPosEditBox)sender) == txtReservTimeMM) //{ // txtReservMemo.Select(); //} } else if (sFuncValue == PosKey.MENU_KEY.SAVE) { if (CheckTxtInPut(null) == true) { if (CustInfoSave() == true) { this.DialogResult = DialogResult.OK; this.Close(); } } } else if (sFuncValue == PosKey.MENU_KEY.CLEAR) { if (((Cosmos.UI.CsmPosEditBox)sender).ReadOnly == false) ((Cosmos.UI.CsmPosEditBox)sender).Text = ""; } else if (sFuncValue == PosKey.MENU_KEY.ESC_PREVIOUS) { this.DialogResult = DialogResult.Cancel; this.Close(); } } catch (Exception ex) { WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message); } } /// /// 입력박스 엔터 이벤트 /// /// /// private void txtEditBox_EnterEvent(object sender, EventArgs e) { try { ActiveTxtBox = (Control)sender; //padInPut.SetActiveControl = (Control)sender; } catch (Exception ex) { WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message); } } /// /// 종료 /// /// /// private void btnExit_Click(object sender, EventArgs e) { txtEditBox_EditBoxKeyDownEvent(null, PosKey.MENU_KEY.ESC_PREVIOUS); } /// /// 콤보박스 이벤트 /// /// /// private void cbTime_TextChanged(object sender, EventArgs e) { try { if (((ComboBox)sender).Text != "") { if ((ComboBox)sender == cbTimeHH) { txtReservTimeHH.Text = cbTimeHH.Text.Trim(); //txtReservTimeHH.Select(); } else { txtReservTimeMM.Text = cbTimeMM.Text.Trim(); //txtReservTimeMM.Select(); } } } catch (Exception ex) { WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message); } } /// /// 기능키 클릭 /// /// /// private void btnProc_Click(object sender, EventArgs e) { try { if ((UI.CsmButton)sender == btnSave) { txtEditBox_EditBoxKeyDownEvent(null, PosKey.MENU_KEY.SAVE); } } catch (Exception ex) { WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message); } } /// /// 달력클릭 /// /// /// private void btnDate_Click(object sender, EventArgs e) { try { string sDate = WinBasic.ShowForm(new string[] { FormManager.FORM_CALENDAR }); if (sDate != "" && sDate.Length == 8) { if (CmUtil.IntParse(sDate) < CmUtil.IntParse(DateTime.Now.ToString("yyyyMMdd"))) { //과거 일자 처리 안함! } else { txtSaleDate.Text = m_cPosStatus.Global.DateToCulture(sDate); } } } catch (Exception ex) { WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message); } } /// /// 키보드 클릭 이벤트 /// /// /// private void btnKbd_Click(object sender, EventArgs e) { try { Button c = (Button)sender; if (c.Name.StartsWith("btnKbd")) { if (ActiveTxtBox == txtReservCustNo) //전화번호란에 숫자만 입력! { if (Char.IsDigit(c.Text,0)) { SendKey(c.Text); } } else { SendKey(c.Text); } } //else if (c == btnFncShiftLeft || c == btnFncShiftRigth) //{ // m_bShift = true; //} // else if (c.Name.StartsWith("btnFncCapsLock") || c.Name.StartsWith("btnFncShiftLeft") || c.Name.StartsWith("btnFncShiftRigth")) { m_bShift = !m_bShift; SetKeyboardText(); } else if (c.Name.StartsWith("btnFnc")) { SendKey(c.Tag.ToString()); } //((UI.CsmPosRichTextBox)ActiveTxtBox).Focus(); } catch (Exception ex) { WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message); } } private void ckbOn_Click(object sender, EventArgs e) { ckbOff.Checked = !ckbOn.Checked; } private void ckbOff_Click(object sender, EventArgs e) { ckbOn.Checked = !ckbOff.Checked; } #endregion #region User Method /// /// 고객 정보 저장 /// /// private bool CustInfoSave() { bool bRet = false; try { string sSaleDate = m_cPosStatus.Global.CultureToDate(txtSaleDate.Text); ArrayList alReservedCustInfo = (ArrayList)StateObject.GetItemObject(Column.TR_RESERV_INFO.ITEM); if (alReservedCustInfo.Count == 0) { Column.TR_RESERV_INFO.DATA clReservedCustInfo = new Column.TR_RESERV_INFO.DATA(); clReservedCustInfo.RESERV_NO = txtReservNo.Text.Replace("-", ""); clReservedCustInfo.ONOFF_DIV = ckbOn.Checked == true ? "0" : "1"; clReservedCustInfo.CUSTNM = txtReservCustNm.Text.Replace("'", "\""); clReservedCustInfo.CUST_PHN_NO = txtReservCustNo.Text.Replace("'", "\""); clReservedCustInfo.RESERV_REG_DT = DateTime.Now.ToString("yyyyMMdd"); clReservedCustInfo.RESERV_REG_TM = DateTime.Now.ToString("HHmmss"); clReservedCustInfo.RESERV_DT = sSaleDate; clReservedCustInfo.RESERV_TM = txtReservTimeHH.Text + txtReservTimeMM.Text + "00"; clReservedCustInfo.RESERV_MEMO = txtReservMemo.Text.Replace("'", "\""); alReservedCustInfo.Add(clReservedCustInfo); } else { Column.TR_RESERV_INFO.DATA clReservedCustInfo = (Column.TR_RESERV_INFO.DATA)alReservedCustInfo[0]; clReservedCustInfo.RESERV_NO = txtReservNo.Text.Replace("-", ""); clReservedCustInfo.ONOFF_DIV = ckbOn.Checked == true ? "0" : "1"; clReservedCustInfo.CUSTNM = txtReservCustNm.Text.Replace("'", "\""); clReservedCustInfo.CUST_PHN_NO = txtReservCustNo.Text.Replace("'", "\""); clReservedCustInfo.RESERV_REG_DT = DateTime.Now.ToString("yyyyMMdd"); clReservedCustInfo.RESERV_REG_TM = DateTime.Now.ToString("HHmmss"); clReservedCustInfo.RESERV_DT = sSaleDate; clReservedCustInfo.RESERV_TM = txtReservTimeHH.Text + txtReservTimeMM.Text + "00"; clReservedCustInfo.RESERV_MEMO = txtReservMemo.Text.Replace("'", "\""); } bRet = true; } catch (Exception ex) { WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message); } return bRet; } /// /// 텍스트박스 입력 유효성 체크 /// /// /// private bool CheckTxtInPut(object sender) { try { if (sender == null || ((Cosmos.UI.CsmPosEditBox)sender) == txtReservCustNm) { if (txtReservCustNm.Text == "") { WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0224); txtReservCustNm.Select(); txtReservCustNm.SelectText(); return false; } } if (sender == null || ((Cosmos.UI.CsmPosEditBox)sender) == txtReservCustNo) { if (txtReservCustNo.Text == "") { WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0225); //txtReservCustNo.Select(); //txtReservCustNo.SelectText(); return false; } else { if (CmUtil.IsNumber(txtReservCustNo.Text.Trim().Replace("-","")) == false) { WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0683); return false; } } } if (sender == null || ((Cosmos.UI.CsmPosEditBox)sender) == txtReservTimeHH || ((Cosmos.UI.CsmPosEditBox)sender) == txtReservTimeMM) { if (txtReservTimeHH.Text == "" || txtReservTimeMM.Text == "") { WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0226); txtReservTimeHH.Select(); txtReservTimeHH.SelectText(); return false; } } if (sender == null || ((TextBox)sender) == txtReservMemo) { if (txtReservMemo.Text == "") { WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0227); txtReservMemo.Focus(); return false; } } } catch (Exception ex) { WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message); return false; } return true; } /// /// 예약번호 체번 /// private void ReservNoCheck() { try { txtReservNo.Text = string.Format("{0}-{1}-{2}", m_cTrnStatus.Head.SaleDate, m_cTrnStatus.Head.PosNo, m_cTrnStatus.Head.TradeNo); //txtReservNo.Text = m_cTrnStatus.Head.SaleDate + "-" + m_cTrnStatus.Head.PosNo + "-" + m_cTrnStatus.Head.TradeNo; } catch (Exception ex) { WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message); } } /// /// 전송키 /// /// private void SendKey(string sKey) { try { if (sKey.Equals("NONE")) return; if (ActiveTxtBox is TextBox) ((TextBox)ActiveTxtBox).Focus(); else ((UI.CsmPosEditBox)ActiveTxtBox).Focus(); string stxt = sKey.Replace("&&", "&"); if (stxt == "{" || stxt == "}" || stxt == "(" || stxt == ")" || stxt == "%" || stxt == "^" || stxt == "~") stxt = Regex.Replace(sKey, "[~%^(){}]", "{$0}"); SendKeys.Send(stxt); } catch (Exception ex) { WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message); } } /// /// 대소문자 변환 표시 /// private void SetKeyboardText() { try { foreach (Control c in pnlKeyBoard.Controls) { if (c is Button) { if (c.Name.StartsWith("btnKbd")) { if (c.Tag.ToString() != "") { string[] aStr = c.Tag.ToString().Split(new string[] { "※" }, StringSplitOptions.None); if(aStr.Length == 2) { if (m_bShift == false) c.Text = aStr[0]; else c.Text = aStr[1]; } } } } } } catch (Exception ex) { WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message); } } #endregion } }