using System; using System.Data; using System.Web.UI; using System.Web.UI.WebControls; 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); } } 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(); } 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) { } } } protected void gvMedication_OnRowDataBound(object sender, GridViewRowEventArgs e) { 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."; } } 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) { 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("medEdit.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) { throw new NotImplementedException(); } } }