예제 #1
0
        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (cboProfitShareGroup.SelectedIndex <= 0)
                {
                    MessageBox.ShowBox("MessageID490", BMC_Icon.Information);
                    return;
                }

                decimal FixedExpenseAmount = (Convert.ToDecimal(txtExpenseShareAmount.Text) * (Convert.ToDecimal(((ExpenseShareGroup)cboExpenseShareGroup.SelectedItem).ExpenseSharePercentage) / 100));
                decimal dTotal             = Convert.ToDecimal(FixedExpenseAmount) + Convert.ToDecimal(txtCarriedForwardAmount.Text);
                if (Math.Round(Convert.ToDecimal(txtWriteOffExpense.Text), 2, MidpointRounding.AwayFromZero) > (Math.Round(FixedExpenseAmount, 2) + Math.Round(Convert.ToDecimal(txtCarriedForwardAmount.Text), 2, MidpointRounding.AwayFromZero)))
                {
                    CAuthorize oCAuthorize = new CAuthorize("BMC.Presentation.CProfitShare.ProfitShareApprover");
                    oCAuthorize.ShowDialog();
                    if (!oCAuthorize.IsAuthorized)
                    {
                        return;
                    }
                    //string strMsg = Application.Current.FindResource("MessageID890").ToString().Replace("@@@@", Convert.ToDecimal(txtWriteOffExpense.Text).ToString("#,##0.00")).Replace("****", dTotal.ToString("#,##0.00"));
                    //MessageBox.ShowBox(strMsg, BMC_Icon.Error, true);
                }
                objCommonLiquidation.ProfitShareGroupId     = Convert.ToInt32(cboProfitShareGroup.SelectedValue);
                objCommonLiquidation.ExpenseShareGroupID    = Convert.ToInt32(cboExpenseShareGroup.SelectedValue);
                objCommonLiquidation.ExpenseShareAmount     = Convert.ToDecimal(txtExpenseShareAmount.Text);
                objCommonLiquidation.WriteOffAmount         = Convert.ToDecimal(txtWriteOffExpense.Text);
                objCommonLiquidation.PayPeriodId            = objPayPeriods == null ? 0 : objPayPeriods.Calendar_Period_ID;
                objCommonLiquidation.Percentage_Setting     = Convert.ToDecimal(((ProfitShareGroup)cboProfitShareGroup.SelectedItem).ProfitSharePercentage);
                objCommonLiquidation.ExpenseSharePercentage = Convert.ToDecimal(((ExpenseShareGroup)cboExpenseShareGroup.SelectedItem).ExpenseSharePercentage);
                this.Close();
            }

            catch (Exception ex)
            {
                ExceptionManager.Publish(ex);
            }
        }
예제 #2
0
        private void GenerateManulJackpot()
        {
            double amount = 0;

            if (txtBox != null && txtBox.Text.Length > 0)
            {
                double.TryParse(txtBox.Text.ToString(), NumberStyles.Currency, new CultureInfo(ExtensionMethods.CurrentCurrenyCulture), out amount);
            }

            //if (amount > Settings.W2GWinAmount)
            //{
            //    MessageBox.ShowBox("MessageID367", BMC_Icon.Information);
            //    //return;
            //}
            try
            {
                jackpotProcessInfoDTO jpinfo       = new jackpotProcessInfoDTO();
                CAuthorize            objAuthorize = null;
                string HP_Type = string.Empty;
                Double iAmount = 0;
                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 iAmount);
                }

                if (Settings.Client != null && Settings.Client.ToLower() == "winchells" &&
                    Settings.MaxHandPayAuthRequired &&
                    txtBox != null &&
                    (iAmount > 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
                    {
                        objAuthorize.IsAuthorized = true;
                    }
                }
                if (optHandpay.IsChecked == true)
                {
                    HP_Type = "AttendantPay Credit";
                    jpinfo.jackpotTypeId = 4;
                }
                else if (optJackpot.IsChecked == true)
                {
                    HP_Type = "AttendantPay Jackpot";
                    jpinfo.jackpotTypeId = 5;
                }
                else
                {
                    HP_Type = "AttendantPay Progressive";
                    jpinfo.jackpotTypeId = 6;
                }

                // Finding Denom for the machine-CR# 167677

                decimal DenomValue = 0;
                DataSet oDt        = handpay.createTickeException_HandpayCAGE(int.Parse((cmbBarPositions.SelectedItem as BarPositions).Bar_Pos_Name), iAmount, 0, HP_Type);
                List <DenomValueResult> lstDenom = handpay.GetDenomValue(oDt.Tables[0].Rows[0]["Asset"].ToString());
                foreach (var denom in lstDenom)
                {
                    DenomValue = denom.Denom;
                }
                jpinfo.Slot = (cmbBarPositions.SelectedItem as BarPositions).Bar_Pos_Name;
                jpinfo.assetConfigNumber = oDt.Tables[0].Rows[0]["Asset"].ToString();
                jpinfo.Denom             = DenomValue;
                jpinfo.hpjpAmount        = long.Parse(oDt.Tables[0].Rows[0]["TE_VALUE"].ToString());
                jpinfo.jackpotNetAmount  = long.Parse(oDt.Tables[0].Rows[0]["TE_VALUE"].ToString());
                jpinfo.sequenceNumber    = long.Parse(oDt.Tables[0].Rows[0]["TE_ID"].ToString());
                jpinfo.TransactionDate   = oDt.Tables[0].Rows[0]["TE_Date"].ToString();
                jpinfo.UserID            = Security.SecurityHelper.CurrentUser.SecurityUserID.ToString();
                jpinfo.siteNo            = Settings.SiteName;
                jpinfo.siteId            = Convert.ToInt32(Settings.SiteCode);
                txtBox.Text = this.DefaultAmount();
                handpay.PrintSlip(jpinfo);


                //send PT 10 from client

                Treasury treasury = new Treasury();
                treasury.ActualTreasuryDate = Convert.ToDateTime(jpinfo.TransactionDate);
                treasury.Asset              = Asset;
                treasury.Authorized_Date    = Convert.ToDateTime(jpinfo.TransactionDate);
                treasury.AuthorizedUser_No  = SecurityHelper.CurrentUser.User_No;
                treasury.CustomerID         = SecurityHelper.CurrentUser.User_No;
                treasury.InstallationNumber = InstallationNumber;
                treasury.TreasuryAmount     = iAmount;
                treasury.UserID             = SecurityHelper.CurrentUser.User_No;
                treasury.TreasuryType       = HP_Type;

                if (((bool)optJackpot.IsChecked) || ((bool)optProgressive.IsChecked)) //|| ((bool)optHandpay.IsChecked))
                {
                    PostHandpayEvent(treasury);
                }
            }
            catch (Exception Ex)
            {
                ExceptionManager.Publish(Ex);
            }
        }
예제 #3
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
                });
            }
        }
