public string ToHtml(CourseType courseType) { const string cellTemplate = "<div class=\"cell\">{0}</div>\r\n"; var cellsContent = string.Format(cellTemplate, Period); cellsContent += string.Format(cellTemplate, PeriodDate.ToString("MM/yyyy")); if (courseType != CourseType.None) { cellsContent += string.Format(cellTemplate, InterestMonthPercentage.ToString("N4") + "%"); cellsContent += string.Format(cellTemplate, InterestYearPercentage.ToString("N2") + "%"); } cellsContent += string.Format(cellTemplate, InterestPayment.ToString("N0")); cellsContent += string.Format(cellTemplate, FundPayment.ToString("N0")); if (PriceIndexCourses.Contains(courseType)) { cellsContent += string.Format(cellTemplate, FundPaymentWithPriceIndex.ToString("N0")); } cellsContent += string.Format(cellTemplate, TotalFund.ToString("N0")); if (PriceIndexCourses.Contains(courseType)) { cellsContent += string.Format(cellTemplate, TotalFundWithPriceIndex.ToString("N0")); } var paymentTemplate = cellTemplate.Replace("class=\"cell\"", "class=\"cell payment_green\""); cellsContent += string.Format(paymentTemplate, "₪" + TotalPayment.ToString("N0")); var result = $"<div class=\"row\">\r\n{cellsContent.Trim()}\r\n</div>\r\n"; return(result); }
public void Update(PeriodDate entity) { var old = periodDates.AsQueryable <PeriodDate>().SingleOrDefault(pd => pd.PeriodId == entity.PeriodId && pd.TermId == entity.TermId); periodDates.Remove(old); periodDates.Add(entity); }
static PeriodDate GetYearAgo(PeriodDate p) { PeriodDate ret = new PeriodDate(); ret.Begin = p.Begin.AddYears(-1); ret.End = p.End.AddYears(-1); return(ret); }
static PeriodDate GetPeriod(int FrequencyID, bool prev, DateTime DTNow) { PeriodDate ret = new PeriodDate(); ret.Begin = Frequency.GetNormalizedDate(FrequencyID, DTNow); if (prev) { ret.Begin = Frequency.AddPeriod(ret.Begin, FrequencyID, -1); } ret.End = Frequency.AddPeriod(ret.Begin, FrequencyID, 1); return(ret); }
public void Remove(PeriodDate periodDate) { periodDates.Remove(periodDate); }
public void Add(PeriodDate entity) { periodDates.Add(entity); }
public static void GetPeriodDate(int ScoreCardPeriodID, int MetricFrequencyID, DateTime DTNow, out PeriodDate CurentPeriod, out PeriodDate PrevPeriod) { CurentPeriod = null; PrevPeriod = null; switch (ScoreCardPeriodID) { case 1: //Current Period CurentPeriod = GetPeriod(MetricFrequencyID, false, DTNow); break; case 2: //Current Month CurentPeriod = GetPeriod(3, false, DTNow); break; case 3: //Current Quarter CurentPeriod = GetPeriod(4, false, DTNow); break; case 4: //Current Year CurentPeriod = GetPeriod(6, false, DTNow); break; case 5: //Previous Period PrevPeriod = GetPeriod(MetricFrequencyID, true, DTNow); break; case 6: //Previous Month PrevPeriod = GetPeriod(3, true, DTNow); break; case 7: //Previous Quarter PrevPeriod = GetPeriod(4, true, DTNow); break; case 8: //Previous Year PrevPeriod = GetPeriod(6, true, DTNow); break; case 9: //Current Period Versus Previous CurentPeriod = GetPeriod(MetricFrequencyID, false, DTNow); PrevPeriod = GetPeriod(MetricFrequencyID, true, DTNow); break; case 10: //Current Period Versus Period 1 Year Ago CurentPeriod = GetPeriod(MetricFrequencyID, false, DTNow); PrevPeriod = GetYearAgo(CurentPeriod); break; case 11: //Current Month Versus Prevous Month CurentPeriod = GetPeriod(3, false, DTNow); PrevPeriod = GetPeriod(3, true, DTNow); break; case 12: //Current Month Versus Month 1 Year Ago CurentPeriod = GetPeriod(3, false, DTNow); PrevPeriod = GetYearAgo(CurentPeriod); break; case 13: //Current Quarter Versus Pevious Quarter CurentPeriod = GetPeriod(4, false, DTNow); PrevPeriod = GetPeriod(4, true, DTNow); break; case 14: //Current Quarter Versus Quarter 1 Year Ago CurentPeriod = GetPeriod(4, false, DTNow); PrevPeriod = GetYearAgo(CurentPeriod); break; case 15: //Current Year Versus Pervious Year CurentPeriod = GetPeriod(6, false, DTNow); PrevPeriod = GetPeriod(6, true, DTNow); break; case 16: //Current Period YTD vs Previous Period CurentPeriod = new PeriodDate(); CurentPeriod.End = DTNow.Date; CurentPeriod.Begin = new DateTime(CurentPeriod.End.Year, 1, 1); break; case 17: //Current YTD Rolling Average vs Previous YTD CurentPeriod = new PeriodDate(); CurentPeriod.End = DTNow.Date; CurentPeriod.Begin = new DateTime(CurentPeriod.End.Year, 1, 1); break; } }
static double?_GetValue(LinqMicajahDataContext dc, Guid MetricID, Guid?OrgLocationID, Guid?UomID, PeriodDate d, Guid OrganizationId, Guid InstanceId, out Guid?TotalUnitOfMessureID) { var values = (from m in dc.Metric join v in dc.MetricValue on new { MetricID, m.FrequencyID, Status = (bool?)true } equals new { v.MetricID, v.FrequencyID, v.Status } //join o in dc.EntityNodeFullNameView on v.OrgLocationID equals (Guid?)o.EntityNodeId join r in dc.FxGetRule(LinqMicajahDataContext.InstanceId) on new { InstanceId = (Guid?)v.InstanceId, MetricID = (Guid?)v.MetricID, OrgLocationID = (Guid?)v.OrgLocationID } equals new { r.InstanceId, r.MetricID, r.OrgLocationID } join l in dc.ViewHierarchyOrgLocation on new { InstanceId = (Guid?)v.InstanceId, OrgLocationID = (Guid?)v.OrgLocationID } equals new { l.InstanceId, OrgLocationID = l.SubOrgLocationID } join o in dc.ViewnameOrgLocation on new { InstanceId = (Guid?)v.InstanceId, OrgLocationID = (Guid?)v.OrgLocationID } equals new { o.InstanceId, o.OrgLocationID } where ( OrgLocationID == null || OrgLocationID == Guid.Empty || OrgLocationID == l.OrgLocationID //OrgLocationID == v.OrgLocationID || OrgLocationID == o.Parent1 || OrgLocationID == o.Parent2 || OrgLocationID == o.Parent3 || OrgLocationID == o.Parent4 || OrgLocationID == o.Parent5 ) && m.MetricID == MetricID && m.Status == true && v.Date >= d.Begin && v.Date < d.End select v).Distinct().ToList(); TotalUnitOfMessureID = null; if (values.Count < 1) { return(null); } double Sum = 0; bool ValueExist = false; TotalUnitOfMessureID = values[0].InputUnitOfMeasureID; for (int i = 1; i < values.Count; i++) { Guid?UID = values[i].InputUnitOfMeasureID; if (UID != TotalUnitOfMessureID) { TotalUnitOfMessureID = UomID; break; } } foreach (var v in values) { if (string.IsNullOrEmpty(v.Value)) { continue; } double SingleValue; try { SingleValue = double.Parse(v.Value, System.Globalization.NumberStyles.Any); } catch { continue; } if (TotalUnitOfMessureID != v.InputUnitOfMeasureID) { if (TotalUnitOfMessureID == null || v.InputUnitOfMeasureID == null) { continue; } double?ConvertedVal = Mc_UnitsOfMeasure.ConvertValue(SingleValue, (Guid)v.InputUnitOfMeasureID, (Guid)TotalUnitOfMessureID, OrganizationId); if (ConvertedVal == null) { continue; } SingleValue = (double)ConvertedVal; } ValueExist = true; Sum += SingleValue; } if (!ValueExist) { return(null); } return(Sum); }