private void btnViewReport_Click(object sender, EventArgs e) { dgvOperatorReport.AutoGenerateColumns = false; int cUser = (cmbUsername.SelectedItem as Employee).Id; var data = new ServiceDao().GetOperatorReport(dtpDate.Value, cUser); var totals = new Service(); totals.Name = "Total"; totals.SoldQuantity = data.Sum(x => x.SoldQuantity); totals.TotalCollection = data.Sum(x => x.TotalCollection); data.Add(totals); dgvOperatorReport.DataSource = data; }
public void LoadReport() { dgvReport.AutoGenerateColumns = false; var data = new ServiceDao().GetDcrReport(dtpFromDate.Value, dtpToDate.Value); DateTime fromDate = dtpFromDate.Value; DateTime toDate = dtpToDate.Value; var startDate = new DateTime(fromDate.Year, fromDate.Month, fromDate.Day); var endDate = new DateTime(toDate.Year, toDate.Month, toDate.Day); if (startDate == endDate) endDate.AddDays(1); //MessageBox.Show("select s.Id, s.Name, s.Cost, sum(t.Quantity) as SoldQuantity, s.Type, sum(t.TotalCost) as TotalCollection, max(t.ServiceDailyNumber) as EndingNumber, min(t.ServiceDailyNumber) as StartingNumber from Services s left outer join Tokens t on ( s.Id = t.ServiceId and t.CreatedOn between " + startDate + " and " + endDate + " and t.Status=1 and s.Type not in(16) ) group by s.Id, s.Name"); var totals = new Service(); totals.Name = "Totals"; //totals.SoldQuantity = data.Sum(x => x.SoldQuantity); totals.TotalCollection = data.Sum(x => x.TotalCollection); data.Add(totals); dgvReport.DataSource = data; }