using System; using System.Text; using System.Data; using System.Drawing; using System.Windows.Forms; using System.Collections; using Cosmos.Win; using Cosmos.BaseFrame; using Cosmos.UserFrame; using Cosmos.ServiceProvider; using Cosmos.Common; using Cosmos.CommonManager; using Cosmos.UI; /*-----------------------------------------------------------------------------------------------*/ // 설 명 : 선불카드 // 작 성 자 : // 변경 이력 : /*-----------------------------------------------------------------------------------------------*/ namespace Cosmos.Win { public partial class frmPrepaidCard : frm_PayMainBack { #region 변수 선언 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 DeviceStatus m_cDevStatus = new DeviceStatus(); // 디바이스 관리 private IDataCommonUs m_cDataCommon = null; // POS 공통함수 인터페이스 private IDataProcessUs m_cDataService = null; private IPaymentUs m_cPrepaidCard = null; 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 bNotDoubleClik = false; // 더블 클릭 방지용 private string m_sPosMenuKey; // 입력코드 /// /// 구분 /// public string SetPosMenuKey { set { this.m_sPosMenuKey = value; } } /// /// 입력구분 /// private string m_sInPutType = ""; /// /// 입력데이터 /// private string m_sInPutData = ""; /// /// 카드데이터 /// private string m_sInEncData = ""; /// /// 결제구분 /// private string m_sPay_DC_Grp_Type = ""; /// /// 결제상세구분 /// private string m_sPay_DC_CD = ""; #endregion 변수 선언 #region 생성자 & 소멸자 & 폼초기화 public frmPrepaidCard() { InitializeComponent(); base.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw, true); //this.UpdateStyles(); m_cPosStatus = (PosStatus)StateObject.POS; // POS 기본정보 m_cTrnStatus = (TranStatus)StateObject.TRAN; // POS 거래정보 m_cDataService = (IDataProcessUs)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.DATA_SERVICE); m_cDataCommon = (IDataCommonUs)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.DATA_COMMON); m_cPrepaidCard = (IPaymentUs)sManager.InitServiceInstance(ServiceLists.BSV_PAYMENT.DLL, ServiceLists.BSV_PAYMENT.PREPAIDCARD); } private void frmPrepaidCard_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(); } private void frmPrepaidCard_Activated(object sender, EventArgs e) { } private void frmPrepaidCard_Deactivate(object sender, EventArgs e) { PosOLEDevice.SetEventHandle(null); } private void frmPrepaidCard_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); } /// /// 폼 컨트롤 초기화 /// private void InitControl() { try { // 이미지 로딩 처리 //picBack.Image = ImageManager.GetImage(BaseCom.NxImgPath, ImageManager.POP_SIZE_S); //this.Size = new Size(788, 402); //this.Location = new Point(216, 173); //picBack.Image = ImageManager.GetImage(BaseCom.NxImgPath, ImageManager.POP_SIZE_S); this.Location = new Point(0, 50); this.Size = new Size(1024, 525); //this.BackColor = Color.FromArgb(114, 114, 114); 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); btnExit.Image = ImageManager.GetImage(BaseCom.NxImgPath, ImageManager.BTN_CLOSE); if (btnExit.Image != null) btnExit.Text = ""; IDataCommonUs m_cDataCommon = (IDataCommonUs)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.DATA_COMMON); InitPayMainBack(m_cPosStatus, m_cDataCommon, m_sPosMenuKey, PosConst.MOT_MSG_TYPE.PAY_STEP_3, ""); //테마색상 적용! btnEnter.BackColor = CmUtil.GetColorToString(m_cPosStatus.ScnMst.ThemeColor); // 타이틀 if (m_sPosMenuKey == PosKey.MENU_KEY.PREPAID_CARDS) lblTitle.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0305); m_sPay_DC_Grp_Type = ItemConst.TR_ITEM_ID.PPCARD_ITEM; m_sPay_DC_CD = ItemConst.TR_ITEM_ID.PPCARD.PP_CARD; lblSaleAmt.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0037); // 받을금액 lblCustID.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0306); // 고객번호 lblCustNM.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0287); // 고 객 명 lblBalanceAmt.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0307); // 선불잔액 lblPayAmt.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0308); // 사용금액 * btnSearch.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0309); // 고객찾기 btnEnter.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0057); // 승인 txtSaleAmt.Text = m_cPosStatus.Global.NumericTOCurrency(m_cTrnStatus.Sale.RemainPayAmt); // 받을금액 m_sInPutType = ""; // 입력구분 m_sInPutData = ""; // 입력데이터 m_sInEncData = ""; // 카드데이터 txtCustID.Text = ""; // 고객번호 txtCustNm.Text = ""; // 고객명 txtBalanceAmt.Text = "0"; // 선불잔액 txtPayAmt.Text = "0"; // 사용금액 bNotDoubleClik = false; txtCustID.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); } } #endregion #region 버튼 입력 처리 /// /// 버튼 입력 처리 /// /// /// private void btnProc_Click(object sender, EventArgs e) { string sRet = UserCom.RST_ERR; try { if (bNotDoubleClik) return; bNotDoubleClik = true; if (((Cosmos.UI.CsmButton)sender) == btnSearch) // 고객찾기 { sRet = SearchTxtInPut(); bNotDoubleClik = false; if (sRet != UserCom.RST_OK) return; } else if (((Cosmos.UI.CsmButton)sender) == btnEnter) // 승인 { // 승인 sRet = CompleteTxtInPut(); bNotDoubleClik = false; if (sRet != UserCom.RST_OK) return; this.DialogResult = DialogResult.OK; this.Close(); return; } padInPut.SetActiveFocus(); } catch (Exception ex) { WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message); bNotDoubleClik = false; } bNotDoubleClik = false; } /// /// 닫기 /// /// /// private void btnExit_Click(object sender, EventArgs e) { try { txtEditBox_EditBoxKeyDownEvent(null, PosKey.MENU_KEY.ESC_PREVIOUS); } 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 텍스트박스 키 입력 이벤트 처리 /// /// 텍스트박스 키 입력 이벤트 처리 /// /// /// private void txtEditBox_EditBoxKeyDownEvent(object sender, string sFuncValue) { string sRet = UserCom.RST_ERR; try { if (sFuncValue == PosKey.MENU_KEY.ENTER) { if (((Cosmos.UI.CsmPosEditBox)sender) == txtCustID) { // 고객찾기 sRet = SearchTxtInPut(); if (sRet != UserCom.RST_OK) return; } else if (((Cosmos.UI.CsmPosEditBox)sender) == txtPayAmt) { // 승인 sRet = CompleteTxtInPut(); if (sRet != UserCom.RST_OK) return; this.DialogResult = DialogResult.OK; this.Close(); return; } } else if (sFuncValue == PosKey.MENU_KEY.CLEAR) { if (((Cosmos.UI.CsmPosEditBox)sender) == txtPayAmt) { txtPayAmt.Text = "0"; } } 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 { 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 txtCardNo_EditBoxTextChangedEvnet(object sender, EventArgs e) { m_sInPutType = ""; // 입력구분 m_sInPutData = ""; // 입력데이터 m_sInEncData = ""; // 카드데이터 txtCustNm.Text = ""; txtBalanceAmt.Text = "0"; txtPayAmt.Text = "0"; } #endregion #region 텍스트박스 입력 유효성 체크 /// /// 텍스트박스 입력 유효성 체크 /// /// /// private bool CheckTxtInPut(object sender, bool bSearchMode) { try { // 코드 체크 if (txtCustID.Text.Length <= 0 && bSearchMode != true) { WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0213); return false; } if (bSearchMode != false) { // 금액 체크 if (txtPayAmt.Value.Length > 10 || m_cDataService.LongParse(txtPayAmt.Value) <= 0) { WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0036); txtPayAmt.Focus(); return false; } if (CmUtil.AmountCut(m_cDataService.DoubleParse(txtPayAmt.Value), CmUtil.IntParse(m_cPosStatus.Mst.PayRudDwLoc)) != m_cDataService.DoubleParse(txtPayAmt.Value)) { WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0036); txtPayAmt.Focus(); return false; } // 사용금액 체크 if (m_cDataService.DoubleParse(txtPayAmt.Value.ToString()) > m_cDataService.DoubleParse(txtBalanceAmt.Text.ToString())) { WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0035); txtSaleAmt.Focus(); return false; } // 결제금액 체크 if (m_cDataService.DoubleParse(txtPayAmt.Value.ToString()) > m_cDataService.DoubleParse(txtSaleAmt.Text.ToString())) { WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0039); txtSaleAmt.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; } #endregion #region 텍스트박스 입력 완료 처리 /// /// 결제 처리 /// /// /// private string CompleteTxtInPut() { string sRet = UserCom.RST_ERR; try { // 승인 if (CheckTxtInPut(null, true) != true) return sRet; if (m_sInEncData == "") { if (m_sInPutData == "") { m_sInPutType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_KEYIN; m_sInPutData = txtCustID.Value; } ///EncryptedCardNo(sInPutData, ref sInEncData, ref sInPutData); } sRet = m_cPrepaidCard.SetPayment(new string[] { ItemConst.IRT_INQ_TYPE.PRPAIDCARD_USE_REQ, m_sPay_DC_Grp_Type, m_sPay_DC_CD, "1", m_sInPutData, m_cDataService.DoubleParse(txtBalanceAmt.Text).ToString(), m_cDataService.DoubleParse(txtPayAmt.Value).ToString(), m_sInPutType, txtCustNm.Text.Trim() }); if (sRet != UserCom.RST_OK) return sRet; } 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 sRet; } /// /// 조회 처리 /// /// private string SearchTxtInPut() { string sRet = UserCom.RST_ERR; string[] saRecvdData = null; try { // 조회 frmCustSearch fForm = (frmCustSearch)FormManager.GetForm(FormManager.FORM_PAY_CUST_SEARCH); if (fForm == null) { fForm = new frmCustSearch(); FormManager.AddForm(FormManager.FORM_PAY_CUST_SEARCH, fForm); } fForm.SearchCD = txtCustID.Value; fForm.SearchType = ItemConst.IRT_INQ_TYPE.PRPAIDCARD_INQ; if (fForm.ShowDialog() != DialogResult.OK) return sRet; txtCustID.Text = fForm.PosMenuKeyOut.Trim(); if (CheckTxtInPut(null, false) != true) return sRet; if (m_sInEncData == "") { if (m_sInPutData == "") { m_sInPutType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_KEYIN; m_sInPutData = txtCustID.Text; } ///EncryptedCardNo(sInPutData, ref sInEncData, ref sInPutData); } sRet = m_cPrepaidCard.SearchPayment(new string[] { ItemConst.IRT_INQ_TYPE.PRPAIDCARD_INQ, m_sPay_DC_Grp_Type, m_sPay_DC_CD, "1", m_sInPutData, m_sInPutType, "0" }, ref saRecvdData); if (sRet != UserCom.RST_OK) return sRet; for (int iLoop = 0; iLoop < saRecvdData.Length; iLoop++) { if (saRecvdData[iLoop].Trim().Length <= 0) continue; string[] aRecvData = saRecvdData[iLoop].Split(new string[] { "|" }, StringSplitOptions.None); if (aRecvData.Length > 0) { if (aRecvData[0].ToString().Trim().Length <= 0) continue; txtCustNm.Text = aRecvData[3].ToString(); // 고객명 txtBalanceAmt.Text = m_cPosStatus.Global.NumericTOCurrency(m_cDataService.DoubleParse(aRecvData[4])).ToString(); // 선불잔액 if (m_cDataService.DoubleParse(txtBalanceAmt.Text.ToString()) > m_cDataService.DoubleParse(txtSaleAmt.Text.ToString())) { // 받을금액이 잔액보다 적은 경우 txtPayAmt.Text = txtSaleAmt.Text; } else { // 잔액이 받을금액보다 적은경우 txtPayAmt.Text = txtBalanceAmt.Text; } txtPayAmt.Select(); break; } } return sRet; } 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 sRet; } #endregion #region DeviceEvent 관련 /// /// DeviceEvent 관련 /// /// /// /// /// public void OnDeviceEvent(string sDevice, string sData1, string sData2, string sData3) { try { switch (sDevice) { case PosConst.OPOS_DEVICE.MSR: this.Invoke(new EventHandler(OnMSREvent)); break; case PosConst.OPOS_DEVICE.SCANNER: this.Invoke(new EventHandler(OnScannerEvent)); break; } } catch (Exception ex) { WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message); } } /// /// MSR Event /// /// /// private void OnMSREvent(object source, EventArgs e) { } /// /// 스캐너 이벤트 처리 /// /// /// private void OnScannerEvent(object source, EventArgs e) { string sScanData = m_cDevStatus.Scanner.DataLabel; try { if (sScanData.Length > 0 && m_sInPutData == "") { m_sInPutType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_BARCODE; m_sInPutData = sScanData; txtCustID.Text = m_sInPutData; /// if (m_cTrnStatus.Head.TradeDiv == ItemConst.TRAN_DIV.NORMAL) SearchTxtInPut(); } } 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 string EncryptedCardNo(string sInData, ref string sCardData, ref string sCardNo) { string sEncData = sInData; 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); } return sEncData; } /// /// IC 카드 정보 입력 처리 /// /// private bool GetIcCardData() { 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); } return false; } #endregion } }