using System;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
using System.Collections;
using System.Data;
using Cosmos.Win;
using Cosmos.BaseFrame;
using Cosmos.UserFrame;
using Cosmos.ServiceProvider;
using Cosmos.Common;
using Cosmos.CommonManager;
/*-----------------------------------------------------------------------------------------------*/
// 설 명 : OKCASHBACK 조회,적립
// 작 성 자 :
// 변경 이력 :
/*-----------------------------------------------------------------------------------------------*/
namespace Cosmos.Win
{
public partial class frmPntOcbSave : 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 PosOLEDevice.DelegateIcReader delegateReader; // IC리더 콜백
//#20170918 IC 콜백 함수 변경 start
//포인트창에서 해피제휴 신용카드 리딩시 IC 우선 거래로 인해 '카드를 읽혀 주세요' 팝업 나오는 현상 수정.
/*
private PosOLEDevice.CallbackIc delegateReaderCardInfo; // IC리더 콜백(CardInfo)
private bool m_bCardInPut; //카드 입력 중복 방지
private string m_sIcChip; //IC CHIP DATA(EMV)
private string m_InputType = ""; //PosConst.POS_VAN_MASTER.VAN_KEYIN; //입력구분
private string m_sCardNo; //입력 카드 번호
private string m_sFallDiv; //FallBack구분
private string m_sServiceCode; //서비스코드
*/
//#20170918 IC 콜백 함수 변경 end
private IICReaderUs m_cDeviceICReader = null;
private ISignPadUs m_cDeviceSignPad = null;
private IDataProcessUs m_cDataService = null; // 거래데이터 합계금액 계산 및 관리
private IDataCommonUs m_cDataCommon = null; // POS 공통함수 인터페이스
private IPaymentExpUs m_cPntOcbSave = null;
private bool bNotDoubleClik = false; // 더블 클릭 방지용
private string m_sPosMenuKey;
///
/// POS 기능키
///
public string SetPosMenuKey { set { this.m_sPosMenuKey = value; } }
///
/// 입력구분
///
private string m_sInPutType = "";
///
/// 입력데이터
///
private string m_sInPutData = "";
///
/// 마스킹데이터
///
private string m_sInMaskData = "";
///
/// 카드데이터(암호화)
///
private string m_sInEncData = "";
///
/// 대상 금액
///
private double m_nDestAmt = 0;
///
/// 조회 성공 여부
///
private bool m_bSearchSuccess = false;
#endregion 변수 선언
#region 생성자 & 소멸자 & 폼초기화
public frmPntOcbSave()
{
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_cDeviceICReader = (IICReaderUs)sManager.InitServiceInstance(ServiceLists.AGENT_OLEDEVICE.DLL, ServiceLists.AGENT_OLEDEVICE.DEVICE_ICREADER);
m_cDeviceSignPad = (ISignPadUs)sManager.InitServiceInstance(ServiceLists.AGENT_OLEDEVICE.DLL, ServiceLists.AGENT_OLEDEVICE.DEVICE_SIGNPAD);
m_cDataService = (IDataProcessUs)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.DATA_SERVICE);
m_cDataCommon = (IDataCommonUs)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.DATA_COMMON);
m_cPntOcbSave = (IPaymentExpUs)sManager.InitServiceInstance(ServiceLists.BSV_PAYMENT.DLL, ServiceLists.BSV_PAYMENT.PNT_OCB_SAVE);
delegatePos = new PosOLEDevice.DelegateOlePos(OnDeviceEvent);
delegateReader = new PosOLEDevice.DelegateIcReader(OnIcReaderCallBack); // IC리더 콜백
//#20170918 IC 콜백 함수 변경 start
//포인트창에서 해피제휴 신용카드 리딩시 IC 우선 거래로 인해 '카드를 읽혀 주세요' 팝업 나오는 현상 수정.
//delegateReaderCardInfo = new PosOLEDevice.CallbackIc(OnIcReaderCallBackCardInfo); // IC리더 콜백(CardInfo)
//#20170918 IC 콜백 함수 변경 end
}
private void frmPntOcbSave_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();
if (PosMstManager.GetPosOption(POS_OPTION.OPT326) != "0" && PosMstManager.GetPosOption(POS_OPTION.OPT326) != "" && m_cDevStatus.ICReader.UseYn != true) // OCB 직통신
{
tmrIcCard.Enabled = false; // IC리더 콜백 설정
}
else
{
tmrIcCard.Tag = "";
tmrIcCard.Enabled = true; // IC리더 콜백 설정
}
}
private void frmPntOcbSave_Activated(object sender, EventArgs e)
{
PosOLEDevice.SetEventHandle(delegatePos);
}
private void frmPntOcbSave_Deactivate(object sender, EventArgs e)
{
PosOLEDevice.SetEventHandle(null);
}
private void frmPntOcbSave_FormClosing(object sender, FormClosingEventArgs e)
{
tmrIcCard.Tag = "CLOSE";
// 마우스(이중클릭방지)
Point nPoint = System.Windows.Forms.Cursor.Position;
Cursor.Clip = new System.Drawing.Rectangle(1024, 0, 1, 1);
UnRegIcCallback(); // IC리더 콜백 해지
InDataToZeroFill();
UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", lblTitle.Text);
// 마우스(이중클릭방지)
Cursor.Clip = Screen.PrimaryScreen.Bounds;
Cursor.Position = nPoint;
}
///
/// 폼 컨트롤 초기화
///
private void InitControl()
{
try
{
this.Location = new Point(0, 50);
this.Size = new Size(1024, 525);
// 이미지 로딩 처리
//picBack.Image = ImageManager.GetImage(BaseCom.NxImgPath, ImageManager.POP_SIZE_S);
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);
lblTitle.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0827);
lblCardNo.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0051);
lblPayAmt.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0098);
lblTotSavePoint.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0071);
lblUsablePoint.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0070);
btnIcCard.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0132);
btnRfCard.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0580);
//MoonSeokWoo 2017.11.03 Add
btnPinPad.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0097);
//MoonSeokWoo 2017.11.03 End
btnSearch.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0004);
btnEnter.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0126);
btnCatApp.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0854);
if (m_cDevStatus.CatTerminal.UseYn == false)
btnCatApp.Visible = false;
else
btnCatApp.Visible = true;
m_nDestAmt = m_cDataService.GetPluTagetAmount(PosKey.MENU_KEY.OKCASHBACK_SAVE); // 적립 대상 금액
txtPayAmt.Text = m_cPosStatus.Global.NumericTOCurrency(m_nDestAmt);
InitPayMainBack(m_cPosStatus, m_cDataCommon, m_sPosMenuKey, PosConst.MOT_MSG_TYPE.PAY_STEP_1, "");
//MoonSeokWoo 2017.11.03 Edit
// 기능 버튼 설정 체크
FormManager.SetbtnMenu(txtCardNo, m_cDevStatus.ICReader.UseYn, btnIcCard, btnRfCard, btnPinPad, null);
//MoonSeokWoo 2017.11.03 End
ClearCardInfo(); // 카드 입력 정보 클리어
bNotDoubleClik = false;
if (PosMstManager.GetPosOption(POS_OPTION.OPT326) != "0" && PosMstManager.GetPosOption(POS_OPTION.OPT326) != "" && m_cDevStatus.ICReader.UseYn != true) // OCB 직통신
{
btnIcCard.Visible = false;
btnRfCard.Visible = false;
}
else
{
// 무결성 실패후 진행시 오류 메시지 표시
if (m_cDevStatus.ICReader.UseYn == true) // 여신전문금융업법 적용여부 체크
{
if (m_cDevStatus.ICReader.Integrity_IC_Status != true && m_cDevStatus.ICReader.UseYn == true) WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0384);
}
}
//MoonSeokWoo 2017.11.03 Add
btnPinPad.Enabled = true;
//MoonSeokWoo 2017.11.03 End
txtCardNo.Value = "";
txtCardNo.Select();
}
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 ClearCardInfo()
{
try
{
m_sInPutType = ""; // 입력구분
m_sInPutData = ""; // 입력데이터
m_sInMaskData = ""; // 마스킹
m_sInEncData = ""; // 카드데이터
txtUsablePoint.Text = "";
txtTotSavePoint.Text = "";
m_bSearchSuccess = 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);
}
}
#endregion
#region 버튼 입력 처리
///
/// 버튼 입력 처리
///
///
///
private void btnProc_Click(object sender, EventArgs e)
{
try
{
if (bNotDoubleClik) return;
bNotDoubleClik = true;
if (((Cosmos.UI.CsmButton)sender) == btnIcCard) // 카드입력
{
if (GetIcCardData(e != null ? true : false) == true)
{
bNotDoubleClik = false;
txtEditBox_EditBoxKeyDownEvent(txtCardNo, PosKey.MENU_KEY.ENTER);
}
}
else if (((Cosmos.UI.CsmButton)sender) == btnRfCard) // 카드입력
{
UnRegIcCallback(); // IC리더 콜백 해지
if (GetRfCardData() == true)
{
bNotDoubleClik = false;
txtEditBox_EditBoxKeyDownEvent(txtCardNo, PosKey.MENU_KEY.ENTER);
}
if (txtCardNo.Value == "") tmrIcCard.Enabled = true;
}
//MoonSeokWoo 2017.11.03 Add
else if (((Cosmos.UI.CsmButton)sender) == btnPinPad) // 핀패드
{
UnRegIcCallback(); // IC리더 콜백 해지
if (GetPinPadData() == true)
{
bNotDoubleClik = false;
txtEditBox_EditBoxKeyDownEvent(txtCardNo, PosKey.MENU_KEY.ENTER);
}
if (txtCardNo.Value == "") tmrIcCard.Enabled = true;
}
//MoonSeokWoo 2017.11.03 End
else if (((Cosmos.UI.CsmButton)sender) == btnSearch) // 조회
{
SearchTxtInPut();
}
else if (((Cosmos.UI.CsmButton)sender) == btnEnter) // 승인
{
CompleteTxtInPut(0);
}
else if (((Cosmos.UI.CsmButton)sender) == btnCatApp) // Cat단말기 승인
{
CompleteTxtInPut(1);
}
else if (((Cosmos.UI.CsmButton)sender) == btnExit)
{
this.DialogResult = DialogResult.Cancel;
this.Close();
return;
}
padInPut.SetActiveFocus();
}
catch (Exception ex)
{
WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
bNotDoubleClik = false;
}
bNotDoubleClik = false;
}
#endregion
#region 텍스트박스 키 입력 이벤트 처리
///
/// 텍스트박스 키 입력 이벤트 처리
///
///
///
private void txtEditBox_EditBoxKeyDownEvent(object sender, string sFuncValue)
{
try
{
if (bNotDoubleClik) return;
bNotDoubleClik = true;
try
{
if (sFuncValue == PosKey.MENU_KEY.ENTER)
{
if (((Cosmos.UI.CsmPosEditBox)sender) == txtCardNo)
{
if (txtCardNo.Text == "")
{
if (GetIcCardData(true) == false) return;
}
if (CheckTxtInPut(sender) == false) return;
if (txtTotSavePoint.Text == "")
SearchTxtInPut(); // 조회
else
CompleteTxtInPut(0); // 적립
}
}
else if (sFuncValue == PosKey.MENU_KEY.CLEAR)
{
if (((Cosmos.UI.CsmPosEditBox)sender).ReadOnly == false)
{
if (((Cosmos.UI.CsmPosEditBox)sender) == txtCardNo)
{
ClearCardInfo(); // 카드 입력 정보 클리어
tmrIcCard.Enabled = true;
}
((Cosmos.UI.CsmPosEditBox)sender).Text = "";
}
}
}
catch (Exception ex)
{
WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
}
finally
{
bNotDoubleClik = 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 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);
}
}
#endregion
#region 텍스트박스 입력 유효성 체크
///
/// 텍스트박스 입력 유효성 체크
///
///
///
private bool CheckTxtInPut(object sender)
{
try
{
// 특정 문자값 제거
try
{
if (m_cDevStatus.Msr.STX != "" && txtCardNo.Value.StartsWith(m_cDevStatus.Msr.STX)) txtCardNo.Value = txtCardNo.Value.Substring(1);
int iLastEtx = txtCardNo.Value.LastIndexOf(m_cDevStatus.Msr.ETX);
if (m_cDevStatus.Msr.ETX != "" && iLastEtx > 0) txtCardNo.Value = CmUtil.MidH(txtCardNo.Value, 0, iLastEtx);
}
catch { }
// 카드번호 길이 체크
if (sender == null || ((Cosmos.UI.CsmPosEditBox)sender) == txtCardNo)
{
if (txtCardNo.Value.Length < 10)
{
WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0037);
txtCardNo.Focus();
return false;
}
// 입력된 카드번호 변경 체크
if (txtCardNo.Value != m_sInPutData)
{
if (txtCardNo.Value != m_sInPutData)
{
ClearCardInfo(); // 카드 입력 정보 클리어
}
}
if (m_sInEncData == "")
{
if (m_sInPutData == "")
{
m_sInPutData = txtCardNo.Value;
if (m_sInPutData.Length > 16 && CmUtil.IsNumber(m_sInPutData.Substring(16, 1)) == false)
{
m_sInPutType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_MOBILE_SWIP;
//txtCardNo.Value = m_sInPutData.Substring(0, 16);
}
else
{
m_sInPutType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_KEYIN;
}
if (m_sInPutData.Contains("=") == true) m_sInPutType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_SWIP;
}
if (EncryptedCardNo(m_sInPutData, ref m_sInMaskData, ref m_sInEncData) == false) return false;
}
}
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 입력 완료 처리
///
/// OKCASHBACK 카드 등록 처리
///
///
///
private bool CompleteTxtInPut(int nFlowMode)
{
string sRet = UserCom.RST_ERR;
try
{
if (nFlowMode == 1)
{
//InParam
// 0.전문구분,1.거래유형, 2.할부개월, 3.승인금액 , 4.봉사료, 5.세금, 6.원승인번호, 7.원거래일자, 8.포인트거래구분, 9.상품코드,
//10.전표인쇄여부, 11.추가항목, 12.제휴할인코드, 13.제휴할인금액, 14.예비1, 15.예비2
string sAppType = PosConst.POS_CAT_MASTER.TRADE_ID.CAT_POINT_SAVE;
//적립 금액은 클래스에서 계산 처리함!
//승인처리 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
sRet = m_cPntOcbSave.CompletePayment(new string[] { PosConst.POS_CAT_MASTER.TRAN_TYPE, sAppType, "00", "", "0", "0", "", "", "02", "", "", "", "", "", "", "" });
if (sRet != UserCom.RST_OK)
{
txtCardNo.Focus();
return false;
}
}
else
{
if (CheckTxtInPut(null) == false) return false;
if (m_bSearchSuccess == false)
{
if (SearchTxtInPut() == false) return false; // 조회
}
// OKCASHBACK 카드 등록 처리
sRet = m_cPntOcbSave.SetPayment(new string[] { m_sInPutType, m_sInMaskData, m_sInEncData });
if (sRet != UserCom.RST_OK)
{
txtCardNo.SelectText();
return false;
}
}
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;
}
///
/// OKCASHBACK 카드 조회 처리
///
///
private bool SearchTxtInPut()
{
string sRet = UserCom.RST_ERR;
try
{
if (CheckTxtInPut(null) == false) return false;
txtUsablePoint.Text = "";
txtTotSavePoint.Text = "";
m_bSearchSuccess = false;
// OKCASHBACK 포인트 조회
string[] saRecvdData = null;
sRet = m_cPntOcbSave.SearchPayment(new string[] { m_sInPutType, m_sInMaskData, m_sInEncData }, ref saRecvdData);
if (sRet != UserCom.RST_OK)
{
txtCardNo.SelectText();
return false;
}
// 조회 데이터 획득
Column.TR_ETC.DATA cEtcItem = (Column.TR_ETC.DATA)m_cPntOcbSave.GetPayment(new string[] { });
txtUsablePoint.Text = m_cPosStatus.Global.NumericTOCurrency(cEtcItem.AMT_ENTRY_04); // 가용포인트
txtTotSavePoint.Text = m_cPosStatus.Global.NumericTOCurrency(cEtcItem.AMT_ENTRY_03); // 누적포인트
txtCardNo.SelectText();
m_bSearchSuccess = 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 DeviceEvent 관련
///
/// DeviceEvent 관련
///
///
///
///
///
public void OnDeviceEvent(string sDevice, string sData1, string sData2, string sData3)
{
try
{
if (bNotDoubleClik) return;
bNotDoubleClik = true;
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);
bNotDoubleClik = false;
}
bNotDoubleClik = false;
}
///
/// MSR Event
///
///
///
private void OnMSREvent(object source, EventArgs e)
{
try
{
string sMsrData = m_cDevStatus.Msr.Track2Data;
if (sMsrData.Length > 0)
{
m_sInEncData = "";
m_sInPutType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_SWIP;
m_sInPutData = sMsrData;
txtCardNo.Value = m_sInPutData.Length > 16 ? m_sInPutData.Substring(0, 16) : m_sInPutData;
txtEditBox_EditBoxKeyDownEvent(txtCardNo, PosKey.MENU_KEY.ENTER);
}
}
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 OnScannerEvent(object source, EventArgs e)
{
try
{
string sScanData = m_cDevStatus.Scanner.DataLabel;
if (sScanData.Length > 0)
{
m_sInEncData = "";
m_sInPutData = sScanData;
if (m_sInPutData.Length > 16 && CmUtil.IsNumber(m_sInPutData.Substring(16, 1)) == false)
{
m_sInPutType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_MOBILE_SWIP;
txtCardNo.Value = m_sInPutData.Substring(0, 16);
}
else
{
m_sInPutType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_KEYIN;
txtCardNo.Value = m_sInPutData;
}
txtEditBox_EditBoxKeyDownEvent(txtCardNo, PosKey.MENU_KEY.ENTER);
}
}
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 bool EncryptedCardNo(string sInData, ref string sInMaskData, ref string sInEncData)
{
string sEncData = sInData;
bool bRet = false;
try
{
if (PosMstManager.GetPosOption(POS_OPTION.OPT326) != "0" && PosMstManager.GetPosOption(POS_OPTION.OPT326) != "" && m_cDevStatus.ICReader.UseYn != true) // OCB 직통신
{
sInEncData = sEncData;
sInMaskData = sEncData;
bRet = true;
}
else
{
UnRegIcCallback(); // IC리더 콜백 해지
sEncData = m_cDeviceICReader.GetEncryptedCardNo(sInData).Trim();
if (CmUtil.MidH(sEncData, 0, 2) == "00")
{
sInEncData = CmUtil.MidH(sEncData, 2, 512).Trim(); // 암호화 데이터
sInMaskData = CmUtil.MidH(sEncData, 514, sEncData.Length - 514).Trim(); // 마스킹 데이터
bRet = true;
}
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);
WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0280);
}
if (txtCardNo.Value == "") tmrIcCard.Enabled = true; // IC리더 콜백 설정
}
}
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 bRet;
}
///
/// IC 카드 정보 입력 처리
///
///
private bool GetIcCardData(bool bCancelCallBack)
{
string sRsvStr = "";
try
{
if (PosMstManager.GetPosOption(POS_OPTION.OPT326) != "0" && PosMstManager.GetPosOption(POS_OPTION.OPT326) != "" && m_cDevStatus.ICReader.UseYn != true) // OCB 직통신
return true;
if (bCancelCallBack == true) UnRegIcCallback(); // IC리더 콜백 해지
txtCardNo.Value = "";
ClearCardInfo(); // 카드 입력 정보 클리어
if (m_cDeviceICReader.GetCardInfo_ICReader(PosConst.IC_READER_TRAN_TYPE.POINT, (int)m_cTrnStatus.Head.NetSaleAmt, ref sRsvStr) == true)
{
if (CmUtil.MidH(sRsvStr, 0, 2) == "00")
{
m_sInEncData = CmUtil.MidH(sRsvStr, 6, 512).Trim();
m_sInMaskData = CmUtil.MidH(sRsvStr, 1030, 37).Trim();
m_sInPutData = m_sInMaskData;
m_sInPutType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_SWIP;
txtCardNo.Value = m_sInPutData.Length > 16 ? m_sInPutData.Substring(0, 16) : m_sInPutData;
//tmrIcCard.Enabled = true; // IC리더 콜백 설정
return true;
}
}
tmrIcCard.Enabled = true; // IC리더 콜백 설정
// WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0321);
}
catch (Exception ex)
{
WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
}
finally
{
// 여전법 대응////////////////////////////////////////////////////////////////////
CmUtil.ZeroFillClear(ref sRsvStr);
//////////////////////////////////////////////////////////////////////////////////
}
return false;
}
///
/// RF 카드 정보 입력 처리
///
///
private bool GetRfCardData()
{
string sRsvStr = "";
try
{
txtCardNo.Value = "";
ClearCardInfo(); // 카드 입력 정보 클리어
//카드 정보 입력
if (m_cDeviceICReader.GetRfCreditCardInfo("1", m_cTrnStatus.Head.NetSaleAmt.ToString(), "", "", "", ref sRsvStr) == false)
{
if (sRsvStr != "") WinManager.ErrorMessage(sRsvStr);
return false;
}
m_sInEncData = CmUtil.MidH(sRsvStr, 2, 512).Trim();
m_sInMaskData = CmUtil.MidH(sRsvStr, 514, 40).Trim();
m_sInPutData = m_sInMaskData;
m_sInPutType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_RF;
txtCardNo.Value = m_sInPutData.Length > 16 ? m_sInPutData.Substring(0, 16) : m_sInPutData;
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);
}
finally
{
// 여전법 대응////////////////////////////////////////////////////////////////////
CmUtil.ZeroFillClear(ref sRsvStr);
//////////////////////////////////////////////////////////////////////////////////
}
return false;
}
#endregion
private void gridList_Enter(object sender, EventArgs e)
{
padInPut.SetActiveFocus();
}
private void lblCardNo_MouseDown(object sender, MouseEventArgs e)
{
//if (e.Button == System.Windows.Forms.MouseButtons.Right)
//{
// m_cDevStatus.Scanner.DataLabel = "8231124183433925%";
// OnScannerEvent(null, null);
//}
}
///
/// MoonSeokWoo 2017.11.03 Add 카드번호 입력처리.
///
///
private bool GetPinPadData()
{
try
{
txtCardNo.Value = "";
ClearCardInfo(); // 카드 입력 정보 클리어
string sRsvStr = "";
if (m_cDeviceSignPad.GetMsg_SignPad(false, MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0065), ref sRsvStr) == false)
{
//WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0321);
return false;
}
txtCardNo.Value = sRsvStr;
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;
}
#region 여전법 대응
///
/// ZeroFill 초기화
///
private void InDataToZeroFill()
{
try
{
//여전법 대응!
//////////////////////////////////////////////////////////////////////////////////
CmUtil.ZeroFillClear(ref m_sInPutData);
CmUtil.ZeroFillClear(ref m_sInEncData);
CmUtil.ZeroFillClear(ref m_sInMaskData);
//////////////////////////////////////////////////////////////////////////////////
txtCardNo.Value = string.Empty;
}
catch (Exception) { }
}
#endregion 여전법 대응
#region IC리더 콜백 관련
///
/// IC리더 콜백 설정
///
///
///
private void tmrIcCard_Tick(object sender, EventArgs e)
{
try
{
if (m_cDevStatus.ICReader.UseYn != true) // 여전법 인증여부(0:MSR, 1:IC)
{
tmrIcCard.Enabled = false;
return;
}
if (tmrIcCard.Tag == null || tmrIcCard.Tag.ToString() == "")
{
// IC리더 콜백 설정
if (bNotDoubleClik) return;
tmrIcCard.Enabled = false;
//#20170918 IC 콜백 함수 변경 start
//포인트창에서 해피제휴 신용카드 리딩시 IC 우선 거래로 인해 '카드를 읽혀 주세요' 팝업 나오는 현상 수정.
//기존
m_cDeviceICReader.RegIcCallback(delegateReader);
//변경
//string sApprID = PosMstManager.GetMstVan(ItemConst.TR_ITEM_ID.CREDITCARD_ITEM, ItemConst.TR_ITEM_ID.CREDITCARD.CREDIT_CARD, PosMst.MST_VAN.DATA.APPR_ID);
//m_cDeviceICReader.RegIcCallbackCardInfo(sApprID, m_cDataService.IntParse(txtPayAmt.Text), delegateReaderCardInfo);
//#20170918 IC 콜백 함수 변경 end
}
else if (tmrIcCard.Tag.ToString() == "MSR")
{
// MSR 카드 읽기
tmrIcCard.Enabled = false;
tmrIcCard.Tag = "";
tmrIcCard.Interval = 500;
bNotDoubleClik = false;
txtEditBox_EditBoxKeyDownEvent(txtCardNo, PosKey.MENU_KEY.ENTER);
tmrIcCard.Enabled = true;
}
else if (tmrIcCard.Tag.ToString() == "IC")
{
// IC리더 카드 읽기
tmrIcCard.Enabled = false;
tmrIcCard.Tag = "";
tmrIcCard.Interval = 500;
bNotDoubleClik = false;
btnProc_Click(btnIcCard, null);
}
else
tmrIcCard.Enabled = 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);
}
}
delegate void DelegateIcReaderCallBack(int rc, StringBuilder str);
///
/// IC리더 콜백 함수
///
///
///
public void OnIcReaderCallBack(int num, StringBuilder str)
{
try
{
if (txtCardNo.InvokeRequired)
{
DelegateIcReaderCallBack d = new DelegateIcReaderCallBack(OnIcReaderCallBack);
this.Invoke(d, new object[] { num, str });
}
else
{
if (bNotDoubleClik) return;
bNotDoubleClik = true;
if (num == 1)
{
// IC 카드
tmrIcCard.Tag = "IC";
tmrIcCard.Interval = 100;
}
else
{
// MSR 카드
if (str.ToString().StartsWith("EN") == true)
{
ClearCardInfo(); // 카드 입력 정보 클리어
m_sInEncData = CmUtil.MidH(str.ToString(), 0, 512).Trim();
m_sInMaskData = CmUtil.MidH(str.ToString(), 512, 40).Trim();
m_sInPutData = m_sInMaskData;
m_sInPutType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_SWIP;
txtCardNo.Value = m_sInPutData;
tmrIcCard.Tag = "MSR";
tmrIcCard.Interval = 100;
}
else
{
tmrIcCard.Interval = 500;
}
}
tmrIcCard.Enabled = true;
bNotDoubleClik = 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;
}
}
///
/// IC리더 콜백 해지
///
private void UnRegIcCallback()
{
try
{
if (m_cDevStatus.ICReader.UseYn == true) // 여신전문금융업법 적용여부 체크
{
tmrIcCard.Enabled = false;
//#20170918 IC 콜백 함수 변경 start
//포인트창에서 해피제휴 신용카드 리딩시 IC 우선 거래로 인해 '카드를 읽혀 주세요' 팝업 나오는 현상 수정.
//기존
m_cDeviceICReader.UnRegIcCallback();
//변경
//m_cDeviceICReader.UnRegIcCallbackCardInfo();
//#20170918 IC 콜백 함수 변경 end
}
}
catch (Exception ex)
{
WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
}
}
//#20170918 IC 콜백 함수 변경 start
//포인트창에서 해피제휴 신용카드 리딩시 IC 우선 거래로 인해 '카드를 읽혀 주세요' 팝업 나오는 현상 수정.
/*
delegate void DelegateWriteLog(int returnValue, StringBuilder returnData);
///
/// IC리더 콜백 함수(CardInfo)
///
///
///
public void OnIcReaderCallBackCardInfo(int returnValue, StringBuilder returnData)
{
if (txtCardNo.InvokeRequired)
{
DelegateWriteLog d = new DelegateWriteLog(OnIcReaderCallBackCardInfo);
this.Invoke(d, new object[] { returnValue, returnData });
}
else
{
if (m_bCardInPut) return;
m_bCardInPut = true;
if (returnValue > 0)
{
string sRsvStr = returnData.ToString();
if (CmUtil.MidH(sRsvStr, 0, 2) == "00")
{
m_sCardNo = CmUtil.MidH(sRsvStr, 6, 512).Trim();
txtCardNo.Value = CmUtil.MidH(sRsvStr, 1030, 37).Trim();
m_sIcChip = CmUtil.MidH(sRsvStr, 518, 512).Trim();
if (CmUtil.MidH(sRsvStr, 4, 2).Trim() == "02")
{
m_InputType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_SWIP;
}
else
{
m_InputType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_IC;
}
m_sServiceCode = CmUtil.MidH(sRsvStr, 1067, 5).Trim();
m_sFallDiv = CmUtil.MidH(sRsvStr, 3, 1); // == "3" ? "0" : "1";
// IC 카드(CardInfo)
tmrIcCard.Tag = "ICREADER";
tmrIcCard.Interval = 100;
tmrIcCard.Enabled = true;
m_bCardInPut = false;
}
}
}
}
*/
//#20170918 IC 콜백 함수 변경 end
#endregion
}
}