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 frmGiftApp : 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_cGiftApp = 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_sBrandCD; /// /// 고정브랜드코드 /// public string SetBrandCD { set { this.m_sBrandCD = value; } } private string m_sGiftType; /// /// 권종 /// public string SetGitftType { set { this.m_sGiftType = value; } get { return m_sGiftType; } } //#15533 상품권(승인) 시 PREFIX 리딩을 통한 승인기능도입 요청 start private string m_sGiftNo; /// /// 상품권 번호 /// public string SetGitftNo { set { this.m_sGiftNo = value; } get { return m_sGiftNo; } } //#15533 상품권(승인) 시 PREFIX 리딩을 통한 승인기능도입 요청 end /// /// 입력구분 /// 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 frmGiftApp() { 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_cGiftApp = (IPaymentUs)sManager.InitServiceInstance(ServiceLists.BSV_PAYMENT.DLL, ServiceLists.BSV_PAYMENT.GIFT_APP); } private void frmGiftApp_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 frmGiftApp_Activated(object sender, EventArgs e) { } private void frmGiftApp_Deactivate(object sender, EventArgs e) { PosOLEDevice.SetEventHandle(null); } private void frmGiftApp_FormClosing(object sender, FormClosingEventArgs e) { if (m_sPosMenuKey == PosKey.MENU_KEY.GIFT_CARD_SCH) FormManager.SetFormAllControlMove(this, 216, 123); 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 { // 이미지 로딩 처리 if (m_sPosMenuKey == PosKey.MENU_KEY.GIFT_CARD_SCH) { this.Size = new Size(788, 402); //#20181015 결제창 엑박 관련 이미지 미사용 처리 start //기존 //picBack.Image = ImageManager.GetImage(BaseCom.NxImgPath, ImageManager.POP_SIZE_S); //#20181015 결제창 엑박 관련 이미지 미사용 처리 end FormManager.SetFormAllControlMove(this, -216, -123); FormManager.MovePopUpForm(this, false, m_cPosStatus.Sale.ScreenSizeUser); } else { this.Location = new Point(0, 50); this.Size = new Size(1024, 525); picBack.Size = new Size(1024, 525); //#20181015 결제창 엑박 관련 이미지 미사용 처리 start //기존 //picBack.Image = ImageManager.GetImage(BaseCom.NxImgPath, ImageManager.PAY_MAIN_BACKGROUND); //#20181015 결제창 엑박 관련 이미지 미사용 처리 end //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 = ""; // mot 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.GIFT_CARD) lblTitle.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0273); else if (m_sPosMenuKey == PosKey.MENU_KEY.GIFT_CARD_SCH) lblTitle.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0273); m_sPay_DC_Grp_Type = ItemConst.TR_ITEM_ID.GIFT_ITEM; m_sPay_DC_CD = ItemConst.TR_ITEM_ID.GIFT.GIFT_COM; lblCardNo.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0269); lblCardNM.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0270); lblAmount.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0271); btnEnter.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0004); // 조회 txtCardNo.Text = ""; txtCardNM.Text = ""; txtAmount.Text = "0"; m_sInPutType = ""; // 입력구분 m_sInPutData = ""; // 입력데이터 m_sInEncData = ""; // 카드데이터 // 기능 버튼 설정 체크 FormManager.SetbtnMenu(txtCardNo, m_cDevStatus.ICReader.UseYn, btnMenu1, btnMenu2, btnMenu3, btnMenu4); bNotDoubleClik = false; txtCardNo.Select(); //#15533 상품권(승인) 시 PREFIX 리딩을 통한 승인기능도입 요청 start if (m_sGiftNo != "") { txtCardNo.Text = m_sGiftNo; btnProc_Click(btnEnter, null); } //#15533 상품권(승인) 시 PREFIX 리딩을 통한 승인기능도입 요청 end } 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) == btnEnter) // 승인 { // 승인 sRet = CompleteTxtInPut(); bNotDoubleClik = false; if (sRet != UserCom.RST_OK) return; if (m_sPosMenuKey == PosKey.MENU_KEY.GIFT_CARD) { 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) == txtCardNo ) { // 승인 sRet = CompleteTxtInPut(); if (sRet != UserCom.RST_OK) return; if (m_sPosMenuKey == PosKey.MENU_KEY.GIFT_CARD) { this.DialogResult = DialogResult.OK; this.Close(); } return; } } else if (sFuncValue == PosKey.MENU_KEY.CLEAR) { if (((Cosmos.UI.CsmPosEditBox)sender) == txtCardNo) { txtCardNo.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 { 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) { txtCardNM.Text = ""; txtAmount.Text = "0"; m_sInPutType = ""; // 입력구분 m_sInPutData = ""; // 입력데이터 m_sInEncData = ""; // 카드데이터 } #endregion #region 텍스트박스 입력 유효성 체크 /// /// 텍스트박스 입력 유효성 체크 /// /// /// private bool CheckTxtInPut(object sender) { try { // 상품권 체크 if (sender == null || ((Cosmos.UI.CsmPosEditBox)sender) == txtCardNo) { if (txtCardNo.Text.Length <= 0) { WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0189); return false; } } // 금액 체크 if (m_cDataService.DoubleParse(txtAmount.Text) <= 0) { WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0191); txtCardNo.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_sInPutData == "") { m_sInPutType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_KEYIN_GIFT; m_sInPutData = txtCardNo.Value; } if (m_sInPutData.Length == 12) { // 상품권 길이 12자리 인 경우 첫자리가 3, 5면 0추가 if (CmUtil.MidH(m_sInPutData, 0, 1) == "3" || CmUtil.MidH(m_sInPutData, 0, 1) == "5") { m_sInPutData = "0" + m_sInPutData; txtCardNo.Value = m_sInPutData; m_sInPutData = txtCardNo.Value; } } if (m_sPosMenuKey == PosKey.MENU_KEY.GIFT_CARD) { if (m_cPosStatus.Base.BrandCd.Trim() == "002") { //// 파리인 경우만 권종과 상품권 첫 4자리 체크 - 인증 대상 //if ( // ((m_sGiftType == "03") && (CmUtil.MidH(m_sInPutData, 0, 4) == "0370")) // || ((m_sGiftType == "03") && (CmUtil.MidH(m_sInPutData, 0, 4) == "0340")) // //|| ((m_sGiftType == "06") && (CmUtil.MidH(m_sInPutData, 0, 4) == "0540")) // || ((m_sGiftType == "06") && (CmUtil.MidH(m_sInPutData, 0, 4) == "0570")) // || ((m_sGiftType == "50") && (CmUtil.MidH(m_sInPutData, 0, 4) == "5060")) // || ((m_sGiftType == "05") && (CmUtil.MidH(m_sInPutData, 0, 4) == "0530")) // || ((m_sGiftType == "10") && (CmUtil.MidH(m_sInPutData, 0, 4) == "1030")) // || ((m_sGiftType == "10") && (CmUtil.MidH(m_sInPutData, 0, 4) == "1040")) // ) //{ // // 정상 // // 카드번호 길이 체크 // if (txtCardNo.Value.Length != 13) // { // WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0189); // txtCardNo.Focus(); // return sRet; // } //} //else //{ // WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0481); // return sRet; //} if (CmUtil.MidH(m_sInPutData, 0, 4) == "0370") m_sGiftType = "03"; else if (CmUtil.MidH(m_sInPutData, 0, 4) == "0340") m_sGiftType = "03"; else if (CmUtil.MidH(m_sInPutData, 0, 4) == "0540") m_sGiftType = "06"; else if (CmUtil.MidH(m_sInPutData, 0, 4) == "0570") m_sGiftType = "06"; else if (CmUtil.MidH(m_sInPutData, 0, 4) == "1040") m_sGiftType = "50"; else if (CmUtil.MidH(m_sInPutData, 0, 4) == "5060") m_sGiftType = "50"; else if (CmUtil.MidH(m_sInPutData, 0, 4) == "0530") m_sGiftType = "05"; else if (CmUtil.MidH(m_sInPutData, 0, 4) == "1030") m_sGiftType = "10"; else { WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0481); return sRet; } // 카드번호 길이 체크 if (txtCardNo.Value.Length != 13) { WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0189); txtCardNo.Focus(); return sRet; } } } string[] aRet = null; sRet = m_cGiftApp.SearchPayment(new string[] { m_sPosMenuKey, m_sPay_DC_Grp_Type, m_sPay_DC_CD, ItemConst.GIFT_APPROVE_DIV.NORMAL, m_sInPutType, m_sInPutData, m_cDataService.DoubleParse(txtAmount.Text).ToString(), "", "", "", m_sBrandCD, m_sGiftType }, ref aRet); if (sRet != UserCom.RST_OK) return sRet; // 결제 내역 받아 오기 Column.TR_PAYMENT.DATA alPayItem = (Column.TR_PAYMENT.DATA)m_cGiftApp.GetPayment(new string[] { }); txtCardNM.Text = alPayItem.OCCUR_ENTRY_11; txtAmount.Text = m_cPosStatus.Global.NumericTOCurrency(alPayItem.AMT_ENTRY_01); m_sGiftType = alPayItem.OCCUR_ENTRY_15; } 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 텍스트박스 입력 유효성 체크 /// /// 텍스트박스 입력 유효성 체크 /// /// /// private bool CheckTxtInPut(object sender, bool bSearchMode) { try { // 카드번호 길이 체크 if (sender == null || ((Cosmos.UI.CsmPosEditBox)sender) == txtCardNo) { if (txtCardNo.Value.Length < 4) { WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0189); txtCardNo.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 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_GIFT; m_sInPutData = sScanData; txtCardNo.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 } }