spc-kiosk-pb/Window/WinPayment/frmGiftApp.cs
2019-06-16 14:12:09 +09:00

662 lines
28 KiB
C#

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; // 입력코드
/// <summary>
/// 구분
/// </summary>
public string SetPosMenuKey { set { this.m_sPosMenuKey = value; } }
private string m_sBrandCD;
/// <summary>
/// 고정브랜드코드
/// </summary>
public string SetBrandCD { set { this.m_sBrandCD = value; } }
private string m_sGiftType;
/// <summary>
/// 권종
/// </summary>
public string SetGitftType { set { this.m_sGiftType = value; } get { return m_sGiftType; } }
//#15533 상품권(승인) 시 PREFIX 리딩을 통한 승인기능도입 요청 start
private string m_sGiftNo;
/// <summary>
/// 상품권 번호
/// </summary>
public string SetGitftNo { set { this.m_sGiftNo = value; } get { return m_sGiftNo; } }
//#15533 상품권(승인) 시 PREFIX 리딩을 통한 승인기능도입 요청 end
/// <summary>
/// 입력구분
/// </summary>
private string m_sInPutType = "";
/// <summary>
/// 입력데이터
/// </summary>
private string m_sInPutData = "";
/// <summary>
/// 카드데이터
/// </summary>
private string m_sInEncData = "";
/// <summary>
/// 결제구분
/// </summary>
private string m_sPay_DC_Grp_Type = "";
/// <summary>
/// 결제상세구분
/// </summary>
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);
}
/// <summary>
/// 폼 컨트롤 초기화
/// </summary>
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
/// <summary>
/// 버튼 입력 처리
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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;
}
/// <summary>
/// 닫기
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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
/// <summary>
/// 텍스트박스 키 입력 이벤트 처리
/// </summary>
/// <param name="sender"></param>
/// <param name="sFuncValue"></param>
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);
}
}
/// <summary>
/// 텍스트박스 활성화 처리
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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);
}
}
/// <summary>
/// 코드 변경시 초기화
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void txtCardNo_EditBoxTextChangedEvnet(object sender, EventArgs e)
{
txtCardNM.Text = "";
txtAmount.Text = "0";
m_sInPutType = ""; // 입력구분
m_sInPutData = ""; // 입력데이터
m_sInEncData = ""; // 카드데이터
}
#endregion
#region
/// <summary>
/// 텍스트박스 입력 유효성 체크
/// </summary>
/// <param name="sender"></param>
/// <returns></returns>
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
/// <summary>
/// 결제 처리
/// </summary>
/// <param name="nFlowMode"></param>
/// <returns></returns>
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
/// <summary>
/// 텍스트박스 입력 유효성 체크
/// </summary>
/// <param name="sender"></param>
/// <returns></returns>
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
/// <summary>
/// DeviceEvent 관련
/// </summary>
/// <param name="sDevice"></param>
/// <param name="sData1"></param>
/// <param name="sData2"></param>
/// <param name="sData3"></param>
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);
}
}
/// <summary>
/// MSR Event
/// </summary>
/// <param name="source"></param>
/// <param name="e"></param>
private void OnMSREvent(object source, EventArgs e)
{
}
/// <summary>
/// 스캐너 이벤트 처리
/// </summary>
/// <param name="source"></param>
/// <param name="e"></param>
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);
}
}
/// <summary>
/// 카드 번호 암호화
/// </summary>
/// <param name="sInData"></param>
/// <param name="sCardData"></param>
/// <param name="sCardNo"></param>
/// <returns></returns>
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;
}
/// <summary>
/// IC 카드 정보 입력 처리
/// </summary>
/// <returns></returns>
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
}
}