using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.IO;
using System.ComponentModel;
using System.Windows.Input;
using System.Windows.Media.Animation;
using System.Windows;
using System.Collections.ObjectModel;
//using System.Windows.Forms;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Threading;
#region SPC.Kiosk
using SPC.Kiosk.Common;
using SPC.Kiosk.Base;
using SPC.Kiosk.PB.Model;
using SPC.Kiosk.Popup;
using SPC.Kiosk.Popup.Model;
using SPC.Kiosk.Popup.ViewModel;
using SPC.Kiosk.Payments;
using SPC.Kiosk.DataHelper;
#endregion

namespace SPC.Kiosk.PB.ViewModel
{
    /// <summary>
    /// PBPaymentsWindow View Model
    /// </summary>
    public class PBPaymentsViewModel : PopupViewModelBase
    {
        #region [ Members ]
        private PosDataService posDataService = null;
        public bool FirstLoaded { get; set; } = true;
        private PopupManager popupManager = PopupManager.GetInstance;

        /// <summary>
        /// Wait Wiondow
        /// </summary>
        public WaitWindow WaitWindowFrom { get; set; }
        private PBPaymentPageType defaultPage = PBPaymentPageType.DetailBasket;
        
        private NhsFuncInfoItem nhsFuncInfo;
        /// <summary>
        /// NHS Func Info
        /// </summary>
        public NhsFuncInfoItem NhsFuncInfo
        {
            get { return nhsFuncInfo; }
            set { nhsFuncInfo = value; PropertyChange("NhsFuncInfo"); }
        }

        /// <summary>
        /// Default Page
        /// </summary>
        public PBPaymentPageType DefaultPage
        {
            get { return defaultPage; }
            set { defaultPage = value; PropertyChange("DefaultPage"); }
        }

        private string optionValue802;
        /// <summary>
        /// 진동벨 사용유무
        /// </summary>
        public string OptionValue802
        {
            get { return optionValue802; }
            set { optionValue802 = value; PropertyChange("OptionValue802"); }
        }
        private string optionValue803;
        /// <summary>
        /// 알림톡 사용유무
        /// </summary>
        public string OptionValue803
        {
            get { return optionValue803; }
            set { optionValue803 = value; PropertyChange("OptionValue803"); }
        }
        private string optionValue804;
        /// <summary>
        /// 대기번호 사용유무
        /// </summary>
        public string OptionValue804
        {
            get { return optionValue804; }
            set { optionValue804 = value; PropertyChange("OptionValue804"); }
        }

        #region BaseValue
        private ObservableCollection<M_BasketItem> detailBasketData;
        /// <summary>
        /// Detail Basket Data
        /// </summary>
        public ObservableCollection<M_BasketItem> DetailBasketData
        {
            get { return detailBasketData; }
            set
            {

                if (detailBasketData is ObservableCollection<M_BasketItem>
                        && detailBasketData.Count > 0)
                {
                    foreach (var DetailItem in detailBasketData)
                    {
                        DetailItem.PropertyChanged -= DetailItem_PropertyChanged;
                    }
                }
                detailBasketData = value;
                PropertyChange("DetailBasketData");
            }
        }
        private ObservableCollection<M_DiscountAndAddValues> discountValues;
        /// <summary>
        /// 할인 금액,결제 금액,사은품
        /// </summary>
        public ObservableCollection<M_DiscountAndAddValues> DiscountValues
        {
            get { return discountValues; }
            set { discountValues = value; PropertyChange("DiscountValues"); }
        }


        private ObservableCollection<M_BasketItem> scanBarcodeBasketData;
        /// <summary>
        /// ScanBarcode Detail Basket Data
        /// </summary>
        public ObservableCollection<M_BasketItem> ScanBarcodeBasketData
        {
            get { return scanBarcodeBasketData; }
            set
            {
                scanBarcodeBasketData = value; PropertyChange("ScanBarcodeBasketData");
            }
        }
        private ObservableCollection<M_BasketItem> orderBasketData;
        /// <summary>
        /// Order Detail Basket Data
        /// </summary>
        public ObservableCollection<M_BasketItem> OrderBasketData
        {
            get { return orderBasketData; }
            set
            {
                orderBasketData = value; PropertyChange("OrderBasketData");
            }
        }
        private M_HappyPointReturn happyPointReturn;
        /// <summary>
        /// HappyPoint Data
        /// </summary>
        public M_HappyPointReturn HappyPointReturn
        {
            get { return happyPointReturn; }
            set { happyPointReturn = value; PropertyChange("HappyPointReturn"); }
        }
        private M_OkCashBagReturn okCashBagReturn;
        /// <summary>
        /// Ok CashBag Data
        /// </summary>
        public M_OkCashBagReturn OkCashBagReturn
        {
            get { return okCashBagReturn; }
            set { okCashBagReturn = value; PropertyChange("OkCashBagReturn"); }
        }
        private M_MobileCompanyReturn mobileCompanyReturn;
        /// <summary>
        /// MobileCompany Discount Data
        /// </summary>
        public M_MobileCompanyReturn MobileCompanyReturn
        {
            get { return mobileCompanyReturn; }
            set { mobileCompanyReturn = value; PropertyChange("MobileCompanyReturn"); }
        }

        private M_PaymentReturn paymentReturn;
        /// <summary>
        ///  Payments Return
        /// </summary>
        public M_PaymentReturn PaymentReturn
        {
            get { return paymentReturn; }
            set { paymentReturn = value; PropertyChange("PaymentReturn"); }
        }
        /// <summary>
        /// Payments End Return
        /// </summary>
        private M_PaymentEndReturn paymentEndReturn;
        /// <summary>
        ///  Payments Return
        /// </summary>
        public M_PaymentEndReturn PaymentEndReturn
        {
            get { return paymentEndReturn; }
            set { paymentEndReturn = value; PropertyChange("PaymentEndReturn"); }
        }
        private M_MobileCouponReturn mobileCouponReturn;
        /// <summary>
        /// Mobile Coupon Return
        /// </summary>
        public M_MobileCouponReturn MobileCouponReturn
        {
            get { return mobileCouponReturn; }
            set { mobileCouponReturn = value; PropertyChange("MobileCouponReturn"); }
        }
        private M_HappyCoupon usingHappyAppCoupon;
        /// <summary>
        /// Used Happy Coupon
        /// </summary>
        public M_HappyCoupon UsingHappyAppCoupon
        {
            get { return usingHappyAppCoupon; }
            set { usingHappyAppCoupon = value; PropertyChange("UsingHappyAppCoupon"); }
        }
        #endregion

        #region GMB

        #region GMB Left
        /// <summary>
        /// Gmb Logo
        /// </summary>
        public string GmbLogo { get; set; } = ResourceManager.GetNximagePathAdd("Img_main_logo.png", CommonValue.PBdesignImagesPath);
        #endregion

        #region GMB Center 
        private List<M_Language> gMBHeaderText;
        /// <summary>
        /// Top Header Text 
        /// </summary>
        public List<M_Language> GMBHeaderText
        {
            get { return gMBHeaderText; }
            set { gMBHeaderText = value; PropertyChange("GMBHeaderText"); }
        }

        private string gmbMemberName;
        /// <summary>
        /// Gmb Member Name        
        /// /// </summary>
        public string GmbMemberName
        {
            get { return gmbMemberName; }
            set { gmbMemberName = value; PropertyChange("GmbMemberName"); }
        }

        private bool memberLoginOK = false;
        /// <summary>
        /// Member Login OK
        /// </summary>
        public bool MemberLoginOK
        {
            get { return memberLoginOK; }
            set { memberLoginOK = value; PropertyChange("MemberLoginOK"); }
        }

        #endregion

        #region GMB Right
        /// <summary>
        /// GMB HappyPoint image
        /// </summary>
        public string GmbHappyPointimage { get; set; } = ResourceManager.GetNximagePathAdd("btn_happypoint_d.png", CommonValue.PBdesignImagesPath);
        /// <summary>
        /// GMB HappyPoint Disable Image
        /// </summary>
        public string GmbHappyPointDisable { get; set; } = ResourceManager.GetNximagePathAdd("btn_happypoint_n.png", CommonValue.PBdesignImagesPath);
        /// <summary>
        /// GMB Call Employee Image
        /// </summary>
        public string GmbCallimage { get; set; } = ResourceManager.GetNximagePathAdd("btn_help.png", CommonValue.PBdesignImagesPath);
        /// <summary>
        /// GMB Goto Home Image
        /// </summary>
        public string GmbHomeimage { get; set; } = ResourceManager.GetNximagePathAdd("btn_reset.png", CommonValue.PBdesignImagesPath);
        private string gmbLanguageimage = ResourceManager.GetNximagePathAdd("btn_language_kor.png", CommonValue.PBdesignImagesPath);
        /// <summary>
        /// GMB Language Image
        /// </summary>
        public string GmbLanguageimage
        {
            get { return gmbLanguageimage; }
            set { gmbLanguageimage = value; PropertyChange("GmbLanguageimage"); }
        }
        private bool gmbHome = true;
        /// <summary>
        ///  GMB Goto Home Enabled
        /// GMB Language
        /// </summary>
        public bool GmbHome
        {
            get { return gmbHome; }
            set { gmbHome = value; PropertyChange("GmbHome"); }
        }
        private bool gmbHappyPointEnable = true;
        /// <summary>
        /// Gmb Happy Point Button Enable
        /// </summary>
        public bool GmbHappyPointEnable
        {
            get { return gmbHappyPointEnable; }
            set { gmbHappyPointEnable = value; PropertyChange("GmbHappyPointEnable"); }
        }
        private bool gmbEmpCall = true;
        /// <summary>
        /// GMB Call Employee Enabled
        /// </summary>
        public bool GmbEmpCall
        {
            get { return gmbEmpCall; }
            set { gmbEmpCall = value; PropertyChange("GmbEmpCall"); }
        }
        private bool gmbLanguage = true;
        /// <summary>
        /// GMB Language Enabled
        /// </summary>
        public bool GmbLanguage
        {
            get { return gmbLanguage; }
            set { gmbLanguage = value; PropertyChange("GmbLanguage"); }
        }
        /// <summary>
        /// GMB Call Employee Command
        /// </summary>
        public ICommand CallEmployeeCommand { get; protected set; } = null;
        /// <summary>
        /// GMB Language Command
        /// </summary>
        public ICommand LanguageCommand { get; protected set; } = null;
        /// <summary>
        /// GMB Goto Intro Page Commad
        /// </summary>
        public ICommand GotoIntroPageCommad { get; protected set; } = null;

        #endregion

        #endregion

        #region Contents
        /// <summary>
        /// Info Logo
        /// </summary>
        public string InfoLogo { get; set; } = ResourceManager.GetNximagePathAdd("ic_info.png", CommonValue.PBdesignImagesPath);
        /// <summary>
        /// Info x mark Logo
        /// </summary>
        public string InfoLogoX { get; set; } = ResourceManager.GetNximagePathAdd("ic_info_x.png", CommonValue.PBdesignImagesPath);
        /// <summary>
        /// Step Buttons Background
        /// </summary>
        public string ButtonBackground { get; set; } = ResourceManager.GetNximagePathAdd("step_bg.png", CommonValue.PBdesignImagesPath);
        /// <summary>
        /// Step1 Selected Brush
        /// </summary>
        public string Step1DisableBrush { get; set; } = ResourceManager.GetNximagePathAdd("step01.png", CommonValue.PBdesignImagesPath);
        /// <summary>
        /// Step2 Selected Brush
        /// </summary>
        public string Step2DisableBrush { get; set; } = ResourceManager.GetNximagePathAdd("step02.png", CommonValue.PBdesignImagesPath);
        /// <summary>
        /// Step3 Selected Brush
        /// </summary>
        public string Step3DisableBrush { get; set; } = ResourceManager.GetNximagePathAdd("step03.png", CommonValue.PBdesignImagesPath);
        /// <summary>
        /// Basket All Delete Brush
        /// </summary>
        public string BasketDeleteBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_basket_delete.png", CommonValue.PBdesignImagesPath);
        /// <summary>
        /// Basket EMpty Brush
        /// </summary>
        public string BasketNoneBrush { get; set; } = ResourceManager.GetNximagePathAdd("bg_basket_none.png", CommonValue.PBdesignImagesPath);
        private bool gotoPointsDisCountsEnable = true;
        /// <summary>
        /// Goto Point & Discount Enabled
        /// </summary>
        public bool GotoPointsDisCountsEnable
        {
            get { return gotoPointsDisCountsEnable; }
            set { gotoPointsDisCountsEnable = value; PropertyChange("GotoPointsDisCountsEnable"); }
        }
        /// <summary>
        /// Goto Point & Discount Command
        /// </summary>
        public ICommand GotoPointsDisCountsCommand { get; protected set; } = null;
        private bool gotoCouponUsePointsEnable = true;
        /// <summary>
        /// Goto Coupon & Using Points Enabled
        /// </summary>
        public bool GotoCouponUsePointsEnable
        {
            get { return gotoCouponUsePointsEnable; }
            set { gotoCouponUsePointsEnable = value; PropertyChange("GotoCouponUsePointsEnable"); }
        }
        /// <summary>
        /// Goto Coupon & Using Points Command
        /// </summary>
        public ICommand GotoCouponUsePointsCommand { get; protected set; } = null;
        private bool gotoPaymentExcuteEnable = true;
        /// <summary>
        /// Goto Payment Execute Enabled
        /// </summary>
        public bool GotoPaymentExcuteEnable
        {
            get { return gotoPaymentExcuteEnable; }
            set { gotoPaymentExcuteEnable = value; PropertyChange("GotoPaymentExcuteEnable"); }
        }
        /// <summary>
        /// Goto Payment Execute Command
        /// </summary>
        public ICommand GotoPaymentExcuteCommand { get; protected set; } = null;

