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 frmiNStorDC : 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 IICReaderUs m_cDeviceICReader = null;
private IDataCommonUs m_cDataCommon = null; // POS 공통함수 인터페이스
private IDataProcessUs m_cDataService = null;
private ISalePluItemUs m_cPluService = null; // 판매 등록 관리
private IPaymentUs m_ciNStorDC = null;
private string m_sPosMenuKeyIn;
public string PosMenuKeyIn { set { m_sPosMenuKeyIn = value; } get { return m_sPosMenuKeyIn; } }
private string m_sPosMenuKeyOut;
public string PosMenuKeyOut { set { m_sPosMenuKeyOut = value; } get { return m_sPosMenuKeyOut; } }
private bool bNotDoubleClik = false; // 더블 클릭 방지용
private string m_sPosMenuKey; // 입력코드
///
/// 할인 구분
///
public string SetPosMenuKey { set { this.m_sPosMenuKey = value; } }
///
/// 입력구분
///
private string m_sInPutType = "";
///
/// 입력데이터
///
private string m_sInPutData = "";
///
/// 카드데이터
///
private string m_sInEncData = "";
///
/// 결제구분
///
private string m_sPay_DC_Grp_Type= "";
///
/// 결제상세구분
///
private string m_sPay_DC_CD = "";
///
/// 할인구분 (1:율, 2:금액)
///
private string m_sDC_Div = "1";
#endregion 변수 선언
#region 생성자 & 소멸자 & 폼초기화
public frmiNStorDC()
{
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_cDataCommon = (IDataCommonUs)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.DATA_COMMON);
m_cPluService = (ISalePluItemUs)sManager.InitServiceInstance(ServiceLists.BSV_SALE.DLL, ServiceLists.BSV_SALE.SALE_PLU_ITEM);
m_ciNStorDC = (IPaymentUs)sManager.InitServiceInstance(ServiceLists.BSV_PAYMENT.DLL, ServiceLists.BSV_PAYMENT.iNStorDC);
delegatePos = new PosOLEDevice.DelegateOlePos(OnDeviceEvent);
}
private void frmiNStorDC_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 frmiNStorDC_Activated(object sender, EventArgs e)
{
PosOLEDevice.SetEventHandle(delegatePos);
}
private void frmiNStorDC_Deactivate(object sender, EventArgs e)
{
PosOLEDevice.SetEventHandle(null);
}
private void frmiNStorDC_FormClosing(object sender, FormClosingEventArgs e)
{
UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", lblTitle.Text);
}
///
/// 폼 컨트롤 초기화
///
private void InitControl()
{
try
{
// 이미지 로딩 처리
picBack.Image = ImageManager.GetImage(BaseCom.NxImgPath, ImageManager.POP_SIZE_S);
this.Size = new Size(788, 402);
FormManager.MovePopUpForm(this, true, m_cPosStatus.Sale.ScreenSizeUser);
//this.Location = new Point(216, 173);
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);
btnExit.Image = ImageManager.GetImage(BaseCom.NxImgPath, ImageManager.BTN_CLOSE);
if (btnExit.Image != null) btnExit.Text = "";
lblSaleAmt.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0037);
lblCardNM.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0168);
lblDCAmount.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0238);
// 기타할인(입점매장직원할인)
if (m_sPosMenuKey == PosKey.MENU_KEY.PAY_INSTOR_DC)
{
lblDCRate.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0163);
lblTitle.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0167);
// 결제 구분
m_sPay_DC_Grp_Type = ItemConst.TR_ITEM_ID.USER_DC_ITEM;
m_sPay_DC_CD = ItemConst.TR_ITEM_ID.USER_DC.IN_EMP_DC;
btnSearch.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0161); // 할인취소
btnEnter.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0047); // 할인적용
btnSearch.Visible = true;
txtDCRate.ReadOnly = true;
}
else if (m_sPosMenuKey == PosKey.MENU_KEY.PAY_INSTOR_PAY)
{
lblDCRate.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0049);
lblTitle.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_1010);
// 결제 구분
m_sPay_DC_Grp_Type = ItemConst.TR_ITEM_ID.PAYETC_ITEM;
m_sPay_DC_CD = ItemConst.TR_ITEM_ID.PAYETC.PAYETC_ITEM;
btnEnter.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0263); // 결제
btnSearch.Visible = false;
txtDCRate.ReadOnly = false;
txtDCRate.Select();
txtDCRate.SelectText();
}
else if (m_sPosMenuKey == PosKey.MENU_KEY.PAY_INSTOR_DC_5) // 입점건물직원할인(적립)(2017.05.25)
{
lblDCRate.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0163);
lblTitle.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0167);
// 결제 구분
m_sPay_DC_Grp_Type = ItemConst.TR_ITEM_ID.USER_DC_ITEM;
m_sPay_DC_CD = ItemConst.TR_ITEM_ID.USER_DC.IN_EMP_DC_5;
btnSearch.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0161); // 할인취소
btnEnter.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0047); // 할인적용
btnSearch.Visible = true;
txtDCRate.ReadOnly = true;
}
txtCardNM.Text = "";
txtDCRate.Text = "";
lblDCRate.Tag = "";
txtDCRate.Tag = "0";
txtDCAmount.Text = "0";
m_sDC_Div = "1";
bNotDoubleClik = false;
if (PosMstManager.GetMstPayDc(m_sPay_DC_Grp_Type, m_sPay_DC_CD, PosMst.MST_PAY_DC.DATA.PAY_DC_TYPE) == PosConst.PAY_DC_TYPE.DC)
{
string sRet = CheckDCUseMode(); // 할인 가능 여부 체크
if (sRet != UserCom.RST_OK)
{
this.DialogResult = DialogResult.Cancel;
this.Close();
return;
}
txtDCAmount.Text = m_cPosStatus.Global.NumericTOCurrency(GetSaleItemDCTargerAmt(2)); // 기존 적용 할인 금액
}
txtSaleAmt.Text = m_cPosStatus.Global.NumericTOCurrency(m_cDataService.GetPluTagetAmount(m_sPosMenuKey)); // 받을 금액
m_sInPutType = ""; // 입력구분
m_sInPutData = ""; // 입력데이터
m_sInEncData = ""; // 카드데이터
LoadFuncMaster(); // 기능키 설정
}
catch (Exception ex)
{
WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
}
}
#endregion
#region 버튼 입력 처리
///
/// 버튼 입력 처리
///
///
///
private void btnProc_Click(object sender, EventArgs e)
{
try
{
if (bNotDoubleClik) return;
bNotDoubleClik = true;
if (((Cosmos.UI.CsmButton)sender) == btnSearch) // 취소
{
CompleteTxtInPut(true);
}
else if (((Cosmos.UI.CsmButton)sender) == btnEnter) // 할인
{
CompleteTxtInPut(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);
bNotDoubleClik = false;
}
bNotDoubleClik = false;
}
///
/// 닫기
///
///
///
private void btnExit_Click(object sender, EventArgs e)
{
try
{
txtEditBox_EditBoxKeyDownEvent(null, PosKey.MENU_KEY.ESC_PREVIOUS);
}
catch (Exception ex)
{
WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
}
}
#endregion
#region 기능키 컨트롤 초기화 및 기능키 마스터 로딩
///
/// 기능키 컨트롤 초기화 및 기능키 마스터 로딩
///
/// 성공/실패
public bool LoadFuncMaster()
{
try
{
btnMenu.ClearMenuButtonInfo();
// 쿠폰 List 조회
DataTable dtMemu = m_cDataCommon.SeletCouponDCFuncKey(m_sPay_DC_Grp_Type, m_sPay_DC_CD);
if (dtMemu == null || dtMemu.Rows.Count <= 0)
{
WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0059); // 메뉴키 마스터가 없습니다
return false;
}
// 우측 상단 기능키 초기화
btnMenu.BackColor = CmUtil.GetColorToString("223223223");
btnMenu.VisibleUpDown = true;
btnMenu.BackColorUpDown = Color.White;
btnMenu.ForeColorUpDown = Color.Black;
btnMenu.ClearMenuButtonInfo(); // 설정된 메뉴정보 초기화
// 메뉴정보 설정
foreach (DataRow dr in dtMemu.Rows)
{
Cosmos.UI.CsmMenu.MenuBtnInfo cMenuInfo = new Cosmos.UI.CsmMenu.MenuBtnInfo();
cMenuInfo.nSeqNo = CmUtil.GetDataRowInt(dr, PosMst.MST_COUPON_DC_KEY.DATA.SEQ); // SEQ
cMenuInfo.sClassCode = CmUtil.GetDataRowStr(dr, PosMst.MST_COUPON_DC_KEY.DATA.STOR_CD); // 점포코드
cMenuInfo.sGroupCode = "1"; // SUB 그룹
string sMenuCode = null;
sMenuCode = CmUtil.RPadH(CmUtil.GetDataRowStr(dr, PosMst.MST_COUPON_DC_KEY.DATA.CPN_TYPE), 1) // 쿠폰구분
+ CmUtil.RPadH(CmUtil.GetDataRowStr(dr, PosMst.MST_COUPON_DC_KEY.DATA.CPN_DC_CD), 40) // 쿠폰구분코드
+ CmUtil.LPadH(CmUtil.GetDataRowStr(dr, PosMst.MST_COUPON_DC_KEY.DATA.DC_RATE), 20) // 할인율(금액)
+ CmUtil.RPadH(CmUtil.GetDataRowStr(dr, PosMst.MST_COUPON_DC_KEY.DATA.CPN_DC_NM), 80); // 쿠폰명
cMenuInfo.sMenuCode = sMenuCode; // 메뉴 코드
cMenuInfo.sMenuName = CmUtil.GetDataRowStr(dr, PosMst.MST_COUPON_DC_KEY.DATA.CPN_DC_NM); // 메뉴 명
cMenuInfo.sMenuPrice = m_cPosStatus.Global.NumericTOCurrency(CmUtil.GetDataRowDouble(dr, PosMst.MST_COUPON_DC_KEY.DATA.DC_RATE)); // 메뉴 가격
cMenuInfo.cBackColor = CmUtil.GetColorToString(CmUtil.GetDataRowStr(dr, PosMst.MST_COUPON_DC_KEY.DATA.BACKGR_COLOR)); // 버튼 BACK 컬러
cMenuInfo.cForeColorName = Color.FromArgb(51, 51, 51); // 메뉴명 컬러
cMenuInfo.cForeColorPrice = Color.Red; //Color.FromArgb(102, 102, 102); // 메뉴가격 컬러
cMenuInfo.fFontSizeName = CmUtil.GetDataRowFloat(dr, PosMst.MST_COUPON_DC_KEY.DATA.FONT_SIZE); // 메뉴명 폰트 사이즈
cMenuInfo.fFontSizePrice = CmUtil.GetDataRowFloat(dr, PosMst.MST_COUPON_DC_KEY.DATA.FONT_SIZE); // 메뉴 가격 폰트 사이즈
cMenuInfo.nButtonSize = CmUtil.GetDataRowInt(dr, PosMst.MST_COUPON_DC_KEY.DATA.BTN_SIZE); // 메뉴버튼 사이즈(0:일반,1:가로확대,2:세로확대,3:가로세로확대)
cMenuInfo.sMenuEtc = "";
if (CmUtil.GetDataRowStr(dr, PosMst.MST_COUPON_DC_KEY.DATA.CPN_TYPE) == "1")
cMenuInfo.sMenuEtc = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0982);
else if (CmUtil.GetDataRowStr(dr, PosMst.MST_COUPON_DC_KEY.DATA.CPN_TYPE) == "3")
cMenuInfo.sMenuEtc = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0364);
else
cMenuInfo.sMenuEtc = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0019);
cMenuInfo.cForeColorEtc = Color.Blue;
cMenuInfo.fFontSizeEtc = CmUtil.GetDataRowFloat(dr, PosMst.MST_COUPON_DC_KEY.DATA.FONT_SIZE);
cMenuInfo.cMenuImage = "";
//if (CmUtil.GetDataRowStr(dr, PosMst.MST_COUPON_DC_KEY.DATA.BTN_ITEM_IMG) != "")
//{
// //cMenuInfo.cMenuImage = CmUtil.LoadImage(BaseCom.NxCDPPath + @"ITEM\" + CmUtil.GetDataRowStr(dr, PosMst.MST_COUPON_DC_KEY.DATA.BTN_ITEM_IMG)); // 메뉴 이미지
//}
btnMenu.AddMenuButtonInfo(cMenuInfo);
}
btnMenu.SetMenuButtonCount(4, 3);
btnMenu.DisplayMenuButton(m_cPosStatus.Base.StoreNo, "1"); // 버튼 표시
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;
}
}
///
/// 메뉴 선택
///
///
///
private void btnMenu_MenuClickHandler(object sender, string sMenuCode)
{
try
{
if (sMenuCode == "") return;
// 메뉴 키 값 = 쿠폰구분(1) + 쿠폰구분코드(40) + 할인율(금액)(20) + 쿠폰명(80)
txtDCRate.Text = m_cPosStatus.Global.NumericTOCurrency(m_cDataService.DoubleParse(CmUtil.MidH(sMenuCode, 41, 20).Trim()));
m_sDC_Div = CmUtil.MidH(sMenuCode, 0, 1).Trim();
lblDCRate.Tag = CmUtil.MidH(sMenuCode, 1, 40).Trim();
txtDCRate.Tag = "0";
txtCardNM.Text = CmUtil.MidH(sMenuCode, 61, 80).Trim();
txtSaleAmt.Text = m_cPosStatus.Global.NumericTOCurrency(m_cDataService.GetPluTagetAmount(m_sPosMenuKey)); // 받을 금액
if (m_sDC_Div == "1")
lblDCRate.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0163);
else if (m_sDC_Div == "3")
{
lblDCRate.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0049);
txtDCRate.Text = m_cPosStatus.Global.NumericTOCurrency(m_cDataService.GetPluTagetAmount(m_sPosMenuKey));
}
else
lblDCRate.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0036);
txtDCRate.Select();
// 선택시 자동 할인 등록 처리(2017.05.20)
CompleteTxtInPut(false);
return;
}
catch (Exception ex)
{
WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
}
}
#endregion
#region 텍스트박스 키 입력 이벤트 처리
///
/// 텍스트박스 키 입력 이벤트 처리
///
///
///
private void txtEditBox_EditBoxKeyDownEvent(object sender, string sFuncValue)
{
try
{
if (sFuncValue == PosKey.MENU_KEY.ENTER)
{
if (((Cosmos.UI.CsmPosEditBox)sender) == txtDCRate)
{
CompleteTxtInPut(false);
}
}
else if (sFuncValue == PosKey.MENU_KEY.CLEAR)
{
if (((Cosmos.UI.CsmPosEditBox)sender) == txtDCRate)
{
txtDCRate.Text = "0";
}
}
else if (sFuncValue == PosKey.MENU_KEY.ESC_PREVIOUS)
{
this.DialogResult = DialogResult.Cancel;
this.Close();
}
}
catch (Exception ex)
{
WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
}
}
///
/// 텍스트박스 활성화 처리
///
///
///
private void txtEditBox_EnterEvent(object sender, EventArgs e)
{
}
#endregion
#region 텍스트박스 입력 유효성 체크
///
/// 텍스트박스 입력 유효성 체크
///
///
///
private bool CheckTxtInPut(object sender)
{
try
{
// 할인율 체크
if (sender == null || ((Cosmos.UI.CsmPosEditBox)sender) == txtDCRate)
{
if (m_sDC_Div == "1")
{
if ((txtDCRate.Text.Length == 0) || (m_cDataService.DoubleParse(txtDCRate.Text) <= 0 && m_cDataService.DoubleParse(txtDCRate.Text) > 100))
{
WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0051);
txtDCRate.Focus();
return false;
}
}
else
{
if ((txtDCRate.Text.Length == 0) || (m_cDataService.DoubleParse(txtDCRate.Text) <= 0))
{
WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0049);
txtDCRate.Focus();
return false;
}
}
}
// 받을금액 체크
if (sender == null || ((Cosmos.UI.CsmLabel)sender) == txtSaleAmt)
{
if (m_sPosMenuKey == PosKey.MENU_KEY.PAY_INSTOR_PAY || m_sDC_Div == "3")
{
if (m_cDataService.DoubleParse(txtDCRate.Text) > m_cDataService.DoubleParse(txtSaleAmt.Text))
{
WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0039);
txtDCRate.Select();
txtDCRate.SelectText();
return false;
}
if (txtCardNM.Text.Trim() == "")
{
WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0628);
return false;
}
}
if (m_cDataService.DoubleParse(txtSaleAmt.Text) <= 0)
{
WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0039);
txtSaleAmt.Focus();
return false;
}
}
}
catch (Exception ex)
{
WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
return false;
}
return true;
}
#endregion
#region 텍스트박스 입력 완료 처리
///
/// 할인 처리
///
///
///
private string CompleteTxtInPut(bool bCancelMode)
{
string sRet = UserCom.RST_ERR;
try
{
// 할인 처리
if (bCancelMode)
{
// 할인 취소
//if (WinManager.QuestionMessage(POS_MESSAGE.ERROR.MSG_0053) == false) // 등록된 할인을 취소 하시겠습니까?
// return sRet;
sRet = GetSaleItemTotalDCCancel();
}
else
{
// 할인 적용
// 쿠폰할인
if (m_sPosMenuKey == PosKey.MENU_KEY.DC_COUPONS || m_sPosMenuKey == PosKey.MENU_KEY.PAY_INSTOR_PAY)
{
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;
}
//EncryptedCardNo(sInPutData, ref sInEncData, ref sInPutData);
}
}
if (CheckTxtInPut(null) == false) return sRet;
//if (WinManager.QuestionMessage(POS_MESSAGE.ERROR.MSG_0124) == false) // 할인 적용을 하시겠습니까?
// return sRet;
sRet = GetSaleItemTotalDC(m_cDataService.DoubleParse(txtDCRate.Value));
}
if (sRet != UserCom.RST_OK) return sRet;
//if (bCancelMode)
//{
// // 할인 취소
// WinManager.ConfirmMessage(POS_MESSAGE.ERROR.MSG_0068);
//}
//else
//{
// // 할인 등록
// WinManager.ConfirmMessage(POS_MESSAGE.ERROR.MSG_0067);
//}
this.DialogResult = DialogResult.OK;
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);
}
return sRet;
}
#endregion
#region 전체상품 할인 처리
///
/// 전체 상품중 할인 대상금액 조회
///
///
public double GetSaleItemDCTargerAmt(int iSearchMode )
{
double nDCSum = 0;
try
{
// 상품정보
ArrayList aSaleItem = (ArrayList)StateObject.GetItemObject(Column.TR_PLU.ITEM);
for (int iRow = 0; iRow < aSaleItem.Count; iRow++)
{
Column.TR_PLU.DATA cSaleItem = (Column.TR_PLU.DATA)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.ITEM_DIV != ItemConst.PLU_ITEM_DIV.NORMAL && iSearchMode != 2) 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 (iSearchMode == 2)
nDCSum = CmUtil.DoubleAdd(nDCSum, cSaleItem.ITEM_DC_AMT); // 기존 할인금액
else
nDCSum = CmUtil.DoubleAdd(nDCSum, cSaleItem.BILL_AMT); // 할인 대상 금액 sum
}
}
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 nDCSum;
}
///
/// 전체상품 할인 처리
///
///
///
///
///
public string GetSaleItemTotalDC(double nAmount)
{
double nSaleAmount = 0, nDCAvaAmount = 0;
double nPrice = 0, nDCSum = 0, nRate = 0, nDCAmount = 0, nMaxPrice = 0;
int iIndex = 0;
string sRet = UserCom.RST_ERR;
try
{
nDCSum = 0;
nRate = 0;
nDCAmount = 0;
nMaxPrice = 0;
if (PosMstManager.GetMstPayDc(m_sPay_DC_Grp_Type, m_sPay_DC_CD, PosMst.MST_PAY_DC.DATA.PAY_DC_TYPE) == PosConst.PAY_DC_TYPE.DC)
{
// 기존 할인 삭제후 적용
sRet = GetSaleItemTotalDCCancel();
// 상품정보
ArrayList aSaleItem = (ArrayList)StateObject.GetItemObject(Column.TR_PLU.ITEM);
//// 전체 받을금액
nSaleAmount = GetSaleItemDCTargerAmt(0);
// 받을금액중 할인 안된 금액만 조회
nDCAvaAmount = GetSaleItemDCTargerAmt(1);
if (m_cTrnStatus.Head.TotDcAmt > 0)
{
// 할인 금액 존재시 받을금액은 할인 대상으로 한다.
nSaleAmount = nDCAvaAmount;
}
nDCAmount = nAmount;
if (m_sDC_Div == "1")
{
// 분배금액 = 받을금액 * %할인 / 100
//nDCAmount = CmUtil.DoubleDivision(CmUtil.DoubleMultiplication(nSaleAmount, nAmount), 100);
nDCAmount = CmUtil.MathAmtPercent(nSaleAmount, nAmount);
nDCAmount = CmUtil.MathRounds(nDCAmount, m_cPosStatus.Mst.DcRudDwLocMethd, CmUtil.IntParse(m_cPosStatus.Mst.DcRudDwLoc));
}
if (nDCAmount <= 0)
{
WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0050);
sRet = UserCom.RST_ERR;
return sRet;
}
else if (nDCAmount > nSaleAmount)
{
WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0049);
sRet = UserCom.RST_ERR;
return sRet;
}
nDCSum = 0;
// 할인 분배등록
for (int iRow = 0; iRow < aSaleItem.Count; iRow++)
{
Column.TR_PLU.DATA cSaleItem = (Column.TR_PLU.DATA)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.ITEM_DIV != ItemConst.PLU_ITEM_DIV.NORMAL) 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; // 할인가능 여부
// 할인 절삭
nDCAmount = CmUtil.MathRounds(nDCAmount, m_cPosStatus.Mst.DcRudDwLocMethd, CmUtil.IntParse(m_cPosStatus.Mst.DcRudDwLoc));
// 비율 = 상품금액 / 총판매가 * 100
//nRate = CmUtil.DoubleMultiplication(CmUtil.DoubleDivision(cSaleItem.SALE_AMT, nDCAvaAmount), 100);
// 분배금액 = 상품금액 * 비율 / 100
//nPrice = CmUtil.DoubleDivision(CmUtil.DoubleMultiplication(nDCAmount, nRate), 100);
// 금액 배분 절삭
//nPrice = CmUtil.MathRounds(nPrice, m_cPosStatus.Mst.DcRudDwLocMethd, CmUtil.IntParse(m_cPosStatus.Mst.DcRudDwLoc));
nPrice = CmUtil.DoubleMultiplication(nDCAmount, CmUtil.DoubleDivision(cSaleItem.BILL_AMT, nDCAvaAmount));
nPrice = CmUtil.MathRounds(nPrice, m_cPosStatus.Mst.ItemRudDwLocMethd, CmUtil.IntParse(m_cPosStatus.Mst.ItemRudDwLoc));
if (nPrice > cSaleItem.SALE_AMT) continue; // 할인금액이 상품금액보다 클수 없음
// 상품할인 적용
cSaleItem.ITEM_DC_AMT = nPrice;
// POS 할인 구분(00:정상, 01:무료(서비스), 02:임의할인,03:환경사랑DC,04:제품교환권,06:입점건물직원할인, 07:입점건물직원할인(적립)
cSaleItem.DC_DIV = m_sPay_DC_Grp_Type + m_sPay_DC_CD; //ItemConst.TR_ITEM_ID.USER_DC_ITEM + ItemConst.TR_ITEM_ID.USER_DC.IN_EMP_DC;
cSaleItem.DC_TYPE = ItemConst.PLU_DC_TYPE.DC_SUM; // 단품 할인 타입(0:없음, 1:소계할인, 2:단품할인)
// 분배후 짜투리 금액 체크용
nDCSum = CmUtil.DoubleAdd(nDCSum, nPrice);
// 최종 적용 상품 index
if (nMaxPrice == 0 || nMaxPrice >= cSaleItem.SALE_AMT)
{
nMaxPrice = cSaleItem.SALE_AMT;
iIndex = iRow;
}
// 상품행별 영수 금액 재계산 처리
m_cDataService.UpdatePluItemAmount(cSaleItem);
}
// 짜투리 금액 최종 적용 상품에 추가
if (nDCSum != nDCAmount)
{
Column.TR_PLU.DATA cSaleItem = (Column.TR_PLU.DATA)aSaleItem[iIndex];
//nPrice = 0;
//nPrice = CmUtil.DoubleSubtraction(nDCAmount, nDCSum);
//cSaleItem.ITEM_DC_AMT = CmUtil.DoubleAdd(cSaleItem.ITEM_DC_AMT, nPrice); // 단품 할인 금액
cSaleItem.ITEM_DC_AMT = CmUtil.DoubleAdd(cSaleItem.ITEM_DC_AMT, CmUtil.DoubleSubtraction(nDCAmount, nDCSum));
// 상품행별 영수 금액 재계산 처리
m_cDataService.UpdatePluItemAmount(cSaleItem);
}
// 상품 판매가 계산
m_cPluService.ItemAmountExeccute(true, true);
// 할인금액
txtDCRate.Tag = nDCAmount.ToString();
}
else
{
nDCAmount = m_cDataService.DoubleParse(txtDCRate.Value);
}
// 쿠폰 결제
sRet = m_ciNStorDC.SetPayment(new string[] { m_sPosMenuKey, m_sInPutType, m_sInPutData, m_sInEncData, nDCAmount.ToString(), m_cDataService.DoubleParse(txtSaleAmt.Text).ToString(), lblDCRate.Tag.ToString(), txtCardNM.Text.Trim() });
if (sRet != UserCom.RST_OK) return sRet;
// 결제 합계금액 재계산 처리
m_cDataService.UpdatePayAmount();
// 할인적용금액 표시
txtDCAmount.Text = m_cPosStatus.Global.NumericTOCurrency(nDCAmount);
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;
}
///
/// 전체상품 할인 취소 처리
///
///
public string GetSaleItemTotalDCCancel()
{
string sRet = UserCom.RST_ERR;
try
{
// 결제 수단 취소
ArrayList alPayItem = (ArrayList)StateObject.GetItemObject(Column.TR_PAYMENT.ITEM);
for (int iRow = 0; iRow < alPayItem.Count; iRow++)
{
Column.TR_PAYMENT.DATA clPayItem = (Column.TR_PAYMENT.DATA)alPayItem[iRow];
// 취소구분
if (clPayItem.CANCEL_DIV == ItemConst.PAY_CANCEL_DIV.CANCEL) continue;
// 쿠폰할인
if (clPayItem.PAY_WAY_CD != ItemConst.TR_ITEM_ID.USER_DC_ITEM) continue;
// 결제 수단 취소
m_ciNStorDC.CancelPayment(new string[] { iRow.ToString() });
}
if (PosMstManager.GetMstPayDc(m_sPay_DC_Grp_Type, m_sPay_DC_CD, PosMst.MST_PAY_DC.DATA.PAY_DC_TYPE) == PosConst.PAY_DC_TYPE.DC)
{
// 상품정보
ArrayList aSaleItem = (ArrayList)StateObject.GetItemObject(Column.TR_PLU.ITEM);
for (int iRow = 0; iRow < aSaleItem.Count; iRow++)
{
Column.TR_PLU.DATA cSaleItem = (Column.TR_PLU.DATA)aSaleItem[iRow];
if (cSaleItem.ITEM_DC_AMT == 0) continue; // 할인 금액
// 상품할인 적용
cSaleItem.ITEM_DC_AMT = 0;
cSaleItem.DC_DIV = ItemConst.PLU_DC_DIV.NORMAL; // POS 할인 구분(00:정상, 01:무료(서비스), 02:임의할인,03:환경사랑DC,04:제품교환권,06:입점건물직원할인, 07:수수료할인)
cSaleItem.DC_TYPE = ItemConst.PLU_DC_TYPE.NORMAL; // 단품 할인 타입(0:없음, 1:소계할인, 2:단품할인)
// 상품행별 영수 금액 재계산 처리
m_cDataService.UpdatePluItemAmount(cSaleItem);
}
// 상품 판매가 계산
m_cPluService.ItemAmountExeccute(true, true);
}
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 CheckDCUseMode()
{
string sRet = UserCom.RST_OK;
try
{
if (m_cTrnStatus.Sale.RecvedPayAmt > 0)
{
// 임의 할인 중복 등록 체크
WinManager.ConfirmMessage(POS_MESSAGE.ERROR.MSG_0198); // 결제 진행 중 처리 할 수 없는 기능 입니다
sRet = UserCom.ERROR;
return sRet;
}
// 상품정보
ArrayList aSaleItem = (ArrayList)StateObject.GetItemObject(Column.TR_PLU.ITEM);
for (int iRow = 0; iRow < aSaleItem.Count; iRow++)
{
Column.TR_PLU.DATA cSaleItem = (Column.TR_PLU.DATA)aSaleItem[iRow];
if (cSaleItem.CANCEL_DIV == PosConst.CANCEL_DIV.CANCEL || cSaleItem.CANCEL_DIV_MAIN == PosConst.CANCEL_DIV.CANCEL) continue;// 지정취소
if (cSaleItem.DC_PRMT_YN != "0") continue; // 할인가능 여부
if (cSaleItem.ITEM_DC_AMT > 0)
{
// 입점건물직원할인(적립) 추가 (2017.05.25)
if (cSaleItem.DC_DIV != ItemConst.PLU_DC_DIV.NORMAL && cSaleItem.DC_DIV != ItemConst.PLU_DC_DIV.IN_EMP_DC && cSaleItem.DC_DIV != ItemConst.PLU_DC_DIV.IN_EMP_DC_5)
// if (cSaleItem.DC_DIV != ItemConst.PLU_DC_DIV.NORMAL && cSaleItem.DC_DIV != ItemConst.PLU_DC_DIV.IN_EMP_DC)
{
WinManager.ConfirmMessage(POS_MESSAGE.ERROR.MSG_0113); // 기존 할인을 취소후 시도하여 주시기 바랍니다.
sRet = UserCom.ERROR;
return sRet;
}
}
}
}
catch (Exception ex)
{
WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
}
return sRet;
}
#endregion
#region DeviceEvent 관련
///
/// DeviceEvent 관련
///
///
///
///
///
public void OnDeviceEvent(string sDevice, string sData1, string sData2, string sData3)
{
try
{
switch (sDevice)
{
case PosConst.OPOS_DEVICE.MSR:
this.Invoke(new EventHandler(OnMSREvent));
break;
case PosConst.OPOS_DEVICE.SCANNER:
this.Invoke(new EventHandler(OnScannerEvent));
break;
}
}
catch (Exception ex)
{
WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
}
}
///
/// MSR Event
///
///
///
private void OnMSREvent(object source, EventArgs e)
{
}
///
/// 스캐너 이벤트 처리
///
///
///
private void OnScannerEvent(object source, EventArgs e)
{
}
///
/// 카드 번호 암호화
///
///
///
///
///
private string EncryptedCardNo(string sInData, ref string sCardData, ref string sCardNo)
{
string sEncData = sInData;
try
{
if (sInData.Length <= 0) return "";
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;
}
///
/// IC 카드 정보 입력 처리
///
///
private bool GetIcCardData()
{
try
{
m_sInPutType = "";
m_sInPutData = "";
m_sInEncData = "";
string sRsvStr = "";
if (m_cDeviceICReader.GetCardInfo_ICReader(PosConst.IC_READER_TRAN_TYPE.POINT, 1, ref sRsvStr) == true)
{
if (CmUtil.MidH(sRsvStr, 0, 2) == "00")
{
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;
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
}
}