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_icd10 : System.Web.UI.UserControl
{
#region methods
///
/// Method to Bind ICD10 Data
///
private void BindICD10Data()
{
try
{
ArrayList ICD10List = xData.GetTypedByCriteriaSpecific("recId", typeof(oMedicalICD10), "", "", "icdCode");
rptICD10.DataSource = ICD10List;
rptICD10.DataBind();
}
catch (Exception ex)
{
exception.HandleException("ICD10:", MethodBase.GetCurrentMethod().Name, ex, Session["ICD10"]);
Response.Redirect("/error", false);
}
}
///
/// Populate Form Values
///
///
private void PopulatePageFormValues(ref oMedicalICD10 _ICD10)
{
try
{
txtCode.Value = _ICD10.icdCode;
txtDescription.Value = _ICD10.icdDescription;
chkActive.Checked = _ICD10.isActive;
chkExternal.Checked = _ICD10.isExternal;
}
catch (Exception ex)
{
exception.HandleException("ICD10:", MethodBase.GetCurrentMethod().Name, ex, 0);
Response.Redirect("/error", false);
}
}
///
/// Save Form Values
///
///
private void SavePageFormValues(ref oMedicalICD10 _ICD10)
{
try
{
_ICD10.icdCode = txtCode.Value;
_ICD10.icdDescription = txtDescription.Value;
_ICD10.isActive = chkActive.Checked;
_ICD10.isExternal = chkExternal.Checked;
}
catch (Exception ex)
{
exception.HandleException("ICD10:", MethodBase.GetCurrentMethod().Name, ex, 0);
Response.Redirect("/error", false);
}
}
///
/// Method to Toggle Panels
///
///
private void TogglePanels(string panelName)
{
switch (panelName)
{
case "pnlICD10Page":
pnlICD10Page.Visible = true;
pnlICD10List.Visible = false;
break;
case "pnlICD10List":
pnlICD10Page.Visible = false;
pnlICD10List.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)
{
BindICD10Data();
}
}
catch (Exception ex)
{
exception.HandleException("ICD10:", MethodBase.GetCurrentMethod().Name, ex, Session["ICD10"]);
Response.Redirect("/error", false);
}
}
///
/// New ICD10 Click
///
///
///
protected void btnNewICD10_Click(object sender, EventArgs e)
{
try
{
//show Content Specific
TogglePanels("pnlICD10Page");
Session["ICD10Id"] = 0;
utils.disposeSession("ICD10");
oMedicalICD10 ICD10 = new oMedicalICD10();
PopulatePageFormValues(ref ICD10);
}
catch (Exception ex)
{
exception.HandleException("ICD10:", MethodBase.GetCurrentMethod().Name, ex, Session["ICD10"]);
Response.Redirect("/error", false);
}
}
///
/// Edit the ICD10 page
///
///
///
protected void lnkEdit_Click(object sender, EventArgs e)
{
oMedicalICD10 _ICD10 = new oMedicalICD10();
ArrayList catList = new ArrayList();
try
{
if (sender.GetType() == typeof(LinkButton))
{
//
int recId = int.Parse(((LinkButton)sender).CommandArgument);
if (recId > 0)
{
Session["ICD10Id"] = recId;
//get cat
catList = xData.GetTypedByCriteriaSpecific("recId", typeof(oMedicalICD10), "recId", recId.ToString());
//enumerate list
foreach (oMedicalICD10 cat in catList)
{
//assign object
_ICD10 = cat;
//populate page form
PopulatePageFormValues(ref _ICD10);
Session["ICD10"] = _ICD10;
break;
}
//show ICD10 Form
TogglePanels("pnlICD10Page");
}
}
}
catch (Exception ex)
{
exception.HandleException("ICD10:", MethodBase.GetCurrentMethod().Name, ex, Session["ICD10"]);
Response.Redirect("/error", false);
}
}
///
/// Remove the ICD10
///
///
///
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(oMedicalICD10)))
{
//rebind pages grid
BindICD10Data();
pnlResult.Visible = true;
//display successful result
lblResult.Text = "the selected ICD10 was deleted successfully.";
}
}
}
catch (Exception ex)
{
exception.HandleException("ICD10:", MethodBase.GetCurrentMethod().Name, ex, Session["ICD10"]);
Response.Redirect("/error", false);
}
}
///
/// Cancel
///
///
///
protected void btnCancel_Click(object sender, EventArgs e)
{
try
{
Session["ICD10Id"] = 0;
utils.disposeSession("ICD10");
BindICD10Data();
//show cat list
TogglePanels("pnlICD10List");
}
catch (Exception ex)
{
exception.HandleException("ICD10:", MethodBase.GetCurrentMethod().Name, ex, Session["ICD10"]);
Response.Redirect("/error", false);
}
}
///
/// Save Click
///
///
///
protected void btnSave_Click(object sender, EventArgs e)
{
oMedicalICD10 ICD10 = new oMedicalICD10();
try
{
if (utils.verifySession("ICD10"))//update mode
{
ICD10 = (oMedicalICD10)Session["ICD10"];
//save form values
SavePageFormValues(ref ICD10);
if (xData.UpdateTyped("recId", ICD10.recId.ToString(), typeof(oMedicalICD10), ICD10))
{
Session["ICD10Id"] = ICD10.recId;
Session["ICD10"] = ICD10;
BindICD10Data();
pnlResult.Visible = true;
lblResult.Text = "your changes were updated successfully.";
}
}
else
{
if (!xData.VerifyExists("recId", typeof(oMedicalICD10), "icdCode", txtCode.Value))
{
//save form values
SavePageFormValues(ref ICD10);
ICD10.recId = xData.SaveTyped("recId", typeof(oMedicalICD10), ICD10);
if (ICD10.recId > 0)
{
Session["ICD10Id"] = ICD10.recId;
Session["ICD10"] = ICD10;
BindICD10Data();
pnlResult.Visible = true;
lblResult.Text = "your ICD10 was created successfully.";
}
}
else
{
pnlResult.Visible = true;
lblResult.Text = "An ICD10 with this code already exists on the system";
}
}
}
catch (Exception ex)
{
exception.HandleException("ICD10:", MethodBase.GetCurrentMethod().Name, ex, Session["ICD10"]);
Response.Redirect("/error", false);
}
}
#endregion
}