        #region Detail Basket
        /// <summary>
        /// Page to Left Normal Image
        /// </summary>
        public string Page2LeftNormalImage { get; set; } = ResourceManager.GetNximagePathAdd("btn_page_before_n.png", CommonValue.PBdesignImagesPath);
        /// <summary>
        /// Page to Right Normal Image
        /// </summary>
        public string Page2RightNormalImage { get; set; } = ResourceManager.GetNximagePathAdd("btn_page_after_n.png", CommonValue.PBdesignImagesPath);
        private bool scanPage2LeftEnable;
        /// <summary>
        /// Scan Page 2 Left Button Enabled
        /// </summary>
        public bool ScanPage2LeftEnable
        {
            get { return scanPage2LeftEnable; }
            set { scanPage2LeftEnable = value; PropertyChange("ScanPage2LeftEnable"); }
        }
        private bool scanPage2RightEnable;
        /// <summary>
        /// Scan Page to Right Button Enabled
        /// </summary>
        public bool ScanPage2RightEnable
        {
            get { return scanPage2RightEnable; }
            set { scanPage2RightEnable = value; PropertyChange("ScanPage2RightEnable"); }
        }
        private bool orderPage2LeftEnable;
        /// <summary>
        /// Order Page to Left Button Enabled
        /// </summary>
        public bool OrderPage2LeftEnable
        {
            get { return orderPage2LeftEnable; }
            set { orderPage2LeftEnable = value; PropertyChange("OrderPage2LeftEnable"); }
        }
        private bool orderPage2RightEnable;
        /// <summary>
        /// Order Page to Right Button Enabled
        /// </summary>
        public bool OrderPage2RightEnable
        {
            get { return orderPage2RightEnable; }
            set { orderPage2RightEnable = value; PropertyChange("OrderPage2RightEnable"); }
        }
        private int scanItemCount;
        /// <summary>
        /// Scan Items Count
        /// </summary>
        public int ScanItemCount
        {
            get { return scanItemCount; }
            set { scanItemCount = value; PropertyChange("ScanItemCount"); }
        }
        private int scanItemPageNo;
        /// <summary>
        /// Scan Items Page No
        /// </summary>
        public int ScanItemPageNo
        {
            get { return scanItemPageNo; }
            set { scanItemPageNo = value; PropertyChange("ScanItemPageNo"); }
        }
        private int scanItemPageCount;
        /// <summary>
        /// Scan Items Page Count
        /// </summary>
        public int ScanItemPageCount
        {
            get { return scanItemPageCount; }
            set { scanItemPageCount = value; PropertyChange("ScanItemPageCount"); }
        }
        private int orderItemCount;
        /// <summary>
        /// Order Items Count
        /// </summary>
        public int OrderItemCount
        {
            get { return orderItemCount; }
            set { orderItemCount = value; PropertyChange("OrderItemCount"); }
        }

        private int orderItemPageNo;
        /// <summary>
        /// Order Items PageNo
        /// </summary>
        public int OrderItemPageNo
        {
            get { return orderItemPageNo; }
            set { orderItemPageNo = value; PropertyChange("OrderItemPageNo"); }
        }
        private int orderItemPageCount;
        /// <summary>
        /// Order Items Page Count
        /// </summary>
        public int OrderItemPageCount
        {
            get { return orderItemPageCount; }
            set { orderItemPageCount = value; PropertyChange("OrderItemPageCount"); }
        }
        private ObservableCollection<M_ItemData> scanItemPageStatus;
        /// <summary>
        /// Scan Items Page Selector Data
        /// </summary>
        public ObservableCollection<M_ItemData> ScanItemPageStatus
        {
            get { return scanItemPageStatus; }
            set { scanItemPageStatus = value; PropertyChange("ScanItemPageStatus"); }
        }
        private ObservableCollection<M_ItemData> orderItemPageStatus;
        /// <summary>
        /// Order Items Page Salector Data
        /// </summary>
        public ObservableCollection<M_ItemData> OrderItemPageStatus
        {
            get { return orderItemPageStatus; }
            set { orderItemPageStatus = value; PropertyChange("OrderItemPageStatus"); }
        }
        private int scanPageStatusColumnCount;
        /// <summary>
        /// Scan Item Page Selector Column Count
        /// </summary>
        public int ScanPageStatusColumnCount
        {
            get { return scanPageStatusColumnCount; }
            set { scanPageStatusColumnCount = value; PropertyChange("ScanPageStatusColumnCount"); }
        }
        private int orderPageStatusColumnCount;
        /// <summary>
        /// Order Items Page Selector Column Count
        /// </summary>
        public int OrderPageStatusColumnCount
        {
            get { return orderPageStatusColumnCount; }
            set { orderPageStatusColumnCount = value; PropertyChange("OrderPageStatusColumnCount"); }
        }
        /// <summary>
        /// Scan Item Page to Left Command
        /// </summary>
        public ICommand ScanPage2LeftCommand { get; protected set; } = null;
        /// <summary>
        /// Scan Item Page to Right Command
        /// </summary>
        public ICommand ScanPage2RightCommand { get; protected set; } = null;
        /// <summary>
        /// Order Item Page to left Command
        /// </summary>
        public ICommand OrderPage2LeftCommand { get; protected set; } = null;
        /// <summary>
        /// Order Item Page to right Command
        /// </summary>
        public ICommand OrderPage2RightCommand { get; protected set; } = null;
        /// <summary>
        /// Scan Page Selector Command
        /// </summary>
        public ICommand ScanPageSelectCommand { get; protected set; } = null;
        /// <summary>
        /// Order Page Selector Command
        /// </summary>
        public ICommand OrderPageSelectCommand { get; protected set; } = null;
        /// <summary>
        /// Scan Items Delete Command
        /// </summary>
        public ICommand ScanBarcodeDeleteCommand { get; protected set; } = null;
        /// <summary>
        /// Order Item Delete Command
        /// </summary>
        public ICommand OrderDeleteCommand { get; protected set; } = null;
        /// <summary>
        /// Scan Items All Delete Command
        /// </summary>
        public ICommand ScanBarcodeAllDeleteCommand { get; protected set; } = null;
        /// <summary>
        /// Order Items All Delete Command
        /// </summary>
        public ICommand OrderAllDeleteCommand { get; protected set; } = null;
        #endregion
        #region PointsDisCounts
        /// <summary>
        /// Happy Point Resrve Noraml Brush
        /// </summary>
        public string HappyPointResrveNoramlBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_happypoint_n.png", CommonValue.PBdesignImagesPath);
        /// <summary>
        /// Happy Point Resrve SwitchOn Brush
        /// </summary>
        public string HappyPointResrveSwitchOnBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_happypoint_f.png", CommonValue.PBdesignImagesPath);
        /// <summary>
        /// Happy Point Resrve Disabled Brush
        /// </summary>
        public string HappyPointResrveDisableBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_happypoint_d.png", CommonValue.PBdesignImagesPath);

        private bool happyPointResrveSwitch;
        /// <summary>
        /// Happy Point Resrve Switch
        /// </summary>
        public bool HappyPointResrveSwitch
        {
            get { return happyPointResrveSwitch; }
            set { happyPointResrveSwitch = value; PropertyChange("HappyPointResrveSwitch"); }
        }
        private bool happyPointResrveEnable = true;
        /// <summary>
        /// Happy Point Resrve Enable
        /// </summary>
        public bool HappyPointResrveEnable
        {
            get { return happyPointResrveEnable; }
            set { happyPointResrveEnable = value; PropertyChange("HappyPointResrveEnable"); }
        }
        /// <summary>
        /// Happy Point Resrve Command
        /// </summary>
        public ICommand HappyPointResrveCommand { get; protected set; } = null;
        
        
        /// <summary>
        /// OkCashBag Resrve Noraml Brush
        /// </summary>
        public string OkCashBagResrveNoramlBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_ocb_n.png", CommonValue.PBdesignImagesPath);
        /// <summary>
        /// OkCashBag Resrve SwitchOn Brush
        /// </summary>
        public string OkCashBagResrveSwitchOnBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_ocb_f.png", CommonValue.PBdesignImagesPath);
        /// <summary>
        /// OkCashBag Resrve Disabled Brush
        /// </summary>
        public string OkCashBagResrveDisableBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_ocb_d.png", CommonValue.PBdesignImagesPath);
        private bool okCashBagResrveSwitch;
        /// <summary>
        /// OkCashBag Resrve Switch
        /// </summary>
        public bool OkCashBagResrveSwitch
        {
            get { return okCashBagResrveSwitch; }
            set { okCashBagResrveSwitch = value; PropertyChange("OkCashBagResrveSwitch"); }
        }
        private bool okCashBagResrveEnable = true;
        /// <summary>
        /// OkCashBag Resrve Enabled
        /// </summary>
        public bool OkCashBagResrveEnable
        {
            get { return okCashBagResrveEnable; }
            set { okCashBagResrveEnable = value; PropertyChange("OkCashBagResrveEnable"); }
        }
        /// <summary>
        /// OkCashBag Resrve Command
        /// </summary>
        public ICommand OkCashBagResrveCommand { get; protected set; } = null;
        
        
        
        
        /// <summary>
        /// Discount SK Noraml Brush
        /// </summary>
        public string DiscountSKNoramlBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_sk_n.png", CommonValue.PBdesignImagesPath);
        /// <summary>
        /// Discount SK SwitchOn Brush
        /// </summary>
        public string DiscountSKSwitchOnBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_sk_f.png", CommonValue.PBdesignImagesPath);
        /// <summary>
        /// Discount SK Disables Brush
        /// </summary>
        public string DiscountSKDisableBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_sk_d.png", CommonValue.PBdesignImagesPath);
        private bool discountSKSwitch;
        /// <summary>
        /// Discount SK Switch
        /// </summary>
        public bool DiscountSKSwitch
        {
            get { return discountSKSwitch; }
            set { discountSKSwitch = value; PropertyChange("DiscountSKSwitch"); }
        }
        private bool discountSKEnable = true;
        /// <summary>
        /// Discount SK Enable
        /// </summary>
        public bool DiscountSKEnable
        {
            get { return discountSKEnable; }
            set { discountSKEnable = value; PropertyChange("DiscountSKEnable"); }
        }
        /// <summary>
        /// Discount SK Command
        /// </summary>
        public ICommand DiscountSKCommand { get; protected set; } = null;
        /// <summary>
        /// Discount KT Noraml Brush
        /// </summary>
        public string DiscountKTNoramlBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_kt_n.png", CommonValue.PBdesignImagesPath);
        /// <summary>
        /// Discount KT SwitchOn Brush
        /// </summary>
        public string DiscountKTSwitchOnBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_kt_f.png", CommonValue.PBdesignImagesPath);
        /// <summary>
        /// Discount KT Disabled Brush
        /// </summary>
        public string DiscountKTDisableBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_kt_d.png", CommonValue.PBdesignImagesPath);
        private bool discountKTSwitch;
        /// <summary>
        /// Discount KT Switch
        /// </summary>
        public bool DiscountKTSwitch
        {
            get { return discountKTSwitch; }
            set { discountKTSwitch = value; PropertyChange("DiscountKTSwitch"); }
        }
        private bool discountKTEnable = true;
        /// <summary>
        /// Discount KT  Enabled
        /// </summary>
        public bool DiscountKTEnable
        {
            get { return discountKTEnable; }
            set { discountKTEnable = value; PropertyChange("DiscountKTEnable"); }
        }
        /// <summary>
        /// Discount KT Command
        /// </summary>
        public ICommand DiscountKTCommand { get; protected set; } = null;
        /// <summary>
        /// Discount LG Noraml Brush
        /// </summary>
        public string DiscountLGNoramlBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_lg_n.png", CommonValue.PBdesignImagesPath);
        /// <summary>
        /// Discount LG SwitchOn Brush
        /// </summary>
        public string DiscountLGSwitchOnBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_lg_f.png", CommonValue.PBdesignImagesPath);
        /// <summary>
        /// Discount LG Disables Brush
        /// </summary>
        public string DiscountLGDisableBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_lg_d.png", CommonValue.PBdesignImagesPath);
        private bool discountLGSwitch;
        /// <summary>
        /// Discount LG Switch
        /// </summary>
        public bool DiscountLGSwitch
        {
            get { return discountLGSwitch; }
            set { discountLGSwitch = value; PropertyChange("DiscountLGSwitch"); }
        }
        private bool discountLGEnable = true;
        /// <summary>
        /// Discount LG Enabled
        /// </summary>
        public bool DiscountLGEnable
        {
            get { return discountLGEnable; }
            set { discountLGEnable = value; PropertyChange("DiscountLGEnable"); }
        }
        /// <summary>
        /// Discount LG Command
        /// </summary>
        public ICommand DiscountLGCommand { get; protected set; } = null;


