public static ContentView AsView(this PageType type)
        {
            ContentView view = null;

            switch (type)
            {
            case PageType.Analysis:
                view = new AnalysisView();
                break;

            case PageType.Favorites:
                view = new FavoritesView();
                break;

            case PageType.Gallery:
                view = new GalleryView();
                break;

            case PageType.Home:
                view = new UploadView();
                break;

            case PageType.Search:
                view = new SearchResultsView();
                break;

            case PageType.Timeline:
                view = new TimelineView();
                break;
            }

            return(view);
        }
Exemple #2
0
        public CASEView()
        {
            InitializeComponent();
            edenIF = new EdenIF("admin", "98321abc");
            //QEng.bActiveWACC = true;
            ISIN = "KR7005930003";

            // init chile views
            ProfileView.Init(edenIF);
            AnalysisView.Init(edenIF);
            ChartView.Init(edenIF);
            FinancialsView.Init(edenIF);
            NewsView.Init(edenIF);
            DisclosureView.Init(edenIF);
            //ReportView.Init(edenIF);

            DataTable properties = edenIF.GetProperties();

            foreach (DataRow row in properties.Rows)
            {
                companyList.Add(row[1].ToString());
            }

            // initialize
            UpdateContent(ISIN);
            UpdateChildViews(ISIN);

            // init configurations
            configManager = new ConfigManager("configurations.xml");
            configManager.Load();
            configManager.AddSection("watchlist");
            InitWatchlist();
        }
Exemple #3
0
        public void UpdateChildViews(string isin)
        {
            if (edenIF.ContainsFinancials(ISIN, AccountingStandard.IFRS_CON) == true)
            {
                standard = AccountingStandard.IFRS_CON;
            }
            else if (edenIF.ContainsFinancials(ISIN, AccountingStandard.IFRS_SEP) == true)
            {
                standard = AccountingStandard.IFRS_SEP;
            }
            else
            {
                standard = AccountingStandard.Undefined;
            }

            QEng.TrySetCompany(ISIN, standard, false);
            QEng.Pricing();

            ProfileView.UpdateContent(isin, QEng);
            AnalysisView.UpdateContent(isin, QEng);
            ChartView.UpdateContent(isin, QEng);
            FinancialsView.UpdateContent(isin, QEng);
            NewsView.UpdateContent(isin, QEng);
            DisclosureView.UpdateContent(isin, QEng);
            //ReportView.UpdateContent(isin, QEng);
        }
