private void LoadSummaryGridView() { IPatientHome PatientManager; PatientManager = (IPatientHome)ObjectFactory.CreateInstance("BusinessProcess.Clinical.BPatientHome, BusinessProcess.Clinical"); DataTable dataTable = PatientManager.GetPatientDebitNoteSummary(Convert.ToInt32(Session["PatientId"])); GridViewSummary.DataSource = dataTable; AddFormattedDateColumn(dataTable); GridViewSummary.DataBind(); GridViewTran.DataSource = null; GridViewTran.DataBind(); }
void LoadData() { DateTime?dtFrom = txtDateFrom.Text.ToDatetimeFromVNFormat(); DateTime?dtTo = txtDateTo.Text.ToDatetimeFromVNFormat(); if (dtFrom.HasValue) { DateTime hourFrom; if (DateTime.TryParse(txtHourFrom.Text, out hourFrom)) { dtFrom = dtFrom.Value.AddHours(hourFrom.Hour).AddMinutes(hourFrom.Minute); } } if (dtTo.HasValue) { DateTime hourTo; if (DateTime.TryParse(txtHourTo.Text, out hourTo)) { dtTo = dtTo.Value.AddHours(hourTo.Hour).AddMinutes(hourTo.Minute); } } RedBloodDataContext db = new RedBloodDataContext(); //var packs = db.Packs.Where(r => r.Date.Value >= dtFrom && r.Date.Value <= dtTo // && r.Donation.OrgPackID != r.ID).OrderBy(r => r.Date); var v = db.Returns.Where(r => r.Date.Value >= dtFrom && r.Date.Value <= dtTo) .OrderBy(r => r.Date) .ToList() .Select(r => new { r.ID, Date = r.Date.ToStringVN_Hour(), r.Note, r.Actor, Packs = r.PackOrders.Select(r1 => r1.Pack) }); GridView1.DataSource = v; GridView1.DataBind(); GridViewSummary.DataSource = v.SelectMany(r => r.Packs).GroupBy(r => r.ProductCode).Select(r => new { ProductCode = r.Key, Count = r.Count() }); GridViewSummary.DataBind(); }