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

1651 lines
82 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 frmMobileCouponHappyCon : Form
{
#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; } }
private string m_sCouponCD;
/// <summary>
/// 외부 입력 쿠폰번호
/// </summary>
public string SetCouponCD { set { this.m_sCouponCD = value; } }
/// <summary>
/// 입력구분
/// </summary>
private string m_sInPutType = "";
/// <summary>
/// 입력데이터
/// </summary>
private string m_sInPutData = "";
/// <summary>
/// 카드데이터
/// </summary>
private string m_sInEncData = "";
/// <summary>
/// 사용가능/불가 펼기기 상태
/// </summary>
private bool m_bUseViewMode = false;
/// <summary>
/// 결제금액 체크용
/// </summary>
private double m_nSaleAmount = 0;
/// <summary>
/// 상품정보 작업용
/// </summary>
private ArrayList m_aSaleItem = null;
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; // 할인
}
private string[] m_aRecvdData = null;
#endregion
#region & &
public frmMobileCouponHappyCon()
{
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_HAPPYCON);
m_cDataCommon = (IDataCommonUs)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.DATA_COMMON);
delegatePos = new PosOLEDevice.DelegateOlePos(OnDeviceEvent);
}
private void frmMobileCouponHappyCon_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 frmMobileCouponHappyCon_Activated(object sender, EventArgs e)
{
PosOLEDevice.SetEventHandle(delegatePos);
}
private void frmMobileCouponHappyCon_Deactivate(object sender, EventArgs e)
{
PosOLEDevice.SetEventHandle(null);
}
private void frmMobileCouponHappyCon_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);
}
/// <summary>
/// 폼 컨트롤 초기화
/// </summary>
private void InitControl()
{
try
{
// 이미지 로딩 처리
this.Size = new Size(800, 578);
this.Location = new Point(1024 - 800 - 10, 768 - 600);
picBack.Image = ImageManager.GetImage(BaseCom.NxImgPath, ImageManager.POP_SIZE_800X578);
picBack.Location = new Point(0, 0);
btnExit.Image = ImageManager.GetImage(BaseCom.NxImgPath, ImageManager.BTN_CLOSE);
if (btnExit.Image != null) btnExit.Text = "";
if (m_sPosMenuKey == PosKey.MENU_KEY.MOBILE_COUPON_HAPPYCON_SCH)
{
FormManager.MovePopUpForm(this, false, m_cPosStatus.Sale.ScreenSizeUser);
}
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);
//테마색상 적용!
btnEnter.BackColor = CmUtil.GetColorToString(m_cPosStatus.ScnMst.ThemeColor);
padInPut.ThemeColor = m_cPosStatus.ScnMst.ThemeColor;
padInPut.ClearBtnText = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0817);
padInPut.SearchBtnText = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_1018);
//버튼이미지 적용
btnAllUp.Image = ImageManager.GetImage(BaseCom.NxImgPath, ImageManager.NAVIBTN_14X9_UP2_BASIC);
btnAllUp.ImageAlign = ContentAlignment.MiddleCenter;
btnAllUp.BorderStyle = BorderStyle.None;
btnAllDw.Image = ImageManager.GetImage(BaseCom.NxImgPath, ImageManager.NAVIBTN_14X9_DOWN2_BASIC);
btnAllDw.ImageAlign = ContentAlignment.MiddleCenter;
btnAllDw.BorderStyle = BorderStyle.None;
if (btnAllUp.Image != null) btnAllUp.Text = "";
if (btnAllDw.Image != null) btnAllDw.Text = "";
btnExit.Image = ImageManager.GetImage(BaseCom.NxImgPath, ImageManager.BTN_CLOSE);
if (btnExit.Image != null) btnExit.Text = "";
// 모바일쿠폰
if (m_sPosMenuKey == PosKey.MENU_KEY.MOBILE_COUPON_HAPPYCON) lblTitle.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0616);
else if (m_sPosMenuKey == PosKey.MENU_KEY.MOBILE_COUPON_HAPPYCON_SCH) lblTitle.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0616);
lblCardNo.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0139);
btnSearch.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0004);
btnEnter.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0629);
btnDelete.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0021);
lblTitle1.Font = new Font(m_cPosStatus.Base.FONT, 12);
lblTitle1.Text = MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0404);
txtPayAmt.Text = m_cPosStatus.Global.NumericTOCurrency(m_cTrnStatus.Sale.RemainPayAmt); // 받을금액
m_sInPutType = ""; // 입력구분
m_sInPutData = ""; // 입력데이터
m_sInEncData = ""; // 카드데이터
//#20171101 해피콘 조회 시 사용한 쿠폰 표시되도록 수정 start
//m_bUseViewMode = false;
m_bUseViewMode = true;
//#20171101 해피콘 조회 시 사용한 쿠폰 표시되도록 수정 end
bNotDoubleClik = false;
m_nSaleAmount = 0;
m_aRecvdData = null;
mPay_DC_Type = ""; // 결제 그룹 코드
mPay_DC_CD = ""; // 결제 상세 코드
btnEnter.Visible = false;
if (m_sPosMenuKey == PosKey.MENU_KEY.MOBILE_COUPON_HAPPYCON) btnEnter.Visible = true;
// 상품정보
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[] aRet = null;
string aRet2 = null;
string aRet3 = null;
DataGridSetting(0, ref aRet, ref aRet2, ref aRet3); // 초기화
txtCardNo.Text = m_sCouponCD;
if (m_sCouponCD.Trim() != "") btnProc_Click(btnSearch, null);
txtCardNo.Select();
txtCardNo.SelectText();
}
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[] aRet = null;
string aRet2 = null;
string aRet3 = null;
try
{
if (bNotDoubleClik) return;
bNotDoubleClik = true;
if ((UI.CsmButton)sender == btnAllUp) // 상단 그리드 Up
{
if (dgvData.Rows.Count == 0)
{
bNotDoubleClik = false;
return;
}
if (dgvData.CurrentRow.Index > 0)
{
for (int iLoop = dgvData.CurrentRow.Index - 1; iLoop >= 0; iLoop--)
{
if (dgvData.Rows[iLoop].Visible == false) continue;
dgvData.Rows[iLoop].Selected = true;
dgvData.Rows[iLoop].Cells[dgvData.CurrentCell.ColumnIndex].Selected = true;
break;
}
}
}
else if ((UI.CsmButton)sender == btnAllDw) // 상단 그리드 Down
{
if (dgvData.Rows.Count == 0)
{
bNotDoubleClik = false;
return;
}
if (dgvData.CurrentRow.Index < dgvData.Rows.Count - 1)
{
for (int iLoop = dgvData.CurrentRow.Index + 1; iLoop <= dgvData.Rows.Count - 1; iLoop++)
{
if (dgvData.Rows[iLoop].Visible == false) continue;
dgvData.Rows[iLoop].Selected = true;
dgvData.Rows[iLoop].Cells[dgvData.CurrentCell.ColumnIndex].Selected = true;
break;
}
}
}
else if (((Cosmos.UI.CsmButton)sender) == btnSearch) // 조회
{
SearchTxtInPut(PosConst.POS_INQ_MODE.SEARCH, "", "");
}
else if (((Cosmos.UI.CsmButton)sender) == btnSearchDtl) // 사용 이력 조회
{
if (dgvData.Rows.Count > 0)
{
if (dgvData.CurrentRow.Index >= 0)
{
if (dgvData.Rows[dgvData.CurrentRow.Index].Cells[0].ReadOnly == true)
{
WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0412);
bNotDoubleClik = false;
return;
}
string sCouponNo = dgvData.Rows[dgvData.CurrentRow.Index].Cells[2].Value.ToString().Trim();
string sVirtualCouponNo = dgvData.Rows[dgvData.CurrentRow.Index].Cells[3].Value.ToString().Trim();
if (SearchTxtInPut(PosConst.POS_INQ_MODE.SEARCH_LOG, sCouponNo, sVirtualCouponNo) == UserCom.RST_OK )
{
// 로그조회 팝업
frmMobileCouponHappyConLog fForm = (frmMobileCouponHappyConLog)FormManager.GetForm(FormManager.FORM_PAY_MOBILE_COUPON_HAPPYCON_LOG);
if (fForm == null)
{
fForm = new frmMobileCouponHappyConLog();
FormManager.AddForm(FormManager.FORM_PAY_MOBILE_COUPON_HAPPYCON_LOG, fForm);
}
fForm.SetPosMenuKey = m_sPosMenuKey;
fForm.SetCouponCD = sCouponNo;
fForm.SetVCouponCD = sVirtualCouponNo;
fForm.SetCouponInfo = m_aRecvdData;
fForm.ShowDialog();
}
}
}
}
else if (((Cosmos.UI.CsmButton)sender) == btnEnter) // 승인
{
CompleteTxtInPut();
}
else if (((Cosmos.UI.CsmButton)sender) == btnDelete) // 삭제
{
DataGridSetting(2, ref aRet, ref aRet2, ref aRet3);
}
else if (((Cosmos.UI.CsmButton)sender) == btnDetail) // 사용가능
{
DataGridSetting(3, ref aRet, ref aRet2, ref aRet3);
}
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;
}
finally
{
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)
{
btnProc_Click(btnSearch, null);
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)
{
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 (bSearchMode == false)
{
if (dgvData.RowCount <= 0)
{
WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0043);
txtCardNo.Focus();
return false;
}
if (m_nSaleAmount > m_cDataService.DoubleParse(txtPayAmt.Text.ToString()))
{
WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0138);
return false;
}
if (m_nSaleAmount <= 0)
{
WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0409);
return false;
}
}
else
{
// 카드번호 길이 체크
if (sender == null || ((Cosmos.UI.CsmPosEditBox)sender) == txtCardNo)
{
if (txtCardNo.Value.Length < 6)
{
WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0080);
txtCardNo.Select();
txtCardNo.SelectText();
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[] aCouponInfo = null;
string sCouponType = null;
string sProductiTem = null;
string sRet = UserCom.RST_ERR;
try
{
// 상품정보
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());
}
// 결제금액 Sum
sRet = DataGridSetting(5, ref aCouponInfo, ref sCouponType, ref sProductiTem);
if (sRet != UserCom.RST_OK) return false;
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);
}
// 승인 처리
sRet = m_cMobileCoupon.SetPayment(new string[] { m_sPosMenuKey, sInPutType, sInPutData, sInPutData, "0", "", "", "", mPay_DC_Type, mPay_DC_CD, aCouponInfo[0], sCouponType, sProductiTem });
if (sRet != UserCom.RST_OK) return false; // 오류시 종료 안함(2017.05.22)
if (m_sPosMenuKey == PosKey.MENU_KEY.MOBILE_COUPON_HAPPYCON)
{
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 string SearchTxtInPut(string sSearchType, string sCouponNo, string VirtualCouponNo)
{
string[] aRet = null;
string aRet2 = null;
string aRet3 = null;
string sRet = UserCom.RST_ERR;
string sCoponinfo = "";
string sInPutType = "";
string sInPutData = "";
string sInEncData = "";
try
{
// 조회
if (sSearchType == PosConst.POS_INQ_MODE.SEARCH)
{
if (CheckTxtInPut(null, true) == false) return sRet;
// 중복체크
if (DataGridSetting(4, ref aRet, ref aRet2, ref aRet3) != UserCom.RST_OK) return sRet;
// Prefix에 의한 사용 Van 정보 조회
if (GetPrefixToPayTypeInfo(txtCardNo.Text) == false) return sRet;
sInPutType = m_sInPutType;
sInPutData = m_sInPutData;
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);
}
}
if (sSearchType == PosConst.POS_INQ_MODE.SEARCH_LOG)
{
// 쿠폰 이력 조회
sCoponinfo = CmUtil.MidH(sCouponNo, 0, 32) ;
sCoponinfo += CmUtil.MidH(VirtualCouponNo, 0, 32);
}
m_aRecvdData = null;
sRet = m_cMobileCoupon.SearchPayment(new string[] { m_sPosMenuKey, sInPutType, sInPutData, sInPutData, m_cDataService.DoubleParse(txtPayAmt.Text).ToString(), "", "", "", mPay_DC_Type, mPay_DC_CD, sSearchType, sCoponinfo }, ref m_aRecvdData);
if (sRet != UserCom.RST_OK) return sRet;
if (sSearchType == PosConst.POS_INQ_MODE.SEARCH)
{
// 그리드에 추가
sRet = DataGridSetting(1, ref m_aRecvdData, ref aRet2, ref aRet3);
if (sRet != UserCom.RST_OK) return sRet;
}
txtCardNo.Text = "";
txtCardNo.Select();
txtCardNo.SelectText();
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
/// <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)
{
try
{
string sMsrData = m_cDevStatus.Msr.Track2Data;
if (sMsrData.Length > 0 && m_sInPutData == "")
{
m_sInPutType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_SWIP;
m_sInPutData = sMsrData;
txtCardNo.Text = m_sInPutData;
//txtCardNo.ReadOnly = true;
if (m_cTrnStatus.Head.TradeDiv == ItemConst.TRAN_DIV.NORMAL) btnProc_Click(btnSearch, null);
}
}
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="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) btnProc_Click(btnSearch, null);
}
}
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 ProductID로
/// <summary>
/// ProductID로 등록된 상품 체크
/// </summary>
/// <param name="sProductID"></param>
/// <param name="sCouponNo"></param>
/// <param name="sVCouponNo"></param>
/// <param name="nPayAmt"></param>
/// <param name="siTemCheck"></param>
/// <returns></returns>
public string GetDCItemAmount(string sProductID, string sCouponNo, string sVCouponNo, double nPayAmt, string sItemChgUse, 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 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");
// 프로덕트 코드 미설정 오류로 인한 수정(2017.05.18)
//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);
}
//// 구매수량 체크
//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 && sItemChgUse == "1")
{
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
#region
private string DataGridSetting(int iWorkMode, ref string[] aRet, ref string sCounponIfo, ref string siTemCheck)
{
string sRet = UserCom.RST_ERR;
try
{
if (iWorkMode == 0)
{
#region
dgvData.Rows.Clear();
dgvData.AllowUserToAddRows = false;
dgvData.EnableHeadersVisualStyles = false;
dgvData.RowsDefaultCellStyle.BackColor = Color.White;
dgvData.AlternatingRowsDefaultCellStyle.BackColor = Color.FromArgb(249, 249, 249);
dgvData.RowHeadersDefaultCellStyle.SelectionBackColor = Color.FromArgb(255, 192, 128);
dgvData.EditMode = DataGridViewEditMode.EditProgrammatically;
dgvData.Font = this.Font;
dgvData.DefaultCellStyle.Font = new Font(m_cPosStatus.Base.FONT, 8);
//dgvData.DefaultCellStyle.SelectionBackColor = Color.Transparent;
dgvData.Font = new Font(m_cPosStatus.Base.FONT, 10);
dgvData.RowHeadersDefaultCellStyle.Font = new Font(m_cPosStatus.Base.FONT, 10);
// 타이틀 설정
dgvData.Columns[0].HeaderText = "V";
dgvData.Columns[1].HeaderText = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0617);
dgvData.Columns[2].HeaderText = "COUPONNO";
dgvData.Columns[3].HeaderText = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0618);
dgvData.Columns[4].HeaderText = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0619);
dgvData.Columns[5].HeaderText = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0052);
dgvData.Columns[6].HeaderText = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0620);
dgvData.Columns[7].HeaderText = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0621);
dgvData.Columns[8].HeaderText = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0622);
dgvData.Columns[9].HeaderText = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0623);
dgvData.Columns[10].HeaderText = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0624);
dgvData.Columns[11].HeaderText = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0049);
#endregion
}
else if (iWorkMode == 1)
{
#region
if (aRet != null)
{
int iRow = 0;
int iStart = 0;
int iAdd = 0;
int iIndex = 0;
string sYYYY = CmUtil.LeftH(DateTime.Now.ToString("yyyy"), 2);
if (aRet.Length > 0)
{
// 가상쿠폰번호 표시
iRow = dgvData.Rows.Add();
dgvData.Rows[iRow].Height = 39; //MoonSeokWoo 2017.11.06 EDIT -> 26 -> * 1.5 = 39
dgvData.Rows[iRow].DefaultCellStyle.BackColor = Color.PowderBlue;
dgvData.Rows[iRow].Visible = true;
dgvData.Rows[iRow].Cells[0].Value = false;
dgvData.Rows[iRow].Cells[0].ReadOnly = true;
dgvData.Rows[iRow].Cells[1].Value = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0139); // 종류
dgvData.Rows[iRow].Cells[2].Value = aRet[2].Trim(); // 쿠폰번호
dgvData.Rows[iRow].Cells[4].Value = aRet[2].Trim(); // 가상쿠폰번호
iStart = 6;
for (int iLoop = 0; iLoop < CmUtil.IntParse(aRet[6].Trim()); iLoop++)
{
// 가상쿠폰 상세 목록
iRow = dgvData.Rows.Add();
dgvData.Rows[iRow].Height = 39; //MoonSeokWoo 2017.11.06 EDIT -> 26 -> * 1.5 = 39
dgvData.Rows[iRow].DefaultCellStyle.BackColor = Color.White;
dgvData.Rows[iRow].Visible = true;
dgvData.Rows[iRow].Cells[0].ReadOnly = false;
dgvData.Rows[iRow].Cells[0].Value = false;
dgvData.Rows[iRow].Cells[1].Value = (aRet[11 + iIndex].Trim() == "1") ? MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0626) : MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0625); // 종류
dgvData.Rows[iRow].Cells[2].Value = aRet[2].Trim(); // 쿠폰번호
dgvData.Rows[iRow].Cells[3].Value = aRet[7 + iIndex].Trim(); // 가상쿠폰번호
dgvData.Rows[iRow].Cells[4].Value = aRet[8 + iIndex].Trim(); // 가상쿠폰명
if (aRet[19 + iIndex].Trim().Length == 6)
{
dgvData.Rows[iRow].Cells[5].Value = sYYYY + aRet[19 + iIndex].Trim() + "\n~" + sYYYY + aRet[20 + iIndex].Trim(); // 유효기간
}
else
{
dgvData.Rows[iRow].Cells[5].Value = aRet[19 + iIndex].Trim() + "\n~" + aRet[20 + iIndex].Trim(); // 유효기간
}
dgvData.Rows[iRow].Cells[6].Value = "";
if (aRet[0].Trim() != "0") dgvData.Rows[iRow].Cells[6].Value = aRet[1].Trim(); // 비고1
dgvData.Rows[iRow].Cells[7].Value = "";
if (aRet[21 + iIndex].Trim() != "Y")
{
//#20171101 해피콘 조회 시 사용한 쿠폰 표시되도록 수정 start
//dgvData.Rows[iRow].Visible = m_bUseViewMode;
//#20180410 해피콘 조회 시 가상쿠폰상태 구분없이 전체 표시 start
//표시 소스 주석
if (aRet[21 + iIndex].Trim() != "D")
{
dgvData.Rows[iRow].Visible = false;
}
//#20180410 해피콘 조회 시 가상쿠폰상태 구분없이 전체 표시 end
//#20171101 해피콘 조회 시 사용한 쿠폰 표시되도록 수정 end
dgvData.Rows[iRow].Cells[7].Value = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0627); // 비고2 사유내용 aRet[22]
}
dgvData.Rows[iRow].Cells[8].Value = m_cPosStatus.Global.NumericTOCurrency(m_cDataService.DoubleParse(aRet[13 + iIndex].Trim())); // 권면가
dgvData.Rows[iRow].Cells[9].Value = m_cPosStatus.Global.NumericTOCurrency(m_cDataService.DoubleParse(aRet[15 + iIndex].Trim())); // 잔액
dgvData.Rows[iRow].Cells[21].Value = m_cDataService.DoubleParse(aRet[16 + iIndex].Trim()); // 가용금액 - 체크용
dgvData.Rows[iRow].Cells[10].Value = m_cPosStatus.Global.NumericTOCurrency(m_cDataService.DoubleParse(aRet[16 + iIndex].Trim())); // 가용금액
dgvData.Rows[iRow].Cells[11].Value = m_cPosStatus.Global.NumericTOCurrency(m_cDataService.DoubleParse("0")); // 결제금액
string siTemCD = "";
iAdd = 0;
for (int iLoop2 = 0; iLoop2 < CmUtil.IntParse(aRet[24 + iIndex].Trim()); iLoop2++)
{
// POS 상품코드 목록
siTemCD += aRet[25 + iIndex + iLoop2].Trim() + "|";
iAdd++;
}
// 사용시 체크사항들
dgvData.Rows[iRow].Cells[12].Value = aRet[5].Trim(); // 동시사용 제약 (0:제약없음, 1:모두 동시사용)
dgvData.Rows[iRow].Cells[13].Value = aRet[12 + iIndex].Trim(); // 쿠폰옵션 (0:옵션없음, 1:타상품 교환불가-상품코드 체크)
dgvData.Rows[iRow].Cells[14].Value = aRet[24 + iIndex].Trim(); // POS상품코드 개수
dgvData.Rows[iRow].Cells[15].Value = siTemCD; // POS상품코드 쿠폰옵션이 1인경우
dgvData.Rows[iRow].Cells[16].Value = aRet[11 + iIndex].Trim(); // 쿠폰종류 (0:물품형, 1:금액형)
dgvData.Rows[iRow].Cells[17].Value = aRet[16 + iIndex].Trim(); // 그룹번호
dgvData.Rows[iRow].Cells[18].Value = aRet[22 + iIndex].Trim(); // 불가사유
dgvData.Rows[iRow].Cells[19].Value = aRet[23 + iIndex].Trim(); // 구성상품순번
dgvData.Rows[iRow].Cells[20].Value = aRet[21 + iIndex].Trim(); // 쿠폰상태 (Y:사용가능, N:사용불가, D:사용됨, C:폐기, R:환불)
iIndex = (24 * (iLoop + 1)) - (iStart * (iLoop + 1)) + iAdd;
}
}
}
#endregion
}
else if (iWorkMode == 2)
{
#region
if (dgvData.RowCount <= 0) return sRet;
if (dgvData.CurrentCell.RowIndex < 0) return sRet;
string sCouponNo = dgvData.Rows[dgvData.CurrentCell.RowIndex].Cells[2].Value.ToString().Trim();
for (int iRow = dgvData.RowCount; iRow > 0 ; iRow--)
{
if (sCouponNo == dgvData.Rows[iRow-1].Cells[2].Value.ToString().Trim())
{
dgvData.Rows.RemoveAt(iRow-1);
}
}
#endregion
}
else if (iWorkMode == 3)
{
#region /
if (dgvData.RowCount <= 0) return sRet;
for (int iRow = 0; iRow < dgvData.RowCount; iRow++)
{
if (m_bUseViewMode == false)
{
dgvData.Rows[iRow].Visible = true;
}
else if (dgvData.Rows[iRow].Cells[0].ReadOnly == false)
{
if (dgvData.Rows[iRow].Cells[20].Value.ToString().Trim() != "Y")
dgvData.Rows[iRow].Visible = false;
else
dgvData.Rows[iRow].Visible = true;
}
}
m_bUseViewMode = !m_bUseViewMode;
#endregion
}
else if (iWorkMode == 4)
{
#region
if (dgvData.RowCount <= 0) return UserCom.RST_OK;
for (int iRow = 0; iRow < dgvData.RowCount; iRow++)
{
if (dgvData.Rows[iRow].Cells[2].Value.ToString().Trim() == txtCardNo.Value.Trim())
{
// 중복 등록 불가
WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0408);
txtCardNo.Select();
txtCardNo.SelectText();
return sRet;
}
}
#endregion
}
else if (iWorkMode == 5)
{
#region Sum
double nPayAmount = 0;
double nQty = 0;
bool biTemCheck = false;
string sSendData = "";
m_nSaleAmount = 0;
siTemCheck = "";
if (dgvData.RowCount <= 0) return sRet;
for (int iRow = 0; iRow < dgvData.RowCount; iRow++)
{
if ((bool)dgvData.Rows[iRow].Cells[0].Value == true)
{
// 선택한 쿠폰만
if (dgvData.Rows[iRow].Cells[12].Value.ToString() == "1")
{
// 모두사용시
string sGroupNo = dgvData.Rows[iRow].Cells[17].Value.ToString().Trim();
for (int iRow2 = 0; iRow2 < dgvData.RowCount; iRow2++)
{
// 동일 그룹 체크
if (dgvData.Rows[iRow2].Cells[17].Value.ToString().Trim() == sGroupNo)
{
// 사용 가능만 체크
if (dgvData.Rows[iRow].Cells[20].Value.ToString().ToUpper().Trim() == "Y")
{
if ((bool)dgvData.Rows[iRow2].Cells[0].Value != true)
{
WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0410);
return sRet;
}
}
}
}
}
if (dgvData.Rows[iRow].Cells[13].Value.ToString() == "1")
{
// 타상품 교환 불가시
string sITemInfo = dgvData.Rows[iRow].Cells[15].Value.ToString().Trim();
string[] aiTemInfo = sITemInfo.Split(new string[] { "|" }, StringSplitOptions.None);
bool bCheckiTem = false;
for (int iRow2 = 0; iRow2 < aiTemInfo.Length; iRow2++)
{
for (int iRow3 = 0; iRow3 < m_aSaleItem.Count; iRow3++)
{
Column.TR_PLU.DATA cSaleItem = (Column.TR_PLU.DATA)m_aSaleItem[iRow3];
if (cSaleItem.CANCEL_DIV == PosConst.CANCEL_DIV.CANCEL || cSaleItem.CANCEL_DIV_MAIN == PosConst.CANCEL_DIV.CANCEL) continue;// 지정취소
if (cSaleItem.ITEM_PLU_CD == aiTemInfo[iRow2].Trim())
{
bCheckiTem = true;
break;
}
}
}
if (bCheckiTem != true)
{
WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0411);
return sRet;
}
}
// 결제 요청금액
nPayAmount = CmUtil.DoubleAdd(m_cDataService.DoubleParse(dgvData.Rows[iRow].Cells[10].EditedFormattedValue.ToString().Trim()), nPayAmount);
nQty++;
// 프로덕트코드가 있고, 쿠폰종류 물품형이면
//#20180329 해피콘 고정금액형 상품 개발 start
//기존
//if (dgvData.Rows[iRow].Cells[19].Value.ToString() != "" && dgvData.Rows[iRow].Cells[16].Value.ToString() == "0")
//변경
if (dgvData.Rows[iRow].Cells[19].Value.ToString() != "" &&
(dgvData.Rows[iRow].Cells[16].Value.ToString() == "0" || dgvData.Rows[iRow].Cells[16].Value.ToString() == "2" || dgvData.Rows[iRow].Cells[16].Value.ToString() == "4"))
//#20180329 해피콘 고정금액형 상품 개발 end
{
// 프로덕트 체크
sRet = GetDCItemAmount(dgvData.Rows[iRow].Cells[19].Value.ToString(), dgvData.Rows[iRow].Cells[2].Value.ToString().Trim(), dgvData.Rows[iRow].Cells[3].Value.ToString().Trim()
, m_cDataService.DoubleParse(dgvData.Rows[iRow].Cells[10].EditedFormattedValue.ToString().Trim()), dgvData.Rows[iRow].Cells[13].Value.ToString(), ref siTemCheck);
if (sRet != UserCom.RST_OK)
{
// 타상품 교환 불가시
if (dgvData.Rows[iRow].Cells[13].Value.ToString() == "1") return sRet;
}
}
sSendData += CmUtil.MidH(dgvData.Rows[iRow].Cells[2].Value.ToString().Trim(), 0, 32); // 쿠폰번호
sSendData += CmUtil.MidH(dgvData.Rows[iRow].Cells[3].Value.ToString().Trim(), 0, 32); // 가상쿠폰번호
sSendData += CmUtil.MidH(m_cDataService.DoubleParse(dgvData.Rows[iRow].Cells[10].EditedFormattedValue.ToString().Trim()).ToString(), 0, 10); // 쿠폰금액 (가용금액)
sCounponIfo += CmUtil.MidH(dgvData.Rows[iRow].Cells[2].Value.ToString().Trim(), 0, 32); // 쿠폰번호
sCounponIfo += "|";
sCounponIfo += CmUtil.MidH(dgvData.Rows[iRow].Cells[3].Value.ToString().Trim(), 0, 32); // 가상쿠폰번호
sCounponIfo += "|";
sCounponIfo += CmUtil.MidH(CmUtil.IntParse(dgvData.Rows[iRow].Cells[16].EditedFormattedValue.ToString()).ToString(), 0, 1); // 쿠폰종류 (0:물품형, 1:금액형)
sCounponIfo += "@~";
if (dgvData.Rows[iRow].Cells[13].Value.ToString() == "1")
{
// 타상품 교환 불가시
biTemCheck = true;
}
}
}
// 상품 정보
if (biTemCheck == true)
{
sSendData += CmUtil.MidH(m_aSaleItem.Count.ToString(), 0, 5); // POS 상품갯수
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;// 지정취소
sSendData += CmUtil.MidH(cSaleItem.ITEM_PLU_CD, 0, 32); // POS 상품코드
// 전문 설정 오류 수정(2017.05.22)
sSendData += CmUtil.MidH(cSaleItem.SALE_AMT.ToString(), 0, 10); // POS 상품금액
//sSendData += m_cDataService.DoubleParse(CmUtil.MidH(cSaleItem.SALE_AMT.ToString(), 0, 10)); // POS 상품금액
}
}
else
{
sSendData += CmUtil.MidH("0", 0, 5); // POS 상품갯수
}
sSendData = CmUtil.MidH(nQty.ToString(), 0, 5) + sSendData; // 사용 쿠폰갯수
sSendData = CmUtil.MidH(nPayAmount.ToString(), 0, 10) + sSendData; // 사용쿠폰 총금액
aRet = new string[] { sSendData } ;
m_nSaleAmount = nPayAmount;
#endregion
}
dgvData.Refresh();
dgvData.Select();
txtCardNo.Select();
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
#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
private void dgvData_CellClick(object sender, DataGridViewCellEventArgs e)
{
double nGiftType = 0;
try
{
if (dgvData.Rows.Count <= 0) return;
//if (e.ColumnIndex == 10) return;
if (e.RowIndex < 0) return;
int iRow = e.RowIndex;
bool bisChecked = !(bool)dgvData.Rows[iRow].Cells[0].Value;
if (CmUtil.IsNull(dgvData.Rows[iRow].Cells[16].Value) != true)
{
nGiftType = CmUtil.IntParse(dgvData.Rows[iRow].Cells[16].Value.ToString()); // 쿠폰종류 (0:물품형, 1:금액형)
}
//#20180329 해피콘 고정금액형 상품 개발 start
//기존
//if (nGiftType == 1)
//변경
if (nGiftType == 1 || nGiftType == 3)
//#20180329 해피콘 고정금액형 상품 개발 end
{
// 금액형은 금액 수정 가능
dgvData.Rows[iRow].Cells[10].ReadOnly = false;
}
else
{
dgvData.Rows[iRow].Cells[10].ReadOnly = true;
}
if (dgvData.CurrentCell != null && e.RowIndex >= 0)
{
// 지정취소 상품 skip
if (dgvData.Rows[e.RowIndex].Visible == false) return;
// 서브타이틀로 사용된 항목 제외
if (dgvData.Rows[e.RowIndex].Cells[0].ReadOnly == true) return;
// 사용불가시 skip
if (dgvData.Rows[e.RowIndex].Cells[7].Value.ToString() != "")
{
WinManager.ErrorMessage(dgvData.Rows[e.RowIndex].Cells[18].Value.ToString().Trim());
return;
}
// 이미 사용시 skip
if (m_cDataService.DoubleParse(dgvData.Rows[e.RowIndex].Cells[11].Value.ToString()) > 0) return;
dgvData.Rows[e.RowIndex].Cells[0].Value = bisChecked;
//#20180329 해피콘 고정금액형 상품 개발 start
//기존
//if (nGiftType == 1)
//변경
if (nGiftType == 1 || nGiftType == 3)
//#20180329 해피콘 고정금액형 상품 개발 end
{
if (bisChecked == true)
{
// 금액형 결제금액 자동 설정용
double nPayAmount = 0;
for (int iLoop = 0; iLoop < dgvData.RowCount; iLoop++)
{
// 지정취소 상품 skip
if (dgvData.Rows[iLoop].Visible == false) continue;
// 서브타이틀로 사용된 항목 제외
if (dgvData.Rows[iLoop].Cells[0].ReadOnly == true) continue;
// 사용불가시 skip
if (dgvData.Rows[iLoop].Cells[7].Value.ToString() != "") continue;
// 미선택 skip
if ((bool)dgvData.Rows[iLoop].Cells[0].Value != true) continue;
if (iLoop != iRow)
nPayAmount = CmUtil.DoubleAdd(m_cDataService.DoubleParse(dgvData.Rows[iLoop].Cells[10].EditedFormattedValue.ToString().Trim()), nPayAmount);
}
//#20180329 해피콘 고정금액형 상품 개발 start
//기존
//if (m_cTrnStatus.Sale.RemainPayAmt > nPayAmount && nGiftType == 1) // 결제금액이 받을금액보다 작고 금액형인 경우만
//변경
if (m_cTrnStatus.Sale.RemainPayAmt > nPayAmount &&
(nGiftType == 1 || nGiftType == 3)) // 결제금액이 받을금액보다 작고 금액형인 경우만
//#20180329 해피콘 고정금액형 상품 개발 end
{
double nMeAmount = m_cDataService.DoubleParse(dgvData.Rows[iRow].Cells[21].EditedFormattedValue.ToString().Trim()); // 가용금액
if (m_cTrnStatus.Sale.RemainPayAmt < CmUtil.DoubleAdd(nPayAmount, nMeAmount))
{
double nAutoAmount = CmUtil.DoubleSubtraction(m_cTrnStatus.Sale.RemainPayAmt, nPayAmount);
if (nAutoAmount > 0)
{
dgvData.Rows[iRow].Cells[10].Value = m_cPosStatus.Global.NumericTOCurrency(nAutoAmount);
dgvData.Update();
}
}
}
}
else
{
double nMeAmount = m_cDataService.DoubleParse(dgvData.Rows[iRow].Cells[21].EditedFormattedValue.ToString().Trim()); // 가용금액
dgvData.Rows[iRow].Cells[10].Value = m_cPosStatus.Global.NumericTOCurrency(nMeAmount);
}
// 금액형은 금액 수정 가능
if ((bool)dgvData.Rows[e.RowIndex].Cells[0].Value == true)
{
dgvData.Rows[e.RowIndex].Cells[10].Selected = true;
dgvData.BeginEdit(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);
}
}
private void dgvData_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
double nGiftType = 0;
try
{
if (dgvData.Rows.Count <= 0) return;
if (e.ColumnIndex != 10) return;
if (e.RowIndex < 0) return;
int iRow = e.RowIndex;
//if (CmUtil.IsNumber( m_cDataService.DoubleParse(dgvinPay.Rows[iRow].Cells[e.ColumnIndex].Value.ToString()).ToString()) != true && dgvinPay.Rows[iRow].Cells[e.ColumnIndex].Value.ToString() != "")
bool bisChecked = (bool)dgvData.Rows[iRow].Cells[0].Value;
if (CmUtil.IsNull(dgvData.Rows[iRow].Cells[16].Value) != true)
{
nGiftType = CmUtil.IntParse(dgvData.Rows[iRow].Cells[16].Value.ToString()); // 쿠폰종류 (0:물품형, 1:금액형)
}
if (bisChecked ==true && e.ColumnIndex == 10)
{
if (dgvData.Rows[iRow].Cells[10].Value == null) dgvData.Rows[iRow].Cells[10].Value = "0";
if (dgvData.Rows[iRow].Cells[21].Value == null) dgvData.Rows[iRow].Cells[21].Value = "0";
if (dgvData.Rows[iRow].Cells[10].Value == null || dgvData.Rows[iRow].Cells[10].Value.ToString().Trim() == "") dgvData.Rows[iRow].Cells[10].Value = "0";
if (dgvData.Rows[iRow].Cells[21].Value == null || dgvData.Rows[iRow].Cells[21].Value.ToString().Trim() == "") dgvData.Rows[iRow].Cells[21].Value = "0";
double nCouponAmt = m_cDataService.DoubleParse(dgvData.Rows[iRow].Cells[10].Value.ToString()); // 가용금액
double nCouponCheckAmt = m_cDataService.DoubleParse( dgvData.Rows[iRow].Cells[21].Value.ToString()); // 가용금액 - 체크용
if (nCouponAmt > nCouponCheckAmt)
{
dgvData.Rows[iRow].Cells[10].Value = m_cPosStatus.Global.NumericTOCurrency(nCouponCheckAmt);
WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0578);
return;
}
if (nCouponAmt.ToString().Length > 10 || nCouponAmt <= 0)
{
dgvData.Rows[iRow].Cells[10].Value = m_cPosStatus.Global.NumericTOCurrency(nCouponCheckAmt);
WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0036);
return;
}
if (CmUtil.AmountCut(nCouponAmt, CmUtil.IntParse(m_cPosStatus.Mst.PayRudDwLoc)) != nCouponAmt)
{
dgvData.Rows[iRow].Cells[10].Value = m_cPosStatus.Global.NumericTOCurrency(nCouponCheckAmt);
WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0036);
return;
}
dgvData.Rows[iRow].Cells[10].Value = m_cPosStatus.Global.NumericTOCurrency(nCouponAmt);
dgvData.Update();
//if (bisChecked == true)
//{
// // 금액형 결제금액 자동 설정용
// double nPayAmount = 0;
// for (int iLoop = 0; iLoop < dgvData.RowCount; iLoop++)
// {
// // 지정취소 상품 skip
// if (dgvData.Rows[iLoop].Visible == false) continue;
// // 서브타이틀로 사용된 항목 제외
// if (dgvData.Rows[iLoop].Cells[0].ReadOnly == true) continue;
// // 사용불가시 skip
// if (dgvData.Rows[iLoop].Cells[7].Value.ToString() != "") continue;
// // 미선택 skip
// if ((bool)dgvData.Rows[iLoop].Cells[0].Value != true) continue;
// if (iLoop != iRow)
// nPayAmount = CmUtil.DoubleAdd(m_cDataService.DoubleParse(dgvData.Rows[iLoop].Cells[10].EditedFormattedValue.ToString().Trim()), nPayAmount);
// }
// if (m_cTrnStatus.Sale.RemainPayAmt > nPayAmount && nGiftType == 1) // 결제금액이 받을금액보다 작고 금액형인 경우만
// {
// double nMeAmount = m_cDataService.DoubleParse(dgvData.Rows[iRow].Cells[21].EditedFormattedValue.ToString().Trim()); // 가용금액
// if (m_cTrnStatus.Sale.RemainPayAmt < CmUtil.DoubleAdd(nPayAmount, nMeAmount))
// {
// double nAutoAmount = CmUtil.DoubleSubtraction(nMeAmount, CmUtil.DoubleSubtraction(m_cTrnStatus.Sale.RemainPayAmt, nPayAmount));
// dgvData.Rows[iRow].Cells[10].Value = m_cPosStatus.Global.NumericTOCurrency(nAutoAmount);
// dgvData.Update();
// }
// }
//}
}
}
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
}
}