        /// <summary>
        /// SpcDiscount2 Noraml Brush
        /// </summary>
        public string SpcDiscount2NoramlBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_spc2_n.png", CommonValue.PBdesignImagesPath);
        /// <summary>
        /// SpcDiscount2 SwitchOn Brush
        /// </summary>
        public string SpcDiscount2SwitchOnBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_spc2_f.png", CommonValue.PBdesignImagesPath);
        /// <summary>
        /// OkCashBag Resrve Disabled Brush
        /// </summary>
        public string SpcDiscount2DisableBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_spc2_d.png", CommonValue.PBdesignImagesPath);
        private bool spcDiscount2Switch;
        /// <summary>
        /// SpcDiscount2 Switch
        /// </summary>
        public bool SpcDiscount2Switch
        {
            get { return spcDiscount2Switch; }
            set { spcDiscount2Switch = value; PropertyChange("SpcDiscount2Switch"); }
        }
        private bool spcDiscount2Enable = true;
        /// <summary>
        /// SpcDiscount2 Resrve Enabled
        /// </summary>
        public bool SpcDiscount2Enable
        {
            get { return spcDiscount2Enable; }
            set { spcDiscount2Enable = value; PropertyChange("SpcDiscount2Enable"); }
        }
        /// <summary>
        /// SpcDiscount2 Command
        /// </summary>
        public ICommand SpcDiscount2Command { get; protected set; } = null;


        #endregion

        #region CouponUsePoints
        /// <summary>
        /// Happy Point Using Noraml Brush
        /// </summary>
        public string HappyPointUsingNoramlBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_happypoint_n.png", CommonValue.PBdesignImagesPath);
        /// <summary>
        /// Happy Point Using SwitchOn Brush
        /// </summary>
        public string HappyPointUsingSwitchOnBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_happypoint_f.png", CommonValue.PBdesignImagesPath);
        /// <summary>
        /// Happy Point Using Disabled Brush
        /// </summary>
        public string HappyPointUsingDisableBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_happypoint_d.png", CommonValue.PBdesignImagesPath);
        private bool happyPointUsingSwitch;
        /// <summary>
        /// Happy Point Using Switch
        /// </summary>
        public bool HappyPointUsingSwitch
        {
            get { return happyPointUsingSwitch; }
            set { happyPointUsingSwitch = value; PropertyChange("HappyPointUsingSwitch"); }
        }
        /// <summary>
        /// Happy Point Using Command
        /// </summary>
        public ICommand HappyPointUsingCommand { get; protected set; } = null;
        /// <summary>
        /// OkCashBag Using Noraml Brush
        /// </summary>
        public string OkCashBagUsingNoramlBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_ocb_n.png", CommonValue.PBdesignImagesPath);
        /// <summary>
        /// OkCashBag Using SwitchOn Brush
        /// </summary>
        public string OkCashBagUsingSwitchOnBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_ocb_f.png", CommonValue.PBdesignImagesPath);
        /// <summary>
        /// OkCashBag Using Disabled Brush
        /// </summary>
        public string OkCashBagUsingDisableBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_ocb_d.png", CommonValue.PBdesignImagesPath);
        private bool okCashBagUsingSwitch;
        /// <summary>
        /// OkCashBag Using Switch
        /// </summary>
        public bool OkCashBagUsingSwitch
        {
            get { return okCashBagUsingSwitch; }
            set { okCashBagUsingSwitch = value; PropertyChange("OkCashBagUsingSwitch"); }
        }
        /// <summary>
        /// OkCashBag Using Command
        /// </summary>
        public ICommand OkCashBagUsingCommand { get; protected set; } = null;


        /// <summary>
        /// SamsungPointUsing Noraml Brush
        /// </summary>
        public string SamsungPointUsingNoramlBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_samsung_n.png", CommonValue.PBdesignImagesPath);
        /// <summary>
        /// SamsungPointUsing Command
        /// </summary>
        public ICommand SamsungPointUsingCommand { get; protected set; } = null;

        /// <summary>
        /// HyundaiPointUsing Noraml Brush
        /// </summary>
        public string HyundaiPointUsingNoramlBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_hyundai_n.png", CommonValue.PBdesignImagesPath);
        /// <summary>
        /// HyundaiPointUsing Command
        /// </summary>
        public ICommand HyundaiPointUsingCommand { get; protected set; } = null;

        /// <summary>
        /// MoreView Noraml Brush
        /// </summary>
        public string MoreViewNoramlBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_more_n.png", CommonValue.PBdesignImagesPath);
        /// <summary>
        /// MoreView Command
        /// </summary>
        public ICommand MoreViewCommand { get; protected set; } = null;



        /// <summary>
        /// ShinHanCardPointUsing Noraml Brush
        /// </summary>
        public string ShinHanCardPointUsingNoramlBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_shinhan_n.png", CommonValue.PBdesignImagesPath);
        /// <summary>
        /// ShinHanCardPointUsing Command
        /// </summary>
        public ICommand ShinHanCardPointUsingCommand { get; protected set; } = null;

        /// <summary>
        /// HyundaiOilBankUsing Noraml Brush
        /// </summary>
        public string HyundaiOilBankUsingNoramlBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_hyundaioilbank_n.png", CommonValue.PBdesignImagesPath);
        /// <summary>
        /// HyundaiOilBankUsing Command
        /// </summary>
        public ICommand HyundaiOilBankUsingCommand { get; protected set; } = null;

        /// <summary>
        /// HyundaiBlueMembersUsing Noraml Brush
        /// </summary>
        public string HyundaiBlueMembersUsingNoramlBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_bluemembers_n.png", CommonValue.PBdesignImagesPath);
        /// <summary>
        /// HyundaiBlueMembersUsing Command
        /// </summary>
        public ICommand HyundaiBlueMembersUsingCommand { get; protected set; } = null;

        /// <summary>
        /// KiaMembersUsing Noraml Brush
        /// </summary>
        public string KiaMembersUsingNoramlBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_kiaredmembers_n.png", CommonValue.PBdesignImagesPath);
        /// <summary>
        /// KiaMembersUsing Command
        /// </summary>
        public ICommand KiaMembersUsingCommand { get; protected set; } = null;

        /// <summary>
        /// MoreViewReturn Noraml Brush
        /// </summary>
        public string MoreViewReturnNoramlBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_back_n.png", CommonValue.PBdesignImagesPath);
        /// <summary>
        /// MoreViewReturn Command
        /// </summary>
        public ICommand MoreViewReturnCommand { get; protected set; } = null;


        /// <summary>
        /// Happy App My Coupon Noraml Brush
        /// </summary>
        public string HappyAppMyCouponNoramlBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_happyapp_n.png", CommonValue.PBdesignImagesPath);
        /// <summary>
        /// Happy App My Coupon SwitchOn Brush
        /// </summary>
        public string HappyAppMyCouponSwitchOnBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_happyapp_f.png", CommonValue.PBdesignImagesPath);
        /// <summary>
        /// Happy App My Coupon Disabled Brush
        /// </summary>
        public string HappyAppMyCouponDisableBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_happyapp_d.png", CommonValue.PBdesignImagesPath);
        private bool happyAppMyCouponSwitch;
        /// <summary>
        /// Happy App My Coupon Switch
        /// </summary>
        public bool HappyAppMyCouponSwitch
        {
            get { return happyAppMyCouponSwitch; }
            set { happyAppMyCouponSwitch = value; PropertyChange("HappyAppMyCouponSwitch"); }
        }
        /// <summary>
        /// Happy App My Coupon Command
        /// </summary>
        public ICommand HappyAppMyCouponCommand { get; protected set; } = null;
        /// <summary>
        /// Mobile Coupon Noraml Brush
        /// </summary>
        public string MobileCouponNoramlBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_mobilecoupon_n.png", CommonValue.PBdesignImagesPath);
        /// <summary>
        /// Mobile Coupon SwitchOn Brush
        /// </summary>
        public string MobileCouponSwitchOnBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_mobilecoupon_f.png", CommonValue.PBdesignImagesPath);
        /// <summary>
        /// Mobile Coupon Disabled Brush
        /// </summary>
        public string MobileCouponDisableBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_mobilecoupon_d.png", CommonValue.PBdesignImagesPath);
        private bool mobileCouponSwitch;
        /// <summary>
        /// Mobile Coupon Switch
        /// </summary>
        public bool MobileCouponSwitch
        {
            get { return mobileCouponSwitch; }
            set { mobileCouponSwitch = value; PropertyChange("MobileCouponSwitch"); }
        }
        /// <summary>
        /// Mobile Coupon Command
        /// </summary>
        public ICommand MobileCouponCommand { get; protected set; } = null;
        #endregion

        #region PaymentExcute
        /// <summary>
        /// ICcard Noraml Brush
        /// </summary>
        public string ICcardNoramlBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_creditcard_n.png", CommonValue.PBdesignImagesPath);
        /// <summary>
        /// ICcard Command
        /// </summary>
        public ICommand ICcardCommand { get; protected set; } = null;
        /// <summary>
        /// LGSSpay Noraml Brush
        /// </summary>
        public string LGSSpayNoramlBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_samsunglg_n.png", CommonValue.PBdesignImagesPath);
        /// <summary>
        /// LGSSpay Command
        /// </summary>
        public ICommand LGSSpayCommand { get; protected set; } = null;
        /// <summary>
        /// CashBee Noraml Brush
        /// </summary>
        public string CashBeeNoramlBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_cashbee_n.png", CommonValue.PBdesignImagesPath);
        /// <summary>
        /// CashBee Command
        /// </summary>
        public ICommand CashBeeCommand { get; protected set; } = null;
        /// <summary>
        /// HappyGift Brush
        /// </summary>
        public string HappyGiftBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_happygift_n.png", CommonValue.PBdesignImagesPath);
        /// <summary>
        /// HappyGift Command
        /// </summary>
        public ICommand HappyGiftCommand { get; protected set; } = null;
        /// <summary>
        /// Tmoney Brush
        /// </summary>
        public string TmoneyBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_tmoney_n.png", CommonValue.PBdesignImagesPath);
        /// <summary>
        /// Tmoney Command
        /// </summary>
        public ICommand TmoneyCommand { get; protected set; } = null;
        /// <summary>
        /// SPCemployee Brush
        /// </summary>
        public string SPCemployeeBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_spc_n.png", CommonValue.PBdesignImagesPath);
        /// <summary>
        /// KakaoPay Brush
        /// </summary>
        public string KakaoPayBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_kakao_n.png", CommonValue.PBdesignImagesPath);
        /// <summary>
        /// SPCemployee Command
        /// </summary>
        public ICommand SPCemployeeCommand { get; protected set; } = null;
        /// <summary>
        /// KakaoPay Command
        /// </summary>
        public ICommand KakaoPayCommand { get; protected set; } = null;
        /// <summary>
        /// SmilePay Brush
        /// </summary>
        public string SmilePayBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_smile_n.png", CommonValue.PBdesignImagesPath);
        /// <summary>
        /// SmilePay Command
        /// </summary>
        public ICommand SmilePayCommand { get; protected set; } = null;
        /// <summary>
        /// AliPay Brush
        /// </summary>
        public string AliPayBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_ali_n.png", CommonValue.PBdesignImagesPath);
        /// <summary>
        /// AliPay Command
        /// </summary>
        public ICommand AliPayCommand { get; protected set; } = null;
        /// <summary>
        /// ZeroPay Brush
        /// </summary>
        public string ZeroPayBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_zero_n.png", CommonValue.PBdesignImagesPath);
        /// <summary>
        /// ZeroPay Command
        /// </summary>
        public ICommand ZeroPayCommand { get; protected set; } = null;

