using framework_business; using framework_library; using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class controls_medical_symptoms : System.Web.UI.UserControl { #region methods /// /// Method to Bind Symptom Data /// private void BindSymptomData() { try { ArrayList symptomList = xData.GetTypedByCriteriaSpecific("recId", typeof(oMedicalSymptom), "", ""); rptSymptom.DataSource = symptomList; rptSymptom.DataBind(); } catch (Exception ex) { exception.HandleException("Symptom:", MethodBase.GetCurrentMethod().Name, ex, Session["Symptom"]); Response.Redirect("/error", false); } } /// /// Populate Form Values /// /// private void PopulatePageFormValues(ref oMedicalSymptom _Symptom) { try { ArrayList patientTypeList = xData.GetTypedByCriteriaSpecific("recId",typeof(oMedicalPatientType),"",""); ddPatientType.DataSource = patientTypeList; ddPatientType.DataTextField = "patientType"; ddPatientType.DataValueField = "recId"; ddPatientType.DataBind(); ddPatientType.SelectedIndex = 0; if (ddPatientType.Items.FindByValue(_Symptom.patientType.ToString()) != null) ddPatientType.SelectedValue = _Symptom.patientType.ToString(); txtSymptom.Value = _Symptom.symptom; chkActive.Checked = _Symptom.isActive; } catch (Exception ex) { exception.HandleException("Symptom:", MethodBase.GetCurrentMethod().Name, ex, 0); Response.Redirect("/error", false); } } /// /// Save Form Values /// /// private void SavePageFormValues(ref oMedicalSymptom _Symptom) { try { _Symptom.patientType = Convert.ToInt32(ddPatientType.SelectedValue); _Symptom.symptom = txtSymptom.Value; _Symptom.isActive = chkActive.Checked; } catch (Exception ex) { exception.HandleException("Symptom:", MethodBase.GetCurrentMethod().Name, ex, 0); Response.Redirect("/error", false); } } /// /// Method to Toggle Panels /// /// private void TogglePanels(string panelName) { switch (panelName) { case "pnlSymptomPage": pnlSymptomPage.Visible = true; pnlSymptomList.Visible = false; break; case "pnlSymptomList": pnlSymptomPage.Visible = false; pnlSymptomList.Visible = true; break; } //clear result pnlResult.Visible = false; } #endregion #region events /// /// Page Load Event /// /// /// protected void Page_Load(object sender, EventArgs e) { try { if (!Page.IsPostBack) { BindSymptomData(); } } catch (Exception ex) { exception.HandleException("Symptom:", MethodBase.GetCurrentMethod().Name, ex, Session["Symptom"]); Response.Redirect("/error", false); } } /// /// New Symptom Click /// /// /// protected void btnNewSymptom_Click(object sender, EventArgs e) { try { //show Content Specific TogglePanels("pnlSymptomPage"); Session["SymptomId"] = 0; utils.disposeSession("Symptom"); oMedicalSymptom Symptom = new oMedicalSymptom(); PopulatePageFormValues(ref Symptom); } catch (Exception ex) { exception.HandleException("Symptom:", MethodBase.GetCurrentMethod().Name, ex, Session["Symptom"]); Response.Redirect("/error", false); } } /// /// Edit the Symptom page /// /// /// protected void lnkEdit_Click(object sender, EventArgs e) { oMedicalSymptom _Symptom = new oMedicalSymptom(); ArrayList catList = new ArrayList(); try { if (sender.GetType() == typeof(LinkButton)) { // int recId = int.Parse(((LinkButton)sender).CommandArgument); if (recId > 0) { Session["SymptomId"] = recId; //get cat catList = xData.GetTypedByCriteriaSpecific("recId", typeof(oMedicalSymptom), "recId", recId.ToString()); //enumerate list foreach (oMedicalSymptom cat in catList) { //assign object _Symptom = cat; //populate page form PopulatePageFormValues(ref _Symptom); Session["Symptom"] = _Symptom; break; } //show Symptom Form TogglePanels("pnlSymptomPage"); } } } catch (Exception ex) { exception.HandleException("Symptom:", MethodBase.GetCurrentMethod().Name, ex, Session["Symptom"]); Response.Redirect("/error", false); } } /// /// Remove the Symptom /// /// /// protected void lnkRemove_Click(object sender, EventArgs e) { try { if (sender.GetType() == typeof(LinkButton)) { // int recId = int.Parse(((LinkButton)sender).CommandArgument); //Delete cat if (xData.DeleteTyped("recId", recId.ToString(), typeof(oMedicalSymptom))) { //rebind pages grid BindSymptomData(); pnlResult.Visible = true; //display successful result lblResult.Text = "the selected Symptom was deleted successfully."; } } } catch (Exception ex) { exception.HandleException("Symptom:", MethodBase.GetCurrentMethod().Name, ex, Session["Symptom"]); Response.Redirect("/error", false); } } /// /// Cancel /// /// /// protected void btnCancel_Click(object sender, EventArgs e) { try { Session["SymptomId"] = 0; utils.disposeSession("Symptom"); BindSymptomData(); //show cat list TogglePanels("pnlSymptomList"); } catch (Exception ex) { exception.HandleException("Symptom:", MethodBase.GetCurrentMethod().Name, ex, Session["Symptom"]); Response.Redirect("/error", false); } } /// /// Save Click /// /// /// protected void btnSave_Click(object sender, EventArgs e) { oMedicalSymptom Symptom = new oMedicalSymptom(); try { if (utils.verifySession("Symptom"))//update mode { Symptom = (oMedicalSymptom)Session["Symptom"]; //save form values SavePageFormValues(ref Symptom); if (xData.UpdateTyped("recId", Symptom.recId.ToString(), typeof(oMedicalSymptom), Symptom)) { Session["SymptomId"] = Symptom.recId; Session["Symptom"] = Symptom; BindSymptomData(); pnlResult.Visible = true; lblResult.Text = "your changes were updated successfully."; } } else { if (!xData.VerifyExists("recId", typeof(oMedicalSymptom), "symptom", txtSymptom.Value)) { //save form values SavePageFormValues(ref Symptom); Symptom.recId = xData.SaveTyped("recId", typeof(oMedicalSymptom), Symptom); if (Symptom.recId > 0) { Session["SymptomId"] = Symptom.recId; Session["Symptom"] = Symptom; BindSymptomData(); pnlResult.Visible = true; lblResult.Text = "your Symptom was created successfully."; } } else { pnlResult.Visible = true; lblResult.Text = "An Symptom with this code already exists on the system"; } } } catch (Exception ex) { exception.HandleException("Symptom:", MethodBase.GetCurrentMethod().Name, ex, Session["Symptom"]); Response.Redirect("/error", false); } } #endregion }