private void MonthlyReportClick(object sender, RoutedEventArgs e) { var lastMonth = DateTime.Now.AddMonths(-1); var start = new DateTime(lastMonth.Year, lastMonth.Month, 1); var end = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1); var header = "Monthly Report for " + lastMonth.ToString("MMMM yyyy", CultureInfo.InvariantCulture); ReportSelectionClick(sender, e); reportViewer.LoadReport(MonthlyReports.GetReport(header, start, end, true)); }
private void CustomReportClick(object sender, RoutedEventArgs e) { var reportDates = new CustomReportDatesDialog(); if ((bool)reportDates.ShowDialog()) { var header = "Custom Report " + reportDates.StartDate.ToString("dd MMMM yyyy", CultureInfo.InvariantCulture) + " to " + reportDates.EndDate.ToString("dd MMMM yyyy", CultureInfo.InvariantCulture); ReportSelectionClick(sender, e); reportViewer.LoadReport(MonthlyReports.GetReport(header, reportDates.StartDate, reportDates.EndDate, false)); } }
public static MonthlyReports GetSetMonthlyReports(int id, string date, string text, int type) { var Res = new MonthlyReports(); if (text == "null") { text = ""; } DateTime FirstDate = date != null?DateTime.Parse(date) : DateTime.Now.Date; using (var Context = new Context()) { Res = Context.MonthlyReports.Where(x => x.UserId == id && x.Date == FirstDate).FirstOrDefault(); if (type == 1) { return(Res); } else { if (Res == null) { Res = new MonthlyReports(); Res.UserId = id; Res.Date = FirstDate; Res.Summery = text; Context.MonthlyReports.Add(Res); } else { Res.Date = FirstDate; Res.Summery = text; Context.Entry(Res).State = System.Data.Entity.EntityState.Modified; } Context.SaveChanges(); } } return(Res); }