CNSA-216-FP/FWA_MAIN/Prescription.aspx.cs

243 lines
7.7 KiB
C#
Raw Normal View History

using System;
using System.Web.UI;
using System.Data;
using System.Web.UI.WebControls;
namespace FWA_MAIN
{
public partial class Prescription : Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
txtRxNum.Text = Convert.ToString(Session["vRxNum"]);
txtPhysID.Text = Convert.ToString(Session["vPhysID"]);
txtPatID.Text = Convert.ToString(Session["vPatID"]);
txtMedID.Text = Convert.ToString(Session["vMedID"]);
btnPreSearch_OnClick(sender,e);
}
}
private void BindData()
{
DataSet ds = new DataSet();
string RxNum = Convert.ToString(Session["vRxNum"]);
string physID = Convert.ToString(Session["vPhysID"]);
string patID = Convert.ToString(Session["vPatID"]);
string medID = Convert.ToString(Session["vMedID"]);
txtRxNum.Text = RxNum;
txtPhysID.Text = physID;
txtPatID.Text = patID;
txtMedID.Text = medID;
// if (textHasValues)
// {
ds = PharmacyDataTier.PrescriptionInfoSearch(RxNum,patID, medID, physID);
// }
// ds = dt.GetStudents();
gvPrescription.DataSource = ds.Tables[0];
if (Cache["PreData"] == null)
{
Cache.Add("PreData", new DataView(ds.Tables[0]),
null,System.Web.Caching.Cache.NoAbsoluteExpiration,
System.TimeSpan.FromMinutes(10), System.Web.Caching.CacheItemPriority.Default,
null);
}
gvPrescription.DataBind();
}
protected void btnPreSearch_OnClick(object sender, EventArgs e)
{
if (txtPatID.Text.Trim().Length > 0 || txtRxNum.Text.Trim().Length > 0 || txtMedID.Text.Trim().Length > 0 ||
txtPhysID.Text.Trim().Length > 0)
{
try
{
Session["vRxNum"] = txtRxNum.Text.Trim();
Session["vPhysID"] = txtPhysID.Text.Trim();
Session["vPatID"] = txtPatID.Text.Trim();
Session["vMedID"] = txtMedID.Text.Trim();
Cache.Remove("PreData");
BindData();
}
catch (Exception exception)
{
}
}
2024-04-01 16:02:24 -04:00
}
protected void gvPatient_OnRowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes["onclick"] = Page.ClientScript.GetPostBackClientHyperlink(gvPrescription, "Select$" + e.Row.RowIndex);
e.Row.ToolTip = "Click to select this row.";
}
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
BindData();
}
protected void gvPatient_OnRowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Select")
{
// Determine the index of the selected row
int index = Convert.ToInt32(e.CommandArgument);
// Check if the selected row index is the same as the previous selected row index
if (gvPrescription.SelectedIndex == index)
{
// Deselect the row
gvPrescription.SelectedIndex = -1;
}
else
{
// Select the row
gvPrescription.SelectedIndex = index;
}
// Refresh the GridView to update the style
gvPrescription.DataBind();
}
}
protected void btnPreNew_OnClick(object sender, EventArgs e)
{
string prescriptionID;
try
{
Session["vRxNum"] = txtRxNum.Text.Trim();
Session["vPhysID"] = txtPhysID.Text.Trim();
Session["vPatID"] = txtPatID.Text.Trim();
Session["vMedID"] = txtMedID.Text.Trim();
// Use the patientID value as needed
try
{
prescriptionID = PharmacyDataTier.GetNextRxNum();
prescriptionID = Crypt.Encrypt(prescriptionID);
Response.Redirect("preNew.aspx" + "?" + "ID=" + prescriptionID, false);
}
catch (Exception exception)
{
}
}
catch (Exception ex)
{
throw new Exception(ex.Message, ex.InnerException);
}
}
protected void bntPreEdit_OnClick(object sender, EventArgs e)
{
string prescriptionID = "0";
Int64 mEditedRecord = 0;
System.Text.StringBuilder sb = new System.Text.StringBuilder();
try
{
Session["vRxNum"] = txtRxNum.Text.Trim();
Session["vPhysID"] = txtPhysID.Text.Trim();
Session["vPatID"] = txtPatID.Text.Trim();
Session["vMedID"] = txtMedID.Text.Trim();
try
{
prescriptionID = Crypt.Encrypt(gvPrescription.SelectedRow.Cells[0].Text);
Response.Redirect("preEdit.aspx" + "?" + "ID=" + prescriptionID, false);
}
catch (Exception exception)
{
}
// Use the patientID value as needed
}
catch (Exception ex)
{
throw new Exception(ex.Message, ex.InnerException);
}
}
protected void btnPreDelete_OnClick(object sender, EventArgs e)
{
try
{
2024-04-01 16:02:24 -04:00
PharmacyDataTier.DeleteAllRefill(gvPrescription.SelectedRow.Cells[0].Text);
PharmacyDataTier.DeletePrescription(gvPrescription.SelectedRow.Cells[0].Text);
BindData();
}
catch (Exception exception)
{
}
}
2024-04-01 16:02:24 -04:00
protected void btnPreView_OnClick(object sender, EventArgs e)
{
string refillID = "0";
try
{
refillID = Crypt.Encrypt(gvPrescription.SelectedRow.Cells[0].Text);
Response.Redirect("Refills.aspx" + "?" + "ID=" + refillID, false);
}
catch (Exception exception)
{
}
}
2024-04-01 16:02:24 -04:00
protected void btnPreRefill_OnClick(object sender, EventArgs e)
{
if (gvPrescription.SelectedRow != null)
{
if (int.Parse(gvPrescription.SelectedRow.Cells[2].Text) < int.Parse(gvPrescription.SelectedRow.Cells[1].Text))
2024-04-01 16:02:24 -04:00
{
PharmacyDataTier.AddRefill(PharmacyDataTier.GetNextRefillID().ToString(), DateTime.Now, gvPrescription.SelectedRow.Cells[5].Text,gvPrescription.SelectedRow.Cells[4].Text,gvPrescription.SelectedRow.Cells[0].Text);
}
else
{
string script = "window.open('MaxRefillNotif.aspx', 'PopupWindow', 'width=600,height=400,left=100,top=100');";
ScriptManager.RegisterStartupScript(this, GetType(), "popup", script, true);
2024-04-01 16:02:24 -04:00
}
PharmacyDataTier.RefreshRefill(gvPrescription.SelectedRow.Cells[0].Text);
BindData();
}
2024-04-01 16:02:24 -04:00
}
}
}