private void SaveManualHandpay()
        {
            if (cmbBarPositions.SelectedIndex <= 0)
                return;
            Window Owner;
            double amount = 0;
            int Auth_User_ID = 0;
            try
            {
                CAuthorize objAuthorize = null;

                if (txtBox != null && txtBox.Text.Length > 0)
                {
                    // Issue fix for ->set cultureinfo='en-US',  currencyculture='it-IT'
                    double.TryParse(txtBox.Text.ToString(), NumberStyles.Currency, new CultureInfo(ExtensionMethods.CurrentCurrenyCulture), out amount);
                }
                Auth_User_ID = Security.SecurityHelper.CurrentUser.User_No;
                if (Settings.Client != null && Settings.Client.ToLower() == "winchells"
                    && Settings.MaxHandPayAuthRequired
                    && txtBox != null
                    && (amount > Settings.HandpayPayoutCustomer_Max))
                {
                    objAuthorize = new CAuthorize("CashdeskOperator.Authorize.cs.MaxHandpay");
                   Auth_User_ID = Security.SecurityHelper.CurrentUser.User_No;
                    if (!Security.SecurityHelper.HasAccess("CashdeskOperator.Authorize.cs.MaxHandpay"))
                    {
                        objAuthorize.ShowDialogEx(this);
                        if (!objAuthorize.IsAuthorized)
                        {
                            IsProcessed = true;
                            return;
                        }
                        else
                        {
                            Auth_User_ID = handpay.GetUserID(objAuthorize.User.SecurityUserID);
                        }
                    }
                    else
                    {
                       objAuthorize.IsAuthorized = true;
                    }
                }

                if (Settings.RegulatoryEnabled == true && Settings.RegulatoryType == "AAMS")
                {
                    if (txtBox != null)
                    {
                        Custid = 0;
                        ProcessCancelled = false;
                        if (amount >= Settings.HandpayPayoutCustomer_Min && amount <= Settings.HandpayPayoutCustomer_Max)
                        {
                            oCustomerDetails = new BMC.Presentation.POS.Views.CustomerDetails();
                            oCustomerDetails.delCustomerUpdated += new BMC.Presentation.POS.Views.CustomerDetails.CustomerUpdateHandler(delCustomerUpdated);
                            oCustomerDetails.delCustomerCancelled += new BMC.Presentation.POS.Views.CustomerDetails.CustomerCancelHandler(delCustomerCancelled);
                            Owner = Window.GetWindow(this);
                            oCustomerDetails.ShowDialogEx(this);
                        }
                        else if (amount >= Settings.HandpayPayoutCustomer_BankAccNo)
                        {
                            oCustomerDetails = new BMC.Presentation.POS.Views.CustomerDetails(true);
                            oCustomerDetails.delCustomerUpdated += new BMC.Presentation.POS.Views.CustomerDetails.CustomerUpdateHandler(delCustomerUpdated);
                            oCustomerDetails.delCustomerCancelled += new BMC.Presentation.POS.Views.CustomerDetails.CustomerCancelHandler(delCustomerCancelled);
                            Owner = Window.GetWindow(this);
                            oCustomerDetails.ShowDialogEx(this);
                        }
                        else if (amount >= Settings.HandpayPayoutCustomer_Max && amount <= Settings.HandpayPayoutCustomer_BankAccNo)
                        {
                            oCustomerDetails = new BMC.Presentation.POS.Views.CustomerDetails();
                            oCustomerDetails.delCustomerUpdated += new BMC.Presentation.POS.Views.CustomerDetails.CustomerUpdateHandler(delCustomerUpdated);
                            oCustomerDetails.delCustomerCancelled += new BMC.Presentation.POS.Views.CustomerDetails.CustomerCancelHandler(delCustomerCancelled);
                            Owner = Window.GetWindow(this);
                            oCustomerDetails.ShowDialogEx(this);
                        }
                    }

                    if (ProcessCancelled) // if the process cancelled from the customer then  back to the handpay screen
                        return;
                }

                List<AssetNumberResult> lstasset = handpay.GetAssetNumber((cmbBarPositions.SelectedItem as BarPositions).Installation_No);

                string Asset = lstasset[0].Stock_No;

                treasury = new Treasury { InstallationNumber = (cmbBarPositions.SelectedItem as BarPositions).Installation_No };

                if (optHandpay.IsChecked == true)
                    treasury.TreasuryType = "AttendantPay Credit";
                else if (optJackpot.IsChecked == true)
                    treasury.TreasuryType = "AttendantPay Jackpot";
                else
                    treasury.TreasuryType = "PROGRESSIVE";
                treasury.TreasuryAmount = amount;
                treasury.ActualTreasuryDate = DateTime.Now;

              // treasury.UserID = Security.SecurityHelper.CurrentUser.User_No;               
                treasury.UserID = Auth_User_ID;


                treasury.Authorized_Date = DateTime.MinValue.DBMinValue();
                if (objAuthorize != null && objAuthorize.IsAuthorized)
                {
                    treasury.AuthorizedUser_No = Auth_User_ID;
                    treasury.Authorized_Date = DateTime.Now;

                    //Audit for authorization
                    AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                    {

                        AuditModuleName = ModuleName.ManualAttendantPay,
                        Audit_Screen_Name = "PositionDetails|ManualAttendantPay",
                        Audit_Desc = "Manual AttendantPay Type-" + treasury.TreasuryType,
                        AuditOperationType = OperationType.ADD,
                        Audit_Field = "AuthorizedUser_No",
                        Audit_New_Vl = Auth_User_ID.ToString(),
                        Audit_Slot = Asset
                    });

                }

                treasury.CustomerID = Custid; // add the customer to the treasury if amt between 1000 & 4000 or >5000

                Treasury_No = handpay.ProcessHandPay(treasury, 0);


                IsProcessed = true;
                if (Treasury_No > 0)
                {
                    DateTime dtTreasury = (DateTime)handpay.GetTreasuryDateTime(Treasury_No);

                    TextBlock_11.Text = "#" + (cmbBarPositions.SelectedItem as BarPositions).Bar_Pos_Name + dtTreasury.ToString("ddMMyyyyHHmmss");
                    txtAmount.Text = Convert.ToDecimal((treasury.TreasuryAmount)).GetUniversalCurrencyFormat();
                    #region GCD
                    if (Settings.IsGloryCDEnabled && Settings.CashDispenserEnabled)
                    {

                        LoadingWindow ld = new LoadingWindow(Window.GetWindow(this), ModuleName.ManualAttendantPay, Treasury_No.ToString(), (cmbBarPositions.SelectedItem as BarPositions).Bar_Pos_Name, Convert.ToInt32(treasury.TreasuryAmount * 100));
                        ld.Topmost = true;
                        ld.ShowDialogEx(this);
                        Result res = ld.Result;
                        if (res.IsSuccess && (Treasury_No > 0))
                        {
                            LogManager.WriteLog(string.Format("Cash Dispensed Successfully - Treasury Amount: {0:0.00}", treasury.TreasuryAmount), LogManager.enumLogLevel.Info);
                            LogManager.WriteLog("Export Manual AttendantPay Details to Enterprise", LogManager.enumLogLevel.Info);
                            handpay.ExportHandPay(Treasury_No);

                            BMC.Presentation.MessageBox.ShowBox(res.error.Message, res.error.MessageType.Equals("Error") ? BMC_Icon.Error : BMC_Icon.Information, true);

                            AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                            {

                                AuditModuleName = ModuleName.AttendantPay,
                                Audit_Screen_Name = "PositionDetails|AttendantPay|Manual HandPay",
                                Audit_Desc = "Manual HandPay Succeed",
                                AuditOperationType = OperationType.ADD,
                                Audit_Old_Vl = "Ticket_ExceptionID:0 (Manual Handpay); TreasuryNo:" + Treasury_No + ";",

                            });

                        }
                        else
                        {
                            BMC.Presentation.MessageBox.ShowBox(res.error.Message, res.error.MessageType.Equals("Error") ? BMC_Icon.Error : BMC_Icon.Information, true);
                            LogManager.WriteLog(string.Format("Unable to Dispense Cash - Treasury Amount: {0:0.00}", treasury.TreasuryAmount), LogManager.enumLogLevel.Info);
                            LogManager.WriteLog("Rollback Manual HandPay Process", LogManager.enumLogLevel.Info);
                            handpay.RollbackHandPay(0, Treasury_No);
                            MessageBox.ShowBox("MessageID117", BMC_Icon.Error);
                            AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                            {

                                AuditModuleName = ModuleName.AttendantPay,
                                Audit_Screen_Name = "PositionDetails|AttendantPay",
                                Audit_Desc = treasury.TreasuryType + " processing was not completed.",
                                AuditOperationType = OperationType.ADD,
                                Audit_Slot = Asset
                            });
                            AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                            {
                                AuditModuleName = ModuleName.AttendantPay,
                                Audit_Screen_Name = "PositionDetails|AttendantPay|Manual HandPay Process Failed",
                                Audit_Desc = "Rollback HandPay Process Voucher due to cash dispenser error",
                                AuditOperationType = OperationType.MODIFY,
                                Audit_Old_Vl = "Ticket_ExceptionID:0 (Manual Handpay); TreasuryNo:" + Treasury_No + ";"
                            });
                        }
                    }
                    else
                    {
                        this.ProcessCashDispense("Manual AttendantPay Type", treasury.TreasuryType, Convert.ToDecimal(amount));
                        MessageBox.ShowBox("MessageID116", BMC_Icon.Information);
                    }
                    #endregion

                    AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                    {

                        AuditModuleName = ModuleName.ManualAttendantPay,
                        Audit_Screen_Name = "PositionDetails|ManualAttendantPay",
                        Audit_Desc = "Manual AttendantPay Type-" + treasury.TreasuryType,
                        AuditOperationType = OperationType.ADD,
                        Audit_Field = "Amount",
                        Audit_New_Vl = String.Format("{0:0.00}", treasury.TreasuryAmount),
                        Audit_Slot = Asset
                    });

                    if (txtBox != null)
                    {
                        //txtBox.Text = "0.00";

                        txtBox.Text = this.DefaultAmount();
                        ucValueCalcComp.s_UnformattedText = "";
                    }

                    if (objAuthorize != null && objAuthorize.User != null)
                        (oCommonUtilities.CreateInstance()).PrintCommonReceipt(false, treasury.TreasuryType, Treasury_No.ToString(), objAuthorize.User);
                    else
                    (oCommonUtilities.CreateInstance()).PrintCommonReceipt(false, treasury.TreasuryType, Treasury_No.ToString());
                    if (((bool)optJackpot.IsChecked) || ((bool)optProgressive.IsChecked))// || ((bool)optHandpay.IsChecked))
                    {
                        treasury.Asset = Asset;
                        //string installationType = installationPathkey.GetValue("InstallationType").ToString();

                        //if (installationType.ToUpper().Equals("EXCHANGECLIENT"))
                        //{
                        //    if (Settings.SendPT10FromClient)
                        //        PostHandpayEvent(treasury);
                        //}
                        //else
                        PostHandpayEvent(treasury);
                    }
                }
                else
                {
                    if (optHandpay.IsChecked == true)
                        MessageBox.ShowBox("MessageID119", BMC_Icon.Error);
                    else if (optJackpot.IsChecked == true)
                        MessageBox.ShowBox("MessageID1191", BMC_Icon.Error);
                    else
                        MessageBox.ShowBox("MessageID1192", BMC_Icon.Error);


                    AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                    {

                        AuditModuleName = ModuleName.ManualAttendantPay,
                        Audit_Screen_Name = "PositionDetails|ManualAttendantPay",

                        Audit_Desc = "Manual AttendantPay Type-" + treasury.TreasuryType + " processing was not completed.",
                        AuditOperationType = OperationType.ADD,
                        Audit_Slot = Asset
                    });
                }
            }
            catch (Exception Ex)
            {
                ExceptionManager.Publish(Ex);
                MessageBox.ShowBox("MessageID119", BMC_Icon.Error);

                AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                {

                    AuditModuleName = ModuleName.ManualAttendantPay,
                    Audit_Screen_Name = "PositionDetails|ManualAttendantPay",
                    Audit_Desc = "Manual AttendantPay Type-" + treasury.TreasuryType + " processing was not completed.",
                    AuditOperationType = OperationType.ADD,
                    Audit_Slot = Asset
                });
            }
        }
