public void UpdateChartsList(ViewDataDictionary ViewDataTransmitted) { // this should be a reflection of the Index view // method called from the controller before initialisation of the Index view or on form submit inside Index view // charts are all created before the call to the view ListChartsCreated = null; int ChartId = 1; DateTime bTF = DateTime.Parse(ViewDataTransmitted["BeginningTF"].ToString(), culture); DateTime eTF = DateTime.Parse(ViewDataTransmitted["EndTF"].ToString(), culture); string ds = ViewDataTransmitted["DeptSelected"].ToString(); string bTS = ViewDataTransmitted["bkgTypeSelected"].ToString(); // the bookings are only selected after the "01/02/2015" var deadlineTable = perfRepo.GenerateDeadlineTable(); var keyStagesDates = compDbRepo.RetrieveKeyStagesDates(); AllBookingsForAnalysis = AllBookingsForAnalysis ?? tpRepo.TransformAllBookings(BeginningFY15, deadlineTable, keyStagesDates); // list of all precalculated charts that will be displayed on the view IList <ChartDisplayed> lCD = new List <ChartDisplayed>(); // Year on year analysis charts ChartParam cpYOY1 = new ChartParam { BeginningTF = bTF, EndTF = eTF, dptSelected = ds, btSelected = bTS, at = analysisType.YearOnYear, bs = bookingStage.received, vd = valueDisplayed.bookingsAmount }; ChartDisplayed cdYOY1 = new ChartDisplayed(cpYOY1, this, ReportType: "YearOnYear"); cdYOY1.ChartId = ChartId; ChartId++; lCD.Add(cdYOY1); ChartParam cpYOY2 = new ChartParam { BeginningTF = bTF, EndTF = eTF, dptSelected = ds, btSelected = bTS, at = analysisType.YearOnYearCumulative, bs = bookingStage.received, vd = valueDisplayed.bookingsAmount }; ChartDisplayed cdYOY2 = new ChartDisplayed(cpYOY2, this, ReportType: "YearOnYear"); cdYOY2.ChartId = ChartId; ChartId++; lCD.Add(cdYOY2); // Departmental and clients overview for (int iAT = 0; iAT < 2; iAT++) { ChartParam cp = new ChartParam { BeginningTF = bTF, EndTF = eTF, dptSelected = ds, btSelected = bTS, at = (analysisType)iAT, bs = bookingStage.received, vd = valueDisplayed.bookingsAmount }; ChartDisplayed cd = new ChartDisplayed(cp, this); cd.ChartId = ChartId; ChartId++; lCD.Add(cd); } // turnover: location analysis , Clients Category analysis ,client name analysis for (int iBS = 1; iBS < 4; iBS++) { for (int iAT = 1; iAT < 4; iAT++) { ChartParam cp = new ChartParam { BeginningTF = bTF, EndTF = eTF, dptSelected = ds, btSelected = bTS, at = (analysisType)iAT, bs = (bookingStage)iBS, vd = valueDisplayed.turnover }; ChartDisplayed cd = new ChartDisplayed(cp, this); cd.ChartId = ChartId; ChartId++; lCD.Add(cd); } } // offers received , sent , confirmed , cancelled , pending , pending past deadline , pendingSalesBDOPS for (int iAT = 2; iAT < 7; iAT++) { for (int iBS = 0; iBS < 8; iBS++) { ChartParam cp = new ChartParam { BeginningTF = bTF, EndTF = eTF, dptSelected = ds, btSelected = bTS, at = (analysisType)iAT, bs = (bookingStage)iBS, vd = valueDisplayed.bookingsAmount }; ChartDisplayed cd = new ChartDisplayed(cp, this); cd.ChartId = ChartId; ChartId++; lCD.Add(cd); } } // offers pending as requotes , per consultant ChartParam cpRequote = new ChartParam { BeginningTF = bTF, EndTF = eTF, dptSelected = ds, btSelected = bTS, at = analysisType.BDconsultant, bs = bookingStage.pendingSalesBDOPSRequote, vd = valueDisplayed.bookingsAmount }; ChartDisplayed cdRequote = new ChartDisplayed(cpRequote, this); cdRequote.ChartId = ChartId; ChartId++; lCD.Add(cdRequote); // offers pending as first quotes , per consultant ChartParam cpFirstquote = new ChartParam { BeginningTF = bTF, EndTF = eTF, dptSelected = ds, btSelected = bTS, at = analysisType.BDconsultant, bs = bookingStage.pendingSalesBDOPSFirstQuote, vd = valueDisplayed.bookingsAmount }; ChartDisplayed cdFirstquote = new ChartDisplayed(cpFirstquote, this); cdFirstquote.ChartId = ChartId; ChartId++; lCD.Add(cdFirstquote); ListChartsCreated = lCD.AsQueryable <ChartDisplayed>(); // Creation of a Table of bookings used to check the charts BkgsSelectedInView = AllBookingsForAnalysis; // filter by department: if (ds != "All") { BkgsSelectedInView = BkgsSelectedInView.Where(b => b.CompanyDepartment == ds); } // filter by booking type: IList <string> btCodesSelected = (IList <string>)compSpec.bookingTypes[bTS]; BkgsSelectedInView = BkgsSelectedInView.Where(b => btCodesSelected.Contains(b.BkgType.Trim())); // sort by date entered belonging to the time frame IEnumerable <BkgAnalysisInfo> BkgsSelectedDE = BkgsSelectedInView.Where(b => (b.DateEntered >= bTF) && (b.DateEntered <= eTF)).OrderBy(b => b.DateEntered); // sort by date confirmed belonging to the timeframe IEnumerable <BkgAnalysisInfo> BkgsSelectedDC = BkgsSelectedInView.Where(b => !string.Equals(b.DateConfirmed, "")); BkgsSelectedDC = BkgsSelectedDC .Where(b => b.DateConfirmed >= bTF && b.DateConfirmed <= eTF) .OrderBy(b => b.DateConfirmed); // merge the 2 lists sorted by timeframe BkgsSelectedInView = BkgsSelectedDC.Union(BkgsSelectedDE); // creation of a second table where data are to be exported to Excel and sorted by date entered BkgsSelectedInView2 = BookingsToBeExported(bTF, eTF, ds, bTS); }
public PopoverElements(ChartDisplayed chartDisplayed) { // create the title switch (chartDisplayed.CP.bs) { case bookingStage.received: title = "Offers received"; break; case bookingStage.sent: title = "Offers sent"; break; case bookingStage.confirmed: title = "Confirmed bookings"; break; case bookingStage.cancelled: title = "Cancelled bookings"; break; case bookingStage.pending: title = "Pending offers"; break; case bookingStage.pendingPastDeadline: title = "Pending offers past deadline"; break; case bookingStage.pendingSalesBDOPS: title = "past deadline with Sale/Bd Ops"; break; case bookingStage.pendingContract: title = "past deadline on contracting"; break; case bookingStage.pendingSalesBDOPSRequote: title = "past deadline being requoted"; break; case bookingStage.pendingSalesBDOPSFirstQuote: title = "pastdeadline being quoted"; break; default: title = "Booking stage not yet titled"; break; } title = (title + " :" + chartDisplayed.Total).Replace(" ", " "); // create the content content = ""; foreach (KeyValuePair <string, double> kvp in chartDisplayed.PieChartLabelsValues) { content += $"{kvp.Key} 
"; } content = content.Replace(" ", " "); }