protected void GrdPtInvoicesOutstanding_Sort(string sortExpression, params string[] sortExpr) { DataTable dataTable = Session["ptinvoicesoutstanding_data"] as DataTable; if (dataTable != null) { if (Session["ptinvoicesoutstanding_sortexpression"] == null) { Session["ptinvoicesoutstanding_sortexpression"] = ""; } DataView dataView = new DataView(dataTable); string[] sortData = Session["ptinvoicesoutstanding_sortexpression"].ToString().Trim().Split(' '); string newSortExpr = (sortExpr.Length == 0) ? (sortExpression == sortData[0] && sortData[1] == "ASC") ? "DESC" : "ASC" : sortExpr[0]; dataView.Sort = sortExpression + " " + newSortExpr; Session["ptinvoicesoutstanding_sortexpression"] = sortExpression + " " + newSortExpr; GrdPtInvoicesOutstanding.DataSource = dataView; GrdPtInvoicesOutstanding.DataBind(); } }
protected void GrdPtInvoicesOutstanding_FillGrid() { DataTable dt = InvoiceDB.GetAllOutstandingByPatientAsReport(Convert.ToInt32(Session["SiteID"])); dt.DefaultView.Sort = "patient_surname"; dt = dt.DefaultView.ToTable(); Session["ptinvoicesoutstanding_data"] = dt; btnExportAllPatients.Visible = dt.Rows.Count > 0; btnPrintAllPatients.Visible = dt.Rows.Count > 0; if (dt.Rows.Count > 0) { GrdPtInvoicesOutstanding.DataSource = dt; try { GrdPtInvoicesOutstanding.DataBind(); GrdPtInvoicesOutstanding.PagerSettings.FirstPageText = "1"; GrdPtInvoicesOutstanding.PagerSettings.LastPageText = GrdPtInvoicesOutstanding.PageCount.ToString(); GrdPtInvoicesOutstanding.DataBind(); } catch (Exception ex) { HideTableAndSetErrorMessage("", ex.ToString()); } } else { dt.Rows.Add(dt.NewRow()); GrdPtInvoicesOutstanding.DataSource = dt; GrdPtInvoicesOutstanding.DataBind(); int TotalColumns = GrdPtInvoicesOutstanding.Rows[0].Cells.Count; GrdPtInvoicesOutstanding.Rows[0].Cells.Clear(); GrdPtInvoicesOutstanding.Rows[0].Cells.Add(new TableCell()); GrdPtInvoicesOutstanding.Rows[0].Cells[0].ColumnSpan = TotalColumns; GrdPtInvoicesOutstanding.Rows[0].Cells[0].Text = "No Record Found"; } btnEmailAllPatients.Attributes["onclick"] = "if (!confirm('Estimating 20 seconds per email for " + dt.Rows.Count + " patients, you will need to let this page run for about " + (dt.Rows.Count / 3) + " Minutes. \\r\\nAre you sure you want to continue?')) return false;"; }