예제 #2
0
        private void SaveManualHandpay()
        {
            if (cmbBarPositions.SelectedIndex <= 0)
            {
                return;
            }
            Window Owner;
            double amount       = 0;
            int    Auth_User_ID = 0;

            try
            {
                CAuthorize objAuthorize = null;

                if (txtBox != null && txtBox.Text.Length > 0)
                {
                    // Issue fix for ->set cultureinfo='en-US',  currencyculture='it-IT'
                    double.TryParse(txtBox.Text.ToString(), NumberStyles.Currency, new CultureInfo(ExtensionMethods.CurrentCurrenyCulture), out amount);
                }
                Auth_User_ID = Security.SecurityHelper.CurrentUser.User_No;
                if (Settings.Client != null && Settings.Client.ToLower() == "winchells" &&
                    Settings.MaxHandPayAuthRequired &&
                    txtBox != null &&
                    (amount > Settings.HandpayPayoutCustomer_Max))
                {
                    objAuthorize = new CAuthorize("CashdeskOperator.Authorize.cs.MaxHandpay");
                    Auth_User_ID = Security.SecurityHelper.CurrentUser.User_No;
                    if (!Security.SecurityHelper.HasAccess("CashdeskOperator.Authorize.cs.MaxHandpay"))
                    {
                        objAuthorize.ShowDialogEx(this);
                        if (!objAuthorize.IsAuthorized)
                        {
                            IsProcessed = true;
                            return;
                        }
                        else
                        {
                            Auth_User_ID = handpay.GetUserID(objAuthorize.User.SecurityUserID);
                        }
                    }
                    else
                    {
                        objAuthorize.IsAuthorized = true;
                    }
                }

                if (Settings.RegulatoryEnabled == true && Settings.RegulatoryType == "AAMS")
                {
                    if (txtBox != null)
                    {
                        Custid           = 0;
                        ProcessCancelled = false;
                        if (amount >= Settings.HandpayPayoutCustomer_Min && amount <= Settings.HandpayPayoutCustomer_Max)
                        {
                            oCustomerDetails = new BMC.Presentation.POS.Views.CustomerDetails();
                            oCustomerDetails.delCustomerUpdated   += new BMC.Presentation.POS.Views.CustomerDetails.CustomerUpdateHandler(delCustomerUpdated);
                            oCustomerDetails.delCustomerCancelled += new BMC.Presentation.POS.Views.CustomerDetails.CustomerCancelHandler(delCustomerCancelled);
                            Owner = Window.GetWindow(this);
                            oCustomerDetails.ShowDialogEx(this);
                        }
                        else if (amount >= Settings.HandpayPayoutCustomer_BankAccNo)
                        {
                            oCustomerDetails = new BMC.Presentation.POS.Views.CustomerDetails(true);
                            oCustomerDetails.delCustomerUpdated   += new BMC.Presentation.POS.Views.CustomerDetails.CustomerUpdateHandler(delCustomerUpdated);
                            oCustomerDetails.delCustomerCancelled += new BMC.Presentation.POS.Views.CustomerDetails.CustomerCancelHandler(delCustomerCancelled);
                            Owner = Window.GetWindow(this);
                            oCustomerDetails.ShowDialogEx(this);
                        }
                        else if (amount >= Settings.HandpayPayoutCustomer_Max && amount <= Settings.HandpayPayoutCustomer_BankAccNo)
                        {
                            oCustomerDetails = new BMC.Presentation.POS.Views.CustomerDetails();
                            oCustomerDetails.delCustomerUpdated   += new BMC.Presentation.POS.Views.CustomerDetails.CustomerUpdateHandler(delCustomerUpdated);
                            oCustomerDetails.delCustomerCancelled += new BMC.Presentation.POS.Views.CustomerDetails.CustomerCancelHandler(delCustomerCancelled);
                            Owner = Window.GetWindow(this);
                            oCustomerDetails.ShowDialogEx(this);
                        }
                    }

                    if (ProcessCancelled) // if the process cancelled from the customer then  back to the handpay screen
                    {
                        return;
                    }
                }

                List <AssetNumberResult> lstasset = handpay.GetAssetNumber((cmbBarPositions.SelectedItem as BarPositions).Installation_No);

                string Asset = lstasset[0].Stock_No;

                treasury = new Treasury {
                    InstallationNumber = (cmbBarPositions.SelectedItem as BarPositions).Installation_No
                };

                if (optHandpay.IsChecked == true)
                {
                    treasury.TreasuryType = "AttendantPay Credit";
                }
                else if (optJackpot.IsChecked == true)
                {
                    treasury.TreasuryType = "AttendantPay Jackpot";
                }
                else
                {
                    treasury.TreasuryType = "PROGRESSIVE";
                }
                treasury.TreasuryAmount     = amount;
                treasury.ActualTreasuryDate = DateTime.Now;

                // treasury.UserID = Security.SecurityHelper.CurrentUser.User_No;
                treasury.UserID = Auth_User_ID;


                treasury.Authorized_Date = DateTime.MinValue.DBMinValue();
                if (objAuthorize != null && objAuthorize.IsAuthorized)
                {
                    treasury.AuthorizedUser_No = Auth_User_ID;
                    treasury.Authorized_Date   = DateTime.Now;

                    //Audit for authorization
                    AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                    {
                        AuditModuleName    = ModuleName.ManualAttendantPay,
                        Audit_Screen_Name  = "PositionDetails|ManualAttendantPay",
                        Audit_Desc         = "Manual AttendantPay Type-" + treasury.TreasuryType,
                        AuditOperationType = OperationType.ADD,
                        Audit_Field        = "AuthorizedUser_No",
                        Audit_New_Vl       = Auth_User_ID.ToString(),
                        Audit_Slot         = Asset
                    });
                }

                treasury.CustomerID = Custid; // add the customer to the treasury if amt between 1000 & 4000 or >5000

                Treasury_No = handpay.ProcessHandPay(treasury, 0);


                IsProcessed = true;
                if (Treasury_No > 0)
                {
                    DateTime dtTreasury = (DateTime)handpay.GetTreasuryDateTime(Treasury_No);

                    TextBlock_11.Text = "#" + (cmbBarPositions.SelectedItem as BarPositions).Bar_Pos_Name + dtTreasury.ToString("ddMMyyyyHHmmss");
                    txtAmount.Text    = Convert.ToDecimal((treasury.TreasuryAmount)).GetUniversalCurrencyFormat();
                    #region GCD
                    if (Settings.IsGloryCDEnabled && Settings.CashDispenserEnabled)
                    {
                        LoadingWindow ld = new LoadingWindow(Window.GetWindow(this), ModuleName.ManualAttendantPay, Treasury_No.ToString(), (cmbBarPositions.SelectedItem as BarPositions).Bar_Pos_Name, Convert.ToInt32(treasury.TreasuryAmount * 100));
                        ld.Topmost = true;
                        ld.ShowDialogEx(this);
                        Result res = ld.Result;
                        if (res.IsSuccess && (Treasury_No > 0))
                        {
                            LogManager.WriteLog(string.Format("Cash Dispensed Successfully - Treasury Amount: {0:0.00}", treasury.TreasuryAmount), LogManager.enumLogLevel.Info);
                            LogManager.WriteLog("Export Manual AttendantPay Details to Enterprise", LogManager.enumLogLevel.Info);
                            handpay.ExportHandPay(Treasury_No);

                            BMC.Presentation.MessageBox.ShowBox(res.error.Message, res.error.MessageType.Equals("Error") ? BMC_Icon.Error : BMC_Icon.Information, true);

                            AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                            {
                                AuditModuleName    = ModuleName.AttendantPay,
                                Audit_Screen_Name  = "PositionDetails|AttendantPay|Manual HandPay",
                                Audit_Desc         = "Manual HandPay Succeed",
                                AuditOperationType = OperationType.ADD,
                                Audit_Old_Vl       = "Ticket_ExceptionID:0 (Manual Handpay); TreasuryNo:" + Treasury_No + ";",
                            });
                        }
                        else
                        {
                            BMC.Presentation.MessageBox.ShowBox(res.error.Message, res.error.MessageType.Equals("Error") ? BMC_Icon.Error : BMC_Icon.Information, true);
                            LogManager.WriteLog(string.Format("Unable to Dispense Cash - Treasury Amount: {0:0.00}", treasury.TreasuryAmount), LogManager.enumLogLevel.Info);
                            LogManager.WriteLog("Rollback Manual HandPay Process", LogManager.enumLogLevel.Info);
                            handpay.RollbackHandPay(0, Treasury_No);
                            MessageBox.ShowBox("MessageID117", BMC_Icon.Error);
                            AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                            {
                                AuditModuleName    = ModuleName.AttendantPay,
                                Audit_Screen_Name  = "PositionDetails|AttendantPay",
                                Audit_Desc         = treasury.TreasuryType + " processing was not completed.",
                                AuditOperationType = OperationType.ADD,
                                Audit_Slot         = Asset
                            });
                            AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                            {
                                AuditModuleName    = ModuleName.AttendantPay,
                                Audit_Screen_Name  = "PositionDetails|AttendantPay|Manual HandPay Process Failed",
                                Audit_Desc         = "Rollback HandPay Process Voucher due to cash dispenser error",
                                AuditOperationType = OperationType.MODIFY,
                                Audit_Old_Vl       = "Ticket_ExceptionID:0 (Manual Handpay); TreasuryNo:" + Treasury_No + ";"
                            });
                        }
                    }
                    else
                    {
                        this.ProcessCashDispense("Manual AttendantPay Type", treasury.TreasuryType, Convert.ToDecimal(amount));
                        MessageBox.ShowBox("MessageID116", BMC_Icon.Information);
                    }
                    #endregion

                    AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                    {
                        AuditModuleName    = ModuleName.ManualAttendantPay,
                        Audit_Screen_Name  = "PositionDetails|ManualAttendantPay",
                        Audit_Desc         = "Manual AttendantPay Type-" + treasury.TreasuryType,
                        AuditOperationType = OperationType.ADD,
                        Audit_Field        = "Amount",
                        Audit_New_Vl       = String.Format("{0:0.00}", treasury.TreasuryAmount),
                        Audit_Slot         = Asset
                    });

                    if (txtBox != null)
                    {
                        //txtBox.Text = "0.00";

                        txtBox.Text = this.DefaultAmount();
                        ucValueCalcComp.s_UnformattedText = "";
                    }

                    if (objAuthorize != null && objAuthorize.User != null)
                    {
                        (oCommonUtilities.CreateInstance()).PrintCommonReceipt(false, treasury.TreasuryType, Treasury_No.ToString(), objAuthorize.User);
                    }
                    else
                    {
                        (oCommonUtilities.CreateInstance()).PrintCommonReceipt(false, treasury.TreasuryType, Treasury_No.ToString());
                    }
                    if (((bool)optJackpot.IsChecked) || ((bool)optProgressive.IsChecked))// || ((bool)optHandpay.IsChecked))
                    {
                        treasury.Asset = Asset;
                        //string installationType = installationPathkey.GetValue("InstallationType").ToString();

                        //if (installationType.ToUpper().Equals("EXCHANGECLIENT"))
                        //{
                        //    if (Settings.SendPT10FromClient)
                        //        PostHandpayEvent(treasury);
                        //}
                        //else
                        PostHandpayEvent(treasury);
                    }
                }
                else
                {
                    if (optHandpay.IsChecked == true)
                    {
                        MessageBox.ShowBox("MessageID119", BMC_Icon.Error);
                    }
                    else if (optJackpot.IsChecked == true)
                    {
                        MessageBox.ShowBox("MessageID1191", BMC_Icon.Error);
                    }
                    else
                    {
                        MessageBox.ShowBox("MessageID1192", BMC_Icon.Error);
                    }


                    AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                    {
                        AuditModuleName   = ModuleName.ManualAttendantPay,
                        Audit_Screen_Name = "PositionDetails|ManualAttendantPay",

                        Audit_Desc         = "Manual AttendantPay Type-" + treasury.TreasuryType + " processing was not completed.",
                        AuditOperationType = OperationType.ADD,
                        Audit_Slot         = Asset
                    });
                }
            }
            catch (Exception Ex)
            {
                ExceptionManager.Publish(Ex);
                MessageBox.ShowBox("MessageID119", BMC_Icon.Error);

                AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                {
                    AuditModuleName    = ModuleName.ManualAttendantPay,
                    Audit_Screen_Name  = "PositionDetails|ManualAttendantPay",
                    Audit_Desc         = "Manual AttendantPay Type-" + treasury.TreasuryType + " processing was not completed.",
                    AuditOperationType = OperationType.ADD,
                    Audit_Slot         = Asset
                });
            }
        }
        private void ProcessHandpay(bool IsVoid)
        {
            Window Owner;
            double amount = 0;
            CAuthorize objAuthorize = null;
            Treasury treasury = null;
            int AuthUserID = 0;
            try
            {
                //
                if (!IsHandpayVoid)
                {
                    if ((lstHandpay.SelectedItem as FillTreasuryList).Amount != null && (double)(lstHandpay.SelectedItem as FillTreasuryList).Amount > 0)
                    {
                        //double.TryParse((lstHandpay.SelectedItem as FillTreasuryList).Amount.ToString(), NumberStyles.Currency, new CultureInfo(ExtensionMethods.CurrentCurrenyCulture), out amount);
                        //------->
                        // Issue fix for ->In ITALY environment if user currency setting is set as italy then while processing handpay amount 
                        // of 99,36 customer information screen is displaying. (If we set user currency setting as US or UK then 
                        // we are able to process handpays properly)
                        //<--------
                        double.TryParse((lstHandpay.SelectedItem as FillTreasuryList).Amount.ToString(), out amount);
                    }

                    if (Settings.W2GMessage)
                    {
                        if (amount > Settings.W2GWinAmount)
                        {
                            MessageBox.ShowBox("MessageID367", BMC_Icon.Information);
                            if (!Settings.ProcessW2GAmount)
                            {
                                MessageBox.ShowBox("MessageID531", BMC_Icon.Information);
                                IsProcessed = true;
                                return;
                            }
                        }
                    }
                    AuthUserID = Security.SecurityHelper.CurrentUser.User_No;

                    if (Settings.Client != null && Settings.Client.ToLower() == "winchells"
                        && Settings.MaxHandPayAuthRequired
                        && (lstHandpay.SelectedItem as FillTreasuryList).Amount != null
                        && (amount > Settings.HandpayPayoutCustomer_Max))
                    {
                        objAuthorize = new CAuthorize("CashdeskOperator.Authorize.cs.MaxHandpay");
                        objAuthorize.User = Security.SecurityHelper.CurrentUser;
                        if (!Security.SecurityHelper.HasAccess("CashdeskOperator.Authorize.cs.MaxHandpay"))
                        {
                            objAuthorize.ShowDialog();
                            if (!objAuthorize.IsAuthorized)
                                return;

                            else
                            {
                                AuthUserID = handpay.GetUserID(objAuthorize.User.SecurityUserID);

                            }
                        }
                        else
                        {
                            objAuthorize.IsAuthorized = true;
                        }
                    }

                    if (Settings.RegulatoryEnabled == true && Settings.RegulatoryType == "AAMS")
                    {
                        if ((lstHandpay.SelectedItem as FillTreasuryList).Amount != null)
                        {
                            Custid = 0;
                            ProcessCancelled = false;
                            if (amount >= Settings.HandpayPayoutCustomer_Min && amount <= Settings.HandpayPayoutCustomer_Max)
                            {
                                oCustomerDetails = new BMC.Presentation.POS.Views.CustomerDetails();
                                oCustomerDetails.delCustomerUpdated += new BMC.Presentation.POS.Views.CustomerDetails.CustomerUpdateHandler(delCustomerUpdated);
                                oCustomerDetails.delCustomerCancelled += new BMC.Presentation.POS.Views.CustomerDetails.CustomerCancelHandler(delCustomerCancelled);
                                Owner = Window.GetWindow(this);
                                oCustomerDetails.ShowDialog();
                            }
                            else if (amount >= Settings.HandpayPayoutCustomer_BankAccNo)
                            {
                                oCustomerDetails = new BMC.Presentation.POS.Views.CustomerDetails(true);
                                oCustomerDetails.delCustomerUpdated += new BMC.Presentation.POS.Views.CustomerDetails.CustomerUpdateHandler(delCustomerUpdated);
                                oCustomerDetails.delCustomerCancelled += new BMC.Presentation.POS.Views.CustomerDetails.CustomerCancelHandler(delCustomerCancelled);
                                Owner = Window.GetWindow(this);
                                oCustomerDetails.ShowDialog();
                            }
                            else if (amount >= Settings.HandpayPayoutCustomer_Max && amount <= Settings.HandpayPayoutCustomer_BankAccNo)
                            {
                                oCustomerDetails = new BMC.Presentation.POS.Views.CustomerDetails();
                                oCustomerDetails.delCustomerUpdated += new BMC.Presentation.POS.Views.CustomerDetails.CustomerUpdateHandler(delCustomerUpdated);
                                oCustomerDetails.delCustomerCancelled += new BMC.Presentation.POS.Views.CustomerDetails.CustomerCancelHandler(delCustomerCancelled);
                                Owner = Window.GetWindow(this);
                                oCustomerDetails.ShowDialog();
                            }
                        }
                        if (ProcessCancelled)
                            return;
                    }
                }

                int TE_ID = (lstHandpay.SelectedItem as FillTreasuryList).TE_ID;
                treasury = new Treasury
                {
                    InstallationNumber =
                        (lstHandpay.SelectedItem as FillTreasuryList).Installation_No,
                    TreasuryType = (lstHandpay.SelectedItem as FillTreasuryList).HP_Type,
                    TreasuryAmount = (double)(lstHandpay.SelectedItem as FillTreasuryList).Amount,
                    TreasuryTemp = IsVoid ? true : false,
                    ActualTreasuryDate =
                        (DateTime)((lstHandpay.SelectedItem as FillTreasuryList).TreasuryDate)
                };
                treasury.CustomerID = Custid;
                treasury.UserID = AuthUserID;
                treasury.Authorized_Date = DateTime.Now.DBMinValue();

                if (objAuthorize != null && objAuthorize.IsAuthorized)
                {
                    treasury.AuthorizedUser_No = objAuthorize.User.SecurityUserID;
                    treasury.Authorized_Date = DateTime.Now;

                    //Audit for authorization
                    AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                    {

                        AuditModuleName = ModuleName.ManualAttendantPay,
                        Audit_Screen_Name = "PositionDetails|ManualAttendantPay",
                        Audit_Desc = "Manual AttendantPay Type-" + treasury.TreasuryType,
                        AuditOperationType = OperationType.ADD,
                        Audit_Field = "AuthorizedUser_No",
                        Audit_New_Vl = objAuthorize.User.SecurityUserID.ToString(),
                        Audit_Slot = (lstHandpay.SelectedItem as FillTreasuryList).Asset
                    });

                }
                Treasury_No = handpay.ProcessHandPay(treasury, TE_ID);

                if (Treasury_No > 0)
                {
                    AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                    {

                        AuditModuleName = ModuleName.AttendantPay,
                        Audit_Screen_Name = "PositionDetails|AttendantPay",
                        Audit_Desc = "AttendantPay Type-" + treasury.TreasuryType,
                        AuditOperationType = OperationType.ADD,
                        Audit_Field = "Treasury Amount",
                        Audit_New_Vl = String.Format("{0:0.00}", treasury.TreasuryAmount),
                        Audit_Slot = (lstHandpay.SelectedItem as FillTreasuryList).Asset
                    });

                    txtAmount.Text = "";

                    if ((bool)(lstHandpay.SelectedItem as FillTreasuryList).HP_Uncleared)
                    {
                        //LogManager.WriteLog("Executing Path : " + BMCRegistryHelper.GetRegLocalMachine().OpenSubKey("Software\\Honeyframe").GetValue("InstallationPath").ToString().Trim() + Common.ConfigurationManagement.ConfigManager.Read(
                        //            "HandpayCommandLinePrompt") + " ClearHandpay " + (lstHandpay.SelectedItem as FillTreasuryList).Datapak_No, LogManager.enumLogLevel.Info);



                        //System.Diagnostics.Process.Start(BMCRegistryHelper.GetRegLocalMachine().OpenSubKey("Software\\Honeyframe").GetValue("InstallationPath").ToString().Trim() + Common.ConfigurationManagement.ConfigManager.Read(
                        //            "HandpayCommandLinePrompt"), " ClearHandpay " + (lstHandpay.SelectedItem as FillTreasuryList).Datapak_No);

                        //var proc = new System.Diagnostics.Process
                        //{
                        //    StartInfo =
                        //    {
                        //        FileName =
                        //            Environment.CurrentDirectory + "\\" + Common.ConfigurationManagement.ConfigManager.Read(
                        //            "HandpayCommandLinePrompt"),
                        //        Arguments =
                        //            "ClearHandpay "+ (lstHandpay.SelectedItem as FillTreasuryList).Datapak_No
                        //    }
                        //};
                        //proc.Start();
                    }

                    if (!IsVoid)
                    {

                        #region GCD
                        if (Settings.IsGloryCDEnabled && Settings.CashDispenserEnabled)
                        {
                            LoadingWindow ld = new LoadingWindow(this, ModuleName.AttendantPay, Treasury_No.ToString(), sPos, Convert.ToInt32(treasury.TreasuryAmount * 100));
                            ld.Topmost = true;
                            ld.ShowDialog();
                            Result res = ld.Result;
                            if (res.IsSuccess && (Treasury_No > 0))
                            {
                                LogManager.WriteLog(string.Format("Cash Dispensed Successfully - Treasury Amount: {0:0.00}", treasury.TreasuryAmount), LogManager.enumLogLevel.Info);
                                LogManager.WriteLog("Export HandPay Details to Enterprise", LogManager.enumLogLevel.Info);
                                handpay.ExportHandPay(Treasury_No);

                                BMC.Presentation.MessageBox.ShowBox(res.error.Message, res.error.MessageType.Equals("Error") ? BMC_Icon.Error : BMC_Icon.Information, true);
                                AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                                {

                                    AuditModuleName = ModuleName.AttendantPay,
                                    Audit_Screen_Name = "PositionDetails|AttendantPay|HandPay",
                                    Audit_Desc = "HandPay Succeed",
                                    AuditOperationType = OperationType.ADD,
                                    Audit_Old_Vl = "Ticket_ExceptionID:" + TE_ID + ";TreasuryNo:" + Treasury_No + ";",

                                });

                            }
                            else
                            {
                                BMC.Presentation.MessageBox.ShowBox(res.error.Message, res.error.MessageType.Equals("Error") ? BMC_Icon.Error : BMC_Icon.Information, true);
                                LogManager.WriteLog(string.Format("Unable to Dispense Cash - Treasury Amount: {0:0.00}", treasury.TreasuryAmount), LogManager.enumLogLevel.Info);
                                LogManager.WriteLog("Rollback HandPay Process", LogManager.enumLogLevel.Info);
                                handpay.RollbackHandPay(TE_ID, Treasury_No);
                                MessageBox.ShowBox("MessageID117", BMC_Icon.Error);
                                AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                                {

                                    AuditModuleName = ModuleName.AttendantPay,
                                    Audit_Screen_Name = "PositionDetails|AttendantPay",
                                    Audit_Desc = treasury.TreasuryType + " processing was not completed.",
                                    AuditOperationType = OperationType.ADD,
                                    Audit_Slot = (lstHandpay.SelectedItem as FillTreasuryList).Asset
                                });
                                AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                                {
                                    AuditModuleName = ModuleName.AttendantPay,
                                    Audit_Screen_Name = "PositionDetails|AttendantPay|HandPay Process Failed",
                                    Audit_Desc = "Rollback HandPay Process Voucher due to cash dispenser error",
                                    AuditOperationType = OperationType.MODIFY,
                                    Audit_Old_Vl = "Ticket_ExceptionID:" + TE_ID + ";TreasuryNo:" + Treasury_No + ";"
                                });
                            }
                        }
                        else
                        {
                            this.ProcessCashDispense("AttendantPay Type", treasury.TreasuryType, Convert.ToDecimal(treasury.TreasuryAmount));
                            MessageBox.ShowBox("MessageID116", BMC_Icon.Information);
                        }
                        #endregion

                        FillTreasury(sPos);
                        Helper_classes.Common.BindListView(treasuryList, lstHandpay);

                        //Newly Added - Venkatesh Kumar - SGVI

                        if (AppSettings.IsReceiptRequired)
                        {
                            if (objAuthorize != null && objAuthorize.User != null)
                                (oCommonUtilities.CreateInstance()).PrintCommonReceipt(false, treasury.TreasuryType, Treasury_No.ToString(), objAuthorize.User);
                            else
                                (oCommonUtilities.CreateInstance()).PrintCommonReceipt(false, treasury.TreasuryType, Treasury_No.ToString());
                        }

                        //---------************---------------

                        LogManager.WriteLog("Binding of Hand Pay completed for the pos : " + sPos, LogManager.enumLogLevel.Info);
                    }
                }
                else
                {

                    switch (Treasury_No)
                    {

                        case -2://LockExists
                        case -3://LockError
                            {
                                MessageBox.ShowBox("MessageID373", BMC_Icon.Error);

                                AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                                {

                                    AuditModuleName = ModuleName.AttendantPay,
                                    Audit_Screen_Name = "PositionDetails|AttendantPay",
                                    Audit_Desc = treasury.TreasuryType + " has been locked by another user for processing.",
                                    AuditOperationType = OperationType.ADD,
                                    Audit_Slot = (lstHandpay.SelectedItem as FillTreasuryList).Asset
                                });

                                break;
                            }
                        case -4://DatabaseError
                            {
                                MessageBox.ShowBox("MessageID374", BMC_Icon.Error);

                                AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                                {

                                    AuditModuleName = ModuleName.AttendantPay,
                                    Audit_Screen_Name = "PositionDetails|AttendantPay",
                                    Audit_Desc = treasury.TreasuryType + " -Unable to Access the database.",
                                    AuditOperationType = OperationType.ADD,
                                    Audit_Slot = (lstHandpay.SelectedItem as FillTreasuryList).Asset
                                });
                                break;
                            }
                        default:
                            {
                                MessageBox.ShowBox("MessageID117", BMC_Icon.Error);

                                AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                                {

                                    AuditModuleName = ModuleName.AttendantPay,
                                    Audit_Screen_Name = "PositionDetails|AttendantPay",
                                    Audit_Desc = treasury.TreasuryType + " processing was not completed.",
                                    AuditOperationType = OperationType.ADD,
                                    Audit_Slot = (lstHandpay.SelectedItem as FillTreasuryList).Asset
                                });
                                break;
                            }
                    }


                }
            }
            catch (Exception Ex)
            {
                ExceptionManager.Publish(Ex);
                MessageBox.ShowBox("MessageID117", BMC_Icon.Error);

                AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                {

                    AuditModuleName = ModuleName.AttendantPay,
                    Audit_Screen_Name = "PositionDetails|AttendantPay",
                    Audit_Desc = treasury.TreasuryType + " processing was not completed.",
                    AuditOperationType = OperationType.ADD,
                    Audit_Slot = handpay.GetAssetNumber(InstallationNumber)[0].Stock_No
                });
            }
            finally
            {
                IsHandpayVoid = false;
            }
        }