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

1105 lines
50 KiB
C#

using System;
using System.Text;
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 System.Data;
/*-----------------------------------------------------------------------------------------------*/
// 설 명 : 모바일쿠폰
// 작 성 자 :
// 변경 이력 :
/*-----------------------------------------------------------------------------------------------*/
namespace Cosmos.Win
{
public partial class frmMobileCoupon : 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 PosOLEDevice.DelegateOlePos delegatePos;
private IDataProcessUs m_cDataService = null;
private IPaymentUs m_cMobileCoupon = null;
private IICReaderUs m_cDeviceICReader = null;
private ISalePluItemUs m_cPluService = null; // 판매 등록 관리
private bool bNotDoubleClik = false; // 더블 클릭 방지용
private IDataCommonUs m_cDataCommon = null;
private string mPay_DC_Type = ""; // 결제 그룹 코드
private string mPay_DC_CD = ""; // 결제 상세 코드
private string m_sPosMenuKey; // 입력값 할인
/// <summary>
/// 할인 구분
/// </summary>
public string SetPosMenuKey { set { this.m_sPosMenuKey = value; } }
/// <summary>
/// 입력구분
/// </summary>
private string m_sInPutType = "";
/// <summary>
/// 입력데이터
/// </summary>
private string m_sInPutData = "";
/// <summary>
/// 카드데이터
/// </summary>
private string m_sInEncData = "";
/// <summary>
/// 상품정보 작업용
/// </summary>
private ArrayList m_aSaleItem = null;
private string m_sProductiTem = "";
private struct ITEM_PLU_CHECK
{
public string sCouponNo; // 쿠폰코드
public string sVCouponNo; // 가상 쿠폰코드
public string sProductID; // 프로덕트 코드
public string iTemCD; // 상품코드
public double T_Qty; // 구매해야될 건수
public double S_Qty; // 구매한 건수
public double SALE_PRC; // 상품단가
public double SaleAmt; // 상품판매금액
public double PayAmt; // 상품결제금액
public double DCAmt; // 할인
}
#endregion
#region & &
public frmMobileCoupon()
{
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_cDevStatus = (DeviceStatus)StateObject.DEVICE;
m_cDataService = (IDataProcessUs)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.DATA_SERVICE);
m_cDeviceICReader = (IICReaderUs)sManager.InitServiceInstance(ServiceLists.AGENT_OLEDEVICE.DLL, ServiceLists.AGENT_OLEDEVICE.DEVICE_ICREADER);
m_cPluService = (ISalePluItemUs)sManager.InitServiceInstance(ServiceLists.BSV_SALE.DLL, ServiceLists.BSV_SALE.SALE_PLU_ITEM);
m_cMobileCoupon = (IPaymentUs)sManager.InitServiceInstance(ServiceLists.BSV_PAYMENT.DLL, ServiceLists.BSV_PAYMENT.MOBILECOUPON);
m_cDataCommon = (IDataCommonUs)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.DATA_COMMON);
delegatePos = new PosOLEDevice.DelegateOlePos(OnDeviceEvent);
}
private void frmMobileCoupon_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();
//#15608 모바일쿠폰해피기프트카드 자동인식 기능 도입요청 start
#region
if (m_cPosStatus.Sale.strMobileCpnNo != "")
{
//==============================================================
// 오버로딩된 모바일쿠폰 이벤트 함수 호출
//--------------------------------------------------------------
// - 파라미터 : sender, 모바일쿠폰 카드번호, 조회까지 실행할지 여부
//==============================================================
#region
txtEditBox_EditBoxKeyDownEvent(null, m_cPosStatus.Sale.strMobileCpnNo, btnSearch); // 조회까지 수행
#endregion
}
#endregion
//#15608 모바일쿠폰해피기프트카드 자동인식 기능 도입요청 end
}
private void frmMobileCoupon_Activated(object sender, EventArgs e)
{
PosOLEDevice.SetEventHandle(delegatePos);
}
private void frmMobileCoupon_Deactivate(object sender, EventArgs e)
{
PosOLEDevice.SetEventHandle(null);
}
private void frmMobileCoupon_FormClosing(object sender, FormClosingEventArgs e)
{
if (m_sPosMenuKey == PosKey.MENU_KEY.MOBILE_COUPON_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.MOBILE_COUPON_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 = "";
//테마색상 적용!
btnEnter.BackColor = CmUtil.GetColorToString(m_cPosStatus.ScnMst.ThemeColor);
// 모바일쿠폰
if (m_sPosMenuKey == PosKey.MENU_KEY.MOBILE_COUPON) lblTitle.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0199);
else if (m_sPosMenuKey == PosKey.MENU_KEY.MOBILE_COUPON_SCH) lblTitle.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0199);
lblCardNo.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0139);
lblCardNM.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0168);
lblCouponAmt.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0200);
lblPayAmt.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0037);
lbliTemAmt.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0215);
btnSearch.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0004);
btnEnter.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0057);
btnEnter.Visible = false;
if (m_sPosMenuKey == PosKey.MENU_KEY.MOBILE_COUPON) btnEnter.Visible = true;
txtCardNo.Text = "";
txtCardNM.Text = "";
txtCouponAmt.Text = "0";
txtPayAmt.Text = m_cPosStatus.Global.NumericTOCurrency(m_cTrnStatus.Sale.RemainPayAmt); // 받을금액
txtiTemAmt.Text = "0";
m_sInPutType = ""; // 입력구분
m_sInPutData = ""; // 입력데이터
m_sInEncData = ""; // 카드데이터
m_sProductiTem = "";
bNotDoubleClik = false;
mPay_DC_Type = ""; // 결제 그룹 코드
mPay_DC_CD = ""; // 결제 상세 코드
// 기능 버튼 설정 체크
FormManager.SetbtnMenu(txtCardNo, m_cDevStatus.ICReader.UseYn, btnMenu1, btnMenu2, btnMenu3, btnMenu4);
InitPayMainBack(m_cPosStatus, m_cDataCommon, m_sPosMenuKey, PosConst.MOT_MSG_TYPE.PAY_STEP_3, "");
txtCardNo.Select();
// 상품정보
ArrayList aSaleItem = (ArrayList)StateObject.GetItemObject(Column.TR_PLU.ITEM);
m_aSaleItem = new ArrayList();
for (int iRow = 0; iRow < aSaleItem.Count; iRow++)
{
Column.TR_PLU.DATA cSaleItem = (Column.TR_PLU.DATA)aSaleItem[iRow];
m_aSaleItem.Add(cSaleItem.Clone());
}
}
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)
{
try
{
if (bNotDoubleClik) return;
bNotDoubleClik = true;
if (((Cosmos.UI.CsmButton)sender) == btnSearch) // 조회
{
SearchTxtInPut();
}
else if (((Cosmos.UI.CsmButton)sender) == btnEnter) // 승인
{
CompleteTxtInPut();
}
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)
{
try
{
if (sFuncValue == PosKey.MENU_KEY.ENTER)
{
if (((Cosmos.UI.CsmPosEditBox)sender) == txtCardNo)
{
SearchTxtInPut();
return;
}
else if (((Cosmos.UI.CsmPosEditBox)sender) == txtCouponAmt)
{
if (txtCardNo.Text == "")
{
SearchTxtInPut();
return;
}
if (txtCardNM.Text == "")
{
SearchTxtInPut();
return;
}
if (CheckTxtInPut(sender, false) == false) return;
if (m_cTrnStatus.Head.TradeDiv == ItemConst.TRAN_DIV.NORMAL)
{
CompleteTxtInPut(); // 할인 승인 처리
}
}
}
else if (sFuncValue == PosKey.MENU_KEY.CLEAR)
{
if (((Cosmos.UI.CsmPosEditBox)sender).ReadOnly == false) ((Cosmos.UI.CsmPosEditBox)sender).Text = "";
if (((Cosmos.UI.CsmPosEditBox)sender) == txtCardNo)
{
m_sInPutType = "";
m_sInPutData = "";
m_sInEncData = "";
txtCardNo.ReadOnly = false;
}
}
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)
{
txtCouponAmt.Value = "0";
txtiTemAmt.Text = "0";
txtCardNM.Text = "";
m_sInPutType = ""; // 입력구분
m_sInPutData = ""; // 입력데이터
m_sInEncData = ""; // 카드데이터
}
#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 < 6)
{
WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0080);
txtCardNo.Focus();
return false;
}
}
if (bSearchMode == false)
{
if (txtCardNM.Text.Trim() == "")
{
WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0043);
txtCardNo.Focus();
return false;
}
if (txtCouponAmt.Value.Length > 10 || m_cDataService.LongParse(txtCouponAmt.Value) <= 0)
{
WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0036);
txtCouponAmt.Focus();
return false;
}
if (CmUtil.AmountCut(m_cDataService.DoubleParse(txtCouponAmt.Value), CmUtil.IntParse(m_cPosStatus.Mst.PayRudDwLoc)) != m_cDataService.DoubleParse(txtCouponAmt.Value))
{
WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0036);
txtCouponAmt.Focus();
return false;
}
if (m_cDataService.DoubleParse(txtCouponAmt.Value.ToString()) > m_cDataService.DoubleParse(txtPayAmt.Text.ToString()))
{
WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0138);
txtCouponAmt.Focus();
return false;
}
if (m_cDataService.DoubleParse(txtCouponAmt.Value.ToString()) > m_cDataService.DoubleParse(txtiTemAmt.Text.ToString()))
{
WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0150);
txtCouponAmt.Focus();
return false;
}
}
// 승인 요청시 금액 체크
if (bSearchMode == false)
{
if (mPay_DC_Type == ItemConst.TR_ITEM_ID.MOBILECON_ITEM && mPay_DC_CD == ItemConst.TR_ITEM_ID.MOBILECON.HPCON)
{
// 해피콘 최소 입력 금액 체크
if (m_cDataService.DoubleParse(txtCouponAmt.Value) < 2500)
{
string stmp = string.Format(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0243), m_cPosStatus.Global.NumericTOCurrency(2500));
WinManager.ErrorMessage(stmp);
txtCouponAmt.Focus();
return false;
}
}
//if (mPay_DC_Type == ItemConst.TR_ITEM_ID.MOBILECON_ITEM && mPay_DC_CD == ItemConst.TR_ITEM_ID.MOBILECON.GIFTCON)
//{
// // 기프티콘 최소 입력 금액 체크
// Column.TR_PAYMENT.DATA m_cPayItem = (Column.TR_PAYMENT.DATA)m_cMobileCoupon.GetPayment(new string[] { });
// if (m_cPayItem.OCCUR_ENTRY_10.Trim() == "03" || m_cPayItem.OCCUR_ENTRY_10.Trim() == "04")
// {
// // 상품종류 (01: 일반상품, 02: 상품권(Gifticon을 종이상품권으로), 03: 정액 할인, 04: 특정 상품 할인, 05: 배송 상품, 06: 금액 차감권, 07: 수량 차감권, 08: 정기권)
// if (m_cDataService.DoubleParse(txtCouponAmt.Value) < m_cDataService.DoubleParse(m_cPayItem.AMT_ENTRY_03.ToString()))
// {
// string stmp = string.Format(MessageManager.GetGuideMessage(POS_MESSAGE.GUIDE.MSG_0014), m_cPosStatus.Global.NumericTOCurrency(m_cDataService.DoubleParse(m_cPayItem.AMT_ENTRY_03.ToString())));
// WinManager.ErrorMessage(stmp);
// txtCouponAmt.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 bool CompleteTxtInPut()
{
string sRet = UserCom.RST_ERR;
try
{
if (CheckTxtInPut(null, false) == false) return false;
string sInPutType = m_sInPutType;
string sInPutData = m_sInPutData;
string sInEncData = m_sInEncData;
if (m_sInEncData == "")
{
if (m_sInPutData == "")
{
sInPutType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_KEYIN_CP;
sInPutData = txtCardNo.Value;
}
///EncryptedCardNo(sInPutData, ref sInEncData, ref sInPutData);
}
Column.TR_PAYMENT.DATA m_cPayItem = (Column.TR_PAYMENT.DATA)m_cMobileCoupon.GetPayment(new string[] { });
// 상품정보
ArrayList aSaleItem = (ArrayList)StateObject.GetItemObject(Column.TR_PLU.ITEM);
m_aSaleItem = new ArrayList();
for (int iRow = 0; iRow < aSaleItem.Count; iRow++)
{
Column.TR_PLU.DATA cSaleItem = (Column.TR_PLU.DATA)aSaleItem[iRow];
m_aSaleItem.Add(cSaleItem.Clone());
}
//string sProductiTem = "";
//double nDCSum = 0;
/////sRet = GetDCItemAmount(m_cPayItem.PAY_DTL_CD_04, sInPutData, "", m_cPayItem.PAY_AMT, ref sProductiTem);
/////if (m_cPayItem.PAY_DTL_CD_04.Trim() != "" && m_cPayItem.OCCUR_ENTRY_10 == "04")
//if (m_cPayItem.PAY_DTL_CD_04.Trim() != "")
//{
// // ProductID로 등록된 상품 체크
// sRet = GetDCItemAmount(m_cPayItem.PAY_DTL_CD_04, sInPutData, "", m_cPayItem.PAY_AMT, ref sProductiTem);
// if (sRet != UserCom.RST_OK) return false;
// txtCouponAmt.Value = m_cPosStatus.Global.NumericTOCurrency(m_cPayItem.PAY_AMT);
// txtiTemAmt.Text = m_cPosStatus.Global.NumericTOCurrency(m_cPayItem.PAY_AMT);
//}
//else if (m_cPayItem.AMT_ENTRY_02 > 0 || nDCSum == 0)
//{
// nDCSum = m_cPayItem.AMT_ENTRY_02;
// txtCouponAmt.Value = m_cPosStatus.Global.NumericTOCurrency(nDCSum);
// txtiTemAmt.Text = m_cPosStatus.Global.NumericTOCurrency(nDCSum);
//}
// 승인 처리
sRet = m_cMobileCoupon.SetPayment(new string[] { m_sPosMenuKey, sInPutType, sInPutData, sInPutData, m_cDataService.DoubleParse(txtCouponAmt.Value).ToString(), m_cPayItem.OCCUR_ENTRY_02, m_cPayItem.OCCUR_ENTRY_03, m_cPayItem.OCCUR_ENTRY_04, mPay_DC_Type, mPay_DC_CD, "", m_sProductiTem });
if (sRet != UserCom.RST_OK) return false;
if (m_sPosMenuKey == PosKey.MENU_KEY.MOBILE_COUPON)
{
this.DialogResult = DialogResult.OK;
this.Close();
}
return 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 false;
}
/// <summary>
/// 조회 처리
/// </summary>
/// <returns></returns>
private bool SearchTxtInPut()
{
string sRet = UserCom.RST_ERR;
try
{
if (CheckTxtInPut(null, true) == false) return false;
// Prefix에 의한 사용 Van 정보 조회
if (GetPrefixToPayTypeInfo(txtCardNo.Text) == false) return false;
///if (mPay_DC_Type == ItemConst.TR_ITEM_ID.MOBILECON_ITEM && mPay_DC_CD == ItemConst.TR_ITEM_ID.MOBILECON.HPCON && CmUtil.MidH (txtCardNo.Value, 0, 3) == "920")
if (mPay_DC_Type == ItemConst.TR_ITEM_ID.MOBILECON_ITEM && mPay_DC_CD == ItemConst.TR_ITEM_ID.MOBILECON.HPCON )
{
// 차세대 해피콘
if (m_sPosMenuKey == PosKey.MENU_KEY.MOBILE_COUPON)
{
sRet = WinPay.ShowForm(new string[] { FormManager.FORM_PAY_MOBILE_COUPON_HAPPYCON, PosKey.MENU_KEY.MOBILE_COUPON_HAPPYCON, txtCardNo.Value.Trim().ToString() });
this.DialogResult = DialogResult.OK;
this.Close();
}
else if (m_sPosMenuKey == PosKey.MENU_KEY.MOBILE_COUPON_SCH)
{
sRet = WinPay.ShowForm(new string[] { FormManager.FORM_PAY_MOBILE_COUPON_HAPPYCON, PosKey.MENU_KEY.MOBILE_COUPON_HAPPYCON_SCH, txtCardNo.Value.Trim().ToString() });
this.DialogResult = DialogResult.Cancel;
this.Close();
}
return true;
}
string sInPutType = m_sInPutType;
string sInPutData = m_sInPutData;
string sInEncData = m_sInEncData;
if (m_sInEncData == "")
{
if (m_sInPutData == "")
{
sInPutType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_KEYIN_CP;
sInPutData = txtCardNo.Value;
}
///EncryptedCardNo(sInPutData, ref sInEncData, ref sInPutData);
}
// 조회
string[] saRecvdData = null;
txtCouponAmt.Value = "0";
txtiTemAmt.Text = "0";
txtCardNM.Text = "";
m_sProductiTem = "";
double nDCSum = 0;
sRet = m_cMobileCoupon.SearchPayment(new string[] { m_sPosMenuKey, sInPutType, sInPutData, sInPutData, m_cDataService.DoubleParse(txtPayAmt.Text).ToString(), "", "", "", mPay_DC_Type, mPay_DC_CD }, ref saRecvdData);
if (sRet != UserCom.RST_OK)
{
txtCardNo.Select();
txtCardNo.SelectText();
return false;
}
Column.TR_PAYMENT.DATA m_cPayItem = (Column.TR_PAYMENT.DATA)m_cMobileCoupon.GetPayment(new string[] { });
///if (m_cPayItem.PAY_DTL_CD_04.Trim() != "" && m_cPayItem.OCCUR_ENTRY_10 == "04")
if (m_cPayItem.PAY_DTL_CD_04.Trim() != "")
{
// ProductID로 등록된 상품 체크
sRet = GetDCItemAmount(m_cPayItem.PAY_DTL_CD_04, sInPutData, " ", m_cPayItem.PAY_AMT, ref nDCSum, ref m_sProductiTem);
if (sRet != UserCom.RST_OK) return false;
txtCouponAmt.Value = m_cPosStatus.Global.NumericTOCurrency(m_cPayItem.PAY_AMT);
txtiTemAmt.Text = m_cPosStatus.Global.NumericTOCurrency(CmUtil.DoubleAdd(nDCSum, m_cPayItem.PAY_AMT));
}
//else if (m_cPayItem.AMT_ENTRY_02 > 0 || nDCSum == 0)
else if (m_cPayItem.AMT_ENTRY_02 > 0)
{
nDCSum = m_cPayItem.AMT_ENTRY_02;
txtCouponAmt.Value = m_cPosStatus.Global.NumericTOCurrency(nDCSum);
txtiTemAmt.Text = m_cPosStatus.Global.NumericTOCurrency(nDCSum);
}
else if (m_cPayItem.PAY_AMT > 0 )
{
nDCSum = m_cPayItem.PAY_AMT;
txtCouponAmt.Value = m_cPosStatus.Global.NumericTOCurrency(nDCSum);
txtiTemAmt.Text = m_cPosStatus.Global.NumericTOCurrency(nDCSum);
}
if (mPay_DC_Type == ItemConst.TR_ITEM_ID.MOBILECON_ITEM && mPay_DC_CD == ItemConst.TR_ITEM_ID.MOBILECON.HPCON)
// 해피 쿠폰인 경우 금액수정 가능
txtCouponAmt.ReadOnly = false;
else
txtCouponAmt.ReadOnly = true;
txtCardNM.Text = PosMstManager.GetMstPayDc(mPay_DC_Type, mPay_DC_CD, PosMst.MST_PAY_DC.DATA.PAY_DC_NM); // 쿠폰명
txtCardNo.Select();
txtCardNo.SelectText();
return 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 false;
}
#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)
{
try
{
string sScanData = m_cDevStatus.Scanner.DataLabel;
if (sScanData.Length > 0 && m_sInPutData == "")
{
m_sInPutType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_BARCODE_CP;
m_sInPutData = sScanData;
txtCardNo.Text = m_sInPutData;
//txtCardNo.ReadOnly = true;
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
{
sEncData = m_cDeviceICReader.GetEncryptedCardNo(sInData).Trim();
if (CmUtil.MidH(sEncData, 0, 2) == "00")
{
sCardData = CmUtil.MidH(sEncData, 2, 512).Trim();
sCardNo = CmUtil.MidH(sEncData, 514, sEncData.Length - 514).Trim();
}
else
{
//암호화 처리 실패!
UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", "Fail =>" + sInData);
}
}
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
{
m_sInPutType = "";
m_sInPutData = "";
m_sInEncData = "";
txtCardNo.Value = "";
txtCardNo.ReadOnly = false;
string sRsvStr = "";
if (m_cDeviceICReader.GetCardInfo_ICReader(PosConst.IC_READER_TRAN_TYPE.POINT, 1, ref sRsvStr) == true)
{
if (CmUtil.MidH(sRsvStr, 0, 2) == "00")
{
txtCardNo.Value = CmUtil.MidH(sRsvStr, 1030, 37).Trim();
m_sInEncData = CmUtil.MidH(sRsvStr, 6, 512).Trim();
m_sInPutData = CmUtil.MidH(sRsvStr, 1030, 37).Trim();
m_sInPutType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_SWIP;
//txtCardNo.ReadOnly = true;
return 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 false;
}
#endregion
#region Prefix에 Van
/// <summary>
/// Prefix에 의한 사용 Van 정보 조회
/// </summary>
/// <param name="sCardNo"></param>
/// <returns></returns>
private bool GetPrefixToPayTypeInfo(string sCardNo)
{
try
{
if (sCardNo.Length == 0) return false;
// PreFix 검색
DataTable dtVanInfo = m_cDataCommon.SeletPrefixToPayTypeInfo(sCardNo);
if (dtVanInfo == null || dtVanInfo.Rows.Count <= 0)
{
WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0080);
return false;
}
DataRow drVanInfo = dtVanInfo.Rows[0];
// 결제 그룹 코드
mPay_DC_Type = CmUtil.GetDataRowStr(drVanInfo, "PAY_DC_GRP_TYPE");
// 결제 상세 코드
mPay_DC_CD = CmUtil.GetDataRowStr(drVanInfo, "PAY_DC_CD");
return 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 false;
}
#endregion
#region ProductID로
/// <summary>
/// ProductID로 등록된 상품 체크
/// </summary>
/// <param name="sProductID"></param>
/// <param name="sCouponNo"></param>
/// <param name="sVCouponNo"></param>
/// <param name="nPayAmt"></param>
/// <param name="nDCAmt"></param>
/// <param name="siTemCheck"></param>
/// <returns></returns>
public string GetDCItemAmount(string sProductID, string sCouponNo, string sVCouponNo, double nPayAmt, ref double nDCAmt, ref string siTemCheck)
{
string sRet = UserCom.RST_ERR;
double niTemSum = 0;
double nQty = 0;
int iMaxIndex = -1;
try
{
// 프로덕트 id 없으면 Skip
if (sProductID.Trim().Length <= 0) return sRet;
// 쿠폰 List 조회
DataTable dtMemu = m_cDataCommon.SeletProductIDToItemCD(sProductID);
if (dtMemu == null || dtMemu.Rows.Count <= 0)
{
//WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0149);
return sRet = UserCom.RST_OK ;
}
ITEM_PLU_CHECK iTemCheck = new ITEM_PLU_CHECK();
if (m_aSaleItem.Count <= 0)
{
WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0149);
return sRet;
}
foreach (DataRow dr in dtMemu.Rows)
{
// Product ID로 결제구분을 재설정한다.
string sDC_Type = CmUtil.GetDataRowStr(dr, "PAY_DC_GRP_TYPE").Trim();
if (sDC_Type.Trim().Length > 0) mPay_DC_Type = sDC_Type.Trim();
// Product ID로 결제상세코드를 재설정한다.
string sDC_CD = CmUtil.GetDataRowStr(dr, "PAY_DC_CD").Trim();
if (sDC_Type.Trim().Length > 0) mPay_DC_CD = sDC_CD.Trim();
for (int iRow = 0; iRow < m_aSaleItem.Count; iRow++)
{
Column.TR_PLU.DATA cSaleItem = (Column.TR_PLU.DATA)m_aSaleItem[iRow];
if (cSaleItem.CANCEL_DIV == PosConst.CANCEL_DIV.CANCEL || cSaleItem.CANCEL_DIV_MAIN == PosConst.CANCEL_DIV.CANCEL) continue;// 지정취소
if (cSaleItem.DC_DIV == ItemConst.PLU_DC_DIV.FREE) continue; // 서비스(무료)
if (cSaleItem.NONSALES_RSN_CD != "0") continue; // 비매출구분
if (cSaleItem.BILLSPR_NO != m_cTrnStatus.Sale.BillSplitNo) continue; // 빌분리번호
if (cSaleItem.BILL_AMT <= 0) continue; // 영수금액
//if (cSaleItem.DC_PRMT_YN != "0") continue; // 할인가능 여부
if (CmUtil.GetDataRowStr(dr, "ITEM_CHECK_YN") == "1")
{
// 등록된 상품과 쿠폰마스터 상품 체크용 저장
if (CmUtil.GetDataRowStr(dr, "ITEM_CD") == cSaleItem.ITEM_PLU_CD)
{
// 할인 대상 iTemCD/수량 체크용 저장
nQty = CmUtil.GetDataRowDouble(dr, "QTY");
// 할인금액+결제요금액 보다 상품판매금액이 같거나 큰 경우만
if (nQty > 0 && cSaleItem.SALE_QTY > 0 && cSaleItem.BILL_AMT >= nPayAmt + CmUtil.GetDataRowDouble(dr, "DC_AMT"))
{
// 제일 큰 금액에 설정
if (iTemCheck.SALE_PRC == 0 || iTemCheck.SALE_PRC < cSaleItem.SALE_PRC)
{
iMaxIndex = iRow;
iTemCheck.sCouponNo = sCouponNo.Trim();
iTemCheck.sVCouponNo = sVCouponNo.Trim();
iTemCheck.sProductID = CmUtil.GetDataRowStr(dr, "PRODUCT_CD").Trim();
iTemCheck.iTemCD = cSaleItem.ITEM_PLU_CD;
iTemCheck.SALE_PRC = cSaleItem.SALE_PRC;
iTemCheck.SaleAmt = cSaleItem.BILL_AMT;
iTemCheck.PayAmt = nPayAmt;
iTemCheck.DCAmt = CmUtil.GetDataRowDouble(dr, "DC_AMT");
// 대상 금액 sum
niTemSum = CmUtil.DoubleAdd(CmUtil.GetDataRowDouble(dr, "DC_AMT"), nPayAmt);
}
}
}
}
else
{
nQty = CmUtil.GetDataRowDouble(dr, "QTY");
if (nQty > 0 && cSaleItem.SALE_QTY > 0 && cSaleItem.BILL_AMT >= nPayAmt + CmUtil.GetDataRowDouble(dr, "DC_AMT"))
{
// 제일 큰 금액에 설정
if (iTemCheck.SALE_PRC == 0 || iTemCheck.SALE_PRC < cSaleItem.SALE_PRC)
{
iMaxIndex = iRow;
iTemCheck.sCouponNo = sCouponNo.Trim();
iTemCheck.sVCouponNo = sVCouponNo.Trim();
iTemCheck.sProductID = CmUtil.GetDataRowStr(dr, "PRODUCT_CD").Trim();
iTemCheck.iTemCD = cSaleItem.ITEM_PLU_CD;
iTemCheck.SALE_PRC = cSaleItem.SALE_PRC;
iTemCheck.SaleAmt = cSaleItem.BILL_AMT;
iTemCheck.PayAmt = nPayAmt;
iTemCheck.DCAmt = CmUtil.GetDataRowDouble(dr, "DC_AMT");
// 대상 금액 sum
niTemSum = CmUtil.DoubleAdd(CmUtil.GetDataRowDouble(dr, "DC_AMT"), nPayAmt);
}
}
}
}
}
// 적용 상품의 상품금액 변경
if (iMaxIndex > -1)
{
Column.TR_PLU.DATA cSaleItem = (Column.TR_PLU.DATA)m_aSaleItem[iMaxIndex];
cSaleItem.CPN_DC_DIV = mPay_DC_Type + mPay_DC_CD;
cSaleItem.CPN_DC_AMT = CmUtil.DoubleAdd(cSaleItem.CPN_DC_AMT, iTemCheck.DCAmt);
cSaleItem.BILL_AMT = CmUtil.DoubleSubtraction(cSaleItem.BILL_AMT, iTemCheck.DCAmt);
nDCAmt = iTemCheck.DCAmt;
}
//// 구매수량 체크
//for (int index = 0; index < m_aSaleItem.Count; index++)
//{
// if (iTemCheck.iTemCD != "")
// {
// if (iTemCheck.T_Qty >= 0 && iTemCheck.S_Qty != 0)
// {
// WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0160);
// return sRet;
// }
// }
//}
// 금액 체크
if (niTemSum > m_cDataService.DoubleParse(txtPayAmt.Text.ToString()))
{
WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0160);
return sRet;
}
// 가능한 상품 미존재시
if (niTemSum <= 0)
{
WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0149);
return sRet;
}
// 프로덕트 정보 체크용
if (iTemCheck.sCouponNo.Trim() != "")
{
siTemCheck += iTemCheck.sCouponNo;
siTemCheck += "!~";
siTemCheck += iTemCheck.sVCouponNo;
siTemCheck += "!~";
siTemCheck += iTemCheck.sProductID;
siTemCheck += "!~";
siTemCheck += iTemCheck.iTemCD;
siTemCheck += "!~";
siTemCheck += iTemCheck.PayAmt;
siTemCheck += "!~";
siTemCheck += iTemCheck.DCAmt;
siTemCheck += "$~";
}
sRet = UserCom.RST_OK;
}
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
//#15608 모바일쿠폰해피기프트카드 자동인식 기능 도입요청 start
#region
public void txtEditBox_EditBoxKeyDownEvent(object sender, string _strMobileCpnNo, object _strDiv)
{
#region (_strDiv) ''() .
if (_strDiv == null)
{
// 카드 번호 설정
txtCardNo.Value = _strMobileCpnNo;
// 카드 번호 설정 후 clear
m_cPosStatus.Sale.strMobileCpnNo = "";
}
#endregion
#region (_strDiv) '' .
else if (((Cosmos.UI.CsmButton)_strDiv) == btnSearch)
{
// 카드 번호 설정 -----
txtCardNo.Value = _strMobileCpnNo;
// 카드 번호 설정 후 clear
m_cPosStatus.Sale.strMobileCpnNo = "";
// 카드 조회 이벤트 호출 -----
txtEditBox_EditBoxKeyDownEvent(txtCardNo, PosKey.MENU_KEY.ENTER);
}
#endregion
#region (_strDiv) '' .
else if (((Cosmos.UI.CsmButton)_strDiv) == btnEnter)
{
// 카드 번호 설정
txtCardNo.Value = _strMobileCpnNo;
// 카드 번호 설정 후 clear
m_cPosStatus.Sale.strMobileCpnNo = "";
// 카드 조회 이벤트 호출
txtEditBox_EditBoxKeyDownEvent(txtCardNo, PosKey.MENU_KEY.ENTER);
// 카드 승인 이벤트 호출
btnProc_Click(btnEnter, null);
}
#endregion
}
#endregion
//#15608 모바일쿠폰해피기프트카드 자동인식 기능 도입요청 end
}
}