예제 #4
0
        private void button_Click(object sender, RoutedEventArgs e)
        {
            bool isValid = false;
            RTOnlineTicketDetail objTicketDetail = null;

            double redeemTicketAmount = 0;

            bool IsCashDispenseError = false;

            try
            {
                if (isScannerFired) //check done not to fire the verify event twice while verifying a ticket using scanner
                {
                    isScannerFired = false;
                    return;
                }
                ClearAll(true);
                TextBlock_11.Text   = string.Empty;
                txtAmount.Text      = string.Empty;
                btnVerify.IsEnabled = false;
                if ((sender is System.Windows.Controls.TextBox))
                {
                    isScannerFired = true;
                }
                else
                {
                    isScannerFired = false;
                }

                if (this.ucValueCalc.txtDisplay.Text.Trim().Length > 0)
                {
                    if (this.ucValueCalc.txtDisplay.Text.Trim().Length < 4)
                    {
                        MessageBox.ShowBox("MessageID403", BMC_Icon.Error);
                        this.txtStatus.Visibility        = Visibility.Hidden;
                        this.ucValueCalc.txtDisplay.Text = String.Empty;
                        return;
                    }

                    IRedeemOnlineTicket objCashDeskOper = RedeemOnlineTicketBusinessObject.CreateInstance();
                    objTicketDetail = new RTOnlineTicketDetail();

                    objTicketDetail.ClientSiteCode  = Settings.SiteCode;
                    objTicketDetail.TicketString    = this.ucValueCalc.txtDisplay.Text.Trim();
                    objTicketDetail.HostSiteCode    = objTicketDetail.TicketString.Substring(0, 4);
                    objTicketDetail.RedeemedMachine = System.Environment.MachineName;

                    objTicketDetail = objCashDeskOper.GetRedeemTicketAmount(objTicketDetail);

                    if (objTicketDetail.TicketStatusCode == -990) //TIS Error (If any)
                    {
                        MessageBox.ShowBox(objTicketDetail.TicketErrorMessage, BMC_Icon.Error, true);
                        disptimerRedeem.Stop();
                        this.txtStatus.Visibility = Visibility.Hidden;
                        return;
                    }

                    if (objTicketDetail.TicketStatusCode == -234) //Exception Occured
                    {
                        MessageBox.ShowBox("MessageID425", BMC_Icon.Error);
                        disptimerRedeem.Stop();
                        this.txtStatus.Visibility = Visibility.Hidden;
                        return;
                    }

                    if (objTicketDetail.TicketStatusCode == -99) //Included for Cross Ticketing
                    {
                        MessageBox.ShowBox("MessageID403", BMC_Icon.Error);
                        disptimerRedeem.Stop();
                        this.txtStatus.Visibility        = Visibility.Hidden;
                        this.ucValueCalc.txtDisplay.Text = String.Empty;
                        return;
                    }



                    if (objTicketDetail.TicketStatusCode == 250)     //Any/specific player card required for TIS
                    {
                        bool ValidCard       = false;
                        int  PlayerCardClose = 0;



                        if (objTicketDetail.CardRequired == 2)
                        {
                            PlayerCardValidation objPlayerCardValidation = new PlayerCardValidation(objTicketDetail.CardRequired);
                            objPlayerCardValidation.ShowDialogEx(this);
                            ValidCard       = objPlayerCardValidation.valid;
                            PlayerCardClose = objPlayerCardValidation.Close;

                            if (PlayerCardClose == 1)
                            {
                                this.ucValueCalc.txtDisplay.Text = String.Empty;
                                this.ucValueCalc.txtDisplay.Focus();
                                return;
                            }

                            else if (!ValidCard)
                            {
                                MessageBox.ShowBox("PlayerCardRedeem6", BMC_Icon.Error);
                                this.ucValueCalc.txtDisplay.Text = String.Empty;
                                this.ucValueCalc.txtDisplay.Focus();
                                return;
                            }
                        }
                        else if (objTicketDetail.CardRequired == 1)
                        {
                            PlayerCardValidation objPlayerCardValidation = new PlayerCardValidation(objTicketDetail.CardRequired, objTicketDetail.PlayerCardNumber);
                            objPlayerCardValidation.ShowDialogEx(this);
                            ValidCard       = objPlayerCardValidation.valid;
                            PlayerCardClose = objPlayerCardValidation.Close;
                            if (PlayerCardClose == 1)
                            {
                                this.ucValueCalc.txtDisplay.Text = String.Empty;
                                this.ucValueCalc.txtDisplay.Focus();
                                return;
                            }
                            else if (!ValidCard)
                            {
                                MessageBox.ShowBox("PlayerCardRedeem6", BMC_Icon.Error);
                                this.ucValueCalc.txtDisplay.Text = String.Empty;
                                this.ucValueCalc.txtDisplay.Focus();
                                return;
                            }
                        }

                        objTicketDetail.TicketStatusCode = 0;
                    }


                    int ticketAmount = Convert.ToInt32(objTicketDetail.RedeemedAmount);

                    redeemTicketAmount = ticketAmount / 100;

                    objTicketDetail.CustomerId = Custid;

                    this.txtStatus.Visibility = Visibility.Visible;
                    this.txtStatus.Text       = "VALIDATING.";
                    disptimerRedeem.IsEnabled = true;
                    disptimerRedeem.Start();


                    //if ((objCashDeskOper.CheckSDGTicket(objTicketDetail.TicketString) == 0) && (Settings.RedeemConfirm))
                    if (objTicketDetail.TicketStatusCode == 0 && (Settings.RedeemConfirm))
                    {
                        disptimerRedeem.Stop();
                        if (Convert.ToBoolean(AppSettings.REDEEM_TICKET_POP_UP_ALERT_VISIBILITY))
                        {
                            _diagResult = MessageBox.ShowBox("MessageID225", BMC_Icon.Question, BMC_Button.YesNo);
                        }
                        else
                        {
                            _diagResult = System.Windows.Forms.DialogResult.Yes;
                        }
                        if (_diagResult == System.Windows.Forms.DialogResult.Yes)
                        {
                            #region ITALY CODE COMMENTED
                            //if (Settings.RegulatoryEnabled == true && Settings.RegulatoryType == "AAMS")
                            //{
                            //    ProcessCancelled = false;
                            //    if (ticketStatus == 0)
                            //    {
                            //        if (redeemTicketAmount >= Settings.RedeemTicketCustomer_Min && redeemTicketAmount <= Settings.RedeemTicketCustomer_Max)
                            //        {
                            //            customerDetails = new BMC.Presentation.POS.Views.CustomerDetails();
                            //            customerDetails.delCustomerUpdated += new BMC.Presentation.POS.Views.CustomerDetails.CustomerUpdateHandler(delCustomerUpdated);
                            //            customerDetails.delCustomerCancelled += new BMC.Presentation.POS.Views.CustomerDetails.CustomerCancelHandler(delCustomerCancelled);
                            //            Owner = Window.GetWindow(this);
                            //            customerDetails.ShowDialog();
                            //        }
                            //        else if (redeemTicketAmount >= Settings.RedeemTicketCustomer_BankAcctNo)
                            //        {
                            //            customerDetails = new BMC.Presentation.POS.Views.CustomerDetails(true);
                            //            customerDetails.delCustomerUpdated += new BMC.Presentation.POS.Views.CustomerDetails.CustomerUpdateHandler(delCustomerUpdated);
                            //            customerDetails.delCustomerCancelled += new BMC.Presentation.POS.Views.CustomerDetails.CustomerCancelHandler(delCustomerCancelled);
                            //            Owner = Window.GetWindow(this);
                            //            customerDetails.ShowDialog();
                            //        }

                            //        if (ProcessCancelled)
                            //        {
                            //            MessageBox.ShowBox("MessageID299", BMC_Icon.Information);
                            //            this.ucValueCalc.txtDisplay.Text = string.Empty;
                            //            return;
                            //        }
                            //    }
                            //}
                            #endregion

                            objTicketDetail = objCashDeskOper.RedeemOnlineTicket(objTicketDetail);
                            isValid         = objTicketDetail.ValidTicket;
                        }
                        else
                        {
                            disptimerRedeem.Start();
                            this.txtStatus.Visibility = Visibility.Hidden;
                            return;
                        }
                        disptimerRedeem.Start();
                    }
                    //else if ((objCashDeskOper.CheckSDGTicket(objTicketDetail.TicketString) == -3) && (Settings.RedeemConfirm)
                    else if (objTicketDetail.TicketStatusCode == -3 && (Settings.RedeemConfirm) && Settings.RedeemExpiredTicket)
                    {
                        disptimerRedeem.Stop();

                        CAuthorize objAuthorize = null;
                        //Manoj 26th Aug 2010. CR383384
                        //RedeemExpiredTicket functionality has been implmented for Winchells.
                        //So, in settings RedeemExpiredTicket will be True for Winchells, for rest it will be False.
                        //So we dont need the following if condition.
                        //if (Settings.Client != null && Settings.Client.ToLower() == "winchells")
                        //{
                        objAuthorize      = new CAuthorize("CashdeskOperator.Authorize.cs.ReedemExpiredTicket");
                        objAuthorize.User = Security.SecurityHelper.CurrentUser;
                        string Cur_User_Name = Security.SecurityHelper.CurrentUser.Last_Name + ", " + Security.SecurityHelper.CurrentUser.First_Name;
                        objTicketDetail.RedeemedUser = Cur_User_Name;

                        if (!Security.SecurityHelper.HasAccess("CashdeskOperator.Authorize.cs.ReedemExpiredTicket"))
                        {
                            objAuthorize.ShowDialogEx(this);

                            string Auth_User_Name = objAuthorize.User.UserName;
                            if (objAuthorize.User.Last_Name != null && objAuthorize.User.First_Name != null)
                            {
                                Auth_User_Name = objAuthorize.User.Last_Name + ", " + objAuthorize.User.First_Name;
                            }
                            else
                            {
                                Auth_User_Name = objAuthorize.User.UserName;
                            }

                            objTicketDetail.RedeemedUser = Auth_User_Name;

                            if (!objAuthorize.IsAuthorized)
                            {
                                ClearAll(false);
                                return;
                            }
                        }
                        else
                        {
                            objAuthorize.IsAuthorized = true;
                        }
                        //}

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

                            AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                            {
                                AuditModuleName    = ModuleName.Voucher,
                                Audit_Screen_Name  = "Vouchers|RedeemVoucher",
                                Audit_Desc         = "Voucher Number-" + objTicketDetail.TicketString,
                                AuditOperationType = OperationType.MODIFY,
                                Audit_Field        = "AuthorizedUser_No",
                                Audit_New_Vl       = Security.SecurityHelper.CurrentUser.SecurityUserID.ToString()
                            });
                        }
                        if (Convert.ToBoolean(AppSettings.REDEEM_TICKET_POP_UP_ALERT_VISIBILITY))
                        {
                            _diagResult = MessageBox.ShowBox("MessageID225", BMC_Icon.Question, BMC_Button.YesNo);
                        }
                        else
                        {
                            _diagResult = System.Windows.Forms.DialogResult.Yes;
                        }
                        if (_diagResult == System.Windows.Forms.DialogResult.Yes)
                        {
                            #region ITALY CODE COMMENTED
                            //if (Settings.RegulatoryEnabled == true && Settings.RegulatoryType == "AAMS")
                            //{
                            //    ProcessCancelled = false;
                            //    if (ticketStatus == 0)
                            //    {
                            //        if (redeemTicketAmount >= Settings.RedeemTicketCustomer_Min && redeemTicketAmount <= Settings.RedeemTicketCustomer_Max)
                            //        {
                            //            customerDetails = new BMC.Presentation.POS.Views.CustomerDetails();
                            //            customerDetails.delCustomerUpdated += new BMC.Presentation.POS.Views.CustomerDetails.CustomerUpdateHandler(delCustomerUpdated);
                            //            customerDetails.delCustomerCancelled += new BMC.Presentation.POS.Views.CustomerDetails.CustomerCancelHandler(delCustomerCancelled);
                            //            Owner = Window.GetWindow(this);
                            //            customerDetails.ShowDialog();
                            //        }
                            //        else if (redeemTicketAmount >= Settings.RedeemTicketCustomer_BankAcctNo)
                            //        {
                            //            customerDetails = new BMC.Presentation.POS.Views.CustomerDetails(true);
                            //            customerDetails.delCustomerUpdated += new BMC.Presentation.POS.Views.CustomerDetails.CustomerUpdateHandler(delCustomerUpdated);
                            //            customerDetails.delCustomerCancelled += new BMC.Presentation.POS.Views.CustomerDetails.CustomerCancelHandler(delCustomerCancelled);
                            //            Owner = Window.GetWindow(this);
                            //            customerDetails.ShowDialog();
                            //        }

                            //        if (ProcessCancelled)
                            //        {
                            //            MessageBox.ShowBox("MessageID299", BMC_Icon.Information);
                            //            this.ucValueCalc.txtDisplay.Text = string.Empty;
                            //            return;
                            //        }
                            //    }
                            //}

                            #endregion
                            objTicketDetail = objCashDeskOper.RedeemOnlineTicket(objTicketDetail);
                            isValid         = objTicketDetail.ValidTicket;
                        }
                        else
                        {
                            disptimerRedeem.Start();
                            this.txtStatus.Visibility = Visibility.Hidden;
                            return;
                        }
                        disptimerRedeem.Start();
                    }
                    else
                    {
                        objTicketDetail = objCashDeskOper.RedeemOnlineTicket(objTicketDetail);
                        isValid         = objTicketDetail.ValidTicket;
                    }

                    if (objTicketDetail.TicketStatus == "MessageID210")
                    {
                        objTicketDetail.TicketStatus = Application.Current.FindResource(objTicketDetail.TicketStatus).ToString() +
                                                       "(" + CommonUtilities.GetCurrency(Convert.ToDouble(objTicketDetail.TicketValue / 100)) + ")";
                    }
                    else
                    {
                        objTicketDetail.TicketStatus = Application.Current.FindResource(objTicketDetail.TicketStatus).ToString();
                    }

                    IsCashDispenseError = true;
                    if (isValid && objTicketDetail.RedeemedMachine != null && objTicketDetail.RedeemedMachine != string.Empty)
                    {
                        try
                        {
                            //DateTime PrintDate;
                            //string strbar_pos = objCashDeskOper.GetTicketPrintDevice(objTicketDetail.TicketString, out PrintDate);
                            DateTime PrintDate  = DateTime.Now;
                            string   strbar_pos = objCashDeskOper.GetTicketPrintDevice(objTicketDetail.TicketString, out PrintDate);
                            //TextBlock_11.Text = "#" + strbar_pos + PrintDate.ToString().Replace("/", "").Replace(":", "").Replace("AM", "0").Replace("PM", "1").Replace(" ", "");
                            //TextBlock_11.Text = "#" + objTicketDetail.PrintedDevice + objTicketDetail.PrintedDate.ToString().Replace("/", "").Replace(":", "").Replace("AM", "0").Replace("PM", "1").Replace(" ", "");
                            if (objTicketDetail.RedeemedDate == null || objTicketDetail.RedeemedDate.ToString().Trim().Equals(string.Empty))
                            {
                                TextBlock_11.Text = string.Empty;
                            }
                            else
                            {
                                TextBlock_11.Text = "#" + strbar_pos + objTicketDetail.RedeemedDate.ToString("ddMMyyyyHHmmss");
                            }

                            txtAmount.Text = objTicketDetail.RedeemedAmount.GetUniversalCurrencyFormat();
                            if (!objTicketDetail.TicketStatus.Trim().ToUpper().Equals("ALREADY CLAIMED"))
                            {
                                #region GCD
                                if (Settings.IsGloryCDEnabled && Settings.CashDispenserEnabled)
                                {
                                    LogManager.WriteLog(string.Format("Process Redeem Voucher: {2} for Bar Postion: {0} - Amount: {1} in cents", strbar_pos, ticketAmount, objTicketDetail.TicketString), LogManager.enumLogLevel.Info);

                                    //implement Cash Dispenser
                                    LogManager.WriteLog(string.Format("Amount: {0:0.00} Sending to Cash Dispenser ", ticketAmount), LogManager.enumLogLevel.Info);
                                    LoadingWindow ld = new LoadingWindow(Window.GetWindow(this), ModuleName.Voucher, TextBlock_11.Text, strbar_pos, ticketAmount);
                                    ld.Topmost = true;
                                    ld.ShowDialogEx(this);
                                    Result res = ld.Result;
                                    if (!res.IsSuccess)
                                    {
                                        IsCashDispenseError = false;
                                        this.txtStatus.Text = res.error.Message;
                                        LogManager.WriteLog(string.Format("Unable to Dispense Cash - Amount: {0}", ticketAmount), LogManager.enumLogLevel.Info);
                                        LogManager.WriteLog("Rollback Redeem Voucher Process", LogManager.enumLogLevel.Info);
                                        AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                                        {
                                            AuditModuleName    = ModuleName.Voucher,
                                            Audit_Screen_Name  = "Vouchers|RedeemVoucher",
                                            Audit_Desc         = "Rollback redeem voucher:" + objTicketDetail.TicketString + " due to cash dispenser error",
                                            AuditOperationType = OperationType.MODIFY,
                                            Audit_Old_Vl       = "iPayDeviceid:" + objTicketDetail.RedeemedDevice + ";dtPaid:" + objTicketDetail.RedeemedDate.GetUniversalDateTimeFormat() + ";Customerid:" + objTicketDetail.CustomerId.ToString()
                                        });
                                        objCashDeskOper.RollbackRedeemTicket(objTicketDetail.TicketString);
                                        if (Convert.ToBoolean(AppSettings.REDEEM_TICKET_POP_UP_ALERT_VISIBILITY))
                                        {
                                            BMC.Presentation.MessageBox.ShowBox(res.error.Message, res.error.MessageType.Equals("Error") ? BMC_Icon.Error : BMC_Icon.Information, true);
                                        }
                                    }
                                    else
                                    {
                                        LogManager.WriteLog(string.Format("Cash Dispensed Successfully - Amount: {0}", ticketAmount), LogManager.enumLogLevel.Info);

                                        IsCashDispenseError = true;
                                        if (Convert.ToBoolean(AppSettings.REDEEM_TICKET_POP_UP_ALERT_VISIBILITY))
                                        {
                                            BMC.Presentation.MessageBox.ShowBox(res.error.Message, res.error.MessageType.Equals("Error") ? BMC_Icon.Error : BMC_Icon.Information, true);
                                        }
                                    }
                                }
                                #endregion
                            }
                        }
                        catch (Exception Ex)
                        {
                            LogManager.WriteLog("Error showing Voucher Info :" + Ex.Message, LogManager.enumLogLevel.Error);
                        }
                    }

                    if (objTicketDetail.ShowOfflineTicketScreen)
                    {
                        int result;

                        if (objTicketDetail.HostSiteCode == Settings.SiteCode) // Offline Tickets redemption is valid only for local site code
                        {
                            result = objCashDeskOper.CheckSDGOfflineTicket(objTicketDetail.TicketString);
                        }
                        else
                        {
                            result = -14;
                        }

                        if (result == -14)// Site Code Mismatch
                        {
                            this.txtStatus.Visibility = Visibility.Visible;
                            this.txtStatus.Text       = Application.Current.FindResource("MessageID312") as string;
                            this.txtStatus.Background = System.Windows.Media.Brushes.Red;
                            return;
                        }
                        else
                        {
                            frmRedeemOffline = new BMC.Presentation.POS.Views.CRedeemOfflineTicket();
                            frmRedeemOffline.TicketNumber = ucValueCalc.txtDisplay.Text.Trim();
                            frmRedeemOffline.ShowDialogEx(this);
                            if (frmRedeemOffline.IsSuccessfull)
                            {
                                this.ucValueCalc.txtDisplay.Text = frmRedeemOffline.TicketNumber;
                                button_Click(sender, e);
                            }
                            else
                            {
                                this.ucValueCalc.txtDisplay.Text = string.Empty;
                                this.txtStatus.Clear();
                            }
                        }
                    }
                    else
                    {
                        if (Settings.IsGloryCDEnabled && (!IsCashDispenseError))
                        {
                            disptimerRedeem.Stop();
                            this.txtStatus.Visibility = Visibility.Visible;
                            this.txtStatus.Background = System.Windows.Media.Brushes.Red;
                            TextBlock_11.Text         = string.Empty;
                            txtAmount.Text            = string.Empty;
                            System.Threading.Thread.Sleep(100);
                            //System.Threading.Thread.CurrentThread
                            disptimerRedeem.Start();
                        }
                        else
                        {
                            this.txtStatus.Text = objTicketDetail.TicketStatus;
                            //"(" + CommonUtilities.GetCurrency(Convert.ToDouble(TicketDetail.TicketValue / 100)) + ")";
                            if (Application.Current.FindResource("MessageID219").ToString() == objTicketDetail.TicketStatus)
                            {
                                bisTicketExpired = true;
                            }
                            this.txtWarning.Text = objTicketDetail.TicketWarning;
                            if (!objTicketDetail.ValidTicket)
                            {
                                this.txtStatus.Background = System.Windows.Media.Brushes.Red;

                                AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                                {
                                    AuditModuleName    = ModuleName.Voucher,
                                    Audit_Screen_Name  = "Vouchers|RedeemVoucher",
                                    Audit_Desc         = "Invalid Voucher Redemption Attempt",
                                    AuditOperationType = OperationType.MODIFY,
                                    Audit_Field        = "Voucher Number",
                                    Audit_New_Vl       = objTicketDetail.TicketString
                                });
                            }
                            else
                            {
                                this.txtStatus.Background = System.Windows.Media.Brushes.White;

                                AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                                {
                                    AuditModuleName    = ModuleName.Voucher,
                                    Audit_Screen_Name  = "Vouchers|RedeemVoucher",
                                    Audit_Desc         = "Voucher Number-" + objTicketDetail.TicketString,
                                    AuditOperationType = OperationType.ADD,
                                    Audit_Field        = "Voucher Status",
                                    Audit_New_Vl       = objTicketDetail.TicketStatus
                                });

                                //Cross Ticketing- Insert Local Record
                                if (!string.IsNullOrEmpty(objTicketDetail.VoucherXMLData))
                                {
                                    objTicketDetail.RedeemedUser = Security.SecurityHelper.CurrentUser.UserName;
                                    objCashDeskOper.ImportVoucherDetails(objTicketDetail);
                                }

                                if (objTicketDetail.TicketStatus.Contains(Application.Current.FindResource("MessageID210").ToString()))
                                {
                                    //disptimerRedeem.Stop();

                                    Action act = new Action(() =>
                                    {
                                        if (Convert.ToBoolean(AppSettings.REDEEM_TICKET_POP_UP_ALERT_VISIBILITY))
                                        {
                                            if (IsCashDispenseError)
                                            {
                                                if (Settings.IsGloryCDEnabled)
                                                {
                                                    disptimerRedeem.Stop();
                                                    this.txtStatus.Visibility = Visibility.Visible;
                                                }
                                                else
                                                {
                                                    this.ClearAll(false);
                                                }
                                                MessageBox.ShowBox("MessageID377", BMC_Icon.Information);
                                            }
                                        }
                                        else
                                        {
                                            this.txtStatus.Text       = Application.Current.FindResource("MessageID377").ToString();
                                            txtAmount.Text            = Convert.ToDecimal(objTicketDetail.TicketValue / 100).GetUniversalCurrencyFormat();
                                            bisTicketExpired          = false;
                                            this.txtStatus.Background = System.Windows.Media.Brushes.GreenYellow;
                                        }
                                        if (!Settings.IsGloryCDEnabled)
                                        {
                                            this.dispenserStatus.LoadItemsAysnc();
                                        }
                                    });

                                    if (!Settings.IsGloryCDEnabled)
                                    {
                                        _worker.Dispense("Voucher Number", objTicketDetail.TicketString, objTicketDetail.RedeemedAmount, act);
                                    }
                                    else
                                    {
                                        act();
                                        disptimerRedeem.Start();
                                    }
                                }
                            }
                            if (objTicketDetail.EnableTickerPrintDetails)
                            {
                                this.gridRedeemedTicket.Visibility = Visibility.Visible;
                                this.txtPrintedMachine.Text        = objTicketDetail.RedeemedMachine;
                                this.txtClaimedDevice.Text         = objTicketDetail.RedeemedDevice;
                                this.txtTickAmount.Text            = objTicketDetail.RedeemedAmount.GetUniversalCurrencyFormatWithSymbol();
                                this.txtClaimedDate.Text           = objTicketDetail.RedeemedDate.GetUniversalDateTimeFormat();
                            }
                            else
                            {
                                this.gridRedeemedTicket.Visibility = Visibility.Hidden;
                            }
                            this.ucValueCalc.txtDisplay.Focus();
                        }
                    }
                }
                else
                {
                    MessageBox.ShowBox("MessageID105", BMC_Icon.Warning);
                    this.ucValueCalc.txtDisplay.Focus();
                }
            }
            catch (Exception ex)
            {
                BMC.Common.ExceptionManagement.ExceptionManager.Publish(ex);
            }
            finally
            {
                btnVerify.IsEnabled = true;
            }
        }
        private void button_Click(object sender, RoutedEventArgs e)
        {
            bool isValid = false;
            RTOnlineTicketDetail objTicketDetail = null;
           
            double redeemTicketAmount = 0;

            bool IsCashDispenseError = false;
            try
            {

                if (isScannerFired) //check done not to fire the verify event twice while verifying a ticket using scanner
                {
                    isScannerFired = false;
                    return;
                }
                ClearAll(true);
                TextBlock_11.Text = string.Empty;
                txtAmount.Text = string.Empty;               
                btnVerify.IsEnabled = false;
                if ((sender is System.Windows.Controls.TextBox))
                    isScannerFired = true;
                else
                    isScannerFired = false;

                if (this.ucValueCalc.txtDisplay.Text.Trim().Length > 0)
                {
                    if (this.ucValueCalc.txtDisplay.Text.Trim().Length < 4 )
                    {
                        MessageBox.ShowBox("MessageID403", BMC_Icon.Error);
                        this.txtStatus.Visibility = Visibility.Hidden;
                        this.ucValueCalc.txtDisplay.Text = String.Empty;
                        return;
                    }

                    IRedeemOnlineTicket objCashDeskOper = RedeemOnlineTicketBusinessObject.CreateInstance();
                    objTicketDetail = new RTOnlineTicketDetail();

                    objTicketDetail.ClientSiteCode = Settings.SiteCode;
                    objTicketDetail.TicketString = this.ucValueCalc.txtDisplay.Text.Trim();
                    objTicketDetail.HostSiteCode = objTicketDetail.TicketString.Substring(0, 4);
                    objTicketDetail.RedeemedMachine = System.Environment.MachineName;

                    objTicketDetail = objCashDeskOper.GetRedeemTicketAmount(objTicketDetail);

                    if (objTicketDetail.TicketStatusCode == -990) //TIS Error (If any)
                    {
                        MessageBox.ShowBox(objTicketDetail.TicketErrorMessage, BMC_Icon.Error, true);
                        disptimerRedeem.Stop();
                        this.txtStatus.Visibility = Visibility.Hidden;
                        return;
                    }

                    if (objTicketDetail.TicketStatusCode == -234) //Exception Occured
                    {
                        MessageBox.ShowBox("MessageID425", BMC_Icon.Error);
                        disptimerRedeem.Stop();
                        this.txtStatus.Visibility = Visibility.Hidden;
                        return;
                    }

                    if (objTicketDetail.TicketStatusCode == -99) //Included for Cross Ticketing
                    {
                        MessageBox.ShowBox("MessageID403", BMC_Icon.Error);
                        disptimerRedeem.Stop();
                        this.txtStatus.Visibility = Visibility.Hidden;
                        this.ucValueCalc.txtDisplay.Text = String.Empty;
                        return;
                    }

                   
                   
                        if (objTicketDetail.TicketStatusCode == 250) //Any/specific player card required for TIS
                        {
                            bool ValidCard = false;
                            int PlayerCardClose = 0;
                            


                            if (objTicketDetail.CardRequired == 2)
                            {
                                PlayerCardValidation objPlayerCardValidation = new PlayerCardValidation(objTicketDetail.CardRequired);
                                objPlayerCardValidation.ShowDialogEx(this);
                                ValidCard = objPlayerCardValidation.valid;
                                PlayerCardClose = objPlayerCardValidation.Close;

                                if (PlayerCardClose == 1)
                                {
                                    this.ucValueCalc.txtDisplay.Text = String.Empty;
                                    this.ucValueCalc.txtDisplay.Focus();
                                    return;
                                }

                                else if (!ValidCard)
                                {
                                    MessageBox.ShowBox("PlayerCardRedeem6", BMC_Icon.Error);
                                    this.ucValueCalc.txtDisplay.Text = String.Empty;
                                    this.ucValueCalc.txtDisplay.Focus();
                                    return;
                                }

                            }
                            else if (objTicketDetail.CardRequired == 1)
                            {
                                PlayerCardValidation objPlayerCardValidation = new PlayerCardValidation(objTicketDetail.CardRequired, objTicketDetail.PlayerCardNumber);
                                objPlayerCardValidation.ShowDialogEx(this);
                                ValidCard = objPlayerCardValidation.valid;
                                PlayerCardClose = objPlayerCardValidation.Close;
                                if (PlayerCardClose == 1)
                                {
                                    this.ucValueCalc.txtDisplay.Text = String.Empty;
                                    this.ucValueCalc.txtDisplay.Focus();
                                    return;
                                }
                                else if (!ValidCard)
                                {
                                    MessageBox.ShowBox("PlayerCardRedeem6", BMC_Icon.Error);
                                    this.ucValueCalc.txtDisplay.Text = String.Empty;
                                    this.ucValueCalc.txtDisplay.Focus();
                                    return;
                                }
                            }

                            objTicketDetail.TicketStatusCode = 0;
                        }
                    

                    int ticketAmount = Convert.ToInt32(objTicketDetail.RedeemedAmount);

                    redeemTicketAmount = ticketAmount / 100;

                    objTicketDetail.CustomerId = Custid;

                    this.txtStatus.Visibility = Visibility.Visible;
                    this.txtStatus.Text = "VALIDATING.";
                    disptimerRedeem.IsEnabled = true;
                    disptimerRedeem.Start();


                    //if ((objCashDeskOper.CheckSDGTicket(objTicketDetail.TicketString) == 0) && (Settings.RedeemConfirm))
                    if (objTicketDetail.TicketStatusCode == 0 && (Settings.RedeemConfirm))
                    {
                        disptimerRedeem.Stop();
                        if (Convert.ToBoolean(AppSettings.REDEEM_TICKET_POP_UP_ALERT_VISIBILITY))
                        {
                            _diagResult = MessageBox.ShowBox("MessageID225", BMC_Icon.Question, BMC_Button.YesNo);
                        }
                        else
                        {
                            _diagResult = System.Windows.Forms.DialogResult.Yes;
                        }
                        if (_diagResult == System.Windows.Forms.DialogResult.Yes)
                        {
                            #region ITALY CODE COMMENTED
                            //if (Settings.RegulatoryEnabled == true && Settings.RegulatoryType == "AAMS")
                            //{
                            //    ProcessCancelled = false;
                            //    if (ticketStatus == 0)
                            //    {
                            //        if (redeemTicketAmount >= Settings.RedeemTicketCustomer_Min && redeemTicketAmount <= Settings.RedeemTicketCustomer_Max)
                            //        {
                            //            customerDetails = new BMC.Presentation.POS.Views.CustomerDetails();
                            //            customerDetails.delCustomerUpdated += new BMC.Presentation.POS.Views.CustomerDetails.CustomerUpdateHandler(delCustomerUpdated);
                            //            customerDetails.delCustomerCancelled += new BMC.Presentation.POS.Views.CustomerDetails.CustomerCancelHandler(delCustomerCancelled);
                            //            Owner = Window.GetWindow(this);
                            //            customerDetails.ShowDialog();
                            //        }
                            //        else if (redeemTicketAmount >= Settings.RedeemTicketCustomer_BankAcctNo)
                            //        {
                            //            customerDetails = new BMC.Presentation.POS.Views.CustomerDetails(true);
                            //            customerDetails.delCustomerUpdated += new BMC.Presentation.POS.Views.CustomerDetails.CustomerUpdateHandler(delCustomerUpdated);
                            //            customerDetails.delCustomerCancelled += new BMC.Presentation.POS.Views.CustomerDetails.CustomerCancelHandler(delCustomerCancelled);
                            //            Owner = Window.GetWindow(this);
                            //            customerDetails.ShowDialog();
                            //        }

                            //        if (ProcessCancelled)
                            //        {
                            //            MessageBox.ShowBox("MessageID299", BMC_Icon.Information);
                            //            this.ucValueCalc.txtDisplay.Text = string.Empty;
                            //            return;
                            //        }
                            //    }
                            //} 
                            #endregion

                            objTicketDetail = objCashDeskOper.RedeemOnlineTicket(objTicketDetail);
                            isValid = objTicketDetail.ValidTicket;
                        }
                        else
                        {
                            disptimerRedeem.Start();
                            this.txtStatus.Visibility = Visibility.Hidden;
                            return;
                        }
                        disptimerRedeem.Start();
                    }
                    //else if ((objCashDeskOper.CheckSDGTicket(objTicketDetail.TicketString) == -3) && (Settings.RedeemConfirm)
                    else if (objTicketDetail.TicketStatusCode == -3 && (Settings.RedeemConfirm) && Settings.RedeemExpiredTicket)
                    {
                        disptimerRedeem.Stop();

                        CAuthorize objAuthorize = null;
                        //Manoj 26th Aug 2010. CR383384
                        //RedeemExpiredTicket functionality has been implmented for Winchells.
                        //So, in settings RedeemExpiredTicket will be True for Winchells, for rest it will be False.
                        //So we dont need the following if condition.
                        //if (Settings.Client != null && Settings.Client.ToLower() == "winchells")
                        //{
                        objAuthorize = new CAuthorize("CashdeskOperator.Authorize.cs.ReedemExpiredTicket");
                        objAuthorize.User = Security.SecurityHelper.CurrentUser;
                        string Cur_User_Name = Security.SecurityHelper.CurrentUser.Last_Name + ", " + Security.SecurityHelper.CurrentUser.First_Name;
                        objTicketDetail.RedeemedUser = Cur_User_Name;
                        
                        if (!Security.SecurityHelper.HasAccess("CashdeskOperator.Authorize.cs.ReedemExpiredTicket"))
                        {
                            objAuthorize.ShowDialogEx(this);
                            
                            string Auth_User_Name = objAuthorize.User.UserName;
                            if (objAuthorize.User.Last_Name != null && objAuthorize.User.First_Name != null)
                            {
                                Auth_User_Name = objAuthorize.User.Last_Name + ", " + objAuthorize.User.First_Name;
                            }
                            else
                            {
                                Auth_User_Name = objAuthorize.User.UserName;
                            }

                            objTicketDetail.RedeemedUser = Auth_User_Name;
                            
                            if (!objAuthorize.IsAuthorized)
                            {
                                ClearAll(false);
                                return;
                            }
                        }
                        else
                        {
                            objAuthorize.IsAuthorized = true;
                        }
                        //}

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

                            AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                            {

                                AuditModuleName = ModuleName.Voucher,
                                Audit_Screen_Name = "Vouchers|RedeemVoucher",
                                Audit_Desc = "Voucher Number-" + objTicketDetail.TicketString,
                                AuditOperationType = OperationType.MODIFY,
                                Audit_Field = "AuthorizedUser_No",
                                Audit_New_Vl = Security.SecurityHelper.CurrentUser.SecurityUserID.ToString()
                            });

                        }
                        if (Convert.ToBoolean(AppSettings.REDEEM_TICKET_POP_UP_ALERT_VISIBILITY))
                        {
                            _diagResult = MessageBox.ShowBox("MessageID225", BMC_Icon.Question, BMC_Button.YesNo);
                        }
                        else
                        {
                            _diagResult = System.Windows.Forms.DialogResult.Yes;
                        }
                        if (_diagResult == System.Windows.Forms.DialogResult.Yes)
                        {
                            #region ITALY CODE COMMENTED
                            //if (Settings.RegulatoryEnabled == true && Settings.RegulatoryType == "AAMS")
                            //{
                            //    ProcessCancelled = false;
                            //    if (ticketStatus == 0)
                            //    {
                            //        if (redeemTicketAmount >= Settings.RedeemTicketCustomer_Min && redeemTicketAmount <= Settings.RedeemTicketCustomer_Max)
                            //        {
                            //            customerDetails = new BMC.Presentation.POS.Views.CustomerDetails();
                            //            customerDetails.delCustomerUpdated += new BMC.Presentation.POS.Views.CustomerDetails.CustomerUpdateHandler(delCustomerUpdated);
                            //            customerDetails.delCustomerCancelled += new BMC.Presentation.POS.Views.CustomerDetails.CustomerCancelHandler(delCustomerCancelled);
                            //            Owner = Window.GetWindow(this);
                            //            customerDetails.ShowDialog();
                            //        }
                            //        else if (redeemTicketAmount >= Settings.RedeemTicketCustomer_BankAcctNo)
                            //        {
                            //            customerDetails = new BMC.Presentation.POS.Views.CustomerDetails(true);
                            //            customerDetails.delCustomerUpdated += new BMC.Presentation.POS.Views.CustomerDetails.CustomerUpdateHandler(delCustomerUpdated);
                            //            customerDetails.delCustomerCancelled += new BMC.Presentation.POS.Views.CustomerDetails.CustomerCancelHandler(delCustomerCancelled);
                            //            Owner = Window.GetWindow(this);
                            //            customerDetails.ShowDialog();
                            //        }

                            //        if (ProcessCancelled)
                            //        {
                            //            MessageBox.ShowBox("MessageID299", BMC_Icon.Information);
                            //            this.ucValueCalc.txtDisplay.Text = string.Empty;
                            //            return;
                            //        }
                            //    }
                            //}

                            #endregion
                            objTicketDetail = objCashDeskOper.RedeemOnlineTicket(objTicketDetail);
                            isValid = objTicketDetail.ValidTicket;
                        }
                        else
                        {
                            disptimerRedeem.Start();
                            this.txtStatus.Visibility = Visibility.Hidden;
                            return;
                        }
                        disptimerRedeem.Start();
                    }
                    else
                    {
                        objTicketDetail = objCashDeskOper.RedeemOnlineTicket(objTicketDetail);
                        isValid = objTicketDetail.ValidTicket;
                    }

                    if (objTicketDetail.TicketStatus == "MessageID210")
                        objTicketDetail.TicketStatus = Application.Current.FindResource(objTicketDetail.TicketStatus).ToString() +
                            "(" + CommonUtilities.GetCurrency(Convert.ToDouble(objTicketDetail.TicketValue / 100)) + ")";
                    else
                        objTicketDetail.TicketStatus = Application.Current.FindResource(objTicketDetail.TicketStatus).ToString();

                    IsCashDispenseError = true;
                    if (isValid && objTicketDetail.RedeemedMachine != null && objTicketDetail.RedeemedMachine != string.Empty)
                    {
                        try
                        {
                            //DateTime PrintDate;
                            //string strbar_pos = objCashDeskOper.GetTicketPrintDevice(objTicketDetail.TicketString, out PrintDate);
                            DateTime PrintDate = DateTime.Now;
                            string strbar_pos = objCashDeskOper.GetTicketPrintDevice(objTicketDetail.TicketString, out PrintDate);
                            //TextBlock_11.Text = "#" + strbar_pos + PrintDate.ToString().Replace("/", "").Replace(":", "").Replace("AM", "0").Replace("PM", "1").Replace(" ", "");
                            //TextBlock_11.Text = "#" + objTicketDetail.PrintedDevice + objTicketDetail.PrintedDate.ToString().Replace("/", "").Replace(":", "").Replace("AM", "0").Replace("PM", "1").Replace(" ", "");
                            if (objTicketDetail.RedeemedDate == null || objTicketDetail.RedeemedDate.ToString().Trim().Equals(string.Empty))
                            {
                                TextBlock_11.Text = string.Empty;
                            }
                            else
                            {
                                TextBlock_11.Text = "#" + strbar_pos + objTicketDetail.RedeemedDate.ToString("ddMMyyyyHHmmss");
                            }

                            txtAmount.Text = objTicketDetail.RedeemedAmount.GetUniversalCurrencyFormat();
                            if (!objTicketDetail.TicketStatus.Trim().ToUpper().Equals("ALREADY CLAIMED"))
                            {
                                #region GCD
                                if (Settings.IsGloryCDEnabled && Settings.CashDispenserEnabled)
                                {
                                    LogManager.WriteLog(string.Format("Process Redeem Voucher: {2} for Bar Postion: {0} - Amount: {1} in cents", strbar_pos, ticketAmount, objTicketDetail.TicketString), LogManager.enumLogLevel.Info);

                                    //implement Cash Dispenser
                                    LogManager.WriteLog(string.Format("Amount: {0:0.00} Sending to Cash Dispenser ", ticketAmount), LogManager.enumLogLevel.Info);
                                    LoadingWindow ld = new LoadingWindow(Window.GetWindow(this), ModuleName.Voucher, TextBlock_11.Text , strbar_pos, ticketAmount);
                                    ld.Topmost = true;
                                    ld.ShowDialogEx(this);
                                    Result res = ld.Result;
                                    if (!res.IsSuccess)
                                    {
                                        IsCashDispenseError = false;
                                        this.txtStatus.Text = res.error.Message;
                                        LogManager.WriteLog(string.Format("Unable to Dispense Cash - Amount: {0}", ticketAmount), LogManager.enumLogLevel.Info);
                                        LogManager.WriteLog("Rollback Redeem Voucher Process", LogManager.enumLogLevel.Info);
                                        AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                                        {
                                            AuditModuleName = ModuleName.Voucher,
                                            Audit_Screen_Name = "Vouchers|RedeemVoucher",
                                            Audit_Desc = "Rollback redeem voucher:" + objTicketDetail.TicketString + " due to cash dispenser error",
                                            AuditOperationType = OperationType.MODIFY,
                                            Audit_Old_Vl = "iPayDeviceid:" + objTicketDetail.RedeemedDevice + ";dtPaid:" + objTicketDetail.RedeemedDate.GetUniversalDateTimeFormat() + ";Customerid:" + objTicketDetail.CustomerId.ToString()
                                        });
                                        objCashDeskOper.RollbackRedeemTicket(objTicketDetail.TicketString);
                                        if (Convert.ToBoolean(AppSettings.REDEEM_TICKET_POP_UP_ALERT_VISIBILITY))
                                        {
                                            BMC.Presentation.MessageBox.ShowBox(res.error.Message, res.error.MessageType.Equals("Error") ? BMC_Icon.Error : BMC_Icon.Information, true);
                                        }
                                    }
                                    else
                                    {
                                        LogManager.WriteLog(string.Format("Cash Dispensed Successfully - Amount: {0}", ticketAmount), LogManager.enumLogLevel.Info);

                                        IsCashDispenseError = true;
                                        if (Convert.ToBoolean(AppSettings.REDEEM_TICKET_POP_UP_ALERT_VISIBILITY))
                                        {
                                            BMC.Presentation.MessageBox.ShowBox(res.error.Message, res.error.MessageType.Equals("Error") ? BMC_Icon.Error : BMC_Icon.Information, true);
                                        }

                                    }
                                }
                                #endregion
                            }

                        }
                        catch (Exception Ex)
                        {
                            LogManager.WriteLog("Error showing Voucher Info :" + Ex.Message, LogManager.enumLogLevel.Error);
                        }
                    }

                    if (objTicketDetail.ShowOfflineTicketScreen)
                    {
                        int result;

                        if (objTicketDetail.HostSiteCode == Settings.SiteCode) // Offline Tickets redemption is valid only for local site code
                            result = objCashDeskOper.CheckSDGOfflineTicket(objTicketDetail.TicketString);
                        else
                            result = -14;

                        if (result == -14)// Site Code Mismatch
                        {
                            this.txtStatus.Visibility = Visibility.Visible;
                            this.txtStatus.Text = Application.Current.FindResource("MessageID312") as string;
                            this.txtStatus.Background = System.Windows.Media.Brushes.Red;
                            return;
                        }
                        else
                        {
                            frmRedeemOffline = new BMC.Presentation.POS.Views.CRedeemOfflineTicket();
                            frmRedeemOffline.TicketNumber = ucValueCalc.txtDisplay.Text.Trim();
                            frmRedeemOffline.ShowDialogEx(this);
                            if(frmRedeemOffline.IsSuccessfull)
                            {
                                this.ucValueCalc.txtDisplay.Text = frmRedeemOffline.TicketNumber;
                                button_Click(sender, e);
                            }
                            else
                            {
                                this.ucValueCalc.txtDisplay.Text = string.Empty;
                                this.txtStatus.Clear();
                            }
                        }
                    }
                    else
                    {
                        if (Settings.IsGloryCDEnabled && (!IsCashDispenseError))
                        {
                            disptimerRedeem.Stop();
                            this.txtStatus.Visibility = Visibility.Visible;
                            this.txtStatus.Background = System.Windows.Media.Brushes.Red;
                            TextBlock_11.Text = string.Empty;
                            txtAmount.Text = string.Empty;
                            System.Threading.Thread.Sleep(100);
                            //System.Threading.Thread.CurrentThread
                            disptimerRedeem.Start();
                        }
                        else
                        {
                            this.txtStatus.Text = objTicketDetail.TicketStatus;
                            //"(" + CommonUtilities.GetCurrency(Convert.ToDouble(TicketDetail.TicketValue / 100)) + ")";
                            if (Application.Current.FindResource("MessageID219").ToString() == objTicketDetail.TicketStatus)
                            {
                                bisTicketExpired = true;
                            }
                            this.txtWarning.Text = objTicketDetail.TicketWarning;
                            if (!objTicketDetail.ValidTicket)
                            {
                                this.txtStatus.Background = System.Windows.Media.Brushes.Red;

                                AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                                {

                                    AuditModuleName = ModuleName.Voucher,
                                    Audit_Screen_Name = "Vouchers|RedeemVoucher",
                                    Audit_Desc = "Invalid Voucher Redemption Attempt",
                                    AuditOperationType = OperationType.MODIFY,
                                    Audit_Field = "Voucher Number",
                                    Audit_New_Vl = objTicketDetail.TicketString
                                });

                            }
                            else
                            {
                                this.txtStatus.Background = System.Windows.Media.Brushes.White;

                                AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                                {

                                    AuditModuleName = ModuleName.Voucher,
                                    Audit_Screen_Name = "Vouchers|RedeemVoucher",
                                    Audit_Desc = "Voucher Number-" + objTicketDetail.TicketString,
                                    AuditOperationType = OperationType.ADD,
                                    Audit_Field = "Voucher Status",
                                    Audit_New_Vl = objTicketDetail.TicketStatus
                                });

                                //Cross Ticketing- Insert Local Record 
                                if (!string.IsNullOrEmpty(objTicketDetail.VoucherXMLData))
                                {
                                    objTicketDetail.RedeemedUser = Security.SecurityHelper.CurrentUser.UserName;
                                    objCashDeskOper.ImportVoucherDetails(objTicketDetail);
                                }

                                if (objTicketDetail.TicketStatus.Contains(Application.Current.FindResource("MessageID210").ToString()))
                                {
                                    //disptimerRedeem.Stop();

                                    Action act = new Action(() =>
                                    {
                                        if (Convert.ToBoolean(AppSettings.REDEEM_TICKET_POP_UP_ALERT_VISIBILITY))
                                        {
                                            if (IsCashDispenseError)
                                            {
                                                if (Settings.IsGloryCDEnabled)
                                                {
                                                    disptimerRedeem.Stop();
                                                    this.txtStatus.Visibility = Visibility.Visible;
                                                }
                                                else
                                                {
                                                    this.ClearAll(false);
                                                }
                                                MessageBox.ShowBox("MessageID377", BMC_Icon.Information);
                                            }


                                        }
                                        else
                                        {
                                            this.txtStatus.Text = Application.Current.FindResource("MessageID377").ToString();
                                            txtAmount.Text = Convert.ToDecimal(objTicketDetail.TicketValue / 100).GetUniversalCurrencyFormat();
                                            bisTicketExpired = false;
                                            this.txtStatus.Background = System.Windows.Media.Brushes.GreenYellow;
                                        }
                                        if (!Settings.IsGloryCDEnabled)
                                        {
                                            this.dispenserStatus.LoadItemsAysnc();
                                        }
                                    });

                                    if (!Settings.IsGloryCDEnabled)
                                    {
                                        _worker.Dispense("Voucher Number", objTicketDetail.TicketString, objTicketDetail.RedeemedAmount, act);

                                    }
                                    else
                                    {
                                        act();
                                        disptimerRedeem.Start();
                                    }

                                }
                            }
                            if (objTicketDetail.EnableTickerPrintDetails)
                            {
                                this.gridRedeemedTicket.Visibility = Visibility.Visible;
                                this.txtPrintedMachine.Text = objTicketDetail.RedeemedMachine;
                                this.txtClaimedDevice.Text = objTicketDetail.RedeemedDevice;
                                this.txtTickAmount.Text = objTicketDetail.RedeemedAmount.GetUniversalCurrencyFormatWithSymbol();
                                this.txtClaimedDate.Text = objTicketDetail.RedeemedDate.GetUniversalDateTimeFormat();
                            }
                            else
                            {
                                this.gridRedeemedTicket.Visibility = Visibility.Hidden;
                            }
                            this.ucValueCalc.txtDisplay.Focus();
                        }
                    }
                }
                else
                {
                    MessageBox.ShowBox("MessageID105", BMC_Icon.Warning);
                    this.ucValueCalc.txtDisplay.Focus();
                }
            }
            catch (Exception ex)
            {
                BMC.Common.ExceptionManagement.ExceptionManager.Publish(ex);
            }
            finally
            {
                btnVerify.IsEnabled = true;
            }
        }
