private  List<TicketExceptions> LoadTicketsAll()
        {
            objCashDeskManager = CashDeskManagerBusinessObject.CreateInstance();

            List<string> lstPositionstoDisplay = objCashDeskManager.FillListOfFilteredPositions(RouteNumber);


            Tickets oTickets = new Tickets();
            oTickets.EndDate = EndDate;
            oTickets.StartDate = StartDate;
            oTickets.IsLiability = false;
            oTickets.BarCode = "%";
            oTickets.Type = "A";
            oTickets.UserNo = UserNo;
            System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate
             {
                 prgDebugState.Value += 50;
             });
            List<TicketExceptions> lstExceptions = objCashDeskManager.TitoTicketsAll(oTickets, lstPositionstoDisplay);

            System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate
            {
                prgDebugState.Value += 150;
            });
            return lstExceptions;
        }
        private  List<TicketExceptions> LoadTicketsAll()
        {
            busTreasury = new TreasuryTransactions();

            List<string> lstPositionstoDisplay = busTreasury.FillListOfFilteredPositions(RouteNumber);


            Tickets oTickets = new Tickets();
            oTickets.EndDate = EndDate + " " + EndTime;
            oTickets.StartDate = StartDate + " " + StartTime;
            oTickets.IsLiability = false;
            oTickets.BarCode = "%";
            oTickets.Type = "A";
            System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate
             {
                 prgDebugState.Value += 50;
             });
            List<TicketExceptions> lstExceptions = busTreasury.TitoTicketsAll(oTickets, lstPositionstoDisplay);

            System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate
            {
                prgDebugState.Value += 150;
            });
            return lstExceptions;
        }
        private List<TicketExceptions> LoadVoidExpiredTickets()
        {
            busTreasury = new TreasuryTransactions();
            System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate
               {
                   lvVoidExpired.Items.Clear();
               });

            List<string> lstPositionstoDisplay = busTreasury.FillListOfFilteredPositions(RouteNumber);

            Tickets oTickets = new Tickets();
            oTickets.EndDate = EndDate + " " + EndTime;
            oTickets.StartDate = StartDate + " " + StartTime;
            oTickets.IsLiability = false;
            oTickets.BarCode = "%";
            oTickets.Type = "D";
            System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate
            {
                prgVoidExpiredState.Value += 75;
            });

            List<TicketExceptions> lstVoidExpired = busTreasury.GetTicket_VoidnExpired(oTickets, lstPositionstoDisplay);


            decimal ExceptionTotal = 0;
            TicketExceptions Total = new TicketExceptions();
            Total.PrintDate = "Total";

            if (lstVoidExpired != null)
            {
                foreach (TicketExceptions exep in lstVoidExpired)
                {
                    ExceptionTotal += (decimal)exep.Value;
                }

                Total.Value = (double)Decimal.Round(ExceptionTotal, 2);
                lstVoidExpired.Insert(0, Total);
                System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate
                {
                    prgVoidExpiredState.Value += 50;
                });
            }

            return lstVoidExpired;
        }
        public  List<TicketExceptions> TitoTicketsPrinted(Tickets oTickets, List<string> lstPositionstoDisplay)
        {
            string strTicketInException = string.Empty;
            string sPosTer = string.Empty;
            List<TicketExceptions> lstTickets = null;
            TicketExceptions excep = null;
            double CurrentCashDesk = 0, currEGM = 0;

            try
            {
                DataTable dtTickets = GetTickets(oTickets);
                if (dtTickets == null || dtTickets.Rows.Count < 0)
                {
                }
                else
                {
                    lstTickets = new List<TicketExceptions>();

                    foreach (DataRow row in dtTickets.Rows)
                    {
                        excep = new TicketExceptions();
                        excep.bExceptionRecordFound = false;
                        excep.SEGM = row["PrintDevice"].ToString();
                        excep.VoucherStatus = row["strVoucherStatus"].ToString();
                        excep.TicketAddedtoList = false;
                        excep.currValue = (float)Convert.ToDouble(row["iAmount"]) / 100;
                        if (!string.IsNullOrEmpty(excep.SEGM))
                        {
                            if (row["strDeviceType"].ToString().Equals("EXTITO") || string.IsNullOrEmpty(row["strDeviceType"].ToString()))
                            {
                                if (DBCommon.IsMachineATicketWorkstation(excep.SEGM))
                                {
                                    sPosTer = excep.SEGM;
                                    excep.Position = excep.SEGM;
                                    excep.Machine = "";
                                    CurrentCashDesk += excep.currValue;

                                    excep.CashDeskPrintedQty += 1;
                                    if (oTickets.IsPrintedInCashDesk)
                                    {
                                        excep.TicketAddedtoList = true;
                                    }
                                }
                                else
                                {
                                    sPosTer = string.Empty;
                                    excep.Machine = GetBarPositionFromAsset(excep.SEGM);
                                    if (DBCommon.CheckPositionToDisplay(excep.Machine, lstPositionstoDisplay))
                                    {
                                        currEGM += excep.currValue;
                                        excep.MachinePrintedQty += 1;
                                        if (oTickets.IsPrintedInMachine)
                                        {
                                            excep.TicketAddedtoList = true;
                                        }
                                    }
                                    else
                                    {
                                        excep.TicketAddedtoList = false;
                                    }
                                }
                            }
                            else
                            {
                                excep.Position = GetBarPositionFromAsset(excep.SEGM);
                                excep.Machine = "";
                                excep.CurrentCashDesk += excep.currValue;

                                excep.CashDeskPrintedQty += 1;
                                excep.TicketAddedtoList = true;
                            }
                        }

                        if (excep.TicketAddedtoList)
                        {
                            excep.Value = Convert.ToDouble(row["iAmount"]) / 100;
                            //excep.Amount = excep.Value.ToString("###0.#0");
                            excep.Amount = CurrencySymbol + " " + Convert.ToDecimal(excep.Value).GetUniversalCurrencyFormat();
                            string dPrintDate = row["dtPrinted"].ToString().ToShortDateTimeString();
                            string dClaimDate = string.IsNullOrEmpty(row["dtPaid"].ToString()) ? "01/01/2100" : row["dtPaid"].ToString();

                            if(excep.MachinePrintedQty > 0)
                                excep.TransactionType = "M/c Voucher Issued";
                            else if(excep.CashDeskPrintedQty > 0)
                                excep.TransactionType = "C/D Voucher Issued";
                            
                            excep.Zone = "n/a";
                            excep.Asset = row["Asset"].ToString();


                            if ((Convert.ToDateTime(row["dtPrinted"].ToString()) >= Convert.ToDateTime(oTickets.StartDate)) &&
                                (Convert.ToDateTime(string.IsNullOrEmpty(row["dtPaid"].ToString()) ? DateTime.Now.ToString() : row["dtPaid"].ToString())
                                <= Convert.ToDateTime(oTickets.EndDate)))
                            {
                                excep.Status = "Printed within, Claimed in different category";
                            }
                            else if (string.IsNullOrEmpty(row["dtPaid"].ToString()))
                            {
                                excep.Status = "Active Ticket";
                            }
                            else
                            {
                                excep.Value = -excep.Value;
                                //  excep.Amount = excep.Value.ToString("###0.#0");
                                excep.Amount = CurrencySymbol + " " + Convert.ToDecimal(excep.Value).GetUniversalCurrencyFormat();
                                excep.Status = "Printed within period, claimed later";
                            }
                            excep.Position = sPosTer;


                            excep.PrintDate = row["dtPrinted"].ToString().ToShortDateTimeString();
                          //  excep.PrintDate = row["dtPrinted"].ToShortDateTimeString();
                         
                            if (!(row["dtPrinted"] == null))
                            {
                                excep.PayDate = Convert.ToDateTime(row["dtPrinted"]) != null ?  row["dtPrinted"].ToString().ToShortDateTimeString() :
                                    string.Empty;
                             }
                            excep.PayDate = Convert.ToDateTime(row["dtPrinted"]) != null ? row["dtPrinted"].ToString().ToShortDateTimeString() :
                                    string.Empty;
                          
                            excep.PayDevice = (row["PayDevice"] != null ? row["PayDevice"].ToString() : string.Empty);

                            if (!string.IsNullOrEmpty(row["strBarCode"].ToString()))
                            {
                                excep.Ticket = row["ActualBarcode"].ToString();
                            }
                            else
                            {
                                excep.Ticket = row["strBarcode"].ToString();
                            }
                            // excep.Details = excep.Ticket;
                            excep.Details = string.Empty;
                         
                        }
                        lstTickets.Add(excep); 
                    }
                }

            }

            catch (Exception ex)
            {
                LogManager.WriteLog(ex.Message, LogManager.enumLogLevel.Info);
                ExceptionManager.Publish(ex);
            }
            if (lstTickets != null && lstTickets.Count > 0)
            {
                lstTickets[0].currEGM = currEGM;
                lstTickets[0].CurrentCashDesk = CurrentCashDesk;
            }

            return lstTickets;
        }
        private List<TicketExceptions> LoadVoidCancelledTickets()
        {
            objCashDeskManager = CashDeskManagerBusinessObject.CreateInstance();

            System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate
               {
                   lvVoidCancelled.Items.Clear();
               });
            List<string> lstPositionstoDisplay = objCashDeskManager.FillListOfFilteredPositions(RouteNumber);

            Tickets oTickets = new Tickets();
            oTickets.EndDate = EndDate;
            oTickets.StartDate = StartDate;
            oTickets.IsLiability = false;
            oTickets.BarCode = "%";
            oTickets.Type = "B";
            oTickets.UserNo = UserNo;

            System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate
            {
                prgVoidcancelled.Value += 50;
            });

            List<TicketExceptions> lstVoidCancelled = objCashDeskManager.GetTicket_VoidnExpired(oTickets, lstPositionstoDisplay);

            if (lstVoidCancelled != null)
            {
                decimal ExceptionTotal = 0;
                TicketExceptions Total = new TicketExceptions();
                Total.PrintDate = "Total";
                foreach (TicketExceptions exep in lstVoidCancelled)
                {
                    ExceptionTotal += (decimal)exep.Value;
                }
                Total.Value = (double)Decimal.Round(ExceptionTotal, 2);
               // Total.Amount = Total.Value.ToString("###0.#0");
                Total.Amount = CurrencySymbol + "" + Convert.ToDecimal(ExceptionTotal).GetUniversalCurrencyFormat();
                lstVoidCancelled.Insert(0, Total);

                System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate
                {
                    prgVoidcancelled.Value += 50;
                });
            }

            return lstVoidCancelled;
            
        }
        private List<TicketExceptions> LoadLiabilities()
        {
            busTreasury = new TreasuryTransactions();
            System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate
             {
                 lvLiability.Items.Clear();
             });
            List<string> lstPositionstoDisplay = busTreasury.FillListOfFilteredPositions(RouteNumber);


            TicketsClaimed oTicketsClaimed = new TicketsClaimed();
            oTicketsClaimed.TicketsClaimedFrom = StartDate + " " + StartTime;
            oTicketsClaimed.TicketsClaimedTo = EndDate + " " + EndTime;

            Tickets oTickets = new Tickets();
            oTickets.EndDate = EndDate + " " + EndTime;
            oTickets.StartDate = StartDate + " " + StartTime;
            oTickets.IsLiability = true;
            oTickets.BarCode = "%";
            oTickets.Type = "C";

            System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate
            {
                prgLiability.Value += 50;
            });
            List<TicketExceptions> lstTitoTicketsClaimed = busTreasury.TitoTicketsClaimedLiability(oTickets, lstPositionstoDisplay);
            if (lstTitoTicketsClaimed == null)
            {
                lstTitoTicketsClaimed = new List<TicketExceptions>();
            }

            oTickets.Type = "P";

            System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate
            {
                prgLiability.Value += 50;
            });
            List<TicketExceptions> lstTitoTicketsPrinted = busTreasury.TitoTicketsPrintedLiability(oTickets, lstPositionstoDisplay);
            //lvLiability.ItemsSource = lstTitoTicketsPrinted;

            if (lstTitoTicketsPrinted != null)
            {
                foreach (TicketExceptions item in lstTitoTicketsPrinted)
                {
                    lstTitoTicketsClaimed.Add(item);
                }
            }
            System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate
            {
                prgLiability.Value += 50;
            });
            List<TicketExceptions> lstTicketsClaimed = busTreasury.TicketsClaimed(oTicketsClaimed, lstPositionstoDisplay);
            if (lstTicketsClaimed != null)
            {
                foreach (TicketExceptions item in lstTicketsClaimed)
                {
                    lstTitoTicketsClaimed.Add(item);
                }
                //lvLiability.ItemsSource = lstTicketsClaimed;
            }
            System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate
            {
                prgLiability.Value += 50;
            });
            List<TicketExceptions> lstTicketsPrinted = busTreasury.TicketsPrinted(oTicketsClaimed, lstPositionstoDisplay);
            if (lstTicketsPrinted != null)
            {
                foreach (TicketExceptions item in lstTicketsPrinted)
                {
                    lstTitoTicketsClaimed.Add(item);
                }
                // lvLiability.ItemsSource = lstTicketsPrinted;
            }


            float ExceptionTotal = 0F;
            TicketExceptions Total = new TicketExceptions();
            Total.PrintDate = "Total";
            foreach (TicketExceptions exep in lstTitoTicketsClaimed)
            {
                ExceptionTotal += (float)exep.Value;
            }
            Total.Value = ExceptionTotal;
            Total.Amount = ExceptionTotal.ToString();
            lstTitoTicketsClaimed.Insert(0, Total);
            System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate
            {
                prgLiability.Value += 50;
            });

            return lstTitoTicketsClaimed;
        }
        public List<TicketExceptions> TITOTicketInExceptions(Tickets oTickets, List<string> lstPositions)
        {
            //            '
            //'
            //Dim oRs             As adodb.Recordset
            //Dim myItem          As ListItem
            //Dim cTicketTotal    As Currency
            //Dim currValue       As Currency
            string strTicketInException = string.Empty;
            List<TicketExceptions> lstTickets = null;
           
            try
            {
                if (DBBuilder.GetTickets(oTickets) == null && DBBuilder.GetTickets(oTickets).Rows.Count < 0)
                {
                }
                else
                {
                
                    lstTickets = new List<TicketExceptions>();
                    TicketExceptions excep = null;
                    DataTable dtTickets = DBBuilder.GetTickets(oTickets);
                    foreach (DataRow row in dtTickets.Rows)
                    {
                        excep = new TicketExceptions();
                        excep.SEGM = row["PrintDevice"].ToString();
                        excep.Machine = DBBuilder.GetBarPositionFromAsset(row["PrintDevice"].ToString());
                        excep.currValue = (float)Convert.ToDouble(row["iAmount"]) / 100;
                        if (!string.IsNullOrEmpty(excep.SEGM) && DBCommon.CheckPositionToDisplay(excep.Machine, lstPositions))
                        {
                            excep.bExceptionRecordFound = true;
                            excep.Type = "IN";
                            excep.Position = DBBuilder.GetBarPositionFromAsset(row["PrintDevice"].ToString());
                            excep.PrintDate = Convert.ToDateTime(row["dtPrinted"]).ToString("dd MMM yyyy") + " " +
                                Convert.ToDateTime(row["dtPrinted"]).ToString("HH:mm");
                            if (!string.IsNullOrEmpty(row["strBarCode"].ToString()))
                            {
                                excep.Ticket = row["ActualBarcode"].ToString();
                            }
                            else
                            {
                                excep.Ticket = row["strBarcode"].ToString();
                            }
                            excep.Value = Convert.ToDouble(row["iAmount"]) / 100;
                            excep.Asset = row["PrintDevice"].ToString();
                            excep.PayDevice = row["PayDevice"].ToString();
                            excep.CreateCompleted = string.Empty;

                            excep.cTicketTotal += excep.currValue;
                            excep.cExceptionsTotal += excep.currValue;
                        }
                        else if (DBCommon.IsMachineATicketWorkstation(row["PrintDevice"].ToString()))
                        {
                            excep.bExceptionRecordFound = true;
                            excep.Type = "IN";
                            excep.Position = DBBuilder.GetBarPositionFromAsset(row["PrintDevice"].ToString());
                            excep.PrintDate = Convert.ToDateTime(row["dtPrinted"]).ToString("dd MMM yyyy") + " " +
                                Convert.ToDateTime(row["dtPrinted"]).ToString("HH:mm");
                            if (!string.IsNullOrEmpty(row["strBarCode"].ToString()))
                            {
                                excep.Ticket = row["ActualBarcode"].ToString();
                            }
                            else
                            {
                                excep.Ticket = row["strBarcode"].ToString();
                            }
                            excep.Value = Convert.ToDouble(row["iAmount"]) / 100;
                            excep.Asset = row["PrintDevice"].ToString();
                            excep.PayDevice = row["PayDevice"].ToString();
                            excep.CreateCompleted = string.Empty;

                            excep.cTicketTotal += excep.currValue;
                            excep.cExceptionsTotal += excep.currValue;
                        }
                        lstTickets.Add(excep);
                    }
                }

            }

            catch (Exception ex)
            {
                LogManager.WriteLog(ex.Message, LogManager.enumLogLevel.Info);
                ExceptionManager.Publish(ex);
            }
            return lstTickets;

        }
        public static DataTable GetTickets(Tickets oTickets)
        {
            DataTable dtTickets = null;
            try
            {
                string strVoucherInformation = "rsp_BGS_VoucherInformation";

                dtTickets = ExecuteTable(strVoucherInformation, oTickets);
                return dtTickets;
            }
            catch (Exception ex)
            {
                LogManager.WriteLog(ex.Message, LogManager.enumLogLevel.Info);
                ExceptionManager.Publish(ex);
                return dtTickets;
            }

        }
        public static List<TicketExceptions> TitoTicketsClaimed(Tickets oTickets, List<string> lstPositionstoDisplay)
        {
            string strTicketInException = string.Empty;
            string sPosTer = string.Empty;
            List<TicketExceptions> lstTickets = null;
            TicketExceptions excep = null;

            try
            {
                DataTable dtTickets = DBBuilder.GetTickets(oTickets);
                if (dtTickets == null && dtTickets.Rows.Count < 0)
                {
                }
                else
                {
                    lstTickets = new List<TicketExceptions>();

                    foreach (DataRow row in dtTickets.Rows)
                    {
                        excep = new TicketExceptions();
                        excep.bExceptionRecordFound = false;
                        excep.SEGM = row["PayDevice"].ToString();
                        excep.currValue = (float)Convert.ToDouble(row["iAmount"]) / 100;
                        if (!string.IsNullOrEmpty(excep.SEGM) && row["strDeviceType"].ToString().Equals("EXTITO"))
                        {
                            if (DBCommon.IsMachineATicketWorkstation(excep.SEGM))
                            {
                                if (DBCommon.CheckPositionToDisplay(GetBarPositionFromAsset(row["PrintDevice"].ToString()), lstPositionstoDisplay))
                                {
                                    sPosTer = excep.SEGM;
                                    excep.Machine = GetBarPositionFromAsset(row["PrintDevice"].ToString());
                                    excep.CurrentCashDesk += excep.currValue;
                                    excep.CashDeskClaimedQty += 1;
                                    if (oTickets.IsClaimedInCashDesk == true)
                                    {
                                        excep.bExceptionRecordFound = true;
                                    }
                                }
                            }
                            else
                            {
                                sPosTer = string.Empty;
                                excep.Machine = GetBarPositionFromAsset(excep.SEGM);

                                if (DBCommon.CheckPositionToDisplay(excep.Machine, lstPositionstoDisplay))
                                {
                                    excep.currEGM += excep.currValue;
                                    excep.MachineClaimedQty += 1;
                                    if (oTickets.IsClaimedInMachine)
                                    {
                                        excep.bExceptionRecordFound = true;
                                    }
                                }
                            }
                        }
                        else
                        {
                            sPosTer = row["PrintDevice"].ToString();
                            excep.Machine = row["PayDevice"].ToString();
                            excep.CurrentCashDesk += excep.currValue;
                            excep.CashDeskClaimedQty += 1;
                            if (oTickets.IsClaimedInCashDesk)
                            {
                                excep.bExceptionRecordFound = true;
                            }
                        }
                        if (excep.bExceptionRecordFound)
                        {

                            string dPrintDate = row["dtPrinted"].ToString();
                            string dClaimDate = row["dtPaid"].ToString();


                            excep.Position = sPosTer;
                            excep.Machine = DBBuilder.GetBarPositionFromAsset(excep.Machine);
                           // excep.Machine = sPosTer;
                            excep.TransactionType="TITO Claimed";
                            excep.Zone = "n/a";

                            excep.PrintDate = Convert.ToDateTime(row["dtPrinted"]).ToString("dd MMM yyyy") + " " +
                                Convert.ToDateTime(row["dtPrinted"]).ToString("HH:mm");

                            if (!(row["dtPaid"] == null))
                            {
                                excep.PayDate = Convert.ToDateTime(row["dtPaid"] != null ? row["dtPaid"] : string.Empty).ToString("dd MMM yyyy") + " " +
                                                Convert.ToDateTime(row["dtPaid"] != null ? row["dtPaid"] : string.Empty).ToString("hh:mm");
                            }


                            excep.PayDevice = (row["PayDevice"] != null ? GetBarPositionFromAsset(row["PayDevice"].ToString()) : string.Empty);

                            if (!string.IsNullOrEmpty(row["strBarCode"].ToString()))
                            {
                                excep.Ticket = row["ActualBarcode"].ToString();
                            }
                            else
                            {
                                excep.Ticket = row["strBarcode"].ToString();
                            }
                            excep.Value = -(Convert.ToDouble(row["iAmount"]) / 100);
                            excep.Amount = (-(excep.Value)).ToString();


                            if ((Convert.ToDateTime(dPrintDate) >= Convert.ToDateTime(oTickets.StartDate)) &&
                                (Convert.ToDateTime(dClaimDate) <= Convert.ToDateTime(oTickets.EndDate)))
                            {
                                excep.Status = "Printed in different category, Claimed within";
                            }
                            else
                            {
                                excep.Status = "Printed prior to period, Claimed within";
                            }
                            excep.Details = "";
                            excep.cExceptionsTotal += (float)excep.Value;
                            
                        }

                        lstTickets.Add(excep);
                    }
                }

            }

            catch (Exception ex)
            {
                LogManager.WriteLog(ex.Message, LogManager.enumLogLevel.Info);
                ExceptionManager.Publish(ex);
            }
            return lstTickets;
        }
 private static DataTable ExecuteTable(string ExchangeConnectionString, Tickets oTickets,bool flag)
 {
     return SqlHelper.ExecuteDataset(ExchangeConnectionString, DBConstants.CONST_SP_RSP_GETTREASURYITEMS,
         GetTreasuryParameters(oTickets)).Tables[0];
     // return SqlHelper.ExecuteDataset(SQLConnection(), StoredProcedure,CommandType.StoredProcedure, GetVoucherParameters(oTickets)).Tables[0];
 }
        private static object[] GetVoucherParameters(Tickets oTickets)
        {
            SqlParameter[] ObjParams = new SqlParameter[5];
            ObjParams[0] = new SqlParameter(DBConstants.CONST_PARAM_STARTDATE, oTickets.StartDate);
            ObjParams[1] = new SqlParameter(DBConstants.CONST_PARAM_ENDDATE, oTickets.EndDate);
            ObjParams[2] = new SqlParameter(DBConstants.CONST_PARAM_TYPE, oTickets.Type);
            ObjParams[3] = new SqlParameter(DBConstants.CONST_PARAM_BARCODE, oTickets.BarCode);
            ObjParams[4] = new SqlParameter(DBConstants.CONST_PARAM_LIABILITY, Convert.ToInt16(oTickets.IsLiability));

            return ObjParams;
        }
        private List<TicketExceptions> LoadCashDeskDetails()
        {
            string szErrDesc = string.Empty;
            double cTicketClaimedTotalCashdesk = 0, cTicketPrintedTotalCashdesk = 0, cTicketPrintedTotalEGM = 0,
                cTicketClaimedTotalEGM = 0, cTicketsUnclaimed = 0, cTicketInExceptions = 0, cTicketOutExceptions = 0;
            double currEGM = 0, currCashdesk = 0, cTicketsVoid = 0, cTicketsExpired = 0, cTicketCancelled = 0;

            double cRefundTotal = 0, cRefillTotal = 0, cShortpayTotal = 0, cHandPayTotal = 0, cCashDeskFloatTotal = 0,
                cProgressiveTotal = 0, cJackpotTotal = 0;

            double RefillQty = 0, RefundQty = 0, ShortpayQty = 0, HandpayQty = 0, CashDeskFloatQty = 0,
                ProgressiveQty = 0, JackpotQty = 0, CashDeskClaimedQty = 0, MachineClaimedQty = 0, CashDeskPrintedQty = 0, MachinePrintedQty = 0;


            busTreasury = new TreasuryTransactions();
            RouteNumber = "0";


            List<string> lstPositionstoDisplay = busTreasury.FillListOfFilteredPositions(RouteNumber);

            if (string.IsNullOrEmpty(StartDate) || string.IsNullOrEmpty(EndDate))
            {
                
                System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate
                  {
                      BMC.Presentation.CashDeskManager.MessageBox.showBox("Not a valid Date Range");
                      //prgViewAll.Value = 0;
                  });
                return null;
            }

            if (!Business.CashDeskManager.Common.isValidDateRange((StartDate + " " + StartTime), (EndDate + " " + EndTime)))
            {
                System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate
                {
                    BMC.Presentation.CashDeskManager.MessageBox.showBox("Not a valid Date Range");
                   // prgViewAll.Value = 0;
                });
                return null;
            }

            TicketsClaimed oTicketsClaimed = new TicketsClaimed();
            oTicketsClaimed.TicketsClaimedTo = EndDate + " " + EndTime;
            oTicketsClaimed.TicketsClaimedFrom = StartDate + " " + StartTime;

            szErrDesc = "pre tickets claimed";
            List<TicketExceptions> lstTicketsClaimed = busTreasury.TicketsClaimed(oTicketsClaimed, lstPositionstoDisplay);
            if (lstTicketsClaimed != null)
            {
                foreach (TicketExceptions exep in lstTicketsClaimed)
                {
                    cTicketClaimedTotalCashdesk += (float)exep.Value;
                }
            }
            else
            {
                lstTicketsClaimed = new List<TicketExceptions>();
            }


            szErrDesc = "pre tickets printed";
            List<TicketExceptions> lstTicketsPrinted = busTreasury.TicketsPrinted(oTicketsClaimed, lstPositionstoDisplay);
            if (lstTicketsPrinted != null)
            {
                foreach (TicketExceptions exep in lstTicketsPrinted)
                {
                    cTicketPrintedTotalEGM += (float)exep.Value;
                }
                foreach (TicketExceptions item in lstTicketsPrinted)
                {
                    lstTicketsClaimed.Add(item);
                }
            }
            

            szErrDesc = "pre TiTo claimed";

            Tickets oTickets = new Tickets();
            oTickets.EndDate = EndDate + " " + EndTime;
            oTickets.StartDate = StartDate + " " + StartTime;
            oTickets.IsLiability = false;
            oTickets.BarCode = "%";
            oTickets.Type = "C";
            System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate
               {
                   oTickets.IsClaimedInCashDesk = (bool)chkCashDeskTicketIn.IsChecked;
                   oTickets.IsClaimedInMachine = (bool)chkTicketIn.IsChecked;
                   prgViewAll.Value += 20;

               }
              
           );
           
           
                List<TicketExceptions> lstTitoClaimed = busTreasury.TitoTicketsClaimed(oTickets, lstPositionstoDisplay);

                if (lstTitoClaimed != null)
                {
                    foreach (TicketExceptions exep in lstTitoClaimed)
                    {
                        currEGM += exep.currEGM;
                        currCashdesk += exep.CurrentCashDesk;
                        CashDeskClaimedQty += exep.CashDeskClaimedQty;
                        MachineClaimedQty += exep.MachineClaimedQty;
                    }
                    System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate
                      {
                          if ((bool)chkCashDeskTicketIn.IsChecked && (bool)chkTicketIn.IsChecked)
                          {
                              foreach (TicketExceptions item in lstTitoClaimed)
                              {
                                  lstTicketsClaimed.Add(item);
                              }
                          }
                          prgViewAll.Value += 20;
                      });
                    cTicketClaimedTotalCashdesk = cTicketClaimedTotalCashdesk + currCashdesk;
                    cTicketClaimedTotalEGM = cTicketClaimedTotalEGM + currEGM;
                }
           

            oTickets.Type = "U";
            List<TicketExceptions> lstTicketsUnclaimed = busTreasury.TitoTicketsUnclaimed(oTickets, lstPositionstoDisplay);
            if (lstTicketsUnclaimed != null)
            {
                foreach (TicketExceptions exep in lstTicketsUnclaimed)
                {
                    cTicketsUnclaimed += (float)exep.Value;
                    lstTicketsClaimed.Add(exep);
                }
            }

            oTickets.Type = "E";
            List<TicketExceptions> lstTicketInExceptions = busTreasury.TITOTicketInExceptions(oTickets, lstPositionstoDisplay);
            if (lstTicketInExceptions != null)
            {
                foreach (TicketExceptions exep in lstTicketInExceptions)
                {
                    cTicketInExceptions += (double)exep.currValue;
                    lstTicketsClaimed.Add(exep);
                }
            }

            oTickets.Type = "E";
            List<TicketExceptions> lstTicketOutExceptions = busTreasury.TitoTicketOutExceptions(oTickets, lstPositionstoDisplay);
            if (lstTicketOutExceptions != null)
            {
                foreach (TicketExceptions exep in lstTicketOutExceptions)
                {
                    cTicketOutExceptions += (float)exep.cTicketTotal;
                   // lstTicketsClaimed.Add(exep);
                }
            }

            //cTicketOutExceptions = lstTicketOutExceptions[0].cTicketTotal;

            oTickets.Type = "V";
            List<TicketExceptions> lstTicketsVoid = busTreasury.GetTicket_VoidnExpired(oTickets, lstPositionstoDisplay);
            if (lstTicketsVoid != null)
            {
                foreach (TicketExceptions exep in lstTicketsVoid)
                {
                    lstTicketsClaimed.Add(exep);
                    cTicketsVoid += (float)exep.cTicketTotal;
                }
            }
            //cTicketsVoid = lstTicketsVoid[0].cTicketTotal;

            oTickets.Type = "D";
            List<TicketExceptions> lstTicketsExpired = busTreasury.GetTicket_VoidnExpired(oTickets, lstPositionstoDisplay);
            if (lstTicketsExpired != null)
            {
                foreach (TicketExceptions exep in lstTicketsExpired)
                {
                    lstTicketsClaimed.Add(exep);
                    cTicketsExpired += (float)exep.currValue;
                }
            }


            oTickets.Type = "B";
            List<TicketExceptions> lstTicketsCancelled = busTreasury.GetTicket_VoidnExpired(oTickets, lstPositionstoDisplay);
            if (lstTicketsCancelled != null)
            {
                foreach (TicketExceptions exep in lstTicketsCancelled)
                {
                    lstTicketsClaimed.Add(exep);
                    cTicketCancelled += (float)exep.cTicketTotal;
                }
            }



            oTickets.Type = "P";
            System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate
               {

                   oTickets.IsPrintedInCashDesk = (bool)chkCashDeskTicketOut.IsChecked;
                   oTickets.IsPrintedInMachine = (bool)chkTicketOut.IsChecked;
                   prgViewAll.Value += 20;
               });
            
                List<TicketExceptions> lstTitoTicketsPrinted = busTreasury.TitoTicketsPrinted(oTickets, lstPositionstoDisplay);
                if (lstTitoTicketsPrinted != null)
                {
                    foreach (TicketExceptions exep in lstTitoTicketsPrinted)
                    {
                        System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate
                          {
                              if ((bool)chkCashDeskTicketOut.IsChecked && (bool)chkTicketOut.IsChecked)
                              {
                                  lstTicketsClaimed.Add(exep);
                              }
                          });

                       
                        CashDeskPrintedQty += exep.CashDeskPrintedQty;
                        MachinePrintedQty += exep.MachinePrintedQty;
                    }
                    if (lstTitoTicketsPrinted != null && lstTitoTicketsPrinted.Count > 0)
                    {
                        currEGM = lstTitoTicketsPrinted[0].currEGM;
                        currCashdesk = lstTitoTicketsPrinted[0].CurrentCashDesk;
                        cTicketPrintedTotalCashdesk += currCashdesk;
                        cTicketPrintedTotalEGM += currEGM;
                    }
                }
            

            szErrDesc = "pre refunds";
            oTickets.Type = TREASURY_REFUND;
            System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate
              {
                  oTickets.IsLiability = (bool)chkRefunds.IsChecked;
                  prgViewAll.Value += 20;
              });
            List<TicketExceptions> RefundItems = busTreasury.GetTreasuryItems(oTickets, lstPositionstoDisplay);
            if (RefundItems != null)
            {
                foreach (TicketExceptions item in RefundItems)
                {
                    lstTicketsClaimed.Add(item);
                    cRefundTotal += item.TreasuryAmount;
                    RefundQty += item.HandpayQty;
                }
            }

            szErrDesc = "pre refill";
            oTickets.Type = TREASURY_REFILL;
            System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate
              {
                  oTickets.IsLiability = (bool)chkRefills.IsChecked;
              });
            List<TicketExceptions> RefillItems = busTreasury.GetTreasuryItems(oTickets, lstPositionstoDisplay);
            if (RefillItems != null)
            {
                foreach (TicketExceptions item in RefillItems)
                {
                    lstTicketsClaimed.Add(item);
                    cRefillTotal += item.TreasuryAmount;
                    RefillQty += item.HandpayQty;
                }
            }

            szErrDesc = "pre shortpay";
            oTickets.Type = TREASURY_SHORTPAY;
            System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate
              {
                  oTickets.IsLiability = (bool)chkShortPays.IsChecked;
              });
            List<TicketExceptions> ShortpayItems = busTreasury.GetTreasuryItems(oTickets, lstPositionstoDisplay);
            if (ShortpayItems != null)
            {
                foreach (TicketExceptions item in ShortpayItems)
                {
                    lstTicketsClaimed.Add(item);
                    cShortpayTotal += item.TreasuryAmount;
                    ShortpayQty += item.HandpayQty;
                }
            }

            szErrDesc = "Handpays";
            oTickets.Type = TREASURY_HANDPAY_CREDIT;
            System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate
              {
                  oTickets.IsLiability = (bool)chkHandpays.IsChecked;
                  prgViewAll.Value += 20;
              });
            List<TicketExceptions> Handpays = busTreasury.GetTreasuryItems(oTickets, lstPositionstoDisplay);
            if (Handpays != null)
            {
                foreach (TicketExceptions item in Handpays)
                {
                    lstTicketsClaimed.Add(item);
                    cHandPayTotal += Convert.ToDouble(item.Amount);
                    HandpayQty += item.HandpayQty;
                }
            }

            szErrDesc = "pre cash desk float";
            oTickets.Type = TREASURY_CASH_DESK_FLOAT;
            System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate
              {
                  oTickets.IsLiability = (bool)chkCashDeskFloat.IsChecked;
              });
            List<TicketExceptions> CashDeskFloatItems = busTreasury.GetTreasuryItems(oTickets, lstPositionstoDisplay);
            if (CashDeskFloatItems != null)
            {
                foreach (TicketExceptions item in CashDeskFloatItems)
                {
                    lstTicketsClaimed.Add(item);
                    cCashDeskFloatTotal += item.TreasuryAmount;
                    CashDeskFloatQty += item.HandpayQty;
                }
            }

            szErrDesc = "Progressive";
            oTickets.Type = TREASURY_PROGRESSIVE;
            System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate
              {
                  oTickets.IsLiability = (bool)chkProghandpays.IsChecked;
              });
            List<TicketExceptions> ProgItems = busTreasury.GetTreasuryItems(oTickets, lstPositionstoDisplay);
            if (ProgItems != null)
            {
                foreach (TicketExceptions item in ProgItems)
                {
                    lstTicketsClaimed.Add(item);
                    cProgressiveTotal += item.TreasuryAmount;
                    ProgressiveQty += item.HandpayQty;
                }
            }

            szErrDesc = "Jackpot";
            oTickets.Type = TREASURY_JACKPOT;
            System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate
              {
                  oTickets.IsLiability = (bool)chkjackpot.IsChecked;
              });
            List<TicketExceptions> JackPotItems = busTreasury.GetTreasuryItems(oTickets, lstPositionstoDisplay);
            if (JackPotItems != null)
            {
                foreach (TicketExceptions item in JackPotItems)
                {
                    lstTicketsClaimed.Add(item);
                    cJackpotTotal += item.TreasuryAmount;
                    JackpotQty += item.HandpayQty;
                }
            }

                System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate
                  {
                      prgViewAll.Value += 20;
                      txtCashDeskTicketInVal.Text = cTicketClaimedTotalCashdesk.ToString(MYFORMAT);
                      txtMachineTicketInVal.Text = cTicketClaimedTotalEGM.ToString(MYFORMAT);
                      txtMachineTicketOutVal.Text = cTicketPrintedTotalEGM.ToString(MYFORMAT);
                      txtCashDeskTicketOutVal.Text = cTicketPrintedTotalCashdesk.ToString(MYFORMAT);
                      txtLiabilityVal.Text = ((cTicketPrintedTotalEGM + cTicketPrintedTotalCashdesk) -
                          (cTicketClaimedTotalEGM + cTicketClaimedTotalCashdesk)).ToString(MYFORMAT);

                      txtExcepVal.Text = cTicketInExceptions.ToString(MYFORMAT) + "/" + cTicketOutExceptions.ToString(MYFORMAT);
                      txtActiveVal.Text = cTicketsUnclaimed.ToString(MYFORMAT);
                      txtVoidval.Text = cTicketsVoid.ToString(MYFORMAT) + "/" + cTicketCancelled.ToString(MYFORMAT);
                      txtExpiredVal.Text = cTicketsExpired.ToString(MYFORMAT);

                      txtRefundVal.Text = cRefundTotal.ToString(MYFORMAT);
                      txtFillsVal.Text = cRefillTotal.ToString(MYFORMAT);
                      txtCashDeskShortPaysVal.Text = cShortpayTotal.ToString(MYFORMAT);
                      txtHandpayVal.Text = cHandPayTotal.ToString(MYFORMAT);
                      txtCashDeskFloatVal.Text = cCashDeskFloatTotal.ToString(MYFORMAT);
                      txtProgHandpayVal.Text = cProgressiveTotal.ToString(MYFORMAT);
                      txtJackpotVal.Text = cJackpotTotal.ToString(MYFORMAT);
                  });
                  double promoTotal = 0;
                  List<TicketExceptions> lstPromo = busTreasury.GetPromoCashableTickets(oTicketsClaimed, lstPositionstoDisplay);
                  if (lstPromo != null)
                  {
                      foreach (TicketExceptions item in lstPromo)
                      {
                          promoTotal += item.Value;
                      }
                  }
                  System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate
                  {
                      txtPromoCashableVal.Text = promoTotal.ToString(MYFORMAT);

                      txtHandpayQty.Text = HandpayQty.ToString();
                      txtProgHandpayQty.Text = ProgressiveQty.ToString();
                      txtJackPotQty.Text = JackpotQty.ToString();
                      txtRefundQty.Text = RefundQty.ToString();
                      txtFillsQty.Text = RefillQty.ToString();
                      txtCashDeskShortPayQty.Text = ShortpayQty.ToString();
                      txtCashDeskFloatQty.Text = CashDeskFloatQty.ToString();
                      txtCashDeskTicketInQty.Text = CashDeskClaimedQty.ToString();
                      txtMachineTicketInQty.Text = MachineClaimedQty.ToString();
                      txtCashDeskTicketOutQty.Text = CashDeskPrintedQty.ToString();
                      txtMachineTicketOutQty.Text = MachinePrintedQty.ToString();
                  });
            HandpayQty = 0;
            ProgressiveQty = 0;
            JackpotQty = 0;
            RefundQty = 0;
            RefillQty = 0;
            ShortpayQty = 0;
            CashDeskFloatQty = 0;
            CashDeskClaimedQty = 0;
            CashDeskPrintedQty = 0;
            MachineClaimedQty = 0;
            MachinePrintedQty = 0;

            return lstTicketsClaimed;
        }
        public static List<TicketExceptions> GetTreasuryItems(Tickets oTickets, List<string> lstPositions)
        {
            List<TicketExceptions> items = null;
            TicketExceptions treasury = null;

            try
            {
                DataTable dtTreasury = ExecuteTable(GetExchangeConnectionString(), oTickets, false);

                items = new List<TicketExceptions>();
                foreach (DataRow row in dtTreasury.Rows)
                {

                    if (DBCommon.CheckPositionToDisplay(row["bar_pos_name"].ToString(), lstPositions))
                    {
                        

                            treasury = new TicketExceptions();
                            treasury.PayDate = row["treasury_date"].ToString() + " " + row["treasury_time"].ToString();
                            treasury.PrintDate = row["treasury_date"].ToString() + " " + row["treasury_time"].ToString();
                            treasury.TransactionType = oTickets.Type;
                            treasury.Zone = row["Zone_name"].ToString();
                            treasury.Position = row["bar_pos_name"].ToString();
                            treasury.Machine = row["machine_name"].ToString();
                            treasury.Amount = row["treasury_amount"].ToString();
                            treasury.Details = "";
                       
                        switch (oTickets.Type)
                        {
                            case DBConstants.CONST_HANDPAYCREDIT:
                                {
                                    treasury.HandpayQty += 1;
                                    break;
                                }
                            case DBConstants.CONST_JACKPOT:
                                {
                                    treasury.JackPotQty += 1;
                                    break;
                                }
                            case DBConstants.CONST_PROG:
                                {
                                    treasury.ProgQty += 1;
                                    break;
                                }
                            case DBConstants.CONST_REFILL:
                                {
                                    treasury.RefillQty += 1;
                                    break;
                                }
                            case DBConstants.CONST_REFUND:
                                {
                                    treasury.RefundQty += 1;
                                    break;
                                }
                            case DBConstants.CONST_SHORTPAY:
                                {
                                    treasury.ShortQty += 1;
                                    break;
                                }
                            case DBConstants.CONST_FLOAT:
                                {
                                    treasury.FloatQty += 1;
                                    break;
                                }
                            default:
                                break;
                        }
                        items.Add(treasury);
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.Publish(ex);
            }

            return items;
        }
        private List<TicketExceptions> LoadExceptions()
        {

            busTreasury = new TreasuryTransactions();
            float ExceptionTotal = 0F;
            System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate
              {
                  lvExceptions.Items.Clear();
              });
            List<string> lstPositionstoDisplay = busTreasury.FillListOfFilteredPositions(RouteNumber);
            //FillListOfFilteredPositions
            Tickets oTickets = new Tickets();
            oTickets.EndDate = dtTo + " " + TimeTo;
            oTickets.StartDate = dtFrom + " " + TimeFrom;
            oTickets.IsLiability = false;
            oTickets.BarCode = "%";
            oTickets.Type = "E";
            System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate
                     {
                         prgExceptions.Value += 50;
                     });
            List<TicketExceptions> lstExceptions = busTreasury.TITOTicketInExceptions(oTickets, lstPositionstoDisplay);
            System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate
            {
                prgExceptions.Value += 50;
            });
            List<TicketExceptions> lstExceptionsOut = busTreasury.TitoTicketOutExceptions(oTickets, lstPositionstoDisplay);

            if (lstExceptionsOut.Count > 0)
            {
                if (lstExceptionsOut[0].bExceptionRecordFound)
                {
                    TicketExceptions Total = new TicketExceptions();
                    Total.Type = "Total";
                    foreach (TicketExceptions exep in lstExceptionsOut)
                    {
                        ExceptionTotal += exep.cExceptionsTotal;
                    }
                    Total.Value = Convert.ToDouble(ExceptionTotal.ToString("###0.00"));
                    lstExceptionsOut.Insert(0, Total);

                    //CreateTotals cExceptionsTotal
                }
            }
            System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate
            {
                prgExceptions.Value += 50;
            });
            return lstExceptionsOut;
        }
        private List<TicketExceptions> LoadExceptions()
        {

            decimal ExceptionTotal = 0;

           
            List<string> lstPositionstoDisplay = objCashDeskManager.FillListOfFilteredPositions(RouteNumber);
            //FillListOfFilteredPositions
            Tickets oTickets = new Tickets();
            oTickets.EndDate = dtTo;
            oTickets.StartDate = dtFrom;
            oTickets.IsLiability = false;
            oTickets.BarCode = "%";
            oTickets.Type = "E";
            oTickets.UserNo = UserNo;
            
            System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate
                     {
                         prgExceptions.Value += 50;
                     });
            List<TicketExceptions> lstExceptions = objCashDeskManager.TITOTicketInExceptions(oTickets, lstPositionstoDisplay);
            if (lstExceptions == null)
            {
                lstExceptions = new List<TicketExceptions>();
                
            }
            System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate
            {
                prgExceptions.Value += 50;
            });
            List<TicketExceptions> lstExceptionsOut = objCashDeskManager.TitoTicketOutExceptions(oTickets, lstPositionstoDisplay);



            if (lstExceptionsOut != null)
            {
                foreach (TicketExceptions exep in lstExceptionsOut)
                { 
                        lstExceptions.Add(exep);
                   
                }
            }

            //CreateTotals cExceptionsTotal
            foreach (TicketExceptions item in lstExceptions)
            {
                ExceptionTotal += (decimal) item.currValue;
            }

            TicketExceptions Total = new TicketExceptions();
            Total.Type = "Total";
            Total.Amount = CurrencySymbol + "" + Convert.ToDecimal(ExceptionTotal).GetUniversalCurrencyFormat();
            lstExceptions.Insert(0, Total);

          

            System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate
            {
                prgExceptions.Value += 50;
            });
            return lstExceptions;
        }
        private List<TicketExceptions> LoadLiabilities()
        {
            objCashDeskManager = CashDeskManagerBusinessObject.CreateInstance();
            System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate
             {
                 lvLiability.Items.Clear();
             });
            List<string> lstPositionstoDisplay = objCashDeskManager.FillListOfFilteredPositions(RouteNumber);


            TicketsClaimed oTicketsClaimed = new TicketsClaimed();
            oTicketsClaimed.TicketsClaimedFrom = StartDate;
            oTicketsClaimed.TicketsClaimedTo = EndDate;

            Tickets oTickets = new Tickets();
            oTickets.EndDate = EndDate;
            oTickets.StartDate = StartDate;
            oTickets.IsLiability = true;
            oTickets.BarCode = "%";
            oTickets.Type = "C";
            oTickets.UserNo = UserNo;

            System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate
            {
                prgLiability.Value += 50;
            });
            List<TicketExceptions> lstTitoTicketsClaimed = objCashDeskManager.TitoTicketsClaimedLiability(oTickets, lstPositionstoDisplay);
            if (lstTitoTicketsClaimed == null)
            {
                lstTitoTicketsClaimed = new List<TicketExceptions>();
            }

            oTickets.Type = "P";

            System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate
            {
                prgLiability.Value += 50;
            });
            List<TicketExceptions> lstTitoTicketsPrinted = objCashDeskManager.TitoTicketsPrintedLiability(oTickets, lstPositionstoDisplay);
            //lvLiability.ItemsSource = lstTitoTicketsPrinted;

            if (lstTitoTicketsPrinted != null)
            {
                foreach (TicketExceptions item in lstTitoTicketsPrinted)
                {
                    if (item.VoucherStatus.ToUpper().Trim() != "PP")
                    {
                        lstTitoTicketsClaimed.Add(item);
                    }
                }
            }
            System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate
            {
                prgLiability.Value += 50;
            });
            List<TicketExceptions> lstTicketsClaimed = objCashDeskManager.TicketsClaimed(oTicketsClaimed, lstPositionstoDisplay);
            if (lstTicketsClaimed != null)
            {
                foreach (TicketExceptions item in lstTicketsClaimed)
                {
                    if (item.VoucherStatus.ToUpper().Trim() != "PP")
                    {
                        lstTitoTicketsClaimed.Add(item);
                    }
                }
                //lvLiability.ItemsSource = lstTicketsClaimed;
            }
            System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate
            {
                prgLiability.Value += 50;
            });
            List<TicketExceptions> lstTicketsPrinted = objCashDeskManager.TicketsPrinted(oTicketsClaimed, lstPositionstoDisplay);
            if (lstTicketsPrinted != null)
            {
                foreach (TicketExceptions item in lstTicketsPrinted)
                {
                    lstTitoTicketsClaimed.Add(item);
                }
                // lvLiability.ItemsSource = lstTicketsPrinted;
            }


            decimal ExceptionTotal = 0;
            TicketExceptions Total = new TicketExceptions();
            Total.PrintDate = "Total";
            foreach (TicketExceptions exep in lstTitoTicketsClaimed)
            {
                if (exep.VoucherStatus.ToUpper().Trim() != "PP")
                {
                    ExceptionTotal += (decimal)exep.Value;
                }
            }
            Total.Value = Convert.ToDouble(ExceptionTotal);
            Total.Amount = CurrencySymbol + "" + Convert.ToDecimal(ExceptionTotal).GetUniversalCurrencyFormat();
             //Total.Amount = ExceptionTotal.ToString();
            lstTitoTicketsClaimed.Insert(0, Total);
            System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate
            {
                prgLiability.Value += 50;
            });

            return lstTitoTicketsClaimed;
        }
        private List<TicketExceptions> LoadActiveTickets()
        {
            busTreasury = new TreasuryTransactions();
            System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate
               {
                   lvActiveTickets.Items.Clear();
               });

            List<string> lstPositionstoDisplay = busTreasury.FillListOfFilteredPositions(RouteNumber);

            TicketsClaimed oTicketsClaimed = new TicketsClaimed();
            oTicketsClaimed.TicketsClaimedFrom = StartDate + " " + StartTime;
            oTicketsClaimed.TicketsClaimedTo = EndDate + " " + EndTime;

            Tickets oTickets = new Tickets();
            oTickets.EndDate = EndDate + " " + EndTime;
            oTickets.StartDate = StartDate + " " + StartTime;
            oTickets.IsLiability = false;
            oTickets.BarCode = "%";
            oTickets.Type = "U";

            System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate
            {
                prgActiveTickets.Value += 50;
            });
            List<TicketExceptions> lstTitoTicketsUnclaimed = busTreasury.TitoTicketsUnclaimed(oTickets, lstPositionstoDisplay);
            if (lstTitoTicketsUnclaimed == null)
            {
                lstTitoTicketsUnclaimed = new List<TicketExceptions>();
            }

            System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate
            {
                prgActiveTickets.Value += 50;
            });
            List<TicketExceptions> lstTicketsUnClaimed = busTreasury.TicketsUnclaimed(oTicketsClaimed, lstPositionstoDisplay);

            if (lstTicketsUnClaimed != null)
            {
                foreach (TicketExceptions item in lstTicketsUnClaimed)
                {
                    lstTitoTicketsUnclaimed.Add(item);
                }

                decimal ExceptionTotal = 0;
                TicketExceptions Total = new TicketExceptions();
                Total.PrintDate = "Total";
                Total.PayDate = "";
                foreach (TicketExceptions exep in lstTitoTicketsUnclaimed)
                {
                    ExceptionTotal += (decimal)exep.Value;
                }
                Total.Value = (double)Decimal.Round(ExceptionTotal, 2);
                lstTitoTicketsUnclaimed.Insert(0, Total);
                System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate
                {
                    prgActiveTickets.Value += 50;
                });
            }

            return lstTitoTicketsUnclaimed;
        }
 public List<TicketExceptions> GetTreasuryItems(Tickets oTickets, List<string> lstPositions)
 {
     return DBBuilder.GetTreasuryItems(oTickets, lstPositions);
 }
 private static DataTable ExecuteTable(string StoredProcedure, Tickets oTickets)
 {
     return SqlHelper.ExecuteDataset(TicketSQLConnection(), StoredProcedure, GetVoucherParameters(oTickets)).Tables[0];
     // return SqlHelper.ExecuteDataset(SQLConnection(), StoredProcedure,CommandType.StoredProcedure, GetVoucherParameters(oTickets)).Tables[0];
 }
        public  List<TicketExceptions> GetTreasuryItems(Tickets oTickets, List<string> lstPositions)
        {
            List<TicketExceptions> items = null;
            TicketExceptions treasury = null;

            try
            {
                DataTable dtTreasury = ExecuteTable(oTickets, false);

                items = new List<TicketExceptions>();
                foreach (DataRow row in dtTreasury.Rows)
                {

                    if (DBCommon.CheckPositionToDisplay(row["bar_pos_name"].ToString(), lstPositions))
                    {


                        treasury = new TicketExceptions();
                        //treasury.PayDate = row["treasury_date"].ToString() + " " + row["treasury_time"].ToString();
                        //treasury.PrintDate = row["treasury_date"].ToString() + " " + row["treasury_time"].ToString();
                        //treasury.PayDate = Convert.ToDateTime(row["treasury_date"]).ToString("dd MMM yyyy HH:mm:ss").ReadDateTimeWithSeconds().ToString();
                        //treasury.PrintDate = Convert.ToDateTime(row["treasury_date"]).ToString("dd MMM yyyy HH:mm:ss").ReadDateTimeWithSeconds().ToString();

                        treasury.PayDate = row["treasury_date"].ToString().ToShortDateTimeString();
                        treasury.PrintDate = row["treasury_date"].ToString().ToShortDateTimeString();



                        treasury.TransactionType = oTickets.Type;
                        treasury.Zone = row["Zone_name"].ToString();
                        treasury.Position = row["bar_pos_name"].ToString();
                        treasury.Machine = row["machine_name"].ToString();
                        //treasury.Amount = Convert.ToDouble(row["treasury_amount"]).ToString("###0.#0");
                        treasury.Amount = CurrencySymbol + " " + Convert.ToDecimal(row["treasury_amount"]).GetUniversalCurrencyFormat();
                        treasury.currValue = Convert.ToInt64(row["treasury_amount"]);
                        treasury.Value = Convert.ToDouble(row["treasury_amount"]);
                        treasury.Reason = row["treasury_reason"].ToString();
                        treasury.ReasonCode = row["treasury_reason_code"].ToString();
                        treasury.Asset = row["Asset"].ToString();
						treasury.TreasuryTemp = Convert.ToBoolean(row["Treasury_Temp"].ToString());
                        treasury.Details = "";
                        

                        if (string.IsNullOrEmpty(treasury.Reason))
                        {
                            switch (oTickets.Type)
                            {
                                case DBConstants.CONST_HANDPAYCREDIT:
                                    {

                                        treasury.HandpayQty += 1;
                                        treasury.TransactionType = row["TreasuryTypeDisplayText"].ToString();
                                        break;
                                    }
                                case DBConstants.CONST_JACKPOT:
                                    {
                                        treasury.JackPotQty += 1;
                                        treasury.TransactionType = row["TreasuryTypeDisplayText"].ToString();
                                        break;
                                    }
                                case DBConstants.CONST_PROG:
                                    {
                                        treasury.ProgQty += 1;
                                        treasury.TransactionType = row["TreasuryTypeDisplayText"].ToString();
                                        break;
                                    }
                                case DBConstants.CONST_REFILL:
                                    {
                                        treasury.RefillQty += 1;
                                        break;
                                    }
                                case DBConstants.CONST_REFUND:
                                    {
                                        treasury.RefundQty += 1;
                                        break;
                                    }
                                case DBConstants.CONST_SHORTPAY:
                                    {
                                        treasury.ShortQty += 1;
                                        break;
                                    }
                                case DBConstants.CONST_FLOAT:
                                    {
                                        treasury.FloatQty += 1;
                                        break;
                                    }
                                default:
                                    break;
                            }
                        }
                        items.Add(treasury);
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.Publish(ex);
            }

            return items;
        }
        private static object[] GetTicketsParameters(Tickets oTickets)
        {
            SqlParameter[] ObjParams = new SqlParameter[4];
            ObjParams[0] = new SqlParameter(DBConstants.CONST_PARAM_STARTDATE, oTickets.StartDate);
            ObjParams[1] = new SqlParameter(DBConstants.CONST_PARAM_ENDDATE, oTickets.EndDate);
            ObjParams[2] = new SqlParameter(DBConstants.CONST_PARAM_TYPE, oTickets.Type);
            ObjParams[3] = new SqlParameter(DBConstants.CONST_PARAM_LIABILITY, oTickets.IsLiability);

            return ObjParams;
        }
        private DataTable ExecuteTable(string StoredProcedure, Tickets oTickets)
        {
            try
            {
                return SqlHelper.ExecuteDataset(TicketSQLConnection(), StoredProcedure, GetVoucherParameters(oTickets)).Tables[0];
            }
            catch (Exception ex)
            {
                ExceptionManager.Publish(ex);
                return null;

            }
            // return SqlHelper.ExecuteDataset(SQLConnection(), StoredProcedure,CommandType.StoredProcedure, GetVoucherParameters(oTickets)).Tables[0];
        }
 private static object[] GetTreasuryParameters(Tickets oTickets)
 {
     SqlParameter[] ObjParams = new SqlParameter[3];
     ObjParams[0] = new SqlParameter(DBConstants.CONST_PARAM_STARTDATE, oTickets.StartDate);
     ObjParams[1] = new SqlParameter(DBConstants.CONST_PARAM_ENDDATE, oTickets.EndDate);
     ObjParams[2] = new SqlParameter(DBConstants.CONST_PARAM_TYPE, oTickets.Type);
  
     return ObjParams;
 }
        private DataTable ExecuteTable(Tickets oTickets, bool flag)
        {
            try
            {
                return SqlHelper.ExecuteDataset(SQLConnection(), DBConstants.CONST_SP_RSP_GETTREASURYITEMS, GetTreasuryParameters(oTickets)).Tables[0];
            }
            catch (Exception ex)
            {
                ExceptionManager.Publish(ex);
                return null;

            }

            // return SqlHelper.ExecuteDataset(SQLConnection(), StoredProcedure,CommandType.StoredProcedure, GetVoucherParameters(oTickets)).Tables[0];
        }
        public static List<TicketExceptions> TitoTicketOutExceptions(Tickets oTickets, List<string> lstPositionstoDisplay)
        {
            List<TicketExceptions> lstTickets = null;
            try
            {
                SqlParameter[] parameters = SqlHelperParameterCache.GetSpParameterSet(GetExchangeConnectionString(), "rsp_GetNonCompletedTicketPrints");
                foreach (SqlParameter param in parameters)
                {
                    if (param.ParameterName == "@StartDate")
                    {
                        param.Value = oTickets.StartDate;
                    }
                    if (param.ParameterName == "@EndDate")
                    {
                        param.Value = oTickets.EndDate;
                    }
                }
                SqlDataReader reader = SqlHelper.ExecuteReader(GetExchangeConnectionString(), "rsp_GetNonCompletedTicketPrints", parameters);

                lstTickets = new List<TicketExceptions>();
                TicketExceptions excep = null;

                while (reader.Read())
                {
                    excep = new TicketExceptions();
                    excep.SEGM = reader["bar_pos_name"].ToString();
                    excep.Machine = DBBuilder.GetBarPositionFromAsset(reader["bar_pos_name"].ToString());
                    excep.currValue = (float)Convert.ToDouble(reader["TE_Value"]) / 100;
                    if (!string.IsNullOrEmpty(excep.SEGM) && DBCommon.CheckPositionToDisplay(excep.Machine, lstPositionstoDisplay))
                    {
                        excep.bExceptionRecordFound = true;
                        excep.Type = "OUT";
                        excep.Position = DBBuilder.GetBarPositionFromAsset(reader["bar_pos_name"].ToString());
                        excep.PrintDate = Convert.ToDateTime(reader["TE_Date"]).ToString("dd MMM yyyy") + " " +
                            Convert.ToDateTime(reader["TE_Date"]).ToString("HH:mm");
                        if (!string.IsNullOrEmpty(reader["TE_TicketNumber"].ToString()))
                        {
                            excep.Ticket = reader["ActualBarcode"].ToString();
                        }
                        else
                        {
                            excep.Ticket = reader["TE_TicketNumber"].ToString();
                        }
                        excep.Value = Convert.ToDouble(reader["TE_Value"]) / 100;
                        excep.Asset = reader["stock_no"].ToString();
                        excep.COLINSTALLID = Convert.ToInt16(reader["TE_Installation_No"].ToString());
                        excep.CreateCompleted = reader["CreateExpected"].ToString();

                        excep.cTicketTotal += excep.currValue;
                        excep.cExceptionsTotal += excep.currValue;
                    }
                    else if (DBCommon.IsMachineATicketWorkstation(excep.Machine))
                    {
                        excep.bExceptionRecordFound = true;
                        excep.Type = "OUT";
                        excep.Position = DBBuilder.GetBarPositionFromAsset(reader["bar_pos_name"].ToString());
                        excep.PrintDate = Convert.ToDateTime(reader["TE_Date"]).ToString("dd MMM yyyy") + " " +
                            Convert.ToDateTime(reader["TE_Date"]).ToString("HH:mm");
                        if (!string.IsNullOrEmpty(reader["TE_TicketNumber"].ToString()))
                        {
                            excep.Ticket = reader["ActualBarcode"].ToString();
                        }
                        else
                        {
                            excep.Ticket = reader["TE_TicketNumber"].ToString();
                        }
                        excep.Value = Convert.ToDouble(reader["TE_Value"]) / 100;
                        excep.Asset = reader["stock_no"].ToString();
                        excep.COLINSTALLID = Convert.ToInt16(reader["TE_Installation_No"].ToString());
                        excep.CreateCompleted = reader["CreateExpected"].ToString();

                        excep.cTicketTotal += excep.currValue;
                        excep.cExceptionsTotal += excep.currValue;
                    }
                    lstTickets.Add(excep);
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.Publish(ex);
            }
            return lstTickets;
        }
        private object[] GetVoucherParameters(Tickets oTickets)
        {
            try
            {
                SqlParameter[] ObjParams = new SqlParameter[6];
                ObjParams[0] = new SqlParameter(DBConstants.CONST_PARAM_STARTDATE, oTickets.StartDate);
                ObjParams[1] = new SqlParameter(DBConstants.CONST_PARAM_ENDDATE, oTickets.EndDate);
                ObjParams[2] = new SqlParameter(DBConstants.CONST_PARAM_TYPE, oTickets.Type);
                ObjParams[3] = new SqlParameter(DBConstants.CONST_PARAM_BARCODE, oTickets.BarCode);
                ObjParams[4] = new SqlParameter(DBConstants.CONST_PARAM_LIABILITY, Convert.ToInt16(oTickets.IsLiability));
                ObjParams[5] = new SqlParameter("@User", oTickets.UserNo);

                return ObjParams;
            }
            catch (Exception ex)
            {
                ExceptionManager.Publish(ex);
                return null;

            }
        }
        public static List<TicketExceptions> TitoTicketsPrintedLiability(Tickets oTickets, List<string> lstPositionstoDisplay)
        {
            string strTicketInException = string.Empty;
            string sPosTer = string.Empty;
            List<TicketExceptions> lstTickets = null;
            TicketExceptions excep = null;

            try
            {
                DataTable dtTickets = DBBuilder.GetTickets(oTickets);
                if (dtTickets == null && dtTickets.Rows.Count < 0)
                {
                }
                else
                {
                    lstTickets = new List<TicketExceptions>();

                    foreach (DataRow row in dtTickets.Rows)
                    {
                        excep = new TicketExceptions();
                        excep.bExceptionRecordFound = false;
                        excep.SEGM = row["PrintDevice"].ToString();
                        excep.VoucherStatus = row["strVoucherStatus"].ToString();
                        excep.TicketAddedtoList = false;
                        excep.currValue = (float)Convert.ToDouble(row["iAmount"]) / 100;
                        if (!string.IsNullOrEmpty(excep.SEGM))
                        {
                            if (row["strDeviceType"].ToString().Equals("EXTITO") || string.IsNullOrEmpty(row["strDeviceType"].ToString()))
                            {
                                if (DBCommon.IsMachineATicketWorkstation(excep.SEGM))
                                {
                                    excep.TicketAddedtoList = true;
                                }
                                else
                                {
                                    sPosTer = string.Empty;
                                    excep.Machine = GetBarPositionFromAsset(excep.SEGM);
                                    if (DBCommon.CheckPositionToDisplay(excep.Machine, lstPositionstoDisplay))
                                    {

                                        excep.TicketAddedtoList = true;
                                    }
                                }
                            }
                            else
                            {  
                                excep.TicketAddedtoList = true;
                            }
                        }

                        if (excep.TicketAddedtoList)
                        {

                            string dPrintDate = row["dtPrinted"].ToString();
                            string dClaimDate = string.IsNullOrEmpty(row["dtPaid"].ToString()) ? "01/01/3100" : row["dtPaid"].ToString();

                            excep.TransactionType = "TITO Printed";
                            excep.Zone = "n/a";


                            if ((Convert.ToDateTime(dPrintDate) >= Convert.ToDateTime(oTickets.StartDate)) &&
                                (Convert.ToDateTime(dClaimDate) <= Convert.ToDateTime(oTickets.EndDate)))
                            {
                                excep.Status = "Printed within, Claimed in different category";
                            }
                            else if (string.IsNullOrEmpty(row["dtPaid"].ToString()))
                            {
                                excep.Status = "Active Ticket";
                            }
                            else
                            {
                                excep.Status = "Printed within period, claimed later";
                            }

                            excep.Position = DBBuilder.GetBarPositionFromAsset(row["PrintDevice"].ToString());

                            excep.PrintDate = Convert.ToDateTime(row["dtPrinted"]).ToString("dd MMM yyyy") + " " +
                                Convert.ToDateTime(row["dtPrinted"]).ToString("HH:mm");

                            if (!(row["dtPaid"] == null))
                            {
                                excep.PayDate = Convert.ToDateTime(row["dtPaid"] != null ? row["dtPaid"] : string.Empty).ToString("dd MMM yyyy") + " " +
                                                Convert.ToDateTime(row["dtPaid"] != null ? row["dtPaid"] : string.Empty).ToString("HH:mm");
                            }


                            excep.PayDevice = (row["PayDevice"] != null ? GetBarPositionFromAsset( row["PayDevice"].ToString() ): string.Empty);

                            if (!string.IsNullOrEmpty(row["strBarCode"].ToString()))
                            {
                                excep.Ticket = row["ActualBarcode"].ToString();
                            }
                            else
                            {
                                excep.Ticket = row["strBarcode"].ToString();
                            }
                            excep.Value = Convert.ToDouble(row["iAmount"]) / 100;
                            excep.Amount = "(" + excep.Value + ")";


                        }

                        lstTickets.Add(excep);
                    }
                }

            }

            catch (Exception ex)
            {
                LogManager.WriteLog(ex.Message, LogManager.enumLogLevel.Info);
                ExceptionManager.Publish(ex);
            }
            return lstTickets;
        }
        private object[] GetTreasuryParameters(Tickets oTickets)
        {
            try
            {
                SqlParameter[] ObjParams = new SqlParameter[3];
                ObjParams[0] = new SqlParameter(DBConstants.CONST_PARAM_STARTDATE, oTickets.StartDate);
                ObjParams[1] = new SqlParameter(DBConstants.CONST_PARAM_ENDDATE, oTickets.EndDate);
                ObjParams[2] = new SqlParameter(DBConstants.CONST_PARAM_TYPE, oTickets.Type);

                return ObjParams;
            }
            catch (Exception ex)
            {
                ExceptionManager.Publish(ex);
                return null;

            }
        }
        private List<TicketExceptions> LoadActiveTickets()
        {
            objCashDeskManager = CashDeskManagerBusinessObject.CreateInstance();

            System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate
               {
                   lvActiveTickets.Items.Clear();
               });

            List<string> lstPositionstoDisplay = objCashDeskManager.FillListOfFilteredPositions(RouteNumber);

            TicketsClaimed oTicketsClaimed = new TicketsClaimed();
            oTicketsClaimed.TicketsClaimedFrom = StartDate;
            oTicketsClaimed.TicketsClaimedTo = EndDate;

            Tickets oTickets = new Tickets();
            oTickets.EndDate = EndDate;
            oTickets.StartDate = StartDate;
            oTickets.IsLiability = false;
            oTickets.BarCode = "%";
            oTickets.Type = "U";
            oTickets.UserNo = UserNo;

            System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate
            {
                prgActiveTickets.Value += 50;
            });
            List<TicketExceptions> lstTitoTicketsUnclaimed = objCashDeskManager.TitoTicketsUnclaimed(oTickets, lstPositionstoDisplay);
            if (lstTitoTicketsUnclaimed == null)
            {
                lstTitoTicketsUnclaimed = new List<TicketExceptions>();
            }

            System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate
            {
                prgActiveTickets.Value += 50;
            });
            List<TicketExceptions> lstTicketsUnClaimed = objCashDeskManager.TicketsUnclaimed(oTicketsClaimed, lstPositionstoDisplay);

            if (lstTicketsUnClaimed != null)
            {
                foreach (TicketExceptions item in lstTicketsUnClaimed)
                {
                    lstTitoTicketsUnclaimed.Add(item);
                }
            }
            decimal ExceptionTotal = 0;
            TicketExceptions Total = new TicketExceptions();
            Total.PrintDate = string.Empty;
            Total.PrintDate = "Total";
            Total.PayDate = string.Empty;
            foreach (TicketExceptions exep in lstTitoTicketsUnclaimed)
            {
                ExceptionTotal += (decimal)exep.Value;
            }
            Total.Value = (double)Decimal.Round(ExceptionTotal, 2);
            Total.Amount = CurrencySymbol + "" + Convert.ToDecimal(ExceptionTotal).GetUniversalCurrencyFormat();
            lstTitoTicketsUnclaimed.Insert(0, Total);
            System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate
            {
                prgActiveTickets.Value += 50;
            });

            return lstTitoTicketsUnclaimed;
        }
        public  List<TicketExceptions> TitoTicketsClaimedLiability(Tickets oTickets, List<string> lstPositionstoDisplay)
        {
            string strTicketInException = string.Empty;
            string sPosTer = string.Empty;
            List<TicketExceptions> lstTickets = null;
            TicketExceptions excep = null;

            try
            {
                DataTable dtTickets = GetTickets(oTickets);
                if (dtTickets == null || dtTickets.Rows.Count < 0)
                {
                }
                else
                {
                    lstTickets = new List<TicketExceptions>();

                    foreach (DataRow row in dtTickets.Rows)
                    {
                        excep = new TicketExceptions();
                        excep.bExceptionRecordFound = false;
                        excep.SEGM = row["PayDevice"].ToString();
                        excep.currValue = (float)Convert.ToDouble(row["iAmount"]) / 100;
                        excep.VoucherStatus = row["strVoucherStatus"].ToString();
                        if (!string.IsNullOrEmpty(excep.SEGM) && row["strDeviceType"].ToString().Equals("EXTITO"))
                        {
                            if (DBCommon.IsMachineATicketWorkstation(excep.SEGM))
                            {
                                if (DBCommon.CheckPositionToDisplay(GetBarPositionFromAsset(row["PrintDevice"].ToString()), lstPositionstoDisplay))
                                {
                                    sPosTer = excep.SEGM;
                                    excep.Machine = GetBarPositionFromAsset(row["PrintDevice"].ToString());
                                    excep.bExceptionRecordFound = true;
                                }
                            }
                            else
                            {
                                sPosTer = string.Empty;
                                excep.Machine = GetBarPositionFromAsset(excep.SEGM);

                                if (DBCommon.CheckPositionToDisplay(excep.Machine, lstPositionstoDisplay))
                                {
                                    excep.bExceptionRecordFound = true;
                                }
                            }
                        }
                        else
                        {

                            excep.bExceptionRecordFound = true;
                        }
                        if (excep.bExceptionRecordFound)
                        {

                            string dPrintDate = row["dtPrinted"].ToString();
                            string dClaimDate = row["dtPaid"].ToString();
                            excep.VoucherStatus = row["strVoucherStatus"].ToString();


                            excep.Position = GetBarPositionFromAsset(row["PrintDevice"].ToString());
                            excep.TransactionType = "Voucher Claimed";
                            excep.Zone = "n/a";

                            excep.PrintDate = row["dtPrinted"].ToString().ToShortDateTimeString();
                               // + " " +           Convert.ToDateTime(row["dtPrinted"]).ToString("HH:mm");

                            if (!(row["dtPaid"] == null))
                            {
                                excep.PayDate = row["dtPaid"].ToString().ToShortDateTimeString();
                                    //+" " + Convert.ToDateTime(row["dtPaid"] != null ? row["dtPaid"] : string.Empty).ToString("HH:mm");
                            }


                            excep.PayDevice = (row["PayDevice"] != null ? GetBarPositionFromAsset(row["PayDevice"].ToString()) : string.Empty);

                            if (!string.IsNullOrEmpty(row["strBarCode"].ToString()))
                            {
                                excep.Ticket = row["ActualBarcode"].ToString();
                            }
                            else
                            {
                                excep.Ticket = row["strBarcode"].ToString();
                            }
                            excep.Value = -(Convert.ToDouble(row["iAmount"]) / 100);
                          //  excep.Amount = (-(excep.Value)).ToString("###0.#0");
                            excep.Amount = CurrencySymbol + " " + Convert.ToDecimal(-excep.Value).GetUniversalCurrencyFormat();

                            if ((Convert.ToDateTime(dPrintDate) >= Convert.ToDateTime(oTickets.StartDate)) &&
                                (Convert.ToDateTime(dClaimDate) <= Convert.ToDateTime(oTickets.EndDate)))
                            {
                                excep.Status = "Printed in different category, Claimed within";
                            }
                            else
                            {
                                excep.Status = "Printed prior to period, Claimed within";
                            }
                            excep.cExceptionsTotal += (float)excep.Value;
                            excep.Asset = row["Asset"].ToString();
                            lstTickets.Add(excep);
                        }
                    }
                }

            }

            catch (Exception ex)
            {
                LogManager.WriteLog(ex.Message, LogManager.enumLogLevel.Info);
                ExceptionManager.Publish(ex);
            }
            return lstTickets;
        }