        #endregion

        #endregion

        #region PaymentsList
        /// <summary>
        /// Detail Basket Delete All Image
        /// </summary>
        public string DetailBasketDeleteAllImage { get; set; } = ResourceManager.GetNximagePathAdd("btn_delete.png", CommonValue.PBdesignImagesPath);
        /// <summary>
        /// Discount Bar Brush
        /// </summary>
        public string DiscountBarBrush { get; set; } = ResourceManager.GetNximagePathAdd("discount_bar.png", CommonValue.PBdesignImagesPath);
        /// <summary>
        /// Detail Basket Delete All Command
        /// </summary>
        public ICommand DetailBasketDeleteAllCommand { get; protected set; } = null;
        private bool detailBasketDeleteAllShow = false;
        /// <summary>
        /// Detail Basket Delete All Show
        /// </summary>
        public bool DetailBasketDeleteAllShow
        {
            get { return detailBasketDeleteAllShow; }
            set { detailBasketDeleteAllShow = value; PropertyChange("DetailBasketDeleteAllShow"); }
        }

        #region PaymentValue
        private int totalItemCount;
        /// <summary>
        /// Total Item Count
        /// </summary>
        public int TotalItemCount
        {
            get { return totalItemCount; }
            set { totalItemCount = value; PropertyChange("TotalItemCount"); }
        }
        private double totalItemsPrice;
        /// <summary>
        /// Total Items Price
        /// </summary>
        public double TotalItemsPrice
        {
            get { return totalItemsPrice; }
            set { totalItemsPrice = value; PropertyChange("TotalItemsPrice"); }
        }
        private double totalDiscountValue = 0d;
        /// <summary>
        /// Total Discount Value
        /// </summary>
        public double TotalDiscountValue
        {
            get { return totalDiscountValue; }
            set { totalDiscountValue = value; PropertyChange("TotalDiscountValue"); }
        }
        private double totalPriceForPayments;
        /// <summary>
        /// Total Price For Payments
        /// </summary>
        public double TotalPriceForPayments
        {
            get { return totalPriceForPayments; }
            set { totalPriceForPayments = value; PropertyChange("TotalPriceForPayments"); }
        }
        /// <summary>
        /// Order Total Payment Icon
        /// </summary>
        public string OrderTotalPaymentIcon { get; set; } = ResourceManager.GetNximagePathAdd("Ic_totalcost.png", CommonValue.PBdesignImagesPath);
        #endregion


        #region Button
        private List<M_Language> gotoLeftText;
        /// <summary>
        /// GotoLeft  Button Text
        /// </summary>
        public List<M_Language> GotoLeftText
        {
            get { return gotoLeftText; }
            set { gotoLeftText = value; PropertyChange("GotoLeftText"); }
        }
        private double gotoLeftWidth = 136d;
        /// <summary>
        /// Goto Left Button Width
        /// </summary>
        public double GotoLeftWidth
        {
            get { return gotoLeftWidth; }
            set { gotoLeftWidth = value; PropertyChange("GotoLeftWidth"); }
        }

        private bool gotoLeftEnable = true;
        /// <summary>
        /// Goto Left Button Enabled
        /// </summary>
        public bool GotoLeftEnable
        {
            get { return gotoLeftEnable; }
            set { gotoLeftEnable = value; PropertyChange("GotoLeftEnable"); }
        }
        /// <summary>
        /// Goto Left Command
        /// </summary>
        public ICommand GotoLeftCommand { get; protected set; } = null;
        private List<M_Language> gotoRightText;
        /// <summary>
        /// GotoRight Button Text
        /// </summary>
        public List<M_Language> GotoRightText
        {
            get { return gotoRightText; }
            set { gotoRightText = value; PropertyChange("GotoRightText"); }
        }
        private double gotoRightWidth = 254d;
        /// <summary>
        /// Goto Right Button Width
        /// </summary>
        public double GotoRightWidth
        {
            get { return gotoRightWidth; }
            set { gotoRightWidth = value; PropertyChange("GotoRightWidth"); }
        }

        private bool gotoRightEnable = true;
        /// <summary>
        /// Goto Right Button Enabled
        /// </summary>
        public bool GotoRightEnable
        {
            get { return gotoRightEnable; }
            set { gotoRightEnable = value; PropertyChange("GotoRightEnable"); }
        }
        /// <summary>
        /// Goto Right Command
        /// </summary>
        public ICommand GotoRightCommand { get; protected set; } = null;
        #endregion

        #endregion PaymentsList
        private PaymentsDiscountAndAddType CurrentRollBakType;

        /// <summary>
        /// SPC 임직원 유무
        /// </summary>
        private bool isCompanyMember;        

        public bool IsCompanyMember
        {
            get { return isCompanyMember; }
            set { isCompanyMember = value; PropertyChange("IsCompanyMember"); }
        }

        #endregion Members

        #region [ Ctor/Etc ]
        /// <summary>
        /// Ctor
        /// </summary>
        public PBPaymentsViewModel()
        {
            InitViewModel();
        }
        /// <summary>
        /// Dispose
        /// </summary>
        public new void Dispose()
        {
            this.PropertyChanged -= PBPaymentsViewModel_PropertyChanged;
            if (posDataService != null)
            {
                posDataService.Dispose();
                posDataService = null;
            }
            if (popupManager != null)
            {
                popupManager = null;
            }
            base.Dispose();
            GC.SuppressFinalize(this);
        }
        #endregion Ctor/Etc