예제 #6
0
        private void btnVerify_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                string ticketNumber = this.ucValueCalc.txtDisplay.Text.Trim();

                //check if ticketstring is numeric
                double Num;
                bool   isNum = double.TryParse(ticketNumber, out Num);


                btnVerify.IsEnabled = false;

                if (isNum && (ticketNumber.IndexOf('.') < 0) && this.ucValueCalc.txtDisplay.Text.Trim().Length > 0)
                {
                    ExceptionVoucher objExceptionVoucher = new ExceptionVoucher();


                    this.txtStatus.Visibility = Visibility.Visible;
                    this.txtStatus.Text       = Application.Current.FindResource("MessageID401") as string;


                    //LogManager.WriteLog("Checking Voucher:" + ticketNumber+" is PP Ticket", LogManager.enumLogLevel.Info);
                    if (objExceptionVoucher.IsExceptionVoucher(ticketNumber) == 1)
                    {
                        this.txtStatus.Text = Application.Current.FindResource("MessageID221") as string;


                        if (MessageBox.ShowBox("MessageID395", BMC_Icon.Warning, BMC_Button.YesNo) == System.Windows.Forms.DialogResult.Yes)
                        {
                            disptimerRedeem.IsEnabled = true;
                            disptimerRedeem.Start();

                            //******Check for user access rights.
                            CAuthorize objAuthorize = null;
                            objAuthorize      = new CAuthorize("BMC.Presentation.CPpTicket");
                            objAuthorize.User = Security.SecurityHelper.CurrentUser;
                            if (!Security.SecurityHelper.HasAccess("BMC.Presentation.CPpTicket"))
                            {
                                objAuthorize.ShowDialog();
                                if (!objAuthorize.IsAuthorized)
                                {
                                    ClearAll();
                                    return;
                                }
                            }
                            else
                            {
                                objAuthorize.IsAuthorized = true;
                            }

                            //Go ahead and Mark the ticket as active
                            if (objExceptionVoucher.MarkExceptionVoucherActive(ticketNumber) == -1)
                            {
                                //Unsuccessfull in Activating PP ticket :(
                                //LogManager.WriteLog("Unsuccessfull in Activating PP Voucher:" + ticketNumber + "!!!", LogManager.enumLogLevel.Info);
                                MessageBox.ShowBox("MessageID397", BMC_Icon.Error, BMC_Button.OK);
                            }
                            else
                            {
                                //Success in Activating PP ticket! :)
                                //LogManager.WriteLog("Success in Activating PP Voucher:" + ticketNumber + "!!!", LogManager.enumLogLevel.Info);
                                disptimerRedeem.Stop();
                                this.txtStatus.Text = Application.Current.FindResource("MessageID402") as string;
                                MessageBox.ShowBox("MessageID396", BMC_Icon.Information, BMC_Button.OK);

                                //****Audit code***
                                #region "Audit log for PP ticket"

                                if (objAuthorize != null && objAuthorize.IsAuthorized)
                                {
                                    // Modified description, removed field & new value for Exception Voucher
                                    AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                                    {
                                        AuditModuleName    = ModuleName.Exception_Voucher,
                                        Audit_Screen_Name  = "Exception Voucher",
                                        Audit_Desc         = "Voucher Number - " + ticketNumber + " activated by " + objAuthorize.User.DisplayName,
                                        AuditOperationType = OperationType.MODIFY,
                                    });
                                }
                                #endregion
                            }

                            disptimerRedeem.Stop();
                            this.txtStatus.Visibility = Visibility.Hidden;
                        }
                        else
                        {
                            disptimerRedeem.Stop();
                            this.txtStatus.Visibility = Visibility.Hidden;
                        }
                    }
                    else // you will enter here if its not an exception voucher
                    {
                        disptimerRedeem.Start();
                        this.txtStatus.Text = Application.Current.FindResource("MessageID398") as string;
                        MessageBox.ShowBox("MessageID399", BMC_Icon.Information, BMC_Button.OK, ticketNumber);

                        this.ucValueCalc.txtDisplay.Focus();
                        disptimerRedeem.Stop();
                        this.txtStatus.Visibility = Visibility.Hidden;
                    }
                }    //  Outer most IF ends here
                else // enter here if Voucher number has anything other than numerals
                {
                    if (ticketNumber.Length > 0)//Show message only if there is something in the textbox
                    {
                        disptimerRedeem.Start();
                        this.txtStatus.Text = Application.Current.FindResource("MessageID403") as string;
                        MessageBox.ShowBox("MessageID400", BMC_Icon.Error, BMC_Button.OK);
                        this.ucValueCalc.txtDisplay.Focus();
                        disptimerRedeem.Stop();
                    }
                    this.txtStatus.Visibility = Visibility.Hidden;
                }
            }//try ends here


            catch (Exception ex)
            {
                BMC.Common.ExceptionManagement.ExceptionManager.Publish(ex);
            }
            finally
            {
                ClearAll();
                btnVerify.IsEnabled = true;
            }
        }
        private void btnMainain_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                CMachineMaintenance objMachineMaintenance = new CMachineMaintenance();

                //Start 
                if (btnMainain.Content == FindResource("CMachineMaintenanceView_xaml_btnMainain"))
                {
                    if (MessageBox.ShowBox("MessageID256", BMC_Icon.Question, BMC_Button.YesNo) == System.Windows.Forms.DialogResult.No)
                        return;

                    if (objMachineMaintenance.ManageMaintenance(installationNo, 0, Security.SecurityHelper.CurrentUser.SecurityUserID) > 0)
                    {
                        MessageBox.ShowBox("MessageID339", BMC_Icon.Information, BMC_Button.OK);

                        PopulateSession();
                        if (txtOpenSession.Tag != null)
                        {
                            PopulateEvents((int)txtOpenSession.Tag);
                        }
                        return;
                    }

                    //LogManager.WriteLog("Executing Path : " + BMCRegistryHelper.GetRegKeyValue(string.Empty,"InstallationPath").ToString().Trim()  + Common.ConfigurationManagement.ConfigManager.Read(
                    //                "HandpayCommandLinePrompt") + " DisableMachine " + installationNo, LogManager.enumLogLevel.Info);



                    //System.Diagnostics.Process.Start(BMCRegistryHelper.GetRegKeyValue(string.Empty, "InstallationPath").ToString().Trim().ToString().Trim() + Common.ConfigurationManagement.ConfigManager.Read(
                    //            "HandpayCommandLinePrompt"), " DisableMachine " + installationNo);

                    LogManager.WriteLog("Executing Path : " + Path.Combine(Extensions.GetStartupDirectory(), Common.ConfigurationManagement.ConfigManager.Read(
                "HandpayCommandLinePrompt")) + " DisableMachine " + installationNo, LogManager.enumLogLevel.Info);

                    System.Diagnostics.Process.Start(Path.Combine(Extensions.GetStartupDirectory(), Common.ConfigurationManagement.ConfigManager.Read(
                                "HandpayCommandLinePrompt")), " DisableMachine " + installationNo);


                    AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                    {
                        
                        AuditModuleName = ModuleName.MachineMaintenance,
                        Audit_Screen_Name = "Machine Maintenance View",
                        Audit_Desc = "Start Maintenance - Installation No: " + installationNo.ToString(),
                        AuditOperationType = OperationType.MODIFY,
                    });

                    MessageBox.ShowBox("MessageID309", BMC_Icon.Information, BMC_Button.OK);
                }
                else//Close 
                {
                    int iMachineEventStatus = objMachineMaintenance.CheckMachineMaintenance(installationNo);
                    if (iMachineEventStatus < 0)
                    {
                        if (MessageBox.ShowBox("MessageID304", BMC_Icon.Question, BMC_Button.YesNo) == System.Windows.Forms.DialogResult.No)
                        {
                            return;
                        }
                        CAuthorize objAuthorize = new CAuthorize("CashdeskOperator.Authorize.cs.OverrideEvents");
                        objAuthorize.User = Security.SecurityHelper.CurrentUser;
                        if (!Security.SecurityHelper.HasAccess("CashdeskOperator.Authorize.cs.OverrideEvents"))
                        {
                            objAuthorize.ShowDialog();
                            if (!objAuthorize.IsAuthorized)
                                return;
                        }
                        else
                        {
                            objAuthorize.IsAuthorized = true;
                        }
                    }

                    if (MessageBox.ShowBox("MessageID257", BMC_Icon.Question, BMC_Button.YesNo) == System.Windows.Forms.DialogResult.No)
                        return;

                    var objReasonCategory = new CReasonCategory();
                    objReasonCategory.ShowDialog();

                    if (objReasonCategory.MaintenanceReasonCategory != null && objReasonCategory.MaintenanceReasonCategory.Length > 0)
                    {
                        objMachineMaintenance.CloseMaintenance(installationNo, Security.SecurityHelper.CurrentUser.SecurityUserID,
                            objReasonCategory.MaintenanceReasonCategory);



                        AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                        {
                            
                            AuditModuleName = ModuleName.MachineMaintenance,
                            Audit_Screen_Name = "Machine Maintenance View",
                            Audit_Desc = "Close Maintenance - Installation No: " + installationNo.ToString(),
                            AuditOperationType = OperationType.MODIFY,
                        });

                        MessageBox.ShowBox("MessageID310", BMC_Icon.Information, BMC_Button.OK);
                    }
                    else
                        return;
                }
                PopulateSession();
            }
            catch (Exception ex)
            {
                ExceptionManager.Publish(ex);
            }
        }
        private void GenerateManulJackpot()
        {
            double amount = 0;
            if (txtBox != null && txtBox.Text.Length > 0)
            {
                double.TryParse(txtBox.Text.ToString(), NumberStyles.Currency, new CultureInfo(ExtensionMethods.CurrentCurrenyCulture), out amount);
            }

            //if (amount > Settings.W2GWinAmount)
            //{
            //    MessageBox.ShowBox("MessageID367", BMC_Icon.Information);
            //    //return;
            //}
            try
            {
                jackpotProcessInfoDTO jpinfo = new jackpotProcessInfoDTO();
                CAuthorize objAuthorize = null;
                string HP_Type = string.Empty;
                Double iAmount = 0;
                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 iAmount);
                }

                if (Settings.Client != null && Settings.Client.ToLower() == "winchells"
               && Settings.MaxHandPayAuthRequired
               && txtBox != null
               && (iAmount > 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
                    {
                        objAuthorize.IsAuthorized = true;
                    }
                }
                if (optHandpay.IsChecked == true)
                {
                    HP_Type = "AttendantPay Credit";
                    jpinfo.jackpotTypeId = 4;
                }
                else if (optJackpot.IsChecked == true)
                {
                    HP_Type = "AttendantPay Jackpot";
                    jpinfo.jackpotTypeId = 5;
                }
                else
                {
                    HP_Type = "AttendantPay Progressive";
                    jpinfo.jackpotTypeId = 6;
                }

                // Finding Denom for the machine-CR# 167677

                decimal DenomValue = 0;
                DataSet oDt = handpay.createTickeException_HandpayCAGE(int.Parse((cmbBarPositions.SelectedItem as BarPositions).Bar_Pos_Name), iAmount, 0, HP_Type);
                List<DenomValueResult> lstDenom = handpay.GetDenomValue(oDt.Tables[0].Rows[0]["Asset"].ToString());
                foreach (var denom in lstDenom)
                {
                    DenomValue = denom.Denom;
                }
                jpinfo.Slot = (cmbBarPositions.SelectedItem as BarPositions).Bar_Pos_Name;
                jpinfo.assetConfigNumber = oDt.Tables[0].Rows[0]["Asset"].ToString();
                jpinfo.Denom = DenomValue;
                jpinfo.hpjpAmount = long.Parse(oDt.Tables[0].Rows[0]["TE_VALUE"].ToString());
                jpinfo.jackpotNetAmount = long.Parse(oDt.Tables[0].Rows[0]["TE_VALUE"].ToString());
                jpinfo.sequenceNumber = long.Parse(oDt.Tables[0].Rows[0]["TE_ID"].ToString());
                jpinfo.TransactionDate = oDt.Tables[0].Rows[0]["TE_Date"].ToString();
                jpinfo.UserID = Security.SecurityHelper.CurrentUser.SecurityUserID.ToString();
                jpinfo.siteNo = Settings.SiteName;
                jpinfo.siteId = Convert.ToInt32(Settings.SiteCode);
                txtBox.Text = this.DefaultAmount();
                handpay.PrintSlip(jpinfo);


                //send PT 10 from client

                Treasury treasury = new Treasury();
                treasury.ActualTreasuryDate = Convert.ToDateTime(jpinfo.TransactionDate);
                treasury.Asset = Asset;
                treasury.Authorized_Date = Convert.ToDateTime(jpinfo.TransactionDate);
                treasury.AuthorizedUser_No = SecurityHelper.CurrentUser.User_No;                
                treasury.CustomerID = SecurityHelper.CurrentUser.User_No;                
                treasury.InstallationNumber = InstallationNumber;
                treasury.TreasuryAmount = iAmount;
                treasury.UserID = SecurityHelper.CurrentUser.User_No;                
                treasury.TreasuryType = HP_Type;

                if (((bool)optJackpot.IsChecked) || ((bool)optProgressive.IsChecked) )//|| ((bool)optHandpay.IsChecked))
                {
                    PostHandpayEvent(treasury);
                }
            }
            catch (Exception Ex)
            {

                ExceptionManager.Publish(Ex);
            }

        }
        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;
            }
        }
        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 btnGenerateSlipNo_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                int Auth_User_ID = 0;
                if (lstHandpay.Items.Count > 0)
                {
                    LogManager.WriteLog("Generating Slip", LogManager.enumLogLevel.Debug);
                    if (Clearhandpay(Convert.ToInt32((lstHandpay.SelectedItem as FillTreasuryList).Installation_No)))
                    {
                        jackpotProcessInfoDTO jpinfo = new jackpotProcessInfoDTO();
                        CAuthorize objAuthorize = null;
                        int TE_ID = (lstHandpay.SelectedItem as FillTreasuryList).TE_ID;
                        Treasury 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 = false,
                            ActualTreasuryDate =
                                (DateTime)((lstHandpay.SelectedItem as FillTreasuryList).TreasuryDate)
                        };
                        Auth_User_ID = Security.SecurityHelper.CurrentUser.User_No;

                        if (treasury.TreasuryAmount > 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
                                    Auth_User_ID = handpay.GetUserID(objAuthorize.User.SecurityUserID);
                            }
                            else
                            {
                                objAuthorize.IsAuthorized = true;
                            }
                        }
                        treasury.CustomerID = Custid;
                        treasury.UserID = Auth_User_ID;
                        treasury.Authorized_Date = DateTime.Now.DBMinValue();
                        jpinfo.Slot = (lstHandpay.SelectedItem as FillTreasuryList).Pos;
                        jpinfo.assetConfigNumber = (lstHandpay.SelectedItem as FillTreasuryList).Asset;
                        jpinfo.Denom = 0.01M;
                        jpinfo.hpjpAmount = Convert.ToInt32((lstHandpay.SelectedItem as FillTreasuryList).Amount * 100);
                        jpinfo.jackpotNetAmount = Convert.ToInt32((lstHandpay.SelectedItem as FillTreasuryList).Amount);
                        jpinfo.jackpotTypeId = (lstHandpay.SelectedItem as FillTreasuryList).HP_Type.ToLower() == "attendantpay Credit" ? Convert.ToInt16(1) :
                            (lstHandpay.SelectedItem as FillTreasuryList).HP_Type.ToLower() == "attendantpay jackpot" ? Convert.ToInt16(2) :
                              (lstHandpay.SelectedItem as FillTreasuryList).HP_Type.ToLower() == "progressive" ? Convert.ToInt16(3) : Convert.ToInt16(1);



                        jpinfo.sequenceNumber = (lstHandpay.SelectedItem as FillTreasuryList).TE_ID;
                        jpinfo.TransactionDate = (lstHandpay.SelectedItem as FillTreasuryList).TreasuryDate.ToString();
                        jpinfo.UserID = Security.SecurityHelper.CurrentUser.SecurityUserID.ToString();
                        jpinfo.siteNo = Settings.SiteName;
                        jpinfo.siteId = Convert.ToInt32(Settings.SiteCode);

                        handpay.PrintSlip(jpinfo);
                    }
                    else
                    {
                        MessageBox.ShowBox("MessageID382", BMC_Icon.Information);
                    }

                }
                else
                    MessageBox.ShowBox("MessageID383", BMC_Icon.Information);
            }
            catch (Exception Ex)
            {
                ExceptionManager.Publish(Ex);
            }
        }
        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (cboProfitShareGroup.SelectedIndex <= 0)
                {
                    MessageBox.ShowBox("MessageID490", BMC_Icon.Information);
                    return;
                }

                decimal FixedExpenseAmount = (Convert.ToDecimal(txtExpenseShareAmount.Text) * (Convert.ToDecimal(((ExpenseShareGroup)cboExpenseShareGroup.SelectedItem).ExpenseSharePercentage) / 100));
                decimal dTotal = Convert.ToDecimal(FixedExpenseAmount) + Convert.ToDecimal(txtCarriedForwardAmount.Text);
                if (Math.Round(Convert.ToDecimal(txtWriteOffExpense.Text), 2, MidpointRounding.AwayFromZero) > (Math.Round(FixedExpenseAmount, 2) + Math.Round(Convert.ToDecimal(txtCarriedForwardAmount.Text), 2, MidpointRounding.AwayFromZero)))
                {
                    CAuthorize oCAuthorize = new CAuthorize("BMC.Presentation.CProfitShare.ProfitShareApprover");
                    oCAuthorize.ShowDialog();
                    if (!oCAuthorize.IsAuthorized)
                        return;
                    //string strMsg = Application.Current.FindResource("MessageID890").ToString().Replace("@@@@", Convert.ToDecimal(txtWriteOffExpense.Text).ToString("#,##0.00")).Replace("****", dTotal.ToString("#,##0.00"));
                    //MessageBox.ShowBox(strMsg, BMC_Icon.Error, true);
                }
                objCommonLiquidation.ProfitShareGroupId = Convert.ToInt32(cboProfitShareGroup.SelectedValue);
                objCommonLiquidation.ExpenseShareGroupID = Convert.ToInt32(cboExpenseShareGroup.SelectedValue);
                objCommonLiquidation.ExpenseShareAmount = Convert.ToDecimal(txtExpenseShareAmount.Text);
                objCommonLiquidation.WriteOffAmount = Convert.ToDecimal(txtWriteOffExpense.Text);
                objCommonLiquidation.PayPeriodId = objPayPeriods == null ? 0 : objPayPeriods.Calendar_Period_ID;
                objCommonLiquidation.Percentage_Setting = Convert.ToDecimal(((ProfitShareGroup)cboProfitShareGroup.SelectedItem).ProfitSharePercentage);
                objCommonLiquidation.ExpenseSharePercentage = Convert.ToDecimal(((ExpenseShareGroup)cboExpenseShareGroup.SelectedItem).ExpenseSharePercentage);
                this.Close();
            }

            catch (Exception ex)
            {
                ExceptionManager.Publish(ex);
            }
        }