Exemple #4
0
        public ActionResult Analysis(String Date, String days)
        {
            AnalysisView analysis = new AnalysisView();
            RecordView   Data     = new RecordView();

            if (days == null)
            {
                days = "7";
            }

            if (!String.IsNullOrEmpty(Date))
            {
                DateTime convertDatetime = Convert.ToDateTime(Date);
                Data.Date = new ForDateTime(convertDatetime);
            }
            else
            {
                Data.Date = new ForDateTime();
            }

            analysis.FoodView        = foodRecordService.GetDistinctFoodRecordList(Data.Date, Convert.ToInt32(days), User.Identity.Name);
            analysis.FoodResultView  = foodRecordService.GetTotalCaloriesList(Data.Date, Convert.ToInt32(days), User.Identity.Name);
            analysis.day             = days;
            ViewBag.CaloriesRequired = accountService.ReturnCaloriesRequired(User.Identity.Name);

            return(View(analysis));

            //Data.SportRecordList = sportRecordService.GetSportRecordList(Data.Date, User.Identity.Name);
            //Data.TotalCaloriesList = foodRecordService.GetTotalCaloriesList(Data.Date, days, User.Identity.Name);
            //ViewBag.CaloriesRequired = accountService.ReturnCaloriesRequired(User.Identity.Name);
            //return View(Data);
        }
 private void btnGo_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         AnalysisView viewType = (cmbView.SelectedIndex == 0 ? AnalysisView.Position : AnalysisView.Zone);
         int          zoneId   = (int)cmbFilter.SelectedValue;
         LogManager.WriteLog("UCSiteIntegorration:btnGo_Click ZoneID:" + zoneId + " Type:" + viewType.ToString(), LogManager.enumLogLevel.Info);
         Refresh(viewType, zoneId);
     }
     catch (Exception ex)
     {
         MessageBox.ShowBox("Unable to Refresh Site Interrogation details", BMC_Icon.Information, true);
         ExceptionManager.Publish(ex);
     }
 }
        public void Initialize(AnalysisDetailsParent parent, string caption, int iType, AnalysisView viewType, int zoneId, DateTime dteStartDate, DateTime DteEndDate, int iWeekID)
        {
            try
            {
                this.ParentElement = parent;
                this.Caption       = caption;

                _dteStartDate         = dteStartDate;
                _DteEndDate           = DteEndDate;
                _viewType             = viewType;
                _zoneId               = zoneId;
                btnRefresh.Visibility = (this.RefreshVisibility ? Visibility.Visible : Visibility.Collapsed);
                LogManager.WriteLog("UCAnalysisDetails:Initialize Started", LogManager.enumLogLevel.Info);
                this.UpdateColumnCaptions();
                LoadFilterData();
                if (iType == -99)
                {
                    //lblStatus.Visibility = Visibility.Visible;
                    //progressBar1.Visibility = Visibility.Visible;
                    //txtHeader.Text = "Drop Week BreakDown";
                    //txtHeader1.Visibility = Visibility.Visible;
                    //txtHeader.Visibility = Visibility.Hidden;
                    btnPrint.Visibility  = Visibility.Hidden;
                    btnExport.Visibility = Visibility.Hidden;

                    _iType   = -99;
                    _iWeekID = iWeekID;

                    backgroundWorker1                     = new BackgroundWorker();
                    backgroundWorker1.DoWork             += new DoWorkEventHandler(backgroundWorker1_DoWork);
                    backgroundWorker1.RunWorkerCompleted += new RunWorkerCompletedEventHandler(backgroundWorker1_RunWorkerCompleted);
                }
                else
                {
                    Refresh(iType, _viewType, _zoneId, dteStartDate, DteEndDate);
                }
                //lstAnalysisDetails.ClipboardCopyMode = (Microsoft.Windows.Controls.DataGridClipboardCopyMode)DataGridClipboardCopyMode.IncludeHeader;
                GetRefreshedData();
            }
            catch (Exception ex)
            {
                ExceptionManager.Publish(ex);
            }
        }
        public void Refresh(int iType, AnalysisView viewType, int zoneId, DateTime dteStartDate, DateTime DteEndDate)
        {
            try
            {
                _iType = iType;
                //lblStatus.Visibility = Visibility.Hidden;
                //progressBar1.Visibility = Visibility.Hidden;
                lstAnalysisDetails.Visibility   = Visibility.Visible;
                lstCollectionDetails.Visibility = Visibility.Hidden;
                //GridViewColumn_NoOfMC.Width = (viewType == AnalysisView.Zone) ? 78 : 0;
                string reportType = string.Empty;
                switch (iType.ToString())
                {
                case "1":
                    reportType = "DAY";
                    break;

                case "2":
                    reportType = "DROP";
                    break;

                case "3":
                    reportType = "WEEK";
                    break;

                case "4":
                    reportType = "MONTH";
                    break;
                }
                LogManager.WriteLog("UCAnalysisDetails:Refresh ZoneID:" + zoneId + " ReportType:" + reportType, LogManager.enumLogLevel.Info);
                Action doAnalysis = () =>
                {
                    IAnalysis objCashdesk = AnalysisBusinessObject.CreateInstance();
                    dtAnalysisDetails = objCashdesk.GetAnalysisDetails(iType, dteStartDate, DteEndDate, viewType, zoneId);
                };


                if (iType == 2)
                {
                    //Getting Installation No for grabbing current meters
                    IList <int> inst = (new CommonDataAccess()).GetInstallationDetailsForReports(reportType)
                                       .AsEnumerable()
                                       .Where(r => (zoneId == -1 ? true : (r["Zone_No"] != DBNull.Value ? (r.Field <int>("Zone_No") == zoneId) : false)))
                                       .Select(row => row.Field <int>("Installation_No"))
                                       .ToList <int>();

                    //Grabbing current meters from VLT
                    LoadingWindow ld_analysis = new LoadingWindow(this, Audit.Transport.ModuleName.AnalysisDetails, inst, doAnalysis);

                    ld_analysis.ShowDialog();
                }
                else
                {
                    LoadingWindow ld_analysis = new LoadingWindow(this, Audit.Transport.ModuleName.AnalysisDetails, doAnalysis, true);

                    ld_analysis.ShowDialog();
                }

                dtPrintDetails = null;
                dtPrintDetails = dtAnalysisDetails.Copy();
                if (dtPrintDetails.Rows.Count > 0)
                {
                    TotalAvgBet = Convert.ToDecimal(dtPrintDetails.Rows[0]["AvgBet"]);
                    dtPrintDetails.Rows[0].Delete();
                    dtPrintDetails.AcceptChanges();
                }
                lstAnalysisDetails.DataContext = dtAnalysisDetails.DefaultView;
                foreach (Microsoft.Windows.Controls.DataGridColumn gvCol in lstAnalysisDetails.Columns)
                {
                    ResizeGridViewColumn(gvCol);
                    lstAnalysisDetails.Columns[0].Width = 0;
                }
                //txtHeader.Visibility = Visibility.Visible;
                //txtHeader1.Visibility = Visibility.Hidden;
                btnPrint.Visibility  = Visibility.Visible;
                btnExport.Visibility = Visibility.Visible;

                if (!Settings.IsAFTEnabledForSite)
                {
                    this.lstAnalysisDetails.Columns.Remove(gvColCashableEFTIn);
                    this.lstAnalysisDetails.Columns.Remove(gvColCashableEFTOut);
                    this.lstAnalysisDetails.Columns.Remove(gvColNonCashableEFTIn);
                    this.lstAnalysisDetails.Columns.Remove(gvColNonCashableEFTOut);
                    this.lstAnalysisDetails.Columns.Remove(gvColWATIn);
                    this.lstAnalysisDetails.Columns.Remove(gvColWATOut);

                    dtPrintDetails.Columns.Add("CashableEFTIn", typeof(decimal), "0.00");
                    dtPrintDetails.Columns.Add("CashableEFTOut", typeof(decimal), "0.00");
                    dtPrintDetails.Columns.Add("NonCashableEFTIn", typeof(decimal), "0.00");
                    dtPrintDetails.Columns.Add("NonCashableEFTOut", typeof(decimal), "0.00");
                    dtPrintDetails.Columns.Add("WATIn", typeof(decimal), "0.00");
                    dtPrintDetails.Columns.Add("WATOut", typeof(decimal), "0.00");
                }

                GetRefreshedData();
            }
            catch (Exception ex)
            {
                MessageBox.ShowBox(ex.Message, true);
                ExceptionManager.Publish(ex);
            }
        }
 public void Refresh(AnalysisView viewType, int zoneId)
 {
     Refresh(_iType, viewType, zoneId, _dteStartDate, _DteEndDate);
 }
        private void btnRefresh_Click(object sender, RoutedEventArgs e)
        {
            AnalysisView viewType = (cmbView.SelectedIndex == 0 ? AnalysisView.Position : AnalysisView.Zone);

            Refresh(_iType, viewType, (int)cmbFilter.SelectedValue, _dteStartDate, _DteEndDate);
        }
        public DataTable GetAnalysisDetails(int SpotCheckDataType, DateTime StartDate, DateTime EndDate, AnalysisView viewType, int zoneId)
        {
            DataTable dtAnalysis = new DataTable();



            double TotalCashIn = 0;
            double TotalCashOut = 0;
            double Totalhandle = 0;
            int InstallationNo = 0;
            double TotalDrop = 0;
            double TotalBills = 0;
            double TotalTicketsIn = 0;
            double TotalCoinsIn = 0;
            double TotalCoinsOut = 0;
            double TicketsOut = 0;
            double TotalHandpay = 0;
            double TotalJackpot = 0;
            double TotalPayout = 0;
            double ProgressiveHandpay = 0;

            double CashableEFTIn = 0;
            double CashableEFTOut = 0;
            double NonCashableEFTIn = 0;
            double NonCashableEFTOut = 0;
            double WATIn = 0;
            double WATOut = 0;

            double TotalNonCashableTicketsIn = 0;
            double TotalNonCashableTicketsOut = 0;
            double TotalMDA = 0;
            double TotalAvgBet = 0;
            double TotalWon = 0;
            double TotalCashRefills = 0;
            DateTime InstallationEndDate;
            double TotalNetWin = 0;
            double NumberofDays = 0;
            double GAMES_BET = 0;


            string reportType = string.Empty;

            IDictionary<int, GetGroupByZone> zoneRows = new SortedDictionary<int, GetGroupByZone>();

            dtAnalysis.Columns.Add("Installation_No");
            dtAnalysis.Columns.Add("Bar_Pos_Name");
            dtAnalysis.Columns.Add("Zone_No");
            dtAnalysis.Columns.Add("Zone_Name");
            dtAnalysis.Columns.Add("Stock_No");
            dtAnalysis.Columns.Add("Name");
            dtAnalysis.Columns.Add("LastMeterDate", typeof(DateTime));
            dtAnalysis.Columns.Add("LastMeterUpdate");
            dtAnalysis.Columns.Add("NoofMachine");
            dtAnalysis.Columns.Add("GMUtoMachine");
            dtAnalysis.Columns.Add("GMUtoServer");
            dtAnalysis.Columns.Add("Bills_In", typeof(decimal));
            dtAnalysis.Columns.Add("Coin_In", typeof(decimal));
            dtAnalysis.Columns.Add("Coin_Out", typeof(decimal));
            dtAnalysis.Columns.Add("Drop", typeof(decimal));
            dtAnalysis.Columns.Add("Tickets_In", typeof(decimal));
            dtAnalysis.Columns.Add("Tickets_Out", typeof(decimal));
            dtAnalysis.Columns.Add("Non_Cashable_Tickets_In", typeof(decimal));
            dtAnalysis.Columns.Add("Non_Cashable_Tickets_Out", typeof(decimal));
            dtAnalysis.Columns.Add("Handpay", typeof(decimal));
            dtAnalysis.Columns.Add("Jackpot", typeof(decimal));
            dtAnalysis.Columns.Add("Prog_Handpay", typeof(decimal));

            if (Settings.IsAFTEnabledForSite)
            {
                dtAnalysis.Columns.Add("CashableEFTIn", typeof(decimal));
                dtAnalysis.Columns.Add("CashableEFTOut", typeof(decimal));
                dtAnalysis.Columns.Add("NonCashableEFTIn", typeof(decimal));
                dtAnalysis.Columns.Add("NonCashableEFTOut", typeof(decimal));
                dtAnalysis.Columns.Add("WATIn", typeof(decimal));
                dtAnalysis.Columns.Add("WATOut", typeof(decimal));
            }
            dtAnalysis.Columns.Add("Cash_In", typeof(decimal));
            dtAnalysis.Columns.Add("Cash_Out", typeof(decimal));
            dtAnalysis.Columns.Add("Handle", typeof(decimal));
            dtAnalysis.Columns.Add("Payout", typeof(decimal));
            dtAnalysis.Columns.Add("MDA", typeof(decimal));
            dtAnalysis.Columns.Add("AvgBet", typeof(decimal));
            dtAnalysis.Columns.Add("NetWin", typeof(decimal));

            dtAnalysis.Columns.Add("Won", typeof(decimal));
            dtAnalysis.Columns.Add("Cash_Refills", typeof(decimal));
            dtAnalysis.Columns.Add("SortColumn", typeof(int));//used to maintain Row "Total" in top
            dtAnalysis.Columns.Add("NumberofDays", typeof(decimal));
            dtAnalysis.Columns.Add("GAMES_BET", typeof(decimal));
            dtAnalysis.Columns.Add("IsTotalRow", typeof(bool)).DefaultValue = false;

            try
            {
                switch (SpotCheckDataType.ToString())
                {
                    case "1":
                        reportType = "DAY";
                        break;
                    case "2":
                        reportType = "DROP";
                        break;
                    case "3":
                        reportType = "WEEK";
                        break;
                    case "4":
                        reportType = "MONTH";
                        break;
                }

                DataTable dtDetails = new CommonDataAccess().GetInstallationDetailsForReports(reportType);
                bool isGrouping = false;
                if (zoneId != -1)
                {
                    dtDetails = (from i in dtDetails.Rows.OfType<DataRow>()
                                 where i["Zone_No"].ToString() == zoneId.ToString()
                                 select i).CopyToDataTable();
                    isGrouping = (viewType == AnalysisView.Zone);
                }
                if (zoneId == -1 && viewType == AnalysisView.Zone)
                {
                    isGrouping = true;
                }
                int ZoneCount = 0;
                foreach (DataRow InstallationDetail in dtDetails.Rows)
                {
                    if (InstallationDetail["Installation_No"] != DBNull.Value)
                    {
                        InstallationNo = Convert.ToInt32(InstallationDetail["Installation_No"]);
                        DateTime dt_date = DateTime.Now;
                        InstallationEndDate = ((InstallationDetail["End_Date"]) != DBNull.Value) ? Convert.ToDateTime(InstallationDetail["End_Date"]) : DateTime.Now.AddDays(1);
                        int StartOfDay = 0;

                        switch (SpotCheckDataType)
                        {
                            case 1:
                                StartOfDay = 1;
                                break;
                            case 2:
                                //spotCheckData.Type = 2;
                                StartOfDay = 2;
                                break;
                            case 3:
                                StartDate = analysisDataAccessHandler.GetMonthOrWeekStartDate().Rows[0]["WeekStart"].ToString().ReadDate();
                                dt_date = StartDate;
                                //if (InstallationEndDate.Date <= StartDate.Date) continue;
                                break;
                            case 4:
                                StartDate = analysisDataAccessHandler.GetMonthOrWeekStartDate().Rows[0]["MonthStart"].ToString().ReadDate();
                                dt_date = StartDate;
                                //if (InstallationEndDate.Date <= StartDate.Date) continue;
                                break;
                        }
                        LogManager.WriteLog("GetAnalysisDetails:Getting Meters for DB for Installation:" + InstallationNo, LogManager.enumLogLevel.Info);
                        DataTable dt_CurrMeters = analysisDataAccessHandler.GetAnalysisDetails(InstallationNo, StartOfDay, 0, dt_date);
                        DataRow dr_CurrM = null;
                        if (dt_CurrMeters.Rows.Count > 0)
                        {
                            dr_CurrM = dt_CurrMeters.Rows[0];
                        }
                        else
                        {

                            LogManager.WriteLog("GetAnalysisDetails:InstallationNo Not Found", LogManager.enumLogLevel.Error);

                        }

                        DataRow dr = null;
                        int zoneIdActual = 0;
                        Int32.TryParse(InstallationDetail["Zone_No"].ToString(), out zoneIdActual);
                        bool addToCollection = false;

                        switch (viewType)
                        {
                            case AnalysisView.Zone:
                                if (zoneRows.ContainsKey(zoneIdActual))
                                {
                                    GetGroupByZone gp_zone = zoneRows[zoneIdActual];
                                    dr = gp_zone.dr_row;
                                    gp_zone.count += 1;
                                   
                                }
                                else
                                {                                   
                                    addToCollection = true;
                                }
                                break;

                            default:
                                break;
                        }

                        if (dr == null)
                        {
                            dr = dtAnalysis.NewRow();
                            dtAnalysis.Rows.Add(dr);
                            if (addToCollection)
                            {
                                zoneRows.Add(zoneIdActual, new GetGroupByZone { dr_row = dr, count = 1 });

                            }
                        }

                        if (!isGrouping)
                        {
                            dr["Installation_No"] = InstallationDetail["Installation_no"].ToString();
                            dr["Bar_Pos_Name"] = InstallationDetail["Bar_Pos_Name"].ToString();
                            dr["Stock_No"] = InstallationDetail["Stock_No"].ToString();
                            dr["Name"] = InstallationDetail["Name"].ToString();
                            dr["LastMeterUpdate"] = InstallationDetail["LastMeterUpdate"].Equals(DBNull.Value) ? "" : Convert.ToDateTime(InstallationDetail["LastMeterUpdate"]).ToString("dd-MMM-yyyy HH:mm:ss");
                            dr["LastMeterDate"] = InstallationDetail["LastMeterUpdate"].Equals(DBNull.Value) ? DateTime.MinValue : InstallationDetail["LastMeterUpdate"];
                            //dr["Payout"] = Convert.ToDouble(dr_CurrM["Payout"]).ToString("F");

                            if (Convert.ToInt16(InstallationDetail["Datapak_PollingStatus"]) == 0)
                                dr["GMUtoServer"] = "ERROR";
                            else
                                dr["GMUtoServer"] = "OK";
                            if (Convert.ToInt16(InstallationDetail["GMU_Machine_Status"]) == 0)
                                dr["GMUtoMachine"] = "ERROR";
                            else
                            {
                                if (Convert.ToInt16(InstallationDetail["Datapak_PollingStatus"]) == 0)
                                    dr["GMUtoMachine"] = "UNKNOWN";
                                else
                                    dr["GMUtoMachine"] = "OK";
                            }
                        }
                        else
                        {
                            dr["Installation_No"] = string.Empty;
                            dr["Bar_Pos_Name"] = string.Empty;
                            dr["Stock_No"] = string.Empty;
                            dr["Name"] = string.Empty;
                            dr["LastMeterUpdate"] = string.Empty;
                            //dr["Payout"] = string.Empty;
                        }


                        dr["SortColumn"] = 0;

                        if (viewType == AnalysisView.Zone)
                        {
                            dr["NoofMachine"] = zoneRows[zoneIdActual].count;
                        }
                        else
                        {
                            dr["NoofMachine"] = Convert.ToInt32(InstallationDetail["NoofMachine"] != DBNull.Value ? InstallationDetail["NoofMachine"] : 0);
                        }

                        dr["Zone_No"] = InstallationDetail["Zone_No"].ToString();
                        dr["Zone_Name"] = InstallationDetail["Zone_Name"].ToString();
                        dr_CurrM["NumberofDays"] = Convert.ToDouble(dr_CurrM["NumberofDays"]).ToString();
                        dr_CurrM["GAMES_BET"] = Convert.ToDouble(dr_CurrM["GAMES_BET"]).ToString();
                        dr_CurrM["Payout"] = Convert.ToDouble(dr_CurrM["Payout"]).ToString("F");
                        TotalBills += this.AddIntValue(dr, dr_CurrM, "Bills_In");
                        TotalTicketsIn += this.AddDoubleValue(dr, dr_CurrM, "Tickets_In");

                        TotalCoinsIn += this.AddDoubleValue(dr, dr_CurrM, "Coin_In");
                        TotalNonCashableTicketsIn += this.AddDoubleValue(dr, dr_CurrM, "Non_Cashable_Tickets_In");
                        TotalNonCashableTicketsOut += this.AddDoubleValue(dr, dr_CurrM, "Non_Cashable_Tickets_Out");
                        TotalPayout += this.AddDoubleValue(dr, dr_CurrM, "Payout");
                        TotalDrop += this.AddDoubleValue(dr, dr_CurrM, "Drop");
                        TotalCashIn += this.AddDoubleValue(dr, dr_CurrM, "Cash_In");
                        TotalCashOut += this.AddDoubleValue(dr, dr_CurrM, "Cash_Out");

                        TotalNetWin += this.AddDoubleValue(dr, dr_CurrM, "NetWin");
                        NumberofDays += this.AddDoubleValue(dr, dr_CurrM, "NumberofDays");
                        GAMES_BET += this.AddDoubleValue(dr, dr_CurrM, "GAMES_BET");
                        Totalhandle += this.AddDoubleValue(dr, dr_CurrM, "Handle");
                        TotalMDA += this.AddDoubleValue(dr, dr_CurrM, "MDA");
                        TotalCoinsOut += this.AddDoubleValue(dr, dr_CurrM, "Coin_Out");
                        TicketsOut += this.AddDoubleValue(dr, dr_CurrM, "Tickets_Out");
                        TotalHandpay += this.AddDoubleValue(dr, dr_CurrM, "Handpay");
                        TotalJackpot += this.AddDoubleValue(dr, dr_CurrM, "Jackpot");
                        ProgressiveHandpay += this.AddDoubleValue(dr, dr_CurrM, "Prog_Handpay");
                        TotalAvgBet += this.AddDoubleValue(dr, dr_CurrM, "AvgBet");

                        TotalWon += this.AddDoubleValue(dr, dr_CurrM, "WON"); ;
                        TotalCashRefills += this.AddDoubleValue(dr, dr_CurrM, "Cash_Refills");
                        if (Settings.IsAFTEnabledForSite)
                        {
                            CashableEFTIn += this.AddDoubleValue(dr, dr_CurrM, "CashableEFTIn");
                            CashableEFTOut += this.AddDoubleValue(dr, dr_CurrM, "CashableEFTOut");
                            NonCashableEFTIn += this.AddDoubleValue(dr, dr_CurrM, "NonCashableEFTIn");
                            NonCashableEFTOut += this.AddDoubleValue(dr, dr_CurrM, "NonCashableEFTOut");
                            WATIn += this.AddDoubleValue(dr, dr_CurrM, "WATIn");
                            WATOut += this.AddDoubleValue(dr, dr_CurrM, "WATOut");
                        }

                    }
                }

                if (dtAnalysis.Rows.Count > 0)
                {
                    DataRow SumOfRows = dtAnalysis.NewRow();
                    SumOfRows["Installation_No"] = string.Empty;
                    SumOfRows["Bar_Pos_Name"] = "Total";
                    SumOfRows["Stock_No"] = string.Empty;
                    SumOfRows["Name"] = string.Empty;
                    SumOfRows["LastMeterUpdate"] = string.Empty;
                    SumOfRows["Cash_In"] = TotalCashIn;
                    SumOfRows["Cash_Out"] = TotalCashOut;
                    SumOfRows["NetWin"] = (TotalCashIn - TotalCashOut);
                    SumOfRows["Handle"] = Totalhandle;
                    SumOfRows["Drop"] = TotalDrop;
                    SumOfRows["NoofMachine"] = dtDetails.Rows.Count;
                    SumOfRows["WON"] = TotalWon;
                    SumOfRows["Cash_Refills"] = TotalCashRefills;
                    SumOfRows["IsTotalRow"] = true;
                    if (Totalhandle != 0)
                        SumOfRows["Payout"] = Math.Round(((Totalhandle - TotalNetWin) / Totalhandle) * 100, 2);
                    else
                        SumOfRows["Payout"] = 0;
                    /// dtDetails.Rows.Count,2,MidpointRounding.AwayFromZero);
                    //if (TotalGamesBet == 0)
                    //    TotalAvgBet = Totalhandle;
                    //else
                    //    TotalAvgBet = Totalhandle / TotalGamesBet;

                    //if (Numberofdays > 0)
                    //    MDA = (decimal)(TotalCashIn - TotalCashOut) /( dtAnalysis.Rows.Count * Numberofdays)  ;
                    //else
                    //    MDA = (decimal)(TotalCashIn - TotalCashOut) / dtAnalysis.Rows.Count;
                    if (GAMES_BET == 0)
                        SumOfRows["AvgBet"] = Math.Round(Totalhandle, 2);
                    else
                        SumOfRows["AvgBet"] = Math.Round(Convert.ToDecimal(Totalhandle / GAMES_BET), 2);// TotalAvgBet;
                    if (NumberofDays == 0)
                        SumOfRows["MDA"] = Math.Round(TotalNetWin, 2);
                    else
                        SumOfRows["MDA"] = Math.Round(Convert.ToDecimal(TotalNetWin / NumberofDays), 2);// TotalMDA;//Modified Total AvgDailyWin calculation CR#92149 Fix
                    SumOfRows["Bills_In"] = TotalBills;
                    SumOfRows["Tickets_In"] = TotalTicketsIn;
                    SumOfRows["Tickets_Out"] = TicketsOut;
                    SumOfRows["Coin_In"] = TotalCoinsIn;
                    SumOfRows["Coin_Out"] = TotalCoinsOut;
                    SumOfRows["Non_Cashable_Tickets_In"] = TotalNonCashableTicketsIn;
                    SumOfRows["Non_Cashable_Tickets_out"] = TotalNonCashableTicketsOut;
                    SumOfRows["Handpay"] = TotalHandpay;
                    SumOfRows["Jackpot"] = TotalJackpot;
                    SumOfRows["Prog_Handpay"] = ProgressiveHandpay;
                    if (Settings.IsAFTEnabledForSite)
                    {
                        SumOfRows["CashableEFTIn"] = CashableEFTIn;
                        SumOfRows["CashableEFTOut"] = CashableEFTOut;
                        SumOfRows["NonCashableEFTIn"] = NonCashableEFTIn;
                        SumOfRows["NonCashableEFTOut"] = NonCashableEFTOut;
                        SumOfRows["WATIn"] = WATIn;
                        SumOfRows["WATOut"] = WATOut;
                    }
                    SumOfRows["SortColumn"] = 100;//used to avoid Column "Total" Sorting
                    dtAnalysis.Rows.InsertAt(SumOfRows, 0);
                }

            }
            catch (Exception ex)
            {
                ExceptionManager.Publish(ex);
            }
            return dtAnalysis;
        }
        public DataTable GetAnalysisDetails(int SpotCheckDataType, DateTime StartDate, DateTime EndDate, AnalysisView viewType, int zoneId)
        {
            DataTable dtAnalysis = new DataTable();



            double TotalCashIn        = 0;
            double TotalCashOut       = 0;
            double Totalhandle        = 0;
            int    InstallationNo     = 0;
            double TotalDrop          = 0;
            double TotalBills         = 0;
            double TotalTicketsIn     = 0;
            double TotalCoinsIn       = 0;
            double TotalCoinsOut      = 0;
            double TicketsOut         = 0;
            double TotalHandpay       = 0;
            double TotalJackpot       = 0;
            double TotalPayout        = 0;
            double ProgressiveHandpay = 0;

            double CashableEFTIn     = 0;
            double CashableEFTOut    = 0;
            double NonCashableEFTIn  = 0;
            double NonCashableEFTOut = 0;
            double WATIn             = 0;
            double WATOut            = 0;

            double   TotalNonCashableTicketsIn  = 0;
            double   TotalNonCashableTicketsOut = 0;
            double   TotalMDA         = 0;
            double   TotalAvgBet      = 0;
            double   TotalWon         = 0;
            double   TotalCashRefills = 0;
            DateTime InstallationEndDate;
            double   TotalNetWin  = 0;
            double   NumberofDays = 0;
            double   GAMES_BET    = 0;


            string reportType = string.Empty;

            IDictionary <int, GetGroupByZone> zoneRows = new SortedDictionary <int, GetGroupByZone>();

            dtAnalysis.Columns.Add("Installation_No");
            dtAnalysis.Columns.Add("Bar_Pos_Name");
            dtAnalysis.Columns.Add("Zone_No");
            dtAnalysis.Columns.Add("Zone_Name");
            dtAnalysis.Columns.Add("Stock_No");
            dtAnalysis.Columns.Add("Name");
            dtAnalysis.Columns.Add("LastMeterDate", typeof(DateTime));
            dtAnalysis.Columns.Add("LastMeterUpdate");
            dtAnalysis.Columns.Add("NoofMachine");
            dtAnalysis.Columns.Add("GMUtoMachine");
            dtAnalysis.Columns.Add("GMUtoServer");
            dtAnalysis.Columns.Add("Bills_In", typeof(decimal));
            dtAnalysis.Columns.Add("Coin_In", typeof(decimal));
            dtAnalysis.Columns.Add("Coin_Out", typeof(decimal));
            dtAnalysis.Columns.Add("Drop", typeof(decimal));
            dtAnalysis.Columns.Add("Tickets_In", typeof(decimal));
            dtAnalysis.Columns.Add("Tickets_Out", typeof(decimal));
            dtAnalysis.Columns.Add("Non_Cashable_Tickets_In", typeof(decimal));
            dtAnalysis.Columns.Add("Non_Cashable_Tickets_Out", typeof(decimal));
            dtAnalysis.Columns.Add("Handpay", typeof(decimal));
            dtAnalysis.Columns.Add("Jackpot", typeof(decimal));
            dtAnalysis.Columns.Add("Prog_Handpay", typeof(decimal));

            if (Settings.IsAFTEnabledForSite)
            {
                dtAnalysis.Columns.Add("CashableEFTIn", typeof(decimal));
                dtAnalysis.Columns.Add("CashableEFTOut", typeof(decimal));
                dtAnalysis.Columns.Add("NonCashableEFTIn", typeof(decimal));
                dtAnalysis.Columns.Add("NonCashableEFTOut", typeof(decimal));
                dtAnalysis.Columns.Add("WATIn", typeof(decimal));
                dtAnalysis.Columns.Add("WATOut", typeof(decimal));
            }
            dtAnalysis.Columns.Add("Cash_In", typeof(decimal));
            dtAnalysis.Columns.Add("Cash_Out", typeof(decimal));
            dtAnalysis.Columns.Add("Handle", typeof(decimal));
            dtAnalysis.Columns.Add("Payout", typeof(decimal));
            dtAnalysis.Columns.Add("MDA", typeof(decimal));
            dtAnalysis.Columns.Add("AvgBet", typeof(decimal));
            dtAnalysis.Columns.Add("NetWin", typeof(decimal));

            dtAnalysis.Columns.Add("Won", typeof(decimal));
            dtAnalysis.Columns.Add("Cash_Refills", typeof(decimal));
            dtAnalysis.Columns.Add("SortColumn", typeof(int));//used to maintain Row "Total" in top
            dtAnalysis.Columns.Add("NumberofDays", typeof(decimal));
            dtAnalysis.Columns.Add("GAMES_BET", typeof(decimal));
            dtAnalysis.Columns.Add("IsTotalRow", typeof(bool)).DefaultValue = false;

            try
            {
                switch (SpotCheckDataType.ToString())
                {
                case "1":
                    reportType = "DAY";
                    break;

                case "2":
                    reportType = "DROP";
                    break;

                case "3":
                    reportType = "WEEK";
                    break;

                case "4":
                    reportType = "MONTH";
                    break;
                }

                DataTable dtDetails  = new CommonDataAccess().GetInstallationDetailsForReports(reportType);
                bool      isGrouping = false;
                if (zoneId != -1)
                {
                    dtDetails = (from i in dtDetails.Rows.OfType <DataRow>()
                                 where i["Zone_No"].ToString() == zoneId.ToString()
                                 select i).CopyToDataTable();
                    isGrouping = (viewType == AnalysisView.Zone);
                }
                if (zoneId == -1 && viewType == AnalysisView.Zone)
                {
                    isGrouping = true;
                }
                int ZoneCount = 0;
                foreach (DataRow InstallationDetail in dtDetails.Rows)
                {
                    if (InstallationDetail["Installation_No"] != DBNull.Value)
                    {
                        InstallationNo = Convert.ToInt32(InstallationDetail["Installation_No"]);
                        DateTime dt_date = DateTime.Now;
                        InstallationEndDate = ((InstallationDetail["End_Date"]) != DBNull.Value) ? Convert.ToDateTime(InstallationDetail["End_Date"]) : DateTime.Now.AddDays(1);
                        int StartOfDay = 0;

                        switch (SpotCheckDataType)
                        {
                        case 1:
                            StartOfDay = 1;
                            break;

                        case 2:
                            //spotCheckData.Type = 2;
                            StartOfDay = 2;
                            break;

                        case 3:
                            StartDate = analysisDataAccessHandler.GetMonthOrWeekStartDate().Rows[0]["WeekStart"].ToString().ReadDate();
                            dt_date   = StartDate;
                            //if (InstallationEndDate.Date <= StartDate.Date) continue;
                            break;

                        case 4:
                            StartDate = analysisDataAccessHandler.GetMonthOrWeekStartDate().Rows[0]["MonthStart"].ToString().ReadDate();
                            dt_date   = StartDate;
                            //if (InstallationEndDate.Date <= StartDate.Date) continue;
                            break;
                        }
                        LogManager.WriteLog("GetAnalysisDetails:Getting Meters for DB for Installation:" + InstallationNo, LogManager.enumLogLevel.Info);
                        DataTable dt_CurrMeters = analysisDataAccessHandler.GetAnalysisDetails(InstallationNo, StartOfDay, 0, dt_date);
                        DataRow   dr_CurrM      = null;
                        if (dt_CurrMeters.Rows.Count > 0)
                        {
                            dr_CurrM = dt_CurrMeters.Rows[0];
                        }
                        else
                        {
                            LogManager.WriteLog("GetAnalysisDetails:InstallationNo Not Found", LogManager.enumLogLevel.Error);
                        }

                        DataRow dr           = null;
                        int     zoneIdActual = 0;
                        Int32.TryParse(InstallationDetail["Zone_No"].ToString(), out zoneIdActual);
                        bool addToCollection = false;

                        switch (viewType)
                        {
                        case AnalysisView.Zone:
                            if (zoneRows.ContainsKey(zoneIdActual))
                            {
                                GetGroupByZone gp_zone = zoneRows[zoneIdActual];
                                dr             = gp_zone.dr_row;
                                gp_zone.count += 1;
                            }
                            else
                            {
                                addToCollection = true;
                            }
                            break;

                        default:
                            break;
                        }

                        if (dr == null)
                        {
                            dr = dtAnalysis.NewRow();
                            dtAnalysis.Rows.Add(dr);
                            if (addToCollection)
                            {
                                zoneRows.Add(zoneIdActual, new GetGroupByZone {
                                    dr_row = dr, count = 1
                                });
                            }
                        }

                        if (!isGrouping)
                        {
                            dr["Installation_No"] = InstallationDetail["Installation_no"].ToString();
                            dr["Bar_Pos_Name"]    = InstallationDetail["Bar_Pos_Name"].ToString();
                            dr["Stock_No"]        = InstallationDetail["Stock_No"].ToString();
                            dr["Name"]            = InstallationDetail["Name"].ToString();
                            dr["LastMeterUpdate"] = InstallationDetail["LastMeterUpdate"].Equals(DBNull.Value) ? "" : Convert.ToDateTime(InstallationDetail["LastMeterUpdate"]).ToString("dd-MMM-yyyy HH:mm:ss");
                            dr["LastMeterDate"]   = InstallationDetail["LastMeterUpdate"].Equals(DBNull.Value) ? DateTime.MinValue : InstallationDetail["LastMeterUpdate"];
                            //dr["Payout"] = Convert.ToDouble(dr_CurrM["Payout"]).ToString("F");

                            if (Convert.ToInt16(InstallationDetail["Datapak_PollingStatus"]) == 0)
                            {
                                dr["GMUtoServer"] = "ERROR";
                            }
                            else
                            {
                                dr["GMUtoServer"] = "OK";
                            }
                            if (Convert.ToInt16(InstallationDetail["GMU_Machine_Status"]) == 0)
                            {
                                dr["GMUtoMachine"] = "ERROR";
                            }
                            else
                            {
                                if (Convert.ToInt16(InstallationDetail["Datapak_PollingStatus"]) == 0)
                                {
                                    dr["GMUtoMachine"] = "UNKNOWN";
                                }
                                else
                                {
                                    dr["GMUtoMachine"] = "OK";
                                }
                            }
                        }
                        else
                        {
                            dr["Installation_No"] = string.Empty;
                            dr["Bar_Pos_Name"]    = string.Empty;
                            dr["Stock_No"]        = string.Empty;
                            dr["Name"]            = string.Empty;
                            dr["LastMeterUpdate"] = string.Empty;
                            //dr["Payout"] = string.Empty;
                        }


                        dr["SortColumn"] = 0;

                        if (viewType == AnalysisView.Zone)
                        {
                            dr["NoofMachine"] = zoneRows[zoneIdActual].count;
                        }
                        else
                        {
                            dr["NoofMachine"] = Convert.ToInt32(InstallationDetail["NoofMachine"] != DBNull.Value ? InstallationDetail["NoofMachine"] : 0);
                        }

                        dr["Zone_No"]            = InstallationDetail["Zone_No"].ToString();
                        dr["Zone_Name"]          = InstallationDetail["Zone_Name"].ToString();
                        dr_CurrM["NumberofDays"] = Convert.ToDouble(dr_CurrM["NumberofDays"]).ToString();
                        dr_CurrM["GAMES_BET"]    = Convert.ToDouble(dr_CurrM["GAMES_BET"]).ToString();
                        dr_CurrM["Payout"]       = Convert.ToDouble(dr_CurrM["Payout"]).ToString("F");
                        TotalBills     += this.AddIntValue(dr, dr_CurrM, "Bills_In");
                        TotalTicketsIn += this.AddDoubleValue(dr, dr_CurrM, "Tickets_In");

                        TotalCoinsIn += this.AddDoubleValue(dr, dr_CurrM, "Coin_In");
                        TotalNonCashableTicketsIn  += this.AddDoubleValue(dr, dr_CurrM, "Non_Cashable_Tickets_In");
                        TotalNonCashableTicketsOut += this.AddDoubleValue(dr, dr_CurrM, "Non_Cashable_Tickets_Out");
                        TotalPayout  += this.AddDoubleValue(dr, dr_CurrM, "Payout");
                        TotalDrop    += this.AddDoubleValue(dr, dr_CurrM, "Drop");
                        TotalCashIn  += this.AddDoubleValue(dr, dr_CurrM, "Cash_In");
                        TotalCashOut += this.AddDoubleValue(dr, dr_CurrM, "Cash_Out");

                        TotalNetWin        += this.AddDoubleValue(dr, dr_CurrM, "NetWin");
                        NumberofDays       += this.AddDoubleValue(dr, dr_CurrM, "NumberofDays");
                        GAMES_BET          += this.AddDoubleValue(dr, dr_CurrM, "GAMES_BET");
                        Totalhandle        += this.AddDoubleValue(dr, dr_CurrM, "Handle");
                        TotalMDA           += this.AddDoubleValue(dr, dr_CurrM, "MDA");
                        TotalCoinsOut      += this.AddDoubleValue(dr, dr_CurrM, "Coin_Out");
                        TicketsOut         += this.AddDoubleValue(dr, dr_CurrM, "Tickets_Out");
                        TotalHandpay       += this.AddDoubleValue(dr, dr_CurrM, "Handpay");
                        TotalJackpot       += this.AddDoubleValue(dr, dr_CurrM, "Jackpot");
                        ProgressiveHandpay += this.AddDoubleValue(dr, dr_CurrM, "Prog_Handpay");
                        TotalAvgBet        += this.AddDoubleValue(dr, dr_CurrM, "AvgBet");

                        TotalWon         += this.AddDoubleValue(dr, dr_CurrM, "WON");;
                        TotalCashRefills += this.AddDoubleValue(dr, dr_CurrM, "Cash_Refills");
                        if (Settings.IsAFTEnabledForSite)
                        {
                            CashableEFTIn     += this.AddDoubleValue(dr, dr_CurrM, "CashableEFTIn");
                            CashableEFTOut    += this.AddDoubleValue(dr, dr_CurrM, "CashableEFTOut");
                            NonCashableEFTIn  += this.AddDoubleValue(dr, dr_CurrM, "NonCashableEFTIn");
                            NonCashableEFTOut += this.AddDoubleValue(dr, dr_CurrM, "NonCashableEFTOut");
                            WATIn             += this.AddDoubleValue(dr, dr_CurrM, "WATIn");
                            WATOut            += this.AddDoubleValue(dr, dr_CurrM, "WATOut");
                        }
                    }
                }

                if (dtAnalysis.Rows.Count > 0)
                {
                    DataRow SumOfRows = dtAnalysis.NewRow();
                    SumOfRows["Installation_No"] = string.Empty;
                    SumOfRows["Bar_Pos_Name"]    = "Total";
                    SumOfRows["Stock_No"]        = string.Empty;
                    SumOfRows["Name"]            = string.Empty;
                    SumOfRows["LastMeterUpdate"] = string.Empty;
                    SumOfRows["Cash_In"]         = TotalCashIn;
                    SumOfRows["Cash_Out"]        = TotalCashOut;
                    SumOfRows["NetWin"]          = (TotalCashIn - TotalCashOut);
                    SumOfRows["Handle"]          = Totalhandle;
                    SumOfRows["Drop"]            = TotalDrop;
                    SumOfRows["NoofMachine"]     = dtDetails.Rows.Count;
                    SumOfRows["WON"]             = TotalWon;
                    SumOfRows["Cash_Refills"]    = TotalCashRefills;
                    SumOfRows["IsTotalRow"]      = true;
                    if (Totalhandle != 0)
                    {
                        SumOfRows["Payout"] = Math.Round(((Totalhandle - TotalNetWin) / Totalhandle) * 100, 2);
                    }
                    else
                    {
                        SumOfRows["Payout"] = 0;
                    }
                    /// dtDetails.Rows.Count,2,MidpointRounding.AwayFromZero);
                    //if (TotalGamesBet == 0)
                    //    TotalAvgBet = Totalhandle;
                    //else
                    //    TotalAvgBet = Totalhandle / TotalGamesBet;

                    //if (Numberofdays > 0)
                    //    MDA = (decimal)(TotalCashIn - TotalCashOut) /( dtAnalysis.Rows.Count * Numberofdays)  ;
                    //else
                    //    MDA = (decimal)(TotalCashIn - TotalCashOut) / dtAnalysis.Rows.Count;
                    if (GAMES_BET == 0)
                    {
                        SumOfRows["AvgBet"] = Math.Round(Totalhandle, 2);
                    }
                    else
                    {
                        SumOfRows["AvgBet"] = Math.Round(Convert.ToDecimal(Totalhandle / GAMES_BET), 2);// TotalAvgBet;
                    }
                    if (NumberofDays == 0)
                    {
                        SumOfRows["MDA"] = Math.Round(TotalNetWin, 2);
                    }
                    else
                    {
                        SumOfRows["MDA"] = Math.Round(Convert.ToDecimal(TotalNetWin / NumberofDays), 2);// TotalMDA;//Modified Total AvgDailyWin calculation CR#92149 Fix
                    }
                    SumOfRows["Bills_In"]                 = TotalBills;
                    SumOfRows["Tickets_In"]               = TotalTicketsIn;
                    SumOfRows["Tickets_Out"]              = TicketsOut;
                    SumOfRows["Coin_In"]                  = TotalCoinsIn;
                    SumOfRows["Coin_Out"]                 = TotalCoinsOut;
                    SumOfRows["Non_Cashable_Tickets_In"]  = TotalNonCashableTicketsIn;
                    SumOfRows["Non_Cashable_Tickets_out"] = TotalNonCashableTicketsOut;
                    SumOfRows["Handpay"]                  = TotalHandpay;
                    SumOfRows["Jackpot"]                  = TotalJackpot;
                    SumOfRows["Prog_Handpay"]             = ProgressiveHandpay;
                    if (Settings.IsAFTEnabledForSite)
                    {
                        SumOfRows["CashableEFTIn"]     = CashableEFTIn;
                        SumOfRows["CashableEFTOut"]    = CashableEFTOut;
                        SumOfRows["NonCashableEFTIn"]  = NonCashableEFTIn;
                        SumOfRows["NonCashableEFTOut"] = NonCashableEFTOut;
                        SumOfRows["WATIn"]             = WATIn;
                        SumOfRows["WATOut"]            = WATOut;
                    }
                    SumOfRows["SortColumn"] = 100;//used to avoid Column "Total" Sorting
                    dtAnalysis.Rows.InsertAt(SumOfRows, 0);
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.Publish(ex);
            }
            return(dtAnalysis);
        }
 public DataTable GetAnalysisDetails(int Type, DateTime StartDate, DateTime EndDate, AnalysisView viewType, int zoneId)
 {
     return analysis.GetAnalysisDetails(Type, StartDate, EndDate, viewType, zoneId);
 }
 public void showAnalysisScreen()
 {
     analysisView = new AnalysisView();
     view.showAnalysisScreen(analysisView);
 }
 public DataTable GetAnalysisDetails(int Type, DateTime StartDate, DateTime EndDate, AnalysisView viewType, int zoneId)
 {
     return(analysis.GetAnalysisDetails(Type, StartDate, EndDate, viewType, zoneId));
 }