private string RedeemTicket(ReedemTicketInfo ticket)
        {
            LogManager.WriteLog("Inside RedeemTicket() Method", LogManager.enumLogLevel.Info);
            bool _isValidTicket = false;
            double RedeemTicketAmt = 0;
            int iCustomerID = 0;
            IRedeemOnlineTicket _objRedeemOnlineTicket = RedeemOnlineTicketBusinessObject.CreateInstance();
            RTOnlineTicketDetail _objOnlineTicketDetail = new RTOnlineTicketDetail();

            try
            {
                _objOnlineTicketDetail.RedeemedMachine = System.Environment.MachineName;
                _objOnlineTicketDetail.ClientSiteCode = Settings.SiteCode;               

                LogManager.WriteLog("The Voucher Redeem is Validating", LogManager.enumLogLevel.Info);
                _objOnlineTicketDetail.TicketString = ticket.Barcode;
                _objOnlineTicketDetail.HostSiteCode = _objOnlineTicketDetail.TicketString.Substring(0, 4);

                LogManager.WriteLog("Redeeming the Voucher :" + _objOnlineTicketDetail.TicketString, LogManager.enumLogLevel.Info);
                Dispatcher.BeginInvoke((Action)(() =>
                     {
                         ticket.Status = Application.Current.Resources["CRedeemMultipleTicketRedemptionValidating"].ToString();

                     }), null);

                validateVoucher(ticket);

                _objOnlineTicketDetail = ticket.oRTOnlineTicketDetail;

                ticket.TicketStatus = _objOnlineTicketDetail.TicketStatusCode;
                ticket.oRTOnlineTicketDetail = _objOnlineTicketDetail;


                if (_objOnlineTicketDetail.TicketStatusCode != 0 && _objOnlineTicketDetail.TicketStatusCode != -14 && _objOnlineTicketDetail.TicketStatusCode != -15 && _objOnlineTicketDetail.TicketStatusCode != 1) //Exception Occured
                {
                    return Application.Current.Resources["MessageID425"].ToString();
                }


                int iTicketAmount = Convert.ToInt32(_objOnlineTicketDetail.RedeemedAmount);
                RedeemTicketAmt = iTicketAmount;
                _objOnlineTicketDetail.CustomerId = iCustomerID;
                _objOnlineTicketDetail.AuthorizedUser_No = Security.SecurityHelper.CurrentUser.User_No;
                _objOnlineTicketDetail.RedeemedUser = Security.SecurityHelper.CurrentUser.UserName;

               
                #region ValidVoucher
                //For active voucher
                if ((_objOnlineTicketDetail.TicketStatusCode == 0) && (Settings.RedeemConfirm))
                {
                      LogManager.WriteLog("Processing valid Voucher with status (0) with Barcode" + _objOnlineTicketDetail.TicketString, LogManager.enumLogLevel.Info);
                        Dispatcher.BeginInvoke((Action)(() =>
                        {

                            ticket.Status = Application.Current.Resources["RedeemMultipleTicketProcessingMessage"].ToString();


                        }), null);

                        _objOnlineTicketDetail.TicketString = ticket.Barcode; // to pass the exact barcode entered in the UI to redeem since validation length check is done during redemption also]
                        _objRedeemOnlineTicket.RedeemOnlineTicket(_objOnlineTicketDetail);
                        _isValidTicket = _objOnlineTicketDetail.ValidTicket;
                        //Thread.Sleep(300);
                        LogManager.WriteLog("The Voucher Redeem is Processed", LogManager.enumLogLevel.Info);


                        ticket.Status = Application.Current.Resources[_objOnlineTicketDetail.TicketStatus].ToString();
                        string AuditTicketStatus = ticket.Status;

                        //DB will return as VALID VOUCHER(MessageID210) if the voucher is redeemed successfully, So if the 
                        //ticket is redeemed successfully,by checking the ticket status, the redemption is displayed in the grid
                        if (ticket.Status == Application.Current.Resources["MessageID210"].ToString())
                        {
                            ticket.Status = Application.Current.Resources["CRedeemMultipleTicketRedemptionSuccess"].ToString();

                            AuditTicketStatus = AuditTicketStatus + "(" + CommonUtilities.GetCurrency(Convert.ToDouble(_objOnlineTicketDetail.TicketValue)) + ")";
                            //Audit the redeemed voucher
                            AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                            {

                                AuditModuleName = ModuleName.MultipleVoucherRedeem,
                                Audit_Screen_Name = "Multiple Redeem Voucher",
                                Audit_Desc = "Voucher Number -" + _objOnlineTicketDetail.TicketString,
                                AuditOperationType = OperationType.ADD,
                                Audit_Field = "Voucher Status",
                                Audit_New_Vl = AuditTicketStatus,
                                Audit_User_ID = _objOnlineTicketDetail.AuthorizedUser_No,
                                Audit_User_Name = _objOnlineTicketDetail.RedeemedUser
                            });

                        }
                        else
                        {
                            ticket.Status = Application.Current.Resources["CRedeemMultipleVoucherRedemptionFailed"].ToString();
                            ticket.TicketStatus = -1;

                            //Audit the redemption failed voucher
                            AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                            {

                                AuditModuleName = ModuleName.MultipleVoucherRedeem,
                                Audit_Screen_Name = "Multiple Redeem Voucher",
                                Audit_Desc = "Voucher redemption failed for :-" + _objOnlineTicketDetail.TicketString,
                                AuditOperationType = OperationType.MODIFY,
                                Audit_Field = "Voucher status",
                                Audit_New_Vl = AuditTicketStatus,
                                Audit_User_ID = _objOnlineTicketDetail.AuthorizedUser_No,
                                Audit_User_Name = _objOnlineTicketDetail.RedeemedUser
                            });


                        }
                        ticket.IsVoucherRedeemed = true;
                        return ticket.Status;
                    
                   
                }

                #endregion ValidVoucher

                #region TISVALIDVOUCHER

                //For active voucher
                else if ((_objOnlineTicketDetail.TicketStatusCode == 1) && (Settings.RedeemConfirm))
                {
                    LogManager.WriteLog("Processing valid TIS Voucher with status (1) with Barcode" + _objOnlineTicketDetail.TicketString, LogManager.enumLogLevel.Info);
                    Dispatcher.BeginInvoke((Action)(() =>
                    {
                      ticket.Status = Application.Current.Resources["RedeemMultipleTicketProcessingMessage"].ToString();
                    }), null);

                    _objRedeemOnlineTicket.RedeemOnlineTicket(_objOnlineTicketDetail);
                    _isValidTicket = _objOnlineTicketDetail.ValidTicket;
                    // Thread.Sleep(300);
                    LogManager.WriteLog("The Voucher Redeem is Processed", LogManager.enumLogLevel.Info);
                    
                    ticket.Status = Application.Current.Resources[_objOnlineTicketDetail.TicketStatus].ToString();
                    string TISAuditStatus = ticket.Status;
                    //DB will return as VALID VOUCHER(MessageID210) if the voucher is redeemed successfully, So if the 
                    //ticket is redeemed successfully,by checking the ticket status, the redemption is displayed in the grid
                    if (ticket.Status == Application.Current.Resources["MessageID210"].ToString())
                    {
                        ticket.Status = Application.Current.Resources["CRedeemTISVoucherRedeemSuccess"].ToString();
                        //Audit the redeemed voucher
                        AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                        {
                            AuditModuleName = ModuleName.MultipleVoucherRedeem,
                            Audit_Screen_Name = "Multiple Redeem Voucher",
                            Audit_Desc = "TIS Voucher Number -" + _objOnlineTicketDetail.TicketString,
                            AuditOperationType = OperationType.ADD,
                            Audit_Field = "Voucher Status",
                            Audit_New_Vl = TISAuditStatus+"["+ ticket.Amount + "]",
                            Audit_User_ID = _objOnlineTicketDetail.AuthorizedUser_No,
                            Audit_User_Name = _objOnlineTicketDetail.RedeemedUser
                        });
                    }
                    else if (ticket.Status == Application.Current.Resources["MessageID876"].ToString()) // for TIS Effective date mismatch
                    {
                        ticket.Status = ticket.Status;
                        ticket.TicketStatus = -1;
                        //Audit the redemption failed voucher
                        AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                        {
                            AuditModuleName = ModuleName.MultipleVoucherRedeem,
                            Audit_Screen_Name = "Multiple Redeem Voucher",
                            Audit_Desc = "TIS Voucher redemption failed for :-" + _objOnlineTicketDetail.TicketString,
                            AuditOperationType = OperationType.MODIFY,
                            Audit_Field = "Voucher status",
                            Audit_New_Vl = TISAuditStatus,
                            Audit_User_ID = _objOnlineTicketDetail.AuthorizedUser_No,
                            Audit_User_Name = _objOnlineTicketDetail.RedeemedUser
                        });
                    }
                    else
                    {
                        ticket.Status = Application.Current.Resources["CRedeemTISVoucherRedeemFailed"].ToString();
                        ticket.TicketStatus = -1;
                        //Audit the redemption failed voucher
                        AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                        {
                            AuditModuleName = ModuleName.MultipleVoucherRedeem,
                            Audit_Screen_Name = "Multiple Redeem Voucher",
                            Audit_Desc = "TIS Voucher redemption failed for :-" + _objOnlineTicketDetail.TicketString,
                            AuditOperationType = OperationType.MODIFY,
                            Audit_Field = "Voucher status",
                            Audit_New_Vl = TISAuditStatus,
                            Audit_User_ID = _objOnlineTicketDetail.AuthorizedUser_No,
                            Audit_User_Name = _objOnlineTicketDetail.RedeemedUser
                        });

                    }
                    ticket.IsVoucherRedeemed = true;
                    return ticket.Status;
                }


                #endregion TISVALIDVOUCHER

                #region forExpiredVoucher
                //Expired Voucher

               
                else if (_objOnlineTicketDetail.TicketStatusCode == -14 && (Settings.RedeemConfirm) && Settings.RedeemExpiredTicket)
                {

                    
                        LogManager.WriteLog("Processing expired Voucher with status -14 with Barcode" + _objOnlineTicketDetail.TicketString, LogManager.enumLogLevel.Info);
                        LogManager.WriteLog("The expired Voucher Redeem is Processing", LogManager.enumLogLevel.Info);
                        Dispatcher.BeginInvoke((Action)(() =>
                        {
                            ticket.Status = Application.Current.Resources["RedeemMultipleTicketProcessingMessage"].ToString();
                        }), null);
                        _objOnlineTicketDetail = _objRedeemOnlineTicket.RedeemOnlineTicket(_objOnlineTicketDetail);
                        _isValidTicket = _objOnlineTicketDetail.ValidTicket;
                        Thread.Sleep(300);

                        LogManager.WriteLog("The Voucher:" + ticket.Barcode + "is Redeemed successfully", LogManager.enumLogLevel.Info);

                        ticket.Status = Application.Current.Resources[_objOnlineTicketDetail.TicketStatus].ToString();
                        string AuditExpiredStatus = ticket.Status;
                        //DB will return as VALID VOUCHER(MessageID210) if the voucher is redeemed successfully, So if the 
                        //ticket is redeemed successfully,by checking the ticket status, the redemption is displayed in the grid

                        if (ticket.Status == Application.Current.Resources["MessageID210"].ToString())
                        {
                            ticket.Status = Application.Current.Resources["CRedeemMultipleTicketRedemptionSuccess"].ToString();

                            
                            //Audit the redeemed voucher
                            AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                            {

                                AuditModuleName = ModuleName.MultipleVoucherRedeem,
                                Audit_Screen_Name = "Multiple Redeem Voucher",
                                Audit_Desc = "Expired Voucher Number -" + _objOnlineTicketDetail.TicketString,
                                AuditOperationType = OperationType.ADD,
                                Audit_Field = "Voucher Status",
                                Audit_New_Vl = AuditExpiredStatus + "[" + ticket.Amount + "]",
                                Audit_User_ID = _objOnlineTicketDetail.AuthorizedUser_No,
                                Audit_User_Name = _objOnlineTicketDetail.RedeemedUser
                            });
                        }
                        else
                        {
                            ticket.Status = Application.Current.Resources["CRedeemMultipleVoucherRedemptionFailed"].ToString();
                            ticket.TicketStatus = -1;

                            //Audit the redemption failed voucher
                            AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                            {

                                AuditModuleName = ModuleName.MultipleVoucherRedeem,
                                Audit_Screen_Name = "Multiple Redeem Voucher",
                                Audit_Desc = "Expired Voucher redemption failed for :-" + _objOnlineTicketDetail.TicketString,
                                AuditOperationType = OperationType.MODIFY,
                                Audit_Field = "Voucher status",
                                Audit_New_Vl = AuditExpiredStatus,
                                Audit_User_ID = _objOnlineTicketDetail.AuthorizedUser_No,
                                Audit_User_Name = _objOnlineTicketDetail.RedeemedUser
                            });
                        }

                        ticket.IsVoucherRedeemed = true;

                    }

                   

              
                
                #endregion forExpiredVoucher

                #region forTISExpiredVoucher
                //Expired Voucher
                else if (_objOnlineTicketDetail.TicketStatusCode == -15 && (Settings.RedeemConfirm) && Settings.RedeemExpiredTicket)
                {
                   
                    LogManager.WriteLog("Processing TIS expired Voucher with status -15 with Barcode" + _objOnlineTicketDetail.TicketString, LogManager.enumLogLevel.Info);
                    LogManager.WriteLog("The expired TIS Voucher Redeem is Processing", LogManager.enumLogLevel.Info);
                    Dispatcher.BeginInvoke((Action)(() =>
                    {
                        ticket.Status = Application.Current.Resources["RedeemMultipleTicketProcessingMessage"].ToString();
                    }), null);
                    _objOnlineTicketDetail = _objRedeemOnlineTicket.RedeemOnlineTicket(_objOnlineTicketDetail);
                    _isValidTicket = _objOnlineTicketDetail.ValidTicket;
                    Thread.Sleep(300);                    
                    LogManager.WriteLog("The Voucher:" + ticket.Barcode + "is Redeemed successfully", LogManager.enumLogLevel.Info);

                    ticket.Status = Application.Current.Resources[_objOnlineTicketDetail.TicketStatus].ToString();
                    string TISExpiredAuditStatus = ticket.Status;
                    //DB will return as VALID VOUCHER(MessageID210) if the voucher is redeemed successfully, So if the 
                    //ticket is redeemed successfully,by checking the ticket status, the redemption is displayed in the grid

                    if (ticket.Status == Application.Current.Resources["MessageID210"].ToString())
                    {
                        ticket.Status = Application.Current.Resources["CRedeemTISVoucherRedeemSuccess"].ToString();

                        //Audit the redeemed voucher
                        AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                        {

                            AuditModuleName = ModuleName.MultipleVoucherRedeem,
                            Audit_Screen_Name = "Multiple Redeem Voucher",
                            Audit_Desc = "TIS Voucher Number -" + _objOnlineTicketDetail.TicketString,
                            AuditOperationType = OperationType.ADD,
                            Audit_Field = "Voucher Status",
                            Audit_New_Vl = TISExpiredAuditStatus+ "["+ ticket.Amount + "]",
                            Audit_User_ID = _objOnlineTicketDetail.AuthorizedUser_No,
                            Audit_User_Name = _objOnlineTicketDetail.RedeemedUser
                        });
                    }
                    else if (ticket.Status == Application.Current.Resources["MessageID876"].ToString()) // for TIS Effective date mismatch
                    {
                        ticket.Status = ticket.Status;
                        ticket.TicketStatus = -1;

                        //Audit the redemption failed voucher
                        AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                        {

                            AuditModuleName = ModuleName.MultipleVoucherRedeem,
                            Audit_Screen_Name = "Multiple Redeem Voucher",
                            Audit_Desc = "TIS Voucher redemption failed for :-" + _objOnlineTicketDetail.TicketString,
                            AuditOperationType = OperationType.MODIFY,
                            Audit_Field = "Voucher status",
                            Audit_New_Vl = TISExpiredAuditStatus,
                            Audit_User_ID = _objOnlineTicketDetail.AuthorizedUser_No,
                            Audit_User_Name = _objOnlineTicketDetail.RedeemedUser
                        });
                    }

                    else
                    {
                        ticket.Status = Application.Current.Resources["CRedeemTISVoucherRedeemFailed"].ToString();
                        ticket.TicketStatus = -1;

                        //Audit the redemption failed voucher
                        AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                        {

                            AuditModuleName = ModuleName.MultipleVoucherRedeem,
                            Audit_Screen_Name = "Multiple Redeem Voucher",
                            Audit_Desc = "TIS Voucher redemption failed for :-" + _objOnlineTicketDetail.TicketString,
                            AuditOperationType = OperationType.MODIFY,
                            Audit_Field = "Voucher status",
                            Audit_New_Vl = TISExpiredAuditStatus,
                            Audit_User_ID = _objOnlineTicketDetail.AuthorizedUser_No,
                            Audit_User_Name = _objOnlineTicketDetail.RedeemedUser
                        });
                    }
                    ticket.IsVoucherRedeemed = true;
                }
                    
                
                #endregion forTISExpiredVoucher                

                else if (_objOnlineTicketDetail.TicketStatusCode == -14 && (Settings.RedeemConfirm) && !Settings.RedeemExpiredTicket)
                {
                    LogManager.WriteLog("Processing expired Voucher with status -14 with Barcode with EXPIRED TICKET setting as FALSE" + _objOnlineTicketDetail.TicketString, LogManager.enumLogLevel.Info);
                    ticket.IsVoucherRedeemed = false;                  
                    ticket.Status = Application.Current.Resources["CRedeemMultipleTicketRedeemExpired"].ToString();

                    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 = _objOnlineTicketDetail.TicketString
                    });			 
                }
                else if (_objOnlineTicketDetail.TicketStatusCode == -15 && (Settings.RedeemConfirm) && !Settings.RedeemExpiredTicket)
                {
                    LogManager.WriteLog("Processing expired Voucher with status -15 with Barcode with EXPIRED TICKET setting as FALSE" + _objOnlineTicketDetail.TicketString, LogManager.enumLogLevel.Info);
                    ticket.IsVoucherRedeemed = false;
                    ticket.Status = Application.Current.Resources["CRedeemMultipleVoucherTISExpiredVoucher"].ToString();

                    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 = _objOnlineTicketDetail.TicketString
                    });			

                }    
            }
            catch (Exception ex)
            {
                ExceptionManager.Publish(ex);
                ticket.Status = Application.Current.Resources["CRedeemMultipleVoucherRedemptionFailed"].ToString();
				ticket.TicketStatus = -1;
            }
            return ticket.Status;
        }
        private void AddingToGrid(string Barcode)
        {
            LogManager.WriteLog("inside AddingToGrid() method", LogManager.enumLogLevel.Info);
            try
            {
                if (String.IsNullOrEmpty(Barcode))
                    return;

                if (!Validate(Barcode))
                {
                    txtErrorStatus.Visibility = System.Windows.Visibility.Visible;
                    txtErrorStatus.Text = Application.Current.Resources["CRedeemMultipleTicketRedeemInvalidTicketEntered"].ToString();
                    return;

                }
                if (!_objTickets.Exists((x) => { return x.Barcode == Barcode; }))
                {
                    ReedemTicketInfo objReedemTicketInfo = new ReedemTicketInfo() { Barcode = Barcode, Status = Application.Current.Resources["RedeemMultipleTicketProcessingMessage"].ToString(), IsRemoveVoucherEnable = true };
                    this.validateVoucher(objReedemTicketInfo);

                    //To calculate the total valid voucher amount count in the grid.
                    decimal dTotalAmount = 0;
                    int iTicketcount = 0;
                    _objTickets.Insert(0, objReedemTicketInfo);
                    _objTickets.ForEach((x) =>
                    {
                        if (x.TicketStatus == 0 ) //for valid voucher
                        {
                            dTotalAmount += x.Amount; iTicketcount++;
                        }

                        else if (x.TicketStatus == -14 && Settings.RedeemConfirm && Settings.RedeemExpiredTicket && Security.SecurityHelper.HasAccess("CashdeskOperator.Authorize.cs.MultipleRedeemExpiredTicket")) //Expired normal voucher
                        {
                            dTotalAmount += x.Amount; iTicketcount++;
                        }
                        else if (x.TicketStatus == -15 && Settings.RedeemConfirm && Settings.RedeemExpiredTicket && Security.SecurityHelper.HasAccess("CashdeskOperator.Authorize.cs.MultipleRedeemExpiredTicket")) //TIS expired voucher
                        {
                            dTotalAmount += x.Amount; iTicketcount++;
                        }

                        else if (x.TicketStatus == 1) //for valid TIS voucher
                        {
                            dTotalAmount += x.Amount; iTicketcount++;
                        }
                      
                    });
                    txtAmountVal.Text = dTotalAmount.ToString("0.00");
                    txtCountVal.Text = iTicketcount.ToString();
                }
                else
                {
                    txtErrorStatus.Visibility = System.Windows.Visibility.Visible;
                    txtBarcodeVal.Clear();
                    txtBarcodeVal.Focus();
                    txtErrorStatus.Text = Application.Current.Resources["CRedeemMultipleTicketRedeemAlreadyInTheList"].ToString();                    
                    return;
                }
                lvTickets.ItemsSource = null;
                lvTickets.ItemsSource = _objTickets;
                txtBarcodeVal.Clear();
                txtBarcodeVal.Focus();

            }
            catch (Exception ex)
            {
                ExceptionManager.Publish(ex);
            }
        }
 private void FindVoucher(ReedemTicketInfo ticket)
 {
     try
     {
         LogManager.WriteLog("Inside FindVoucher(),to return voucher not found", LogManager.enumLogLevel.Info);
         ticket.Status = Application.Current.Resources["CRedeemMultipleTicketRedeemVoucherNotFound"].ToString();               
         ticket.TicketStatus = -1;
         _objOnlineTicketDetail.TicketStatusCode = -1;
         _objOnlineTicketDetail.TicketString = ticket.Barcode;
         return;
     }
     catch (Exception ex)
     {
         ExceptionManager.Publish(ex);
     }
 }
        private void validateVoucher(ReedemTicketInfo ticket)
        {
            LogManager.WriteLog("Inside validateVoucher() Method", LogManager.enumLogLevel.Info);
            int iCustomerID = 0;
            IRedeemOnlineTicket _objRedeemOnlineTicket = RedeemOnlineTicketBusinessObject.CreateInstance();            
            LinqDataAccessDataContext linqDBExchange = new LinqDataAccessDataContext(CommonDataAccess.ExchangeConnectionString);
            RedeemTicket _redeemTicket = new RedeemTicket();            
            string strTableTicketNumber = string.Empty;
            int iInstallationID = 0;
            int iTicketValidationLength = 0;
            
            try
            {
                _objOnlineTicketDetail.RedeemedMachine = System.Environment.MachineName;
                _objOnlineTicketDetail.ClientSiteCode = Settings.SiteCode;


                LogManager.WriteLog("The Voucher Redeem is Validating", LogManager.enumLogLevel.Info);
                if (ticket.Barcode.Length != 18)
                {
                    LogManager.WriteLog("Checking for exact barcode if it is less than 18, The barcode is: " + ticket.Barcode, LogManager.enumLogLevel.Info);
                    
                    InstallationFromTicket _TicketInstallationDetails = linqDBExchange.GetInstallationNumber(ticket.Barcode).SingleOrDefault();
                    
                    if (_TicketInstallationDetails != null)
                    {   
                        strTableTicketNumber = _TicketInstallationDetails.strbarcode;                        
                        iInstallationID = Convert.ToInt32(_TicketInstallationDetails.installation_no);

                        LogManager.WriteLog("Barcode obtained from Table is :" + strTableTicketNumber, LogManager.enumLogLevel.Info);                       

                        //To get the validation length
                        if (iInstallationID > 0)
                        {
                            DataTable InstallationDetails = (new CommonDataAccess()).GetInstallationDetails(0, iInstallationID, false, false);
                            if (InstallationDetails.Rows.Count > 0)
                            {
                                int.TryParse(InstallationDetails.Rows[0]["Validation_length"].ToString(), out iTicketValidationLength);

                                //linqDBExchange.GetValidationLength(iInstallationID, ref iTicketValidationLength);
                                LogManager.WriteLog("The validation length for the entered barcode," + ticket.Barcode + "is:" + iTicketValidationLength, LogManager.enumLogLevel.Info);
                                if (iTicketValidationLength != 0 && ticket.Barcode.Length == iTicketValidationLength)// when validation length does not match with the barcode
                                {
                                    _objOnlineTicketDetail.TicketString = strTableTicketNumber;                                    
                                }
                                else
                                {
                                    LogManager.WriteLog("the validation length mismatch for barcode :->" + ticket.Barcode, LogManager.enumLogLevel.Info);
                                    FindVoucher(ticket);
                                    
                                }
                            }
                            else
                            {
                                LogManager.WriteLog("No installation details found for this Ticket :->" + ticket.Barcode, LogManager.enumLogLevel.Info);
                                FindVoucher(ticket);
                                
                            }
                        }
                        else
                        {

                            LogManager.WriteLog("No installation details found for this Ticket :->" + ticket.Barcode, LogManager.enumLogLevel.Info);
                            FindVoucher(ticket);
                           // _objOnlineTicketDetail.TicketString = ticket.Barcode;
                        }                    
                    }
                    else
                    {
                       
                        LogManager.WriteLog("No installation details found for this Ticket :->" + ticket.Barcode, LogManager.enumLogLevel.Info);
                        FindVoucher(ticket);
                        _objOnlineTicketDetail.TicketString = ticket.Barcode;
                    }
                }
                else               
                  _objOnlineTicketDetail.TicketString = ticket.Barcode;     
                
         
                _objOnlineTicketDetail.HostSiteCode = _objOnlineTicketDetail.TicketString.Substring(0, 4);

                LogManager.WriteLog("Validating the Voucher,Barcode is:" + _objOnlineTicketDetail.TicketString, LogManager.enumLogLevel.Info);

                ticket.Status = Application.Current.Resources["CRedeemMultipleTicketRedemptionValidating"].ToString();                
                
                _objOnlineTicketDetail = _objRedeemOnlineTicket.GetVoucherAmountAndStatusForMultipleTicket(_objOnlineTicketDetail);

                /*****************STATUS FOR VALIDATING VOUCHER*********************************
                 *******************************************************************************
                 * NORMAL VOUCHER                   *                TIS VOUCHER
                 * ******************************************************************************
                -1 Voucher not found                *              -2 TIS ticket not found,pending
                -3  Already paid					*			  -4 Already paid TIS
                -5  partially paid					*			  -6 Partially paid TIS
                -7  void voucher					*			  -8 void voucher for TIS 
                -9  cancelled voucher				*			  -10 cancelled voucher for TIS
                -11 Non cashable voucher			*			  -12 Non cashable voucher for TIS
                -13 Site code mismatch				*			  -15 Expired voucher for TIS
                -14 Expired voucher					*			   1  Valid voucher TIS
                 0  valid voucher                   *             -16 Player card required for TIS voucher
                 *                                  *             -17 TIS expired but player card requried
                 *                                                -18 TIS Effective Date Mismatch  
                 ********************************************************************************************** */

                //_objOnlineTicketDetail = _objRedeemOnlineTicket.GetRedeemTicketAmount(_objOnlineTicketDetail);
                _objOnlineTicketDetail.CustomerId = iCustomerID;
                ticket.TicketStatus = _objOnlineTicketDetail.TicketStatusCode;
                if (_objOnlineTicketDetail.TicketStatusCode == -2)
                {
                   // RTOnlineTicketDetail objTicketDetail = new RTOnlineTicketDetail();
                    IRedeemOnlineTicket objCashDeskOper = RedeemOnlineTicketBusinessObject.CreateInstance();
                    _objOnlineTicketDetail = objCashDeskOper.GetMultiRedeemTicketAmount(_objOnlineTicketDetail);

                    if (_objOnlineTicketDetail != null)
                    {   
                        if (_objOnlineTicketDetail.RedeemedAmount  > 0)
                        {

                            _objOnlineTicketDetail.RedeemedAmount = (_objOnlineTicketDetail.RedeemedAmount)/100;
                            _objOnlineTicketDetail.TicketValue = Convert.ToDouble(_objOnlineTicketDetail.RedeemedAmount);
                            _objOnlineTicketDetail.TicketStatusCode = 1;
                            ticket.TicketStatus = 1; //For making it valid tis voucher 
                            
                        }
                    }
                     
                }
                
                ticket.oRTOnlineTicketDetail = _objOnlineTicketDetail;

                string strRedeemedAmount = _objOnlineTicketDetail.TicketValue.ToString("0.00");
                
                ticket.Amount = Convert.ToDecimal(strRedeemedAmount);
        
                string str_status = "";
               // bool isTISPrintedTicket = VoucherHelper.IsTISPrintedTicketPrefix(_objOnlineTicketDetail.TicketString);

                
                _objOnlineTicketDetail.AuthorizedUser_No = Security.SecurityHelper.CurrentUser.User_No;
                _objOnlineTicketDetail.RedeemedUser = Security.SecurityHelper.CurrentUser.UserName;
               
                if (_objOnlineTicketDetail.TicketStatusCode == -234) //Exception Occured
                {
                    str_status = Application.Current.Resources["CRedeemMultipleTicketRedeemErrorMessage1"].ToString(); 
                }
                else if (_objOnlineTicketDetail.TicketStatusCode == -99) //Invalid ticket 
                {
                    str_status = Application.Current.Resources["CRedeemMultipleTicketRedeemErrorMessage2"].ToString();
                }
                else if (_objOnlineTicketDetail.TicketStatusCode == 0) //Valid Voucher
                {
                    str_status = Application.Current.Resources["CRedeemMultipleTicketRedeemValidVoucher"].ToString();
                }                
                else if (_objOnlineTicketDetail.TicketStatusCode == 1) //Valid TIS Voucher
                {
                    str_status = Application.Current.Resources["CRedeemValidTISVoucher"].ToString();
                }
               
                else if (_objOnlineTicketDetail.TicketStatusCode == -1) //Voucher not found for  normal voucher
                {
                    str_status = Application.Current.Resources["CRedeemMultipleTicketRedeemVoucherNotFound"].ToString();

                    //insert into audit
                    AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                    {

                        AuditModuleName = ModuleName.MultipleVoucherRedeem,
                        Audit_Screen_Name = "Multiple Redeem Voucher",
                        Audit_Desc = "Voucher Number -" + _objOnlineTicketDetail.TicketString,
                        AuditOperationType = OperationType.MODIFY,
                        Audit_Field = "Voucher Status",
                        Audit_New_Vl = str_status,
                        Audit_User_ID = _objOnlineTicketDetail.AuthorizedUser_No,
                        Audit_User_Name = _objOnlineTicketDetail.RedeemedUser
                    });

                }
                else if (_objOnlineTicketDetail.TicketStatusCode == -2) //TIS Voucher not found in local DB
                {
                    str_status = Application.Current.Resources["CRedeemTISMultipleTicketNotFound"].ToString();

                    //insert into audit
                    AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                    {

                        AuditModuleName = ModuleName.MultipleVoucherRedeem,
                        Audit_Screen_Name = "Multiple Redeem Voucher",
                        Audit_Desc = "TIS Voucher Number -" + _objOnlineTicketDetail.TicketString,
                        AuditOperationType = OperationType.MODIFY,
                        Audit_Field = "Voucher Status",
                        Audit_New_Vl = str_status,
                        Audit_User_ID = _objOnlineTicketDetail.AuthorizedUser_No,
                        Audit_User_Name = _objOnlineTicketDetail.RedeemedUser
                    });
                }
                else if (_objOnlineTicketDetail.TicketStatusCode == -3) //Already Paid
                {
                    str_status = Application.Current.Resources["CRedeemMultipleTicketRedeemAlreadyPaid"].ToString();

                    //insert into audit
                    AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                    {

                        AuditModuleName = ModuleName.MultipleVoucherRedeem,
                        Audit_Screen_Name = "Multiple Redeem Voucher",
                        Audit_Desc = "Voucher Number -" + _objOnlineTicketDetail.TicketString,
                        AuditOperationType = OperationType.MODIFY,
                        Audit_Field = "Voucher Status",
                        Audit_New_Vl = str_status,
                        Audit_User_ID = _objOnlineTicketDetail.AuthorizedUser_No,
                        Audit_User_Name = _objOnlineTicketDetail.RedeemedUser
                    });



                }
                else if (_objOnlineTicketDetail.TicketStatusCode == -4) //TIS Already Paid
                {
                    str_status = Application.Current.Resources["CRedeemMultipleVoucherAlreadyPaidTISVoucher"].ToString();

                    //insert into audit
                    AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                    {

                        AuditModuleName = ModuleName.MultipleVoucherRedeem,
                        Audit_Screen_Name = "Multiple Redeem Voucher",
                        Audit_Desc = "TIS Voucher Number -" + _objOnlineTicketDetail.TicketString,
                        AuditOperationType = OperationType.MODIFY,
                        Audit_Field = "Voucher Status",
                        Audit_New_Vl = str_status,
                        Audit_User_ID = _objOnlineTicketDetail.AuthorizedUser_No,
                        Audit_User_Name = _objOnlineTicketDetail.RedeemedUser
                    });

                }
                else if (_objOnlineTicketDetail.TicketStatusCode == -5) //Partially paid
                {
                    str_status = Application.Current.Resources["CRedeemMultipleTicketsPartiallyPaidTickets"].ToString();

                    //insert into audit
                    AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                    {

                        AuditModuleName = ModuleName.MultipleVoucherRedeem,
                        Audit_Screen_Name = "Multiple Redeem Voucher",
                        Audit_Desc = "Voucher Number -" + _objOnlineTicketDetail.TicketString,
                        AuditOperationType = OperationType.MODIFY,
                        Audit_Field = "Voucher Status",
                        Audit_New_Vl = str_status,
                        Audit_User_ID = _objOnlineTicketDetail.AuthorizedUser_No,
                        Audit_User_Name = _objOnlineTicketDetail.RedeemedUser
                    });
                }
                else if (_objOnlineTicketDetail.TicketStatusCode == -6) //TIS Partially paid
                {
                    str_status = Application.Current.Resources["CRedeemMultipleVoucherPartiallyPaidTISVoucher"].ToString();

                    //insert into audit
                    AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                    {

                        AuditModuleName = ModuleName.MultipleVoucherRedeem,
                        Audit_Screen_Name = "Multiple Redeem Voucher",
                        Audit_Desc = "TIS Voucher Number -" + _objOnlineTicketDetail.TicketString,
                        AuditOperationType = OperationType.MODIFY,
                        Audit_Field = "Voucher Status",
                        Audit_New_Vl = str_status,
                        Audit_User_ID = _objOnlineTicketDetail.AuthorizedUser_No,
                        Audit_User_Name = _objOnlineTicketDetail.RedeemedUser
                    });
                }
                else if (_objOnlineTicketDetail.TicketStatusCode == -7) //Voided ticket
                {
                    str_status = Application.Current.Resources["CRedeemMultipleTicketsVoidticket"].ToString();

                    //insert into audit
                    AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                    {

                        AuditModuleName = ModuleName.MultipleVoucherRedeem,
                        Audit_Screen_Name = "Multiple Redeem Voucher",
                        Audit_Desc = "Voucher Number -" + _objOnlineTicketDetail.TicketString,
                        AuditOperationType = OperationType.MODIFY,
                        Audit_Field = "Voucher Status",
                        Audit_New_Vl = str_status,
                        Audit_User_ID = _objOnlineTicketDetail.AuthorizedUser_No,
                        Audit_User_Name = _objOnlineTicketDetail.RedeemedUser
                    });
                }
                else if (_objOnlineTicketDetail.TicketStatusCode == -8) //TIS Voided ticket
                {
                    str_status = Application.Current.Resources["CRedeemMultipleVoucherVoidTISVoucher"].ToString();

                    //insert into audit
                    AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                    {

                        AuditModuleName = ModuleName.MultipleVoucherRedeem,
                        Audit_Screen_Name = "Multiple Redeem Voucher",
                        Audit_Desc = "TIS Voucher Number -" + _objOnlineTicketDetail.TicketString,
                        AuditOperationType = OperationType.MODIFY,
                        Audit_Field = "Voucher Status",
                        Audit_New_Vl = str_status,
                        Audit_User_ID = _objOnlineTicketDetail.AuthorizedUser_No,
                        Audit_User_Name = _objOnlineTicketDetail.RedeemedUser
                    });
                }
                else if (_objOnlineTicketDetail.TicketStatusCode == -9) //Cancelled VOucher
                {
                    str_status = Application.Current.Resources["CRedeemMultipleTicketsCancelledTickets"].ToString();

                    //insert into audit
                    AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                    {

                        AuditModuleName = ModuleName.MultipleVoucherRedeem,
                        Audit_Screen_Name = "Multiple Redeem Voucher",
                        Audit_Desc = "Voucher Number -" + _objOnlineTicketDetail.TicketString,
                        AuditOperationType = OperationType.MODIFY,
                        Audit_Field = "Voucher Status",
                        Audit_New_Vl = str_status,
                        Audit_User_ID = _objOnlineTicketDetail.AuthorizedUser_No,
                        Audit_User_Name = _objOnlineTicketDetail.RedeemedUser
                    });
                }
                else if (_objOnlineTicketDetail.TicketStatusCode == -10) //TIS Cancelled VOucher
                {
                    str_status = Application.Current.Resources["CRedeemMultipleVoucherTISCancelledVoucher"].ToString();

                    //insert into audit
                    AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                    {

                        AuditModuleName = ModuleName.MultipleVoucherRedeem,
                        Audit_Screen_Name = "Multiple Redeem Voucher",
                        Audit_Desc = "Voucher Number -" + _objOnlineTicketDetail.TicketString,
                        AuditOperationType = OperationType.MODIFY,
                        Audit_Field = "Voucher Status",
                        Audit_New_Vl = str_status,
                        Audit_User_ID = _objOnlineTicketDetail.AuthorizedUser_No,
                        Audit_User_Name = _objOnlineTicketDetail.RedeemedUser
                    });
                }
                else if (_objOnlineTicketDetail.TicketStatusCode == -11) //Non Cashable
                {
                    str_status = Application.Current.Resources["CRedeemMultipleTicketsNonCashableTickets"].ToString();

                    //insert into audit
                    AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                    {

                        AuditModuleName = ModuleName.MultipleVoucherRedeem,
                        Audit_Screen_Name = "Multiple Redeem Voucher",
                        Audit_Desc = "Voucher Number -" + _objOnlineTicketDetail.TicketString,
                        AuditOperationType = OperationType.MODIFY,
                        Audit_Field = "Voucher Status",
                        Audit_New_Vl = str_status,
                        Audit_User_ID = _objOnlineTicketDetail.AuthorizedUser_No,
                        Audit_User_Name = _objOnlineTicketDetail.RedeemedUser
                    });
                }
                else if (_objOnlineTicketDetail.TicketStatusCode == -12) // TIS Non Cashable
                {
                    str_status = Application.Current.Resources["CRedeemMultipleVoucherTISNonCashableVoucher"].ToString();

                    //insert into audit
                    AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                    {

                        AuditModuleName = ModuleName.MultipleVoucherRedeem,
                        Audit_Screen_Name = "Multiple Redeem Voucher",
                        Audit_Desc = "Voucher Number -" + _objOnlineTicketDetail.TicketString,
                        AuditOperationType = OperationType.MODIFY,
                        Audit_Field = "Voucher Status",
                        Audit_New_Vl = str_status,
                        Audit_User_ID = _objOnlineTicketDetail.AuthorizedUser_No,
                        Audit_User_Name = _objOnlineTicketDetail.RedeemedUser
                    });
                }
                else if (_objOnlineTicketDetail.TicketStatusCode == -13) //Site Code Mismatch
                {
                    str_status = Application.Current.Resources["CRedeemMultipleTicketsSiteCodeMismatch"].ToString();

                    //insert into audit
                    AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                    {

                        AuditModuleName = ModuleName.MultipleVoucherRedeem,
                        Audit_Screen_Name = "Multiple Redeem Voucher",
                        Audit_Desc = "Voucher Number -" + _objOnlineTicketDetail.TicketString,
                        AuditOperationType = OperationType.MODIFY,
                        Audit_Field = "Voucher Status",
                        Audit_New_Vl = str_status,
                        Audit_User_ID = _objOnlineTicketDetail.AuthorizedUser_No,
                        Audit_User_Name = _objOnlineTicketDetail.RedeemedUser
                    });
                }

                else if (_objOnlineTicketDetail.TicketStatusCode == -14) //Expired
                {
                    if (Security.SecurityHelper.HasAccess("CashdeskOperator.Authorize.cs.MultipleRedeemExpiredTicket"))
                    {
                        str_status = Application.Current.Resources["CRedeemMultipleTicketRedeemExpired"].ToString();
                    }
                    else
                    {
                        str_status = Application.Current.Resources["CRedeemExpireUserAccess"].ToString();

                        AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                        {

                            AuditModuleName = ModuleName.MultipleVoucherRedeem,
                            Audit_Screen_Name = "Multiple Redeem Voucher",
                            Audit_Desc = "Expired Voucher Number -" + _objOnlineTicketDetail.TicketString,
                            AuditOperationType = OperationType.MODIFY,
                            Audit_Field = "Voucher Status",
                            Audit_New_Vl = Application.Current.Resources["CRedeemExpireUserAccess"].ToString(),
                            Audit_User_ID = _objOnlineTicketDetail.AuthorizedUser_No,
                            Audit_User_Name = _objOnlineTicketDetail.RedeemedUser
                        });
                    }
                }
                else if (_objOnlineTicketDetail.TicketStatusCode == -15) //TIS Expired
                {
                    if (Security.SecurityHelper.HasAccess("CashdeskOperator.Authorize.cs.MultipleRedeemExpiredTicket"))
                    {
                        str_status = Application.Current.Resources["CRedeemMultipleVoucherTISExpiredVoucher"].ToString();
                    }
                    else
                    {
                        str_status = Application.Current.Resources["CRedeemTISExpireUserAccess"].ToString();

                        AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                        {

                            AuditModuleName = ModuleName.MultipleVoucherRedeem,
                            Audit_Screen_Name = "Multiple Redeem Voucher",
                            Audit_Desc = "Expired Voucher Number -" + _objOnlineTicketDetail.TicketString,
                            AuditOperationType = OperationType.MODIFY,
                            Audit_Field = "Voucher Status",
                            Audit_New_Vl = Application.Current.Resources["CRedeemExpireUserAccess"].ToString(),
                            Audit_User_ID = _objOnlineTicketDetail.AuthorizedUser_No,
                            Audit_User_Name = _objOnlineTicketDetail.RedeemedUser
                        });
                    }

                }
                else if (_objOnlineTicketDetail.TicketStatusCode == -16)//TIS valid player details required , cannot redeem here
                {
                    str_status = Application.Current.Resources["CRedeemTISMultipleVoucherPlayerDetailsRequired"].ToString();
                }
                else if (_objOnlineTicketDetail.TicketStatusCode == -17)//TIS expired voucher player details required , cannot redeem here-expired
                {
                    str_status = Application.Current.Resources["CRedeemTISMultipleVoucherExpiredPlayerdetailsRequired"].ToString();
                }

                else if (_objOnlineTicketDetail.TicketStatusCode == -18)//TIS Effective date mismatch
                {
                    str_status = Application.Current.Resources["CRedeemsTISEffectiveDateMismatch"].ToString();
                }
                else if (_objOnlineTicketDetail.TicketStatusCode == -990) // When TIS web service hits fails
                {
                    str_status = Application.Current.Resources["CRedeemsTISWebServiceError"].ToString();
                }

               
                #region offlineVoucherHandler-Commented
                    //if (!_objOnlineTicketDetail.ShowOfflineTicketScreen)
                    //{
                    // str_status = Application.Current.Resources["CRedeemMultipleTicketRedeemVoucherNotFound"].ToString();
                    //}
                    //else
                    //{
                    //_iCheckOfflineVoucher = _redeemTicket.CheckSDGOfflineTicket(ticket.Barcode); //checks whether it is offline voucher or not
                    //if (_iCheckOfflineVoucher == -14) //since SP returns -14 if its offline voucher
                    //{
                    //    str_status = Application.Current.Resources["CRedeemMultipleTicketsOfflineTickets"].ToString();
                    //}
                    //else
                    //{
                    //    str_status = Application.Current.Resources["CRedeemMultipleTicketRedeemVoucherNotFound"].ToString();
                    //}
                //} 
                #endregion offlineVoucherHandler-Commented


                Dispatcher.BeginInvoke((Action)(() =>
                     {
                         ticket.Status = str_status;
                         LogManager.WriteLog("the Barcode " + ticket.Barcode + "has returned" + str_status, LogManager.enumLogLevel.Info);
                     }), null);

            }
            catch (Exception Ex)
            {
                ExceptionManager.Publish(Ex);
            }
        }