예제 #13
0
        private void btnMainain_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                CMachineMaintenance objMachineMaintenance = new CMachineMaintenance();

                //Start
                if (btnMainain.Content == FindResource("CMachineMaintenanceView_xaml_btnMainain"))
                {
                    if (MessageBox.ShowBox("MessageID256", BMC_Icon.Question, BMC_Button.YesNo) == System.Windows.Forms.DialogResult.No)
                    {
                        return;
                    }

                    if (objMachineMaintenance.ManageMaintenance(installationNo, 0, Security.SecurityHelper.CurrentUser.SecurityUserID) > 0)
                    {
                        MessageBox.ShowBox("MessageID339", BMC_Icon.Information, BMC_Button.OK);

                        PopulateSession();
                        if (txtOpenSession.Tag != null)
                        {
                            PopulateEvents((int)txtOpenSession.Tag);
                        }
                        return;
                    }

                    //LogManager.WriteLog("Executing Path : " + BMCRegistryHelper.GetRegKeyValue(string.Empty,"InstallationPath").ToString().Trim()  + Common.ConfigurationManagement.ConfigManager.Read(
                    //                "HandpayCommandLinePrompt") + " DisableMachine " + installationNo, LogManager.enumLogLevel.Info);



                    //System.Diagnostics.Process.Start(BMCRegistryHelper.GetRegKeyValue(string.Empty, "InstallationPath").ToString().Trim().ToString().Trim() + Common.ConfigurationManagement.ConfigManager.Read(
                    //            "HandpayCommandLinePrompt"), " DisableMachine " + installationNo);

                    LogManager.WriteLog("Executing Path : " + Path.Combine(Extensions.GetStartupDirectory(), Common.ConfigurationManagement.ConfigManager.Read(
                                                                               "HandpayCommandLinePrompt")) + " DisableMachine " + installationNo, LogManager.enumLogLevel.Info);

                    System.Diagnostics.Process.Start(Path.Combine(Extensions.GetStartupDirectory(), Common.ConfigurationManagement.ConfigManager.Read(
                                                                      "HandpayCommandLinePrompt")), " DisableMachine " + installationNo);


                    AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                    {
                        AuditModuleName    = ModuleName.MachineMaintenance,
                        Audit_Screen_Name  = "Machine Maintenance View",
                        Audit_Desc         = "Start Maintenance - Installation No: " + installationNo.ToString(),
                        AuditOperationType = OperationType.MODIFY,
                    });

                    MessageBox.ShowBox("MessageID309", BMC_Icon.Information, BMC_Button.OK);
                }
                else//Close
                {
                    int iMachineEventStatus = objMachineMaintenance.CheckMachineMaintenance(installationNo);
                    if (iMachineEventStatus < 0)
                    {
                        if (MessageBox.ShowBox("MessageID304", BMC_Icon.Question, BMC_Button.YesNo) == System.Windows.Forms.DialogResult.No)
                        {
                            return;
                        }
                        CAuthorize objAuthorize = new CAuthorize("CashdeskOperator.Authorize.cs.OverrideEvents");
                        objAuthorize.User = Security.SecurityHelper.CurrentUser;
                        if (!Security.SecurityHelper.HasAccess("CashdeskOperator.Authorize.cs.OverrideEvents"))
                        {
                            objAuthorize.ShowDialog();
                            if (!objAuthorize.IsAuthorized)
                            {
                                return;
                            }
                        }
                        else
                        {
                            objAuthorize.IsAuthorized = true;
                        }
                    }

                    if (MessageBox.ShowBox("MessageID257", BMC_Icon.Question, BMC_Button.YesNo) == System.Windows.Forms.DialogResult.No)
                    {
                        return;
                    }

                    var objReasonCategory = new CReasonCategory();
                    objReasonCategory.ShowDialog();

                    if (objReasonCategory.MaintenanceReasonCategory != null && objReasonCategory.MaintenanceReasonCategory.Length > 0)
                    {
                        objMachineMaintenance.CloseMaintenance(installationNo, Security.SecurityHelper.CurrentUser.SecurityUserID,
                                                               objReasonCategory.MaintenanceReasonCategory);



                        AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                        {
                            AuditModuleName    = ModuleName.MachineMaintenance,
                            Audit_Screen_Name  = "Machine Maintenance View",
                            Audit_Desc         = "Close Maintenance - Installation No: " + installationNo.ToString(),
                            AuditOperationType = OperationType.MODIFY,
                        });

                        MessageBox.ShowBox("MessageID310", BMC_Icon.Information, BMC_Button.OK);
                    }
                    else
                    {
                        return;
                    }
                }
                PopulateSession();
            }
            catch (Exception ex)
            {
                ExceptionManager.Publish(ex);
            }
        }
        private void btnVerify_Click(object sender, RoutedEventArgs e)
        {
            try
            {

                string ticketNumber = this.ucValueCalc.txtDisplay.Text.Trim();

                //check if ticketstring is numeric
                double Num;
                bool isNum = double.TryParse(ticketNumber, out Num);

                
                btnVerify.IsEnabled = false;

                if (isNum && (ticketNumber.IndexOf('.') < 0) && this.ucValueCalc.txtDisplay.Text.Trim().Length > 0)
                {
                    ExceptionVoucher objExceptionVoucher = new ExceptionVoucher();
                    

                    this.txtStatus.Visibility = Visibility.Visible;
                    this.txtStatus.Text = Application.Current.FindResource("MessageID401") as string;


                    //LogManager.WriteLog("Checking Voucher:" + ticketNumber+" is PP Ticket", LogManager.enumLogLevel.Info);
                    if (objExceptionVoucher.IsExceptionVoucher(ticketNumber) == 1)
                    {
                        
                        this.txtStatus.Text = Application.Current.FindResource("MessageID221") as string;

                        
                        if (MessageBox.ShowBox("MessageID395", BMC_Icon.Warning, BMC_Button.YesNo) == System.Windows.Forms.DialogResult.Yes)
                        {
                            disptimerRedeem.IsEnabled = true;
                            disptimerRedeem.Start();

                            //******Check for user access rights.
                            CAuthorize objAuthorize = null;
                            objAuthorize = new CAuthorize("BMC.Presentation.CPpTicket");
                            objAuthorize.User = Security.SecurityHelper.CurrentUser;
                            if (!Security.SecurityHelper.HasAccess("BMC.Presentation.CPpTicket"))
                            {
                                objAuthorize.ShowDialog();
                                if (!objAuthorize.IsAuthorized)
                                {
                                    ClearAll();
                                    return;
                                }
                            }
                            else
                            {
                                objAuthorize.IsAuthorized = true;
                            }

                            //Go ahead and Mark the ticket as active
                            if (objExceptionVoucher.MarkExceptionVoucherActive(ticketNumber) == -1)
                            {
                                //Unsuccessfull in Activating PP ticket :(
                                //LogManager.WriteLog("Unsuccessfull in Activating PP Voucher:" + ticketNumber + "!!!", LogManager.enumLogLevel.Info);                                
                                MessageBox.ShowBox("MessageID397", BMC_Icon.Error, BMC_Button.OK);
                            }
                            else
                            {
                                //Success in Activating PP ticket! :)
                                //LogManager.WriteLog("Success in Activating PP Voucher:" + ticketNumber + "!!!", LogManager.enumLogLevel.Info);                                
                                disptimerRedeem.Stop();
                                this.txtStatus.Text = Application.Current.FindResource("MessageID402") as string;
                                MessageBox.ShowBox("MessageID396", BMC_Icon.Information, BMC_Button.OK);

                                //****Audit code***
                                #region "Audit log for PP ticket"

                                if (objAuthorize != null && objAuthorize.IsAuthorized)
                                {
                                    // Modified description, removed field & new value for Exception Voucher
                                    AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                                    {
                                        AuditModuleName = ModuleName.Exception_Voucher,
                                        Audit_Screen_Name = "Exception Voucher",
                                        Audit_Desc = "Voucher Number - " + ticketNumber + " activated by " + objAuthorize.User.DisplayName,
                                        AuditOperationType = OperationType.MODIFY,
                                    });
                                }
                                #endregion

                            }

                            disptimerRedeem.Stop();
                            this.txtStatus.Visibility = Visibility.Hidden;

                        }
                        else
                        {
                            disptimerRedeem.Stop();
                            this.txtStatus.Visibility = Visibility.Hidden;
                        }

                    }
                    else // you will enter here if its not an exception voucher 
                    {
                        disptimerRedeem.Start();
                        this.txtStatus.Text = Application.Current.FindResource("MessageID398") as string;
                        MessageBox.ShowBox("MessageID399", BMC_Icon.Information, BMC_Button.OK, ticketNumber);
                        
                        this.ucValueCalc.txtDisplay.Focus();
                        disptimerRedeem.Stop();
                        this.txtStatus.Visibility = Visibility.Hidden;
                    }
                    

                }//  Outer most IF ends here
                else // enter here if Voucher number has anything other than numerals
                {                    
                    if (ticketNumber.Length > 0)//Show message only if there is something in the textbox
                    {
                        disptimerRedeem.Start();
                        this.txtStatus.Text = Application.Current.FindResource("MessageID403") as string;
                        MessageBox.ShowBox("MessageID400", BMC_Icon.Error, BMC_Button.OK);
                        this.ucValueCalc.txtDisplay.Focus();
                        disptimerRedeem.Stop();
                    }                    
                    this.txtStatus.Visibility = Visibility.Hidden;
                }
                

            }//try ends here
            

            catch (Exception ex)
            {
                BMC.Common.ExceptionManagement.ExceptionManager.Publish(ex);
            }
            finally
            {
                ClearAll();
                btnVerify.IsEnabled = true;
            }
        }
        private void GenerateManulJackpot()
        {

            try
            {
                jackpotProcessInfoDTO jpinfo = new jackpotProcessInfoDTO();
                CAuthorize objAuthorize = null;
                string HP_Type = string.Empty;
                Double iAmount = 0;
                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 iAmount);
                }

                if (Settings.Client != null && Settings.Client.ToLower() == "winchells"
               && Settings.MaxHandPayAuthRequired
               && txtBox != null
               && (iAmount > Settings.HandpayPayoutCustomer_Max))
                {
                    objAuthorize = new CAuthorize("CashdeskOperator.Authorize.cs.MaxHandpay");
                    objAuthorize.User = Security.SecurityHelper.CurrentUser;
                    if (!Security.SecurityHelper.HasAccess("CashdeskOperator.Authorize.cs.MaxHandpay"))
                    {
                        objAuthorize.ShowDialogEx(this);
                        if (!objAuthorize.IsAuthorized)
                            return;
                    }
                    else
                    {
                        objAuthorize.IsAuthorized = true;
                    }
                }
                if ((dgHandpay.SelectedItem as FillTreasuryList).HP_Type.ToUpper() == "HANDPAY")
                {
                    HP_Type = "AttendantPay Credit";
                    jpinfo.jackpotTypeId = 4;
                }
                else if ((dgHandpay.SelectedItem as FillTreasuryList).HP_Type.ToUpper() == "JACKPOT")
                {
                    HP_Type = "AttendantPay Jackpot";
                    jpinfo.jackpotTypeId = 5;
                }
                else
                {
                    HP_Type = "AttendantPay Progressive";
                    jpinfo.jackpotTypeId = 6;
                }

                DataSet oDt = handpay.createTickeException_HandpayCAGE(int.Parse(this.BarPosition), iAmount, 0, HP_Type);
                if (Asset.IsNullOrEmpty())
                {
                    Asset = handpay.GetAssetNumber(InstallationNumber)[0].Stock_No;
                }

                jpinfo.Slot = this.BarPosition;
                jpinfo.assetConfigNumber = Asset;
                jpinfo.Denom = 0.01M;
                jpinfo.hpjpAmount = long.Parse(oDt.Tables[0].Rows[0]["TE_VALUE"].ToString());
                jpinfo.jackpotNetAmount = long.Parse(oDt.Tables[0].Rows[0]["TE_VALUE"].ToString());
                jpinfo.sequenceNumber = long.Parse(oDt.Tables[0].Rows[0]["TE_ID"].ToString());
                jpinfo.TransactionDate = oDt.Tables[0].Rows[0]["TE_Date"].ToString();
                jpinfo.UserID = objAuthorize.User.SecurityUserID.ToString();
                jpinfo.siteNo = Settings.SiteName;
                jpinfo.siteId = Convert.ToInt32(Settings.SiteCode);
                txtBox.Text = this.DefaultAmount();
                handpay.PrintSlip(jpinfo);

                //send PT 10 from client

                Treasury treasury = new Treasury();
                treasury.ActualTreasuryDate = Convert.ToDateTime(jpinfo.TransactionDate);
                treasury.Asset = Asset;
                treasury.Authorized_Date = Convert.ToDateTime(jpinfo.TransactionDate);
                treasury.AuthorizedUser_No = BMC.Security.SecurityHelper.CurrentUser.User_No;
                treasury.CustomerID = BMC.Security.SecurityHelper.CurrentUser.User_No;
                treasury.InstallationNumber = InstallationNumber;
                treasury.TreasuryAmount = iAmount;

                treasury.UserID = BMC.Security.SecurityHelper.CurrentUser.User_No;
                treasury.TreasuryType = HP_Type;

                PostHandpayEvent(treasury);
            }
            catch (Exception Ex)
            {

                ExceptionManager.Publish(Ex);
            }

        }