Added search function to Medication Search Page with working gridview
This commit is contained in:
parent
2680e87e2c
commit
39023fcdf8
@ -155,7 +155,7 @@
|
||||
<virtualDirectoryDefaults allowSubDirConfig="true" />
|
||||
<site name="FWA_MAIN" id="1">
|
||||
<application path="/" applicationPool="Clr4IntegratedAppPool">
|
||||
<virtualDirectory path="/" physicalPath="C:\Users\caschick221\RiderProjects\FWA_MAIN\FWA_MAIN" />
|
||||
<virtualDirectory path="/" physicalPath="C:\Users\cmoore\RiderProjects\FWA_MAIN\FWA_MAIN" />
|
||||
</application>
|
||||
<bindings>
|
||||
<binding protocol="http" bindingInformation="*:5000:localhost" />
|
||||
|
@ -2,26 +2,21 @@
|
||||
|
||||
<asp:Content runat="server" ContentPlaceHolderID="cph1">
|
||||
|
||||
<link type="text/css" href="main.css"/>
|
||||
|
||||
<script type="text/javascript">
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
var inputElements = document.getElementsByTagName('input');
|
||||
for (var i = 0; i < inputElements.length; i++) {
|
||||
var input = inputElements[i];
|
||||
if (input.type === 'text') {
|
||||
input.addEventListener('keydown', function (event) {
|
||||
if (event.keyCode === 13) { // 13 is the Enter key
|
||||
event.preventDefault(); // Prevent the default action
|
||||
document.getElementById('<%= btnMediSearch.ClientID %>').click(); // Trigger button click
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$(document).keypress(function(e) {
|
||||
if (e.which === 13) { // Enter key = keycode 13
|
||||
e.preventDefault(); // Prevent the default Enter action
|
||||
$("#<%= btnMediSearch.ClientID %>").click(); // Trigger the search button click
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
<link type="text/css" href="main.css"/>
|
||||
|
||||
<h1 style="text-align: center; font-size: 44px">
|
||||
Medications
|
||||
@ -61,15 +56,23 @@
|
||||
|
||||
</div>
|
||||
|
||||
<asp:GridView runat="server" ID="gvMedication" BorderColor="white" AutoGenerateColumns="False" OnSelectedIndexChanged="gvMedication_OnSelectedIndexChanged"
|
||||
OnRowDataBound="gvMedication_OnRowDataBound">
|
||||
<asp:GridView runat="server" ID="gvMedication" CssClass="gridview"
|
||||
HeaderStyle-CssClass="headerstyle"
|
||||
RowStyle-CssClass="rowstyle"
|
||||
AlternatingRowStyle-CssClass="alternatingrowstyle"
|
||||
SelectedRowStyle-CssClass="selectedrowstyle"
|
||||
OnRowCommand="gvMedication_OnRowCommand"
|
||||
AutoGenerateColumns="False"
|
||||
OnRowDataBound="gvMedication_OnRowDataBound"
|
||||
OnSelectedIndexChanged="GridView1_SelectedIndexChanged">
|
||||
<Columns>
|
||||
<asp:BoundField DataField="Medication_id" HeaderText="Medication ID" ItemStyle-Width="100px"/>
|
||||
<asp:BoundField DataField="FirstName" HeaderText="First Name" ItemStyle-Width="100px"/>
|
||||
<asp:BoundField DataField="LastName" HeaderText="Last Name" ItemStyle-Width="100px"/>
|
||||
<asp:BoundField DataField="DOB" HeaderText="Date of Birth" ItemStyle-Width="100px"/>
|
||||
<asp:BoundField DataField="PhoneNumber" HeaderText="Phone Number" ItemStyle-Width="100px"/>
|
||||
<asp:BoundField DataField="Gender" HeaderText="Gender" ItemStyle-Width="100px"/>
|
||||
<asp:BoundField DataField="MedicationName" HeaderText="Medication Name" ItemStyle-Width="100px"/>
|
||||
<asp:BoundField DataField="IntakeMethod" HeaderText="Intake Method" ItemStyle-Width="100px"/>
|
||||
<asp:BoundField DataField="Frequency" HeaderText="Frequency" ItemStyle-Width="100px"/>
|
||||
<asp:BoundField DataField="Dosage" HeaderText="Dosage" ItemStyle-Width="100px"/>
|
||||
<asp:BoundField DataField="Purpose" HeaderText="Purpose" ItemStyle-Width="100px"/>
|
||||
<asp:BoundField DataField="RxNum" HeaderText="RxNum" ItemStyle-Width="100px"/>
|
||||
</Columns>
|
||||
</asp:GridView>
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
@ -8,20 +9,120 @@ namespace FWA_MAIN
|
||||
{
|
||||
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)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
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_OnSelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1 +1 @@
|
||||
8e9911070208912cc09443f3ed39db28706d92c028ebb520b053693deaaf19ef
|
||||
5c5d3543aa3df97a4bf6915d78123652c5cfa939186f89192a82bb6d5f3ed9b9
|
||||
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user