        #region [ Methods ]
        private void InitViewModel()
        {
            try
            {
                posDataService = new PosDataService();
                WaitWindowFrom = WaitWindow.GetInstance;
                WaitWindowFrom.CloseWaitWindow();
                //GMB Right
                LanguageCommand = new Command(LanguageCommandHandler);
                CallEmployeeCommand = new Command(CallEmployeeCommandHandler);
                GotoIntroPageCommad = new Command(GotoIntroPageCommadHandler);

                //Contents
                GotoPointsDisCountsCommand = new Command(GotoPointsDisCountsCommandHandler);
                GotoCouponUsePointsCommand = new Command(GotoCouponUsePointsCommandHandler);
                GotoPaymentExcuteCommand = new Command(GotoPaymentExcuteCommandHandler);
                //Detail Basket
                ScanPage2LeftCommand = new Command(ScanPage2LeftCommandHandler);
                ScanPage2RightCommand = new Command(ScanPage2RightCommandHandler);
                OrderPage2LeftCommand = new Command(OrderPage2LeftCommandHandler);
                OrderPage2RightCommand = new Command(OrderPage2RightCommandHandler);
                ScanPageSelectCommand = new Command(ScanPageSelectCommandHandler);
                OrderPageSelectCommand = new Command(OrderPageSelectCommandHandler);
                ScanBarcodeDeleteCommand = new Command(ScanBarcodeDeleteCommandHandler);
                OrderDeleteCommand = new Command(OrderDeleteCommandHandler);
                ScanBarcodeAllDeleteCommand = new Command(ScanBarcodeAllDeleteCommandHandler);
                OrderAllDeleteCommand = new Command(OrderAllDeleteCommandHandler);

                //Reserve
                HappyPointResrveCommand = new Command(HappyPointResrveCommadHandler);
                OkCashBagResrveCommand = new Command(OkCashBagResrveCommandHandler);

                //Discount
                DiscountSKCommand = new Command(DiscountSKCommandHandler);
                DiscountKTCommand = new Command(DiscountKTCommandHandler);
                DiscountLGCommand = new Command(DiscountLGCommandHandler);

                //PointUsing
                HappyPointUsingCommand = new Command(HappyPointUsingCommandHandler);
                OkCashBagUsingCommand = new Command(OkCashBagUsingCommandHandler);

                //PointUsing MoreView
                MoreViewCommand = new Command(MoreViewCommandHandler);

                //PointUsing MoreViewReturn
                MoreViewReturnCommand = new Command(MoreViewReturnCommandHandler);

                //Coupon
                HappyAppMyCouponCommand = new Command(HappyAppMyCouponCommandHandler);
                MobileCouponCommand = new Command(MobileCouponCommandHandler);

                //PaymentsKind
                ICcardCommand = new Command(ICcardCommandHandler);
                LGSSpayCommand = new Command(LGSSpayCommandHandler);
                CashBeeCommand = new Command(CashBeeCommandHandler);
                HappyGiftCommand = new Command(HappyGiftCommandHandler);
                TmoneyCommand = new Command(TmoneyCommandHandler);
                SPCemployeeCommand = new Command(SPCemployeeCommandHandler);
                KakaoPayCommand = new Command(KakaoPayCommandHandler);
                SmilePayCommand = new Command(SmilePayCommandHandler);
                AliPayCommand = new Command(AliPayCommandHandler);
                ZeroPayCommand = new Command(ZeroPayCommandHandler);
                //PaymentsList
                DetailBasketDeleteAllCommand = new Command(DetailBasketDeleteAllCommandHandler);
                GotoLeftCommand = new Command(GotoLeftCommandHandler);
                GotoRightCommand = new Command(GotoRightCommandHandler);

                this.GetPosOption();
                this.GetNhsFuncInfo();
                this.IsCompanyMember = new posHappyPoint().IsCompanyMember;

                this.PropertyChanged += PBPaymentsViewModel_PropertyChanged;

                ShowLanguageType = CommonValue.CommonLanguageType;

            }
            catch (Exception ex)
            {
                CommonLog.ErrorLogWrite(this, "InitViewModel()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
            }
            finally
            {
            }
        }

        private void GetPosOption()
        {
            //PosOption 값 획득
            using (var backDataService = new BackDataService())
            {
                this.OptionValue802 = backDataService.GetPosOption(nameof(PosOptionType.OPT802));
                this.OptionValue803 = backDataService.GetPosOption(nameof(PosOptionType.OPT803));
                this.OptionValue804 = backDataService.GetPosOption(nameof(PosOptionType.OPT804));
            }
        }

        private void GetNhsFuncInfo()
        {
            using (var commonDataHelper = new CommonDataHelper())
            {
                //Get NHS_FUNC_INFO Data Dictionary                 
                var nhsFuncInfoData = commonDataHelper.GetNhsFuncInfo();
                //고유식별 Type
                var nhsFuncInfoType = new NhsFuncInfoType();
                //View Binding 데이터 
                if (NhsFuncInfo == null) { NhsFuncInfo = new NhsFuncInfoItem(); }

                //전체 const로 잡힌 필드를 돌며 DB에서 받아온 Key와 매칭
                foreach (var item in nhsFuncInfoType.GetType().GetFields())
                {
                    if (nhsFuncInfoData.ContainsKey(item.GetValue(nhsFuncInfoType)?.ToString()))
                    {
                        //받아온 데이터 키와 고유식별 Type을 매칭해 View Binding데이터와 일치하게 삽입
                        NhsFuncInfo.GetType().GetProperty(item.Name).SetValue(NhsFuncInfo, nhsFuncInfoData[item.GetValue(nhsFuncInfoType)?.ToString()], System.Reflection.BindingFlags.SetField, null, null, null);
                    }
                }
            }
        }

        #region Contents
        private void InitailizeDetailBasket()
        {
            GMBHeaderText = Languages.GetMessages("LBL0098");
            GotoLeftWidth = 136d;
            GotoRightWidth = 254d;
            GotoLeftText = Languages.GetMessages("BTN0026");
            GotoRightText = Languages.GetMessages("BTN0004");
            DetailBasketDeleteAllShow = true;

        }
        private void SubDataReset()
        {
            if (DetailBasketData is ObservableCollection<M_BasketItem>
                && DetailBasketData.Count > 0)
            {
                ScanBarcodeBasketData = new ObservableCollection<M_BasketItem>(DetailBasketData.Where(r => r.ItemType.Equals(BasketItemType.Barcode) || r.ItemType.Equals(BasketItemType.Scan)).ToList());
                OrderBasketData = new ObservableCollection<M_BasketItem>(DetailBasketData.Where(r => r.ItemType.Equals(BasketItemType.Order)).ToList());
            }
            else
            {
                ScanBarcodeBasketData = null;
                OrderBasketData = null;
            }
            ScanItemPageNo = 0;
            OrderItemPageNo = 0;
        }
        private ObservableCollection<M_ItemData> SetPageNumber(int _pageCount)
        {
            var pageNumbers = new ObservableCollection<M_ItemData>();
            try
            {
                if (_pageCount > 0)
                {

                    for (int index = 0; index < _pageCount; index++)
                    {
                        pageNumbers.Add(new M_ItemData
                        {
                            Index = index,
                            DataParameter = new M_AnimationButton
                            {
                                NormalBrush = ResourceManager.GetNximagePathAdd("Img_page_dot_off.png", CommonValue.PBdesignImagesPath),
                                SwitchOnBrush = ResourceManager.GetNximagePathAdd("Img_page_dot_on.png", CommonValue.PBdesignImagesPath),
                                Width = 20,
                                Height = 20,
                                BrushStretch = Stretch.Fill,
                                ClickAnimationType = ButtonAnimationType.SizeDown,
                                CircleBackBrush = "Transparent",
                                CircleTextBruch = "Transparent",
                                CircleText = string.Empty,
                                TextVisible = Visibility.Collapsed,
                            }
                        });

                    }
                }
            }
            catch (Exception ex)
            {
                CommonLog.ErrorLogWrite(this, "SetPageNumber()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
                pageNumbers = new ObservableCollection<M_ItemData>();
            }
            return pageNumbers;
        }
        private void DeleteBasketItem(M_BasketItem _deleteItem)
        {
            if (DetailBasketData is ObservableCollection<M_BasketItem>)
            {
                var newBasketData = DetailBasketData.ToList();
                using (var posDataService = new PosDataService())
                {
                    if (posDataService.DelItem(_deleteItem))
                    {
                        newBasketData.Remove(_deleteItem);
                    }
                }
                newBasketData.Remove(_deleteItem);
                DetailBasketData = new ObservableCollection<M_BasketItem>(newBasketData);

            }
        }
        private void DeleteScanAndBarcordItem()
        {
            if (DetailBasketData is ObservableCollection<M_BasketItem>)
            {
                var newBasketData = DetailBasketData.ToList();
                using (var posDataService = new PosDataService())
                {
                    foreach (var aitem in newBasketData.Where(r => r.ItemType.Equals(BasketItemType.Scan)
                                          || r.ItemType.Equals(BasketItemType.Barcode)).ToList())
                    {
                        if (posDataService.DelItem(aitem))
                        {
                            newBasketData.Remove(aitem);
                        }
                    }
                }
                DetailBasketData = new ObservableCollection<M_BasketItem>(newBasketData);
            }
        }
        private void DeleteSelfOrderItem()
        {
            if (DetailBasketData is ObservableCollection<M_BasketItem>)
            {
                var newBasketData = DetailBasketData.ToList();
                using (var posDataService = new PosDataService())
                {
                    foreach (var aitem in newBasketData.Where(r => r.ItemType.Equals(BasketItemType.Order)).ToList())
                    {
                        if (posDataService.DelItem(aitem))
                        {
                            newBasketData.Remove(aitem);
                        }
                    }
                }
                DetailBasketData = new ObservableCollection<M_BasketItem>(newBasketData);
            }
        }
        public void DeledteAllBasket()
        {

            using (var posDataService = new PosDataService())
            {
                foreach (var aitem in DetailBasketData)
                {
                    posDataService.DelItem(aitem);
                }
            }
            DetailBasketData = null;
        }
        private void InitailizePointsDisCounts()
        {
            GMBHeaderText = Languages.GetMessages("LBL0035");
            GotoPointsDisCountsEnable = false;
            GotoCouponUsePointsEnable = true;
            GotoPaymentExcuteEnable = true;
            GotoLeftWidth = 136d;
            GotoRightWidth = 254d;
            GotoLeftText = Languages.GetMessages("BTN0028");
            GotoRightText = Languages.GetMessages("BTN0008");
            DetailBasketDeleteAllShow = false;
        }
        private void InitailizeCouponUsePoints()
        {
            GMBHeaderText = Languages.GetMessages("LBL0035");
            GotoPointsDisCountsEnable = true;
            GotoCouponUsePointsEnable = false;
            GotoPaymentExcuteEnable = true;
            GotoLeftWidth = 136d;
            GotoRightWidth = 254d;
            GotoLeftText = Languages.GetMessages("BTN0028");
            GotoRightText = Languages.GetMessages("BTN0008");
            DetailBasketDeleteAllShow = false;

        }
        private void InitailizeMoreView()
        {
            GMBHeaderText = Languages.GetMessages("LBL0035");
            GotoPointsDisCountsEnable = true;
            GotoCouponUsePointsEnable = false;
            GotoPaymentExcuteEnable = true;
            GotoLeftWidth = 136d;
            GotoRightWidth = 254d;
            GotoLeftText = Languages.GetMessages("BTN0028");
            GotoRightText = Languages.GetMessages("BTN0008");
            DetailBasketDeleteAllShow = false;
        }
        private void InitailizePaymentExcute()
        {
            GMBHeaderText = Languages.GetMessages("LBL0035");
            GotoPointsDisCountsEnable = true;
            GotoPointsDisCountsEnable = true;
            GotoCouponUsePointsEnable = true;
            GotoPaymentExcuteEnable = false;
            GotoLeftWidth = 390d;
            GotoRightWidth = 0d;
            GotoLeftText = Languages.GetMessages("BTN0028");
            DetailBasketDeleteAllShow = false;

        }

        public void OpenFistPopup()
        {
            FirstLoaded = false;
            var setPosItems = false;
            using (var newPosDataService = new PosDataService())
            {
                setPosItems = newPosDataService.ResetItems(DetailBasketData.ToList());
            }
            if (setPosItems)
            {
                popupManager.OpenStepInfoPopup();
            }
            else
            {
                PopupMessageBox.ShowMessageBox(ShowLanguageType
                                                , Languages.GetMessages("LBL0077")
                                                , null
                                                , MessageBoxButton.OK
                                                , OpenCloseAnimationType.FullSizeUp
                                                , OpenCloseAnimationType.FullSizeDown
                                                , 0.5, 0.2, 10);
                RollBacklEnd();
            }
        }

        private void OpenReserveHappyPoint()
        {
            TimerEnabled = false;
            try
            {
                var popupReturn = popupManager.OpenHappyPointCertify(false, false, ParentPage.PBPaymentsWindow);
                if (popupReturn is M_PopupReturn)
                {
                    if (popupReturn.OKAnswer)
                    {
                        if (popupReturn.PopupArgs is M_HappyPointReturn _HappyPointReturn)
                        {
                            HappyPointReturn = _HappyPointReturn;
                        }
                        else
                        {
                            HappyPointReturn = null;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                CommonLog.ErrorLogWrite(this, "OpenReserveHappyPoint()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
            }
            finally
            {
                TimerEnabled = true;
            }
        }
        private void OpenReserveOkCashBag()
        {
            TimerEnabled = false;
            try
            {
                var popupReturn = popupManager.OpenOkCashBagCertify();
                if (popupReturn is M_PopupReturn)
                {
                    if (popupReturn.OKAnswer)
                    {
                        if (popupReturn.PopupArgs is M_OkCashBagReturn okCashBagReturnValue)
                        {
                            OkCashBagReturn = okCashBagReturnValue;
                        }
                        else
                        {
                            OkCashBagReturn = null;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                CommonLog.ErrorLogWrite(this, "OpenReserveOkCashBag()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
            }
            finally
            {
                TimerEnabled = true;
            }
        }
        private bool OpenRollbackConfirmDiscountOrPayments(PaymentsDiscountAndAddType _discountType)
        {
            bool result = false;
            TimerEnabled = false;
            try
            {

                var miniPopup = new M_MiniPopup
                {
                    Icon = MiniPopupIcon.DiscountCancel,
                    DisplayLanguage = ShowLanguageType,
                    Message = GetPaymentsDiscountAndAddTypeText(_discountType).CombineLanguageData(Languages.GetMessages("LBL0080")),
                    CencalButtonText = Languages.GetMessages("BTN0021"),
                    OkButtonText = Languages.GetMessages("BTN0005"),
                    IsCencalButton = true,
                    TimeoutSeconds = 10,
                };
                var popupReturn = popupManager.OpenMiniPopup(miniPopup);
                if (popupReturn is M_PopupReturn)
                {
                    result = popupReturn.OKAnswer;
                }
            }
            catch (Exception ex)
            {
                CommonLog.ErrorLogWrite(this, "OpenRollbackConfirmDiscountOrPayments()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
                result = false;
            }
            finally
            {
                TimerEnabled = true;
            }
            return result;
        }
        private List<M_Language> GetPaymentsDiscountAndAddTypeText(PaymentsDiscountAndAddType _discountType)
        {
            var result = new List<M_Language>();
            try
            {
                switch (_discountType)
                {
                    case PaymentsDiscountAndAddType.HappyPoint:
                        result = new List<M_Language>
                        {
                            new M_Language
                            {
                                Type=SupportLanguageType.ko,
                                LanguageData = "해피포인트 사용"
                            }
                        };
                        break;
                    case PaymentsDiscountAndAddType.HappyCoupon:
                        result = new List<M_Language>
                        {
                            new M_Language
                            {
                                Type=SupportLanguageType.ko,
                                LanguageData = "해피앱 쿠폰"
                            }
                        };
                        break;

                    case PaymentsDiscountAndAddType.MobileCoupon:
                        result = new List<M_Language>
                        {
                            new M_Language
                            {
                                Type=SupportLanguageType.ko,
                                LanguageData = "모바일 쿠폰 사용"
                            }
                        };
                        break;
                    case PaymentsDiscountAndAddType.SkTelecomDiscount:
                        result = new List<M_Language>
                        {
                            new M_Language
                            {
                                Type=SupportLanguageType.ko,
                                LanguageData = "SKT 멤버쉽 할인"
                            }
                        };
                        break;
                    case PaymentsDiscountAndAddType.AllehKTDiscount:
                        result = new List<M_Language>
                        {
                            new M_Language
                            {
                                Type=SupportLanguageType.ko,
                                LanguageData = "KT 멤버쉽 할인"
                            }
                        };
                        break;
                    case PaymentsDiscountAndAddType.LGUPlusDisCount:
                        result = new List<M_Language>
                        {
                            new M_Language
                            {
                                Type=SupportLanguageType.ko,
                                LanguageData = "LG U+ 멤버쉽 할인"
                            }
                        };
                        break;
                }
            }
            catch (Exception ex)
            {
                CommonLog.ErrorLogWrite(this, "GetPaymentsDiscountAndAddTypeText()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
                result = new List<M_Language>();
            }
            return result;
        }
        private void MobileCompanyDiscountExcute(MobileCompanyType _mobileCompany)
        {
            if (MobileCompanyReturn is M_MobileCompanyReturn mobileCompanyReturn
               && mobileCompanyReturn.Company.Equals(_mobileCompany)
               && mobileCompanyReturn.DiscountValue > 0)
            {

                var paymentsDiscountType = PaymentsDiscountAndAddType.None;
                switch (_mobileCompany)
                {
                    case MobileCompanyType.KT_Mobile:
                        paymentsDiscountType = PaymentsDiscountAndAddType.AllehKTDiscount;
                        break;
                    case MobileCompanyType.SK_Telecom:
                        paymentsDiscountType = PaymentsDiscountAndAddType.SkTelecomDiscount;
                        break;
                    case MobileCompanyType.LG_Uplus:
                        paymentsDiscountType = PaymentsDiscountAndAddType.LGUPlusDisCount;
                        break;
                }
                if (!paymentsDiscountType.Equals(PaymentsDiscountAndAddType.None) && OpenRollbackConfirmDiscountOrPayments(paymentsDiscountType)) 
                {
                    TimerEnabled = false;
                    WaitWindowFrom.ShowWaitWindow();
                    RollBackExcute(paymentsDiscountType, MobileCompanyReturn.PaySEQ);
                    WaitWindowFrom.CloseWaitWindow();
                    TimerEnabled = true;
                }
            }
            else
            {
                OpenMobileCompanyDiscount(_mobileCompany);
            }
        }
        private void OpenMobileCompanyDiscount(MobileCompanyType _mobileCompany)
        {
            TimerEnabled = false;
            try
            {
                var popupReturn = popupManager.OpenMobileCompanyCertify(_mobileCompany, TotalItemsPrice);
                if (popupReturn is M_PopupReturn)
                {
                    if (popupReturn.OKAnswer)
                    {
                        if (popupReturn.PopupArgs is M_MobileCompanyReturn mobileCompanyReturnValue)
                        {
                            MobileCompanyReturn = mobileCompanyReturnValue;
                            var discountType = PaymentsDiscountAndAddType.None;
                            switch (MobileCompanyReturn.Company)
                            {
                                case MobileCompanyType.SK_Telecom:
                                    discountType = PaymentsDiscountAndAddType.SkTelecomDiscount;
                                    break;
                                case MobileCompanyType.KT_Mobile:
                                    discountType = PaymentsDiscountAndAddType.AllehKTDiscount;
                                    break;
                                case MobileCompanyType.LG_Uplus:
                                    discountType = PaymentsDiscountAndAddType.LGUPlusDisCount;
                                    break;
                            }
                            AddDiscountValue
                            (
                                new M_DiscountAndAddValues
                                {
                                    DiscountType = discountType,
                                    DiscountName = GetPaymentsDiscountAndAddTypeText(discountType),
                                    DiscountValue = MobileCompanyReturn.DiscountValue,
                                    IsCanRollBack = true
                                }
                            );
                        }
                        else
                        {
                            MobileCompanyReturn = null;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                CommonLog.ErrorLogWrite(this, "OpenMobileCompanyDiscount()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
            }
            finally
            {
                TimerEnabled = true;
            }
        }
        private void OpenHappyPointUsing()
        {
            TimerEnabled = false;
            try
            {
                var popupReturn = popupManager.OpenHappyPointUsing(HappyPointReturn, TotalPriceForPayments);
                if (popupReturn is M_PopupReturn)
                {
                    if (popupReturn.OKAnswer)
                    {
                        if (popupReturn.PopupArgs is M_HappyPointReturn _HappyPointReturn)
                        {
                            HappyPointReturn = _HappyPointReturn;
                            if (HappyPointReturn.PointUse)
                            {
                                HappyPointUsingSwitch = true;
                                AddDiscountValue(new M_DiscountAndAddValues
                                {
                                    DiscountType = PaymentsDiscountAndAddType.HappyPoint,
                                    DiscountName = GetPaymentsDiscountAndAddTypeText(PaymentsDiscountAndAddType.HappyPoint),
                                    DiscountValue = HappyPointReturn.UsingPoints,
                                    IsCanRollBack = true
                                });
                                if (TotalPriceForPayments.Equals(HappyPointReturn.UsingPoints))
                                {
                                    HappyPointReturn.ReservePoint = false;
                                    HappyPointResrveSwitch = false;
                                }
                                else if (!GetReserveOKChashBag())
                                {
                                    HappyPointReturn.ReservePoint = true;
                                    HappyPointResrveSwitch = true;
                                }
                            }

                        }
                        else
                        {
                            HappyPointReturn = null;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                CommonLog.ErrorLogWrite(this, "OpenHappyPointUsing()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
            }
            finally
            {
                TimerEnabled = true;
            }
        }

        private void OpenHappyAppCoupon()
        {
            TimerEnabled = false;
            try
            {
                var popupReturn = popupManager.OpenHappyAppCoupon(HappyPointReturn, TotalItemsPrice);
                if (popupReturn is M_PopupReturn)
                {
                    if (popupReturn.OKAnswer)
                    {
                        if (popupReturn.PopupArgs is M_HappyCoupon _usingHappyAppCoupon)
                        {
                            UsingHappyAppCoupon = _usingHappyAppCoupon;
                            HappyAppMyCouponSwitch = true;
                            AddDiscountValue(new M_DiscountAndAddValues
                            {
                                DiscountType = PaymentsDiscountAndAddType.HappyCoupon,
                                DiscountName = GetPaymentsDiscountAndAddTypeText(PaymentsDiscountAndAddType.HappyCoupon),
                                DiscountValue = UsingHappyAppCoupon.UseAmount,
                                IsCanRollBack = true
                            });
                        }
                        else
                        {
                            UsingHappyAppCoupon = null;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                CommonLog.ErrorLogWrite(this, "OpenHappyAppCoupon()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
            }
            finally
            {
                TimerEnabled = true;
            }
        }

        private void OpenMobileCoupon()
        {
            try
            {
                var popupReturn = popupManager.OpenMobileHappyCoupon(DetailBasketData.ToList(), TotalPriceForPayments);
                if (popupReturn is M_PopupReturn)
                {
                    if (popupReturn.OKAnswer)
                    {
                        if (popupReturn.PopupArgs is M_MobileCouponReturn _mobileCouponReturn)
                        {
                            MobileCouponReturn = _mobileCouponReturn;
                            if (MobileCouponReturn.TotalUseAmount > 0)
                            {
                                MobileCouponSwitch = true;
                                AddDiscountValue(new M_DiscountAndAddValues
                                {
                                    DiscountType = PaymentsDiscountAndAddType.MobileCoupon,
                                    DiscountName = GetPaymentsDiscountAndAddTypeText(PaymentsDiscountAndAddType.MobileCoupon),
                                    DiscountValue = MobileCouponReturn.TotalUseAmount,
                                    IsCanRollBack = true
                                });
                            }

                        }
                        else
                        {
                            MobileCouponReturn = null;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                CommonLog.ErrorLogWrite(this, "OpenMobileCoupon()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
            }
            finally
            {
                TimerEnabled = true;
            }
        }

        private void OpenPaymetsProcess(LastPaymentsType _paymentType)
        {
            TimerEnabled = false;
            try
            {
                var popupReturn = popupManager.OpenPaymentProcess(_paymentType, TotalPriceForPayments);
                if (popupReturn is M_PopupReturn)
                {
                    if (popupReturn.OKAnswer)
                    {
                        if (popupReturn.PopupArgs is M_PaymentReturn paymentReturn)
                        {
                            PaymentReturn = paymentReturn;
                            AddDiscountValue(new M_DiscountAndAddValues
                            {
                                DiscountType = PaymentsDiscountAndAddType.LastPayment,
                                DiscountName = Languages.GetMessages("BTN0031"),
                                DiscountValue = PaymentReturn.PaymentsTotal,
                                IsCanRollBack = false
                            });
                        }
                        else
                        {
                            PaymentReturn = null;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                CommonLog.ErrorLogWrite(this, "OpenPaymetsProcess()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
            }
            finally
            {
                TimerEnabled = true;
            }
        }
        private void OpenPaymentEndProcess()
        {
            TimerEnabled = false;
            try
            {

                PaymentEndWindowEndType paymentEndType;
                //var paymentEndType = DetailBasketData.Where(r => r.ItemType.Equals(BasketItemType.Order)).Count().Equals(0)
                //                ? PaymentEndWindowEndType.None
                //                : CommonValue.PaymentEndType;
                var happyPointReturn = HappyPointReturn is M_HappyPointReturn
                            && !string.IsNullOrEmpty(HappyPointReturn.MemberNumber)
                            && HappyPointReturn.IsAppMamber
                            ? HappyPointReturn
                            : null;

                if (DetailBasketData.Where(r => r.ItemType.Equals(BasketItemType.Order)).Count().Equals(0))
                {
                    paymentEndType = PaymentEndWindowEndType.None;
                }
                else if (OptionValue802 == "1")
                {
                    paymentEndType = PaymentEndWindowEndType.Bell;
                }
                else if (OptionValue803 == "1")
                {
                    paymentEndType = PaymentEndWindowEndType.Talk;
                }
                else if (OptionValue804 == "1")
                {
                    paymentEndType = PaymentEndWindowEndType.WaitNumber;
                }
                else
                {
                    paymentEndType = PaymentEndWindowEndType.None;
                }

                popupManager.OpenPaymentsEnd(paymentEndType, DetailBasketData.ToList(), GetReserveHappyPoint(), GetReserveOKChashBag(), happyPointReturn);
                WaitWindowFrom.ShowWaitWindow();
                ProcessOK();

            }
            catch (Exception ex)
            {
                CommonLog.ErrorLogWrite(this, "OpenPaymentEndProcess()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
            }
            finally
            {
                TimerEnabled = true;
                WaitWindowFrom.CloseWaitWindow();
            }
        }


        #endregion

        #region Total Values
        private void SetBasketSum()
        {
            if (DetailBasketData is ObservableCollection<M_BasketItem>)
            {
                TotalItemCount = DetailBasketData.Sum(r => r.Count)
                               + (DiscountValues is ObservableCollection<M_DiscountAndAddValues> 
                                 ?  DiscountValues.Sum(r=>r.AddCount)
                                 : 0) ;
                TotalItemsPrice = DetailBasketData.Sum(r => r.Count * r.Price)
                                + (DiscountValues is ObservableCollection<M_DiscountAndAddValues> 
                                 ? DiscountValues.Sum(r=> r.AddCount * r.AddValue)
                                 : 0) ;
            }
            else
            {
                TotalItemCount = 0;
                TotalItemsPrice = 0;
            }
            ScanItemCount = ScanBarcodeBasketData is ObservableCollection<M_BasketItem> && DetailBasketData.Count > 0
                          ? ScanBarcodeBasketData.Sum(r => r.Count)
                          : 0;
            OrderItemCount = OrderBasketData is ObservableCollection<M_BasketItem> && OrderBasketData.Count > 0
                           ? OrderBasketData.Sum(r => r.Count)
                           : 0;

        }
        private void SetDiscountValue()
        {
            if (DiscountValues is ObservableCollection<M_DiscountAndAddValues>)
            {
                TotalDiscountValue = DiscountValues.Sum(r => r.DiscountValue);
            }
            else
            {
                TotalDiscountValue = 0;
            }
            
        }

        #endregion

        #region DiscountValue
        private void AddDiscountValue(M_DiscountAndAddValues _discountValues)
        {
            var listDiscountValues = DiscountValues is ObservableCollection<M_DiscountAndAddValues>
                                   ? DiscountValues.ToList()
                                   : new List<M_DiscountAndAddValues>();
            if (!listDiscountValues.Exists(r => r.DiscountType.Equals(_discountValues.DiscountType)))
            {
                listDiscountValues.Add(_discountValues);
                DiscountValues = new ObservableCollection<M_DiscountAndAddValues>(listDiscountValues);
            }
            else
            {
                CommonLog.ErrorLogWrite(this, "AddDiscountValue()", "Duplicate Discount", string.Format("Type:{0}", _discountValues.DiscountType));
            }

        }
        private void RemoveDiscountValue(PaymentsDiscountAndAddType _discountType)
        {
            if (DiscountValues is ObservableCollection<M_DiscountAndAddValues>)
            {
                var listDiscountValues = DiscountValues.ToList();
                listDiscountValues.Remove(listDiscountValues.Find(r => r.DiscountType.Equals(_discountType)));
                DiscountValues = new ObservableCollection<M_DiscountAndAddValues>(listDiscountValues);

            }
        }

        private void DiscountsRollBack()
        {
            if (DiscountValues is ObservableCollection<M_DiscountAndAddValues>)
            {
                foreach (var aDiscountValue in DiscountValues)
                {
                    switch (aDiscountValue.DiscountType)
                    {
                        case PaymentsDiscountAndAddType.HappyPoint:
                            if (HappyPointReturn is M_HappyPointReturn happyPointReturn)
                            {
                                RollBackExcute(aDiscountValue.DiscountType, HappyPointReturn.PaySEQ);
                            }
                            break;
                        case PaymentsDiscountAndAddType.OkCashBagPoint:
                            break;
                        case PaymentsDiscountAndAddType.HappyCoupon:
                            RollBackExcute(PaymentsDiscountAndAddType.HappyCoupon, UsingHappyAppCoupon.PaySEQ);
                            break;
                        case PaymentsDiscountAndAddType.MobileCoupon:
                            if (MobileCouponReturn is M_MobileCouponReturn mobileCouponReturn)
                            {
                                foreach (var aCoupon in mobileCouponReturn.VirtureCoupons)
                                {
                                    if (aCoupon.PaySEQ > -1) RollBackExcute(PaymentsDiscountAndAddType.MobileCoupon, HappyPointReturn.PaySEQ);
                                }
                            }
                            break;
                        case PaymentsDiscountAndAddType.SkTelecomDiscount:
                        case PaymentsDiscountAndAddType.AllehKTDiscount:
                        case PaymentsDiscountAndAddType.LGUPlusDisCount:
                            if (MobileCompanyReturn is M_MobileCompanyReturn mobileCompanyReturn)
                            {
                                RollBackExcute(aDiscountValue.DiscountType,MobileCompanyReturn.PaySEQ);
                            }
                            break;
                    }
                }
            }
        }


        #endregion

        #region Discount RollBack Process
        private void RollBackExcute(PaymentsDiscountAndAddType _discountType, long _paySEQ)
        {
            TimerEnabled = false;
            try
            {
                using (var posRollBack = new posPaymentsCancel())
                {
                    CurrentRollBakType = _discountType;
                    if (posRollBack != null)
                    {
                        posRollBack.ReadEnd += posRollBack_ReadEnd;
                        posRollBack.ErrorEvent += posRollBack_ErrorEvent;
                        posRollBack.ErrorMessageEvent += posRollBack_ErrorMessageEvent;
                        posRollBack.StartProcessing(_paySEQ);
                        posRollBack.ReadEnd -= posRollBack_ReadEnd;
                        posRollBack.ErrorEvent -= posRollBack_ErrorEvent;
                        posRollBack.ErrorMessageEvent -= posRollBack_ErrorMessageEvent;
                    }

                }
            }
            catch (Exception ex)
            {
                CommonLog.ErrorLogWrite(this, "RollBackExcute()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
            }
            finally
            {
                TimerEnabled = true;
            }
        }


        #endregion

        private bool GetReserveHappyPoint()
        {
            bool result = false;
            try
            {
                if (HappyPointReturn is M_HappyPointReturn)
                {
                    result = HappyPointReturn.ReservePoint;
                }
            }
            catch
            {
                result = false;
            }
            return result;
        }
        private bool GetReserveOKChashBag()
        {
            bool result = false;
            try
            {
                if (OkCashBagReturn is M_OkCashBagReturn)
                {
                    result = OkCashBagReturn.ReservePoint;
                }
            }
            catch
            {
                result = false;
            }
            return result;
        }


        private void TimeOutEnd()
        {
            DiscountsRollBack();
            ReturnValue = new M_PopupReturn
            {
                OKAnswer = false,
                TimeOut = true,
                ReturnLanguage = ShowLanguageType,
                PopupArgs = DetailBasketData is ObservableCollection<M_BasketItem> 
                          ? DetailBasketData.ToList()
                          : null ,
            };
            CanWindowClose = true;
        }
        private void RollBacklEnd()
        {
            DiscountsRollBack();
            ReturnValue = new M_PopupReturn
            {
                OKAnswer = false,
                TimeOut = false,
                ReturnLanguage = ShowLanguageType,
                PopupArgs = DetailBasketData is ObservableCollection<M_BasketItem>
                          ? DetailBasketData.ToList()
                          : null,
            };
            CanWindowClose = true;
        }
        private void ProcessOK()
        {
            ReturnValue = new M_PopupReturn
            {
                OKAnswer = true,
                TimeOut = false,
                ReturnLanguage = ShowLanguageType,
                PopupArgs = null
            };
            CanWindowClose = true;
        }
        #endregion Methods

        #region [ Event Handlers ]
        private void PBPaymentsViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            switch (e.PropertyName)
            {
                case "IsTimeout":
                    if (IsTimeout) TimeOutEnd();
                    break;
                case "ShowLanguageType":
                    switch (ShowLanguageType)
                    {
                        case SupportLanguageType.ko:
                            GmbLanguageimage = ResourceManager.GetNximagePathAdd("btn_language_kor.png", CommonValue.PBdesignImagesPath);
                            break;
                        case SupportLanguageType.en:
                            GmbLanguageimage = ResourceManager.GetNximagePathAdd("btn_language_eng.png", CommonValue.PBdesignImagesPath);
                            break;
                        case SupportLanguageType.ja:
                            GmbLanguageimage = ResourceManager.GetNximagePathAdd("btn_language_jap.png", CommonValue.PBdesignImagesPath);
                            break;
                        case SupportLanguageType.zh:
                            GmbLanguageimage = ResourceManager.GetNximagePathAdd("btn_language_chi.png", CommonValue.PBdesignImagesPath);
                            break;
                    }
                    break;
                case "DefaultPage":
                    switch (DefaultPage)
                    {
                        case PBPaymentPageType.DetailBasket:
                            InitailizeDetailBasket();
                            break;
                        case PBPaymentPageType.PointsDisCounts:
                            InitailizePointsDisCounts();
                            break;
                        case PBPaymentPageType.CouponUsePoints:
                            InitailizeCouponUsePoints();
                            break;
                        case PBPaymentPageType.MoreVIewPoints:
                            InitailizeMoreView();
                            break;
                        case PBPaymentPageType.PaymentExcute:
                            InitailizePaymentExcute();
                            break;
                    }
                    break;
                case "DetailBasketData":
                    SubDataReset();
                    if (DetailBasketData is ObservableCollection<M_BasketItem>
                        && DetailBasketData.Count > 0)
                    {
                        foreach (var DetailItem in DetailBasketData)
                        {
                            DetailItem.PropertyChanged += DetailItem_PropertyChanged;
                        }
                        SetBasketSum();
                    }
                    else
                    {
                        RollBacklEnd();
                    }
                    break;
                case "ScanItemPageNo":
                    ScanPage2LeftEnable = !ScanItemPageNo.Equals(0);
                    ScanPage2RightEnable = !ScanItemPageNo.Equals(ScanItemPageCount.Equals(0) ? 0: ScanItemPageCount-1);
                    break;
                case "OrderItemPageNo":
                    OrderPage2LeftEnable = !OrderItemPageNo.Equals(0);
                    OrderPage2RightEnable = !OrderItemPageNo.Equals(OrderItemPageCount.Equals(0) ? 0 : OrderItemPageCount - 1);
                    break;
                case "ScanItemPageCount":
                    ScanPageStatusColumnCount = ScanItemPageCount;
                    ScanItemPageStatus = SetPageNumber(ScanItemPageCount);
                    break;
                case "OrderItemPageCount":
                    OrderPageStatusColumnCount = OrderItemPageCount;
                    OrderItemPageStatus = SetPageNumber(OrderItemPageCount);
                    break;
                case "DiscountValues":
                    SetDiscountValue();
                    break;
                case "MemberLoginOK":
                    GmbHappyPointEnable = !MemberLoginOK;
                    break;
                case "HappyPointReturn":
                    if (HappyPointReturn is M_HappyPointReturn happyPointReturn)
                    {
                        HappyPointResrveSwitch = happyPointReturn.ReservePoint;
                    }
                    else
                    {
                        HappyPointResrveSwitch = false;
                    }
                    break;
                case "HappyPointResrveSwitch":
                    OkCashBagResrveEnable = !HappyPointResrveSwitch;
                    break;
                case "OkCashBagReturn":
                    if (OkCashBagReturn is M_OkCashBagReturn okCashBagReturn)
                    {
                        OkCashBagResrveSwitch = okCashBagReturn.ReservePoint;
                    }
                    else
                    {
                        OkCashBagResrveSwitch = false;
                    }
                    break;
                case "OkCashBagResrveSwitch":
                    HappyPointResrveEnable = !OkCashBagResrveSwitch;
                    break;
                case "MobileCompanyReturn":
                    if (MobileCompanyReturn is M_MobileCompanyReturn mobileCompanyReturn)
                    {
                        if (mobileCompanyReturn.DiscountValue > 0)
                        {
                            switch (mobileCompanyReturn.Company)
                            {
                                case MobileCompanyType.SK_Telecom:
                                    DiscountSKSwitch = true;
                                    break;
                                case MobileCompanyType.KT_Mobile:
                                    DiscountKTSwitch = true;
                                    break;
                                case MobileCompanyType.LG_Uplus:
                                    DiscountLGSwitch = true;
                                    break;
                            }
                        }
                    }
                    break;
                case "DiscountSKSwitch":
                    DiscountKTEnable = !DiscountSKSwitch;
                    DiscountLGEnable = !DiscountSKSwitch;
                    break;
                case "DiscountKTSwitch":
                    DiscountSKEnable = !DiscountKTSwitch;
                    DiscountLGEnable = !DiscountKTSwitch; 
                    break;
                case "DiscountLGSwitch":
                    DiscountSKEnable = !DiscountLGSwitch;
                    DiscountKTEnable = !DiscountLGSwitch; 
                    break;
                case "TotalItemsPrice":
                case "TotalDiscountValue":
                    TotalPriceForPayments = TotalItemsPrice - TotalDiscountValue;
                    break;
                case "TotalPriceForPayments":
                    if (TotalPriceForPayments.Equals(0d)) OpenPaymentEndProcess();
                    break;
            }
        }
        private void DetailItem_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            LastAccessTime = DateTime.Now;
            if (sender is M_BasketItem updatedItem)
            {
                using (var posDataService = new PosDataService())
                {
                    posDataService.UpdatedItem(updatedItem);
                }
            }
            SetBasketSum();
        }



        #region GMB Right Click

        private void CallEmployeeCommandHandler(object obj)
        {
            TimerEnabled = false;
            try
            {
                var popupReturn = popupManager.OpenCallEmployee();
                if (popupReturn is M_PopupReturn)
                {
                    if (popupReturn.TimeOut)
                    {
                        TimeOutEnd();
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                CommonLog.ErrorLogWrite(this, "CallEmployeeCommandHandler()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
            }
            finally
            {
                TimerEnabled = true;
            }
        }
        private void LanguageCommandHandler(object obj)
        {
            TimerEnabled = false;
            try
            {
                var popupReturn = popupManager.OpenLanguageSelector(ShowLanguageType);
                if (popupReturn is M_PopupReturn)
                {
                    if (popupReturn.TimeOut)
                    {
                        TimeOutEnd();
                        return;
                    }
                    else
                    {
                        ShowLanguageType = popupReturn.ReturnLanguage;
                    }
                }
            }
            catch
            {
                throw;
            }
            finally
            {
                TimerEnabled = true;
            }
        }
        private void GotoIntroPageCommadHandler(object obj)
        {
            TimerEnabled=false;
            try
            {
                var miniPopup = new M_MiniPopup
                {
                    Icon = MiniPopupIcon.Cancel,
                    DisplayLanguage = ShowLanguageType,
                    Message = Languages.GetMessages("LBL0085"),
                    CencalButtonText = Languages.GetMessages("BTN0021"),
                    OkButtonText = Languages.GetMessages("BTN0005"),
                    IsCencalButton = true,
                    TimeoutSeconds = 10,
                };
                var popupReturn = popupManager.OpenMiniPopup(miniPopup);
                if (popupReturn is M_PopupReturn && popupReturn.OKAnswer)
                {
                    TimeOutEnd();
                }
            }
            catch (Exception ex)
            {
                CommonLog.ErrorLogWrite(this, "GotoIntroPageCommadHandler()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
            }
            {
                TimerEnabled = true;
            }
            
        }
        #endregion

        #region Contents Click
        private void GotoPointsDisCountsCommandHandler(object obj)
        {
            DefaultPage = PBPaymentPageType.PointsDisCounts;
        }

        private void GotoCouponUsePointsCommandHandler(object obj)
        {
            DefaultPage = PBPaymentPageType.CouponUsePoints;
        }

        private void GotoPaymentExcuteCommandHandler(object obj)
        {
            DefaultPage = PBPaymentPageType.PaymentExcute;
        }
        private void ScanPage2LeftCommandHandler(object obj)
        {
            ScanItemPageNo -= 1;
        }

        private void ScanPage2RightCommandHandler(object obj)
        {
            ScanItemPageNo += 1;
        }

        private void OrderPage2LeftCommandHandler(object obj)
        {
            OrderItemPageNo -= 1;
        }

        private void OrderPage2RightCommandHandler(object obj)
        {
            OrderItemPageNo += 1;
        }
        private void ScanPageSelectCommandHandler(object obj)
        {
            if (obj is AnimationButton targetButton && targetButton.DataParameter is M_ItemData _ItemData)
            {
                ScanItemPageNo = ScanItemPageStatus.IndexOf(_ItemData);
            }
        }
        private void OrderPageSelectCommandHandler(object obj)
        {
            if (obj is AnimationButton targetButton && targetButton.DataParameter is M_ItemData _ItemData)
            {
                OrderItemPageNo = OrderItemPageStatus.IndexOf(_ItemData);
            }
        }


        private void ScanBarcodeDeleteCommandHandler(object obj)
        {
            if (obj is M_BasketItem deleteItem)
            {
                DeleteBasketItem(deleteItem);
            }
        }

        private void OrderDeleteCommandHandler(object obj)
        {
            if (obj is M_BasketItem deleteItem)
            {
                DeleteBasketItem(deleteItem);
            }
        }
        private void ScanBarcodeAllDeleteCommandHandler(object obj)
        {
            TimerEnabled = false;
            try
            {
                var miniPopup = new M_MiniPopup
                {
                    Icon = MiniPopupIcon.Delete,
                    DisplayLanguage = ShowLanguageType,
                    Message = Languages.GetMessages("LBL0094"),
                    CencalButtonText = Languages.GetMessages("BTN0021"),
                    OkButtonText = Languages.GetMessages("BTN0005"),
                    IsCencalButton = true,
                    TimeoutSeconds = 10,
                };
                var popupReturn = popupManager.OpenMiniPopup(miniPopup);
                if (popupReturn is M_PopupReturn && popupReturn.OKAnswer)
                {
                    DeleteScanAndBarcordItem();
                }
            }
            catch (Exception ex)
            {
                CommonLog.ErrorLogWrite(this, "ScanBarcodeAllDeleteCommandHandler()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
            }
            finally
            {
                TimerEnabled = true;
            }
        }

        private void OrderAllDeleteCommandHandler(object obj)
        {
            TimerEnabled = false;
            try
            {
                var topMessage = new List<M_Language>
                {
                    new M_Language
                    {
                        Type = SupportLanguageType.ko,
                        LanguageData = "커피주문 제품들을 삭제하시겠습니까?"
                    },
                    new M_Language
                    {
                        Type = SupportLanguageType.en,
                        LanguageData = "en커피주문 제품들을 삭제하시겠습니까?"
                    },
                };
                var miniPopup = new M_MiniPopup
                {
                    Icon = MiniPopupIcon.Delete,
                    DisplayLanguage = ShowLanguageType,
                    Message = topMessage,
                    CencalButtonText = Languages.GetMessages("BTN0021"),
                    OkButtonText = Languages.GetMessages("BTN0005"),
                    IsCencalButton = true,
                    TimeoutSeconds = 10,
                };
                var popupReturn = popupManager.OpenMiniPopup(miniPopup);
                if (popupReturn is M_PopupReturn && popupReturn.OKAnswer)
                {
                    DeleteSelfOrderItem();
                }
            }
            catch (Exception ex)
            {
                CommonLog.ErrorLogWrite(this, "OrderAllDeleteCommandHandler()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
            }
            finally
            {
                TimerEnabled = true;
            }
        }

        private void HappyPointResrveCommadHandler(object _param)
        {
            if (HappyPointReturn is M_HappyPointReturn happyPointReturn)
            {
                if (happyPointReturn.ReservePoint)
                {
                    happyPointReturn.ReservePoint = false;
                    HappyPointResrveSwitch = false;
                }
                else
                {
                    happyPointReturn.ReservePoint = true;
                    HappyPointResrveSwitch = true;
                }
            }
            else
            {
                OpenReserveHappyPoint();
            }
        }

        private void OkCashBagResrveCommandHandler(object _param)
        {
            if (OkCashBagReturn is M_OkCashBagReturn okCashBagReturn 
                && okCashBagReturn.ReservePoint)
            {
                OkCashBagReturn = null; //적립 취소
            }
            else
            {
                OpenReserveOkCashBag();
            }
        }


        private void DiscountSKCommandHandler(object _param)
        {
            MobileCompanyDiscountExcute(MobileCompanyType.SK_Telecom);
        }
        private void DiscountKTCommandHandler(object _param)
        {
            MobileCompanyDiscountExcute(MobileCompanyType.KT_Mobile);
        }
        private void DiscountLGCommandHandler(object _param)
        {
            MobileCompanyDiscountExcute(MobileCompanyType.LG_Uplus);
        }

        private void HappyPointUsingCommandHandler(object _param)
        {
            if (HappyPointReturn is M_HappyPointReturn happyPointReturn
                && happyPointReturn.PointUse
                && happyPointReturn.UsingPoints > 0
                && HappyPointUsingSwitch)
            {
                if (OpenRollbackConfirmDiscountOrPayments(PaymentsDiscountAndAddType.HappyPoint))
                {
                    TimerEnabled = false;
                    WaitWindowFrom.ShowWaitWindow();
                    RollBackExcute(PaymentsDiscountAndAddType.HappyPoint, HappyPointReturn.PaySEQ);
                    WaitWindowFrom.CloseWaitWindow();
                    TimerEnabled = true;
                }
            }
            else
            {
                OpenHappyPointUsing();
            }
        }


        private void OkCashBagUsingCommandHandler(object _param)
        {
            
        }

        private void MoreViewCommandHandler(object _param)
        {
            DefaultPage = PBPaymentPageType.MoreVIewPoints;
        }

        private void MoreViewReturnCommandHandler(object _param)
        {
            DefaultPage = PBPaymentPageType.CouponUsePoints;
        }

        private void HappyAppMyCouponCommandHandler(object _param)
        {
            if (UsingHappyAppCoupon is M_HappyCoupon happyAppCoupon
                && happyAppCoupon.IsUsed)
            {
                if (OpenRollbackConfirmDiscountOrPayments(PaymentsDiscountAndAddType.HappyCoupon))
                {
                    TimerEnabled = false;
                    WaitWindowFrom.ShowWaitWindow();
                    RollBackExcute(PaymentsDiscountAndAddType.HappyCoupon, UsingHappyAppCoupon.PaySEQ);
                    WaitWindowFrom.CloseWaitWindow();
                    TimerEnabled = true;
                }
            }
            else
            {
                OpenHappyAppCoupon();
            }
        }
        private void MobileCouponCommandHandler(object _param)
        {
            if (MobileCouponReturn is M_MobileCouponReturn mobileCouponReturn
                && mobileCouponReturn.TotalUseAmount > 0)
            {
                if (OpenRollbackConfirmDiscountOrPayments(PaymentsDiscountAndAddType.MobileCoupon))
                {
                    TimerEnabled = false;
                    WaitWindowFrom.ShowWaitWindow();
                    foreach (var aCoupon in mobileCouponReturn.VirtureCoupons)
                    {
                        if (aCoupon.PaySEQ > -1) RollBackExcute(PaymentsDiscountAndAddType.MobileCoupon, aCoupon.PaySEQ);
                    }
                    WaitWindowFrom.CloseWaitWindow();
                    TimerEnabled = true;
                }
            }
            else
            {
                OpenMobileCoupon();
            }

        }

        private void ICcardCommandHandler(object _param)
        {
            OpenPaymetsProcess(LastPaymentsType.IcCard);
        }


        private void LGSSpayCommandHandler(object _param)
        {
            OpenPaymetsProcess(LastPaymentsType.SsLgPay);
        }

        private void CashBeeCommandHandler(object _param)
        {
        }

        private void HappyGiftCommandHandler(object _param)
        {
        }

        private void TmoneyCommandHandler(object _param)
        {
        }

        private void SPCemployeeCommandHandler(object _param)
        {
        }

        private void KakaoPayCommandHandler(object _param)
        {         
        }

        private void SmilePayCommandHandler(object _param)
        {
            OpenPaymetsProcess(LastPaymentsType.SmilePay);
        }

        private void AliPayCommandHandler(object _param)
        {
        }

        private void ZeroPayCommandHandler(object _param)
        {
        }
        #endregion

        #region PaymentsList Click
        private void DetailBasketDeleteAllCommandHandler(object _param)
        {

            TimerEnabled = false;
            try
            {
                var miniPopup = new M_MiniPopup
                {
                    Icon = MiniPopupIcon.ListCancel,
                    DisplayLanguage = ShowLanguageType,
                    Message = Languages.GetMessages("LBL0099"),
                    CencalButtonText = Languages.GetMessages("BTN0021"),
                    OkButtonText = Languages.GetMessages("BTN0005"),
                    IsCencalButton = true,
                    TimeoutSeconds = 10,
                };
                var popupReturn = popupManager.OpenMiniPopup(miniPopup);
                if (popupReturn is M_PopupReturn && popupReturn.OKAnswer)
                {
                    DeledteAllBasket();
                }
            }
            catch (Exception ex)
            {
                CommonLog.ErrorLogWrite(this, "DetailBasketDeleteAllCommandHandler()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
            }
            finally
            {
                TimerEnabled = true;
            }

        }

        private void GotoLeftCommandHandler(object _param)
        {
            switch (DefaultPage)
            {
                case PBPaymentPageType.DetailBasket:
                    RollBacklEnd();
                    break;
                case PBPaymentPageType.PointsDisCounts:
                case PBPaymentPageType.CouponUsePoints:
                case PBPaymentPageType.PaymentExcute:
                    TimerEnabled = false;
                    try
                    {
                        var miniPopup = new M_MiniPopup
                        {
                            Icon = MiniPopupIcon.OrderCancel,
                            DisplayLanguage = ShowLanguageType,
                            Message = Languages.GetMessages("LBL0100"),
                            CencalButtonText = Languages.GetMessages("BTN0021"),
                            OkButtonText = Languages.GetMessages("BTN0005"),
                            IsCencalButton = true,
                            TimeoutSeconds = 10,
                        };
                        var popupReturn = popupManager.OpenMiniPopup(miniPopup);
                        if (popupReturn is M_PopupReturn && popupReturn.OKAnswer)
                        {
                            RollBacklEnd();
                        }
                    }
                    catch (Exception ex)
                    {
                        CommonLog.ErrorLogWrite(this, "GotoLeftCommandHandler()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
                    }
                    finally
                    {
                        TimerEnabled = true;
                    }
                    break;
            }
        }

        private void GotoRightCommandHandler(object _param)
        {
            switch (DefaultPage)
            {
                case PBPaymentPageType.DetailBasket:
                    DefaultPage = PBPaymentPageType.PointsDisCounts;
                    break;
                case PBPaymentPageType.PointsDisCounts:
                    DefaultPage = PBPaymentPageType.CouponUsePoints;
                    break;
                case PBPaymentPageType.CouponUsePoints:
                    DefaultPage = PBPaymentPageType.PaymentExcute;
                    break;
            }
        }

        #region Discount Rollback Events
        private void posRollBack_ReadEnd(object sender)
        {
            if (sender is posPaymentsCancel getRollBack)
            {
                if (getRollBack.ProcessOK)
                {
                    RemoveDiscountValue(CurrentRollBakType);
                    switch (CurrentRollBakType)
                    {
                        case PaymentsDiscountAndAddType.HappyPoint:
                            if (HappyPointReturn is M_HappyPointReturn happyPointReturn)
                            {
                                HappyPointReturn.PaySEQ = -1L;
                                HappyPointReturn.PointUse = false;
                                HappyPointReturn.UsingPoints = 0d;
                            }
                            HappyPointUsingSwitch = false;
                            break;
                        case PaymentsDiscountAndAddType.OkCashBagPoint:
                            break;
                        case PaymentsDiscountAndAddType.HappyCoupon:
                            HappyAppMyCouponSwitch = false;
                            UsingHappyAppCoupon = null;
                            break;
                        case PaymentsDiscountAndAddType.MobileCoupon:
                            MobileCouponSwitch = false;
                            MobileCouponReturn = null;
                            break;
                        case PaymentsDiscountAndAddType.SkTelecomDiscount:
                            DiscountSKSwitch = false;
                            MobileCompanyReturn = null;
                            break;
                        case PaymentsDiscountAndAddType.AllehKTDiscount:
                            DiscountKTSwitch = false;
                            MobileCompanyReturn = null;
                            break;
                        case PaymentsDiscountAndAddType.LGUPlusDisCount:
                            DiscountLGSwitch = false;
                            MobileCompanyReturn = null;
                            break;
                    }
                }
            }
        }

        private void posRollBack_ErrorEvent(posPaymentsCancel.ErrorCode _errorCode)
        {
            var errorText = new List<M_Language>
            {
                new M_Language
                {
                    Type = SupportLanguageType.ko,
                    LanguageData = _errorCode.ToString()
                },
            };
            KioskMessageBox.ShowMessageBox(errorText
                             , MessageBoxButton.OK
                             , OpenCloseAnimationType.FullSizeUp
                             , OpenCloseAnimationType.FullSizeDown
                             , 0.5, 0.2, 5);
        }

        #endregion

        #region Common Rollback Error Message Popup Event
        private void posRollBack_ErrorMessageEvent(string ErrorString)
        {
            var errorText = new List<M_Language>
            {
                new M_Language
                {
                    Type = SupportLanguageType.ko,
                    LanguageData = ErrorString.Replace("\n"," ").Replace("\r","")
                },
            };
            KioskMessageBox.ShowMessageBox(errorText
                                         , MessageBoxButton.OK
                                         , OpenCloseAnimationType.FullSizeUp
                                         , OpenCloseAnimationType.FullSizeDown
                                         , 0.5, 0.2, 5);
        } 
        #endregion

        #endregion

        #endregion Event Handlers
    }
}
