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_traumaticevents : System.Web.UI.UserControl
{
#region methods
///
/// Method to Bind TraumaticEvent Data
///
private void BindTraumaticEventData()
{
try
{
ArrayList traumaticEventList = xData.GetTypedByCriteriaSpecific("recId", typeof(oMedicalTraumaticEvent), "", "");
rptTraumaticEvent.DataSource = traumaticEventList;
rptTraumaticEvent.DataBind();
}
catch (Exception ex)
{
exception.HandleException("Traumatic Event:", MethodBase.GetCurrentMethod().Name, ex, Session["TraumaticEvent"]);
Response.Redirect("/error", false);
}
}
///
/// Populate Form Values
///
///
private void PopulatePageFormValues(ref oMedicalTraumaticEvent _TraumaticEvent)
{
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(_TraumaticEvent.patientType.ToString()) != null)
ddPatientType.SelectedValue = _TraumaticEvent.patientType.ToString();
txtTraumaticEvent.Value = _TraumaticEvent.traumaticEvent;
chkActive.Checked = _TraumaticEvent.isActive;
}
catch (Exception ex)
{
exception.HandleException("TraumaticEvent:", MethodBase.GetCurrentMethod().Name, ex, 0);
Response.Redirect("/error", false);
}
}
///
/// Save Form Values
///
///
private void SavePageFormValues(ref oMedicalTraumaticEvent _TraumaticEvent)
{
try
{
_TraumaticEvent.patientType = Convert.ToInt32(ddPatientType.SelectedValue);
_TraumaticEvent.traumaticEvent = txtTraumaticEvent.Value;
_TraumaticEvent.isActive = chkActive.Checked;
}
catch (Exception ex)
{
exception.HandleException("TraumaticEvent:", MethodBase.GetCurrentMethod().Name, ex, 0);
Response.Redirect("/error", false);
}
}
///
/// Method to Toggle Panels
///
///
private void TogglePanels(string panelName)
{
switch (panelName)
{
case "pnlTraumaticEventPage":
pnlTraumaticEventPage.Visible = true;
pnlTraumaticEventList.Visible = false;
break;
case "pnlTraumaticEventList":
pnlTraumaticEventPage.Visible = false;
pnlTraumaticEventList.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)
{
BindTraumaticEventData();
}
}
catch (Exception ex)
{
exception.HandleException("TraumaticEvent:", MethodBase.GetCurrentMethod().Name, ex, Session["TraumaticEvent"]);
Response.Redirect("/error", false);
}
}
///
/// New TraumaticEvent Click
///
///
///
protected void btnNewTraumaticEvent_Click(object sender, EventArgs e)
{
try
{
//show Content Specific
TogglePanels("pnlTraumaticEventPage");
Session["TraumaticEventId"] = 0;
utils.disposeSession("TraumaticEvent");
oMedicalTraumaticEvent TraumaticEvent = new oMedicalTraumaticEvent();
PopulatePageFormValues(ref TraumaticEvent);
}
catch (Exception ex)
{
exception.HandleException("TraumaticEvent:", MethodBase.GetCurrentMethod().Name, ex, Session["TraumaticEvent"]);
Response.Redirect("/error", false);
}
}
///
/// Edit the TraumaticEvent page
///
///
///
protected void lnkEdit_Click(object sender, EventArgs e)
{
oMedicalTraumaticEvent _TraumaticEvent = new oMedicalTraumaticEvent();
ArrayList catList = new ArrayList();
try
{
if (sender.GetType() == typeof(LinkButton))
{
//
int recId = int.Parse(((LinkButton)sender).CommandArgument);
if (recId > 0)
{
Session["TraumaticEventId"] = recId;
//get cat
catList = xData.GetTypedByCriteriaSpecific("recId", typeof(oMedicalTraumaticEvent), "recId", recId.ToString());
//enumerate list
foreach (oMedicalTraumaticEvent cat in catList)
{
//assign object
_TraumaticEvent = cat;
//populate page form
PopulatePageFormValues(ref _TraumaticEvent);
Session["TraumaticEvent"] = _TraumaticEvent;
break;
}
//show TraumaticEvent Form
TogglePanels("pnlTraumaticEventPage");
}
}
}
catch (Exception ex)
{
exception.HandleException("TraumaticEvent:", MethodBase.GetCurrentMethod().Name, ex, Session["TraumaticEvent"]);
Response.Redirect("/error", false);
}
}
///
/// Remove the TraumaticEvent
///
///
///
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(oMedicalTraumaticEvent)))
{
//rebind pages grid
BindTraumaticEventData();
pnlResult.Visible = true;
//display successful result
lblResult.Text = "the selected TraumaticEvent was deleted successfully.";
}
}
}
catch (Exception ex)
{
exception.HandleException("TraumaticEvent:", MethodBase.GetCurrentMethod().Name, ex, Session["TraumaticEvent"]);
Response.Redirect("/error", false);
}
}
///
/// Cancel
///
///
///
protected void btnCancel_Click(object sender, EventArgs e)
{
try
{
Session["TraumaticEventId"] = 0;
utils.disposeSession("TraumaticEvent");
BindTraumaticEventData();
//show cat list
TogglePanels("pnlTraumaticEventList");
}
catch (Exception ex)
{
exception.HandleException("TraumaticEvent:", MethodBase.GetCurrentMethod().Name, ex, Session["TraumaticEvent"]);
Response.Redirect("/error", false);
}
}
///
/// Save Click
///
///
///
protected void btnSave_Click(object sender, EventArgs e)
{
oMedicalTraumaticEvent TraumaticEvent = new oMedicalTraumaticEvent();
try
{
if (utils.verifySession("TraumaticEvent"))//update mode
{
TraumaticEvent = (oMedicalTraumaticEvent)Session["TraumaticEvent"];
//save form values
SavePageFormValues(ref TraumaticEvent);
if (xData.UpdateTyped("recId", TraumaticEvent.recId.ToString(), typeof(oMedicalTraumaticEvent), TraumaticEvent))
{
Session["TraumaticEventId"] = TraumaticEvent.recId;
Session["TraumaticEvent"] = TraumaticEvent;
BindTraumaticEventData();
pnlResult.Visible = true;
lblResult.Text = "your changes were updated successfully.";
}
}
else
{
if (!xData.VerifyExists("recId", typeof(oMedicalTraumaticEvent), "traumaticEvent", txtTraumaticEvent.Value))
{
//save form values
SavePageFormValues(ref TraumaticEvent);
TraumaticEvent.recId = xData.SaveTyped("recId", typeof(oMedicalTraumaticEvent), TraumaticEvent);
if (TraumaticEvent.recId > 0)
{
Session["TraumaticEventId"] = TraumaticEvent.recId;
Session["TraumaticEvent"] = TraumaticEvent;
BindTraumaticEventData();
pnlResult.Visible = true;
lblResult.Text = "your traumatic event was created successfully.";
}
}
else
{
pnlResult.Visible = true;
lblResult.Text = "a traumatic event with this code already exists on the system";
}
}
}
catch (Exception ex)
{
exception.HandleException("TraumaticEvent:", MethodBase.GetCurrentMethod().Name, ex, Session["TraumaticEvent"]);
Response.Redirect("/error", false);
}
}
#endregion
}