protected void FillGrid() { DataTable dt = ConditionDB.GetDataTable(chkShowDeleted.Checked); Session["condition_data"] = dt; if (dt.Rows.Count > 0) { GrdCondition.DataSource = dt; try { GrdCondition.DataBind(); } catch (Exception ex) { SetErrorMessage("", ex.ToString()); } //Sort("parent_descr", "ASC"); } else { dt.Rows.Add(dt.NewRow()); GrdCondition.DataSource = dt; GrdCondition.DataBind(); int TotalColumns = GrdCondition.Rows[0].Cells.Count; GrdCondition.Rows[0].Cells.Clear(); GrdCondition.Rows[0].Cells.Add(new TableCell()); GrdCondition.Rows[0].Cells[0].ColumnSpan = TotalColumns; GrdCondition.Rows[0].Cells[0].Text = "No Conditions Found"; } }
protected void FillGrdCondition(Patient patient = null) { if (patient == null) { patient = PatientDB.GetByID(GetFormPatientID()); } DataTable dt = ConditionDB.GetDataTable(false); Hashtable conditionHash = ConditionDB.GetHashtable(false); Session["patientcondition_data"] = dt; if (dt.Rows.Count > 0) { GrdCondition.DataSource = dt; try { GrdCondition.DataBind(); Hashtable selectedConditions = PatientConditionDB.GetHashtable_ByPatientID(patient.PatientID, false); foreach (GridViewRow row in GrdCondition.Rows) { Label lblId = row.FindControl("lblId") as Label; CheckBox chkSelect = row.FindControl("chkSelect") as CheckBox; DropDownList ddlDate_Day = (DropDownList)row.FindControl("ddlDate_Day"); DropDownList ddlDate_Month = (DropDownList)row.FindControl("ddlDate_Month"); DropDownList ddlDate_Year = (DropDownList)row.FindControl("ddlDate_Year"); DropDownList ddlNbrWeeksDue = (DropDownList)row.FindControl("ddlNbrWeeksDue"); Label lblNextDue = row.FindControl("lblNextDue") as Label; Label lblWeeksLater = row.FindControl("lblWeeksLater") as Label; Label lblAdditionalInfo = row.FindControl("lblAdditionalInfo") as Label; System.Web.UI.HtmlControls.HtmlControl br_date = (System.Web.UI.HtmlControls.HtmlControl)row.FindControl("br_date"); System.Web.UI.HtmlControls.HtmlControl br_nweeksdue = (System.Web.UI.HtmlControls.HtmlControl)row.FindControl("br_nweeksdue"); System.Web.UI.HtmlControls.HtmlControl br_text = (System.Web.UI.HtmlControls.HtmlControl)row.FindControl("br_text"); TextBox txtText = (TextBox)row.FindControl("txtText"); if (lblId == null || chkSelect == null) { continue; } Condition condition = (Condition)conditionHash[Convert.ToInt32(lblId.Text)]; br_date.Visible = condition.ShowDate; ddlDate_Day.Visible = condition.ShowDate; ddlDate_Month.Visible = condition.ShowDate; ddlDate_Year.Visible = condition.ShowDate; br_nweeksdue.Visible = condition.ShowNWeeksDue; ddlNbrWeeksDue.Visible = condition.ShowNWeeksDue; lblNextDue.Visible = condition.ShowNWeeksDue; lblWeeksLater.Visible = condition.ShowNWeeksDue; br_text.Visible = condition.ShowText; txtText.Visible = condition.ShowText; lblAdditionalInfo.Visible = condition.ShowText; if (selectedConditions[Convert.ToInt32(lblId.Text)] != null) { PatientCondition ptCondition = (PatientCondition)selectedConditions[Convert.ToInt32(lblId.Text)]; chkSelect.Checked = selectedConditions[Convert.ToInt32(lblId.Text)] != null; if (condition.ShowDate) { if (ptCondition.Date != DateTime.MinValue) { ddlDate_Day.SelectedValue = ptCondition.Date.Day.ToString(); ddlDate_Month.SelectedValue = ptCondition.Date.Month.ToString(); ddlDate_Year.SelectedValue = ptCondition.Date.Year.ToString(); } } if (condition.ShowNWeeksDue) { ddlNbrWeeksDue.SelectedValue = ptCondition.NWeeksDue.ToString(); } if (condition.ShowText) { txtText.Text = ptCondition.Text; } } } } catch (Exception ex) { SetErrorMessage("", ex.ToString()); } //Sort("parent_descr", "ASC"); } else { dt.Rows.Add(dt.NewRow()); GrdCondition.DataSource = dt; GrdCondition.DataBind(); int TotalColumns = GrdCondition.Rows[0].Cells.Count; GrdCondition.Rows[0].Cells.Clear(); GrdCondition.Rows[0].Cells.Add(new TableCell()); GrdCondition.Rows[0].Cells[0].ColumnSpan = TotalColumns; GrdCondition.Rows[0].Cells[0].Text = "No Record Found"; } }
protected void FillGrdConditionView(Patient patient = null) { if (patient == null) { patient = PatientDB.GetByID(GetFormPatientID()); } DataTable dt = ConditionDB.GetDataTable(false); Hashtable conditionHash = ConditionDB.GetHashtable(false); Session["patientconditionview_data"] = dt; if (dt.Rows.Count > 0) { GrdConditionView.DataSource = dt; try { GrdConditionView.DataBind(); Hashtable selectedConditions = PatientConditionDB.GetHashtable_ByPatientID(patient.PatientID, false); for (int i = GrdConditionView.Rows.Count - 1; i >= 0; i--) { Label lblId = GrdConditionView.Rows[i].FindControl("lblId") as Label; Label lblDate = GrdConditionView.Rows[i].FindControl("lblDate") as Label; Label lblNextDue = GrdConditionView.Rows[i].FindControl("lblNextDue") as Label; Label lblDateDue = GrdConditionView.Rows[i].FindControl("lblDateDue") as Label; Label lblAdditionalInfo = GrdConditionView.Rows[i].FindControl("lblAdditionalInfo") as Label; Label lblText = GrdConditionView.Rows[i].FindControl("lblText") as Label; System.Web.UI.HtmlControls.HtmlControl br_date = (System.Web.UI.HtmlControls.HtmlControl)GrdConditionView.Rows[i].FindControl("br_date"); System.Web.UI.HtmlControls.HtmlControl br_nweeksdue = (System.Web.UI.HtmlControls.HtmlControl)GrdConditionView.Rows[i].FindControl("br_nweeksdue"); System.Web.UI.HtmlControls.HtmlControl br_text = (System.Web.UI.HtmlControls.HtmlControl)GrdConditionView.Rows[i].FindControl("br_text"); if (lblId == null) { continue; } Condition condition = (Condition)conditionHash[Convert.ToInt32(lblId.Text)]; br_date.Visible = condition.ShowDate; lblDate.Visible = condition.ShowDate; br_nweeksdue.Visible = condition.ShowNWeeksDue; lblNextDue.Visible = condition.ShowNWeeksDue; lblDateDue.Visible = condition.ShowNWeeksDue; br_text.Visible = condition.ShowText; lblText.Visible = condition.ShowText; lblAdditionalInfo.Visible = condition.ShowText; if (selectedConditions[Convert.ToInt32(lblId.Text)] != null) { PatientCondition ptCondition = (PatientCondition)selectedConditions[Convert.ToInt32(lblId.Text)]; if (condition.ShowDate) { lblDate.Text = ptCondition.Date == DateTime.MinValue ? "[Date Not Set]" : ptCondition.Date.ToString("d MMM, yyyy"); } if (condition.ShowNWeeksDue) { bool expired = ptCondition.Date != DateTime.MinValue && ptCondition.Date.AddDays(7 * ptCondition.NWeeksDue) < DateTime.Today; lblDateDue.Text = ptCondition.Date == DateTime.MinValue ? "[Date Not Set]" : (expired ? "<font color=\"red\">" : "") + ptCondition.Date.AddDays(7 * ptCondition.NWeeksDue).ToString("d MMM, yyyy") + (expired ? "</font>" : ""); } if (condition.ShowText) { lblText.Text = ptCondition.Text.Length == 0 ? "[Blank]" : ptCondition.Text; } } else { GrdConditionView.Rows[i].Visible = false; } } } catch (Exception ex) { SetErrorMessage("", ex.ToString()); } //Sort("parent_descr", "ASC"); } else { dt.Rows.Add(dt.NewRow()); GrdConditionView.DataSource = dt; GrdConditionView.DataBind(); int TotalColumns = GrdConditionView.Rows[0].Cells.Count; GrdConditionView.Rows[0].Cells.Clear(); GrdConditionView.Rows[0].Cells.Add(new TableCell()); GrdConditionView.Rows[0].Cells[0].ColumnSpan = TotalColumns; GrdConditionView.Rows[0].Cells[0].Text = "No Record Found"; } }