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

174 lines
5.1 KiB
C#
Raw Normal View History

2024-03-21 14:26:50 -07:00
using System;
using System.Data;
2024-03-21 14:26:50 -07:00
using System.Web.UI;
2024-03-21 15:17:57 -07:00
using System.Web.UI.WebControls;
2024-03-21 14:26:50 -07:00
namespace FWA_MAIN
{
public partial class MediSearch : Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
txtMedID.Text = Convert.ToString(Session["vMedID"]);
txtMedName.Text = Convert.ToString(Session["vMedName"]);
txtRxNum.Text = Convert.ToString(Session["vRxNum"]);
btnMediSearch_OnClick(sender,e);
2024-03-21 14:26:50 -07:00
}
2024-03-21 14:26:50 -07:00
}
2024-03-21 15:17:57 -07:00
private void BindData()
{
DataSet ds = new DataSet();
string medID = Convert.ToString(Session["vMedID"]);
string medicationname = Convert.ToString(Session["vMedName"]);
//string RxNum = Convert.ToString(Session["vRxNum"]);
txtMedID.Text = medID;
txtMedName.Text = medicationname;
//txtRxNum.Text = RxNum;
// if (textHasValues)
// {
ds = PharmacyDataTier.MedicationInfoSearch(medID, medicationname);
// }
// ds = dt.GetStudents();
gvMedication.DataSource = ds.Tables[0];
if (Cache["StudentData"] == null)
{
Cache.Add("StudentData", new DataView(ds.Tables[0]),
null,System.Web.Caching.Cache.NoAbsoluteExpiration,
System.TimeSpan.FromMinutes(10), System.Web.Caching.CacheItemPriority.Default,
null);
}
gvMedication.DataBind();
}
2024-03-21 15:17:57 -07:00
protected void btnMediSearch_OnClick(object sender, EventArgs e)
{
if (txtMedID.Text.Trim().Length > 0 || txtMedName.Text.Trim().Length > 0 || txtRxNum.Text.Trim().Length > 0)
{
try
{
Session["vMedID"] = txtMedID.Text.Trim();
Session["vMedName"] = txtMedName.Text.Trim();
Session["vRxNum"] = txtRxNum.Text.Trim();
Cache.Remove("StudentData");
BindData();
}
catch (Exception exception)
{
}
}
2024-03-21 15:17:57 -07:00
}
protected void gvMedication_OnRowDataBound(object sender, GridViewRowEventArgs e)
2024-03-21 15:17:57 -07:00
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes["onclick"] = Page.ClientScript.GetPostBackClientHyperlink(gvMedication, "Select$" + e.Row.RowIndex);
e.Row.ToolTip = "Click to select this row.";
}
2024-03-21 15:17:57 -07:00
}
protected void gvMedication_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 (gvMedication.SelectedIndex == index)
{
// Deselect the row
gvMedication.SelectedIndex = -1;
}
else
{
// Select the row
gvMedication.SelectedIndex = index;
}
// Refresh the GridView to update the style
gvMedication.DataBind();
}
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
2024-04-03 07:01:25 -07:00
{
BindData();
}
protected void btnMedNew_OnClick(object sender, EventArgs e)
{
throw new NotImplementedException();
}
protected void bntMedEdit_OnClick(object sender, EventArgs e)
{
string medicationID = "0";
//Int64 mEditedRecord = 0;
//System.Text.StringBuilder sb = new System.Text.StringBuilder();
try
{
Session["vMedID"] = txtMedID.Text.Trim();
Session["vMedName"] = txtMedName.Text.Trim();
Session["vRxNum"] = txtRxNum.Text.Trim();
try
{
medicationID = Crypt.Encrypt(gvMedication.SelectedRow.Cells[0].Text);
Response.Redirect("patEdit.aspx" + "?" + "ID=" + medicationID, false);
}
catch (Exception exception)
{
}
// Use the patientID value as needed
}
catch (Exception ex)
{
throw new Exception(ex.Message, ex.InnerException);
}
}
protected void btnMedDelete_OnClick(object sender, EventArgs e)
2024-03-21 15:17:57 -07:00
{
throw new NotImplementedException();
}
2024-03-21 14:26:50 -07:00
}
}