worked on Prescription.aspx

This commit is contained in:
caschick221 2024-04-01 16:02:24 -04:00
parent 93cbf4a428
commit 2680e87e2c
21 changed files with 631 additions and 5 deletions

View File

@ -155,7 +155,7 @@
<virtualDirectoryDefaults allowSubDirConfig="true" />
<site name="FWA_MAIN" id="1">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\Users\eggman\Nextcloud\TSCT\2nd Year\SEM 4\RiderProjects\FWA_MAIN\FWA_MAIN" />
<virtualDirectory path="/" physicalPath="C:\Users\caschick221\RiderProjects\FWA_MAIN\FWA_MAIN" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:5000:localhost" />

View File

@ -203,6 +203,20 @@
<DependentUpon>Prescription.aspx</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RefEdit.aspx.cs">
<SubType>ASPXCodeBehind</SubType>
<DependentUpon>RefEdit.aspx</DependentUpon>
</Compile>
<Compile Include="RefEdit.aspx.designer.cs">
<DependentUpon>RefEdit.aspx</DependentUpon>
</Compile>
<Compile Include="Refills.aspx.cs">
<SubType>ASPXCodeBehind</SubType>
<DependentUpon>Refills.aspx</DependentUpon>
</Compile>
<Compile Include="Refills.aspx.designer.cs">
<DependentUpon>Refills.aspx</DependentUpon>
</Compile>
<Compile Include="testpage.aspx.cs">
<SubType>ASPXCodeBehind</SubType>
<DependentUpon>testpage.aspx</DependentUpon>
@ -239,6 +253,8 @@
<Content Include="preEdit.aspx" />
<Content Include="preNew.aspx" />
<Content Include="Prescription.aspx" />
<Content Include="RefEdit.aspx" />
<Content Include="Refills.aspx" />
<Content Include="Scripts\bootstrap.js" />
<Content Include="Scripts\bootstrap.min.js" />
<Content Include="Default.aspx" />

View File

@ -1081,7 +1081,7 @@ namespace FWA_MAIN
}
}
public static double GetNextRefillID()
public static string GetNextRefillID()
{
try
{
@ -1109,9 +1109,15 @@ namespace FWA_MAIN
// MessageBox.Show("Error Getting next Refill ID", "ERROR", MessageBoxButtons.OK);
}
string stringval = value.ToString();
while (stringval.Length < 10)
{
stringval = "0" + stringval;
}
// return dataSet
return value;
return stringval;
}
catch (Exception ex)
{
@ -1154,6 +1160,7 @@ namespace FWA_MAIN
myConn.Close();
}
}
public static void UpdateRefill(string refillID, DateTime date, string patientID, string medicationID, string rxNum)
{
@ -1216,6 +1223,38 @@ namespace FWA_MAIN
}
}
public static void DeleteAllRefill(string PrescriptionID)
{
try
{
// open connection
myConn.Open();
//clear any parameters
cmdString.Parameters.Clear();
// command
cmdString.Connection = myConn;
cmdString.CommandType = CommandType.StoredProcedure;
cmdString.CommandTimeout = 1500;
cmdString.CommandText = "DeleteAllRefill";
// Define input parameter
cmdString.Parameters.Add("@RxID", SqlDbType.Char, 11).Value = PrescriptionID;
cmdString.ExecuteNonQuery();
}
catch (Exception ex)
{
throw new ArgumentException(ex.Message);
}
finally
{
myConn.Close();
}
}
public static void PastRefills(string rxNum)
{
@ -1244,6 +1283,34 @@ namespace FWA_MAIN
myConn.Close();
}
}
public static void RefreshRefill(string rxNum)
{
try
{
myConn.Open();
cmdString.Parameters.Clear();
cmdString.Connection = myConn;
cmdString.CommandType = CommandType.StoredProcedure;
cmdString.CommandTimeout = 1500;
cmdString.CommandText = "RefreshRefill";
cmdString.Parameters.Add("@Prescription_id", SqlDbType.VarChar, 11).Value = rxNum;
cmdString.ExecuteNonQuery();
}
catch (Exception ex)
{
throw new ArgumentException(ex.Message);
}
finally
{
myConn.Close();
}
}
public static void DecrementPastRefills(string rxNum)
{

View File

@ -97,6 +97,12 @@
<li style="height: 25px">
<asp:Button runat="server" CssClass="standardbtn" ID="btnPreDelete" Text="Delete" OnClick="btnPreDelete_OnClick"/>
</li>
<li style="height: 25px">
<asp:Button runat="server" CssClass="standardbtn" ID="btnPreRefill" Text="Refill" OnClick="btnPreRefill_OnClick"/>
</li>
<li style="height: 25px">
<asp:Button runat="server" CssClass="standardbtn" ID="btnPreView" Text="View Refills" OnClick="btnPreView_OnClick"/>
</li>
<%-- <asp:Button runat="server" Text="New" OnClick="btnNew_OnClick" /> --%>
</ul>

View File

@ -85,6 +85,7 @@ namespace FWA_MAIN
{
}
}
}
protected void gvPatient_OnRowDataBound(object sender, GridViewRowEventArgs e)
@ -194,6 +195,7 @@ namespace FWA_MAIN
try
{
PharmacyDataTier.DeleteAllRefill(gvPrescription.SelectedRow.Cells[0].Text);
PharmacyDataTier.DeletePrescription(gvPrescription.SelectedRow.Cells[0].Text);
BindData();
}
@ -204,6 +206,31 @@ namespace FWA_MAIN
}
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)
{
}
}
protected void btnPreRefill_OnClick(object sender, EventArgs e)
{
var ds = new DataSet();
ds = PharmacyDataTier.PrescriptionInfoSearch(gvPrescription.SelectedRow.Cells[0].Text);
if (int.Parse(ds.Tables[0].Rows[0]["test2"].ToString()) < int.Parse(ds.Tables[0].Rows[0]["test"].ToString()))
{
PharmacyDataTier.AddRefill(PharmacyDataTier.GetNextRefillID().ToString(), DateTime.Now, gvPrescription.SelectedRow.Cells[5].Text,gvPrescription.SelectedRow.Cells[4].Text,gvPrescription.SelectedRow.Cells[0].Text);
}
PharmacyDataTier.RefreshRefill(gvPrescription.SelectedRow.Cells[0].Text);
BindData();
}
}
}

View File

@ -95,6 +95,24 @@ namespace FWA_MAIN
/// </remarks>
protected global::System.Web.UI.WebControls.Button btnPreDelete;
/// <summary>
/// btnPreRefill control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Button btnPreRefill;
/// <summary>
/// btnPreView control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Button btnPreView;
/// <summary>
/// Master property.
/// </summary>

43
FWA_MAIN/RefEdit.aspx Normal file
View File

@ -0,0 +1,43 @@
<%@ Page Title="EditRefill" Language="C#" MasterPageFile="main.master" CodeBehind="RefEdit.aspx.cs" Inherits="FWA_MAIN.RefEdit" %>
<asp:Content runat="server" ContentPlaceHolderID="cph1">
<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
$("#<%= btnSaveRef.ClientID %>").click(); // Trigger the search button click
}
});
});
</script>
<link type="text/css" href="main.css"/>
<h1 style="text-align: center; font-size: 44px">Edit Refill</h1>
<div class="patDiv" style="margin-left: 300px">
<div class="patDiv">
<div class="patDiv" style="padding-left: 150px; padding-right: 5px;width: 100px">
<div class="indivPatDiv" style="text-align: right"><label class="buttonLabel">Refill ID: </label></div>
<div class="indivPatDiv" style="text-align: right"><label class="buttonLabel">Refill Date: </label></div>
<div class="indivPatDiv" style="text-align: right"><label class="buttonLabel">Patient ID: </label></div>
<div class="indivPatDiv" style="text-align: right"><label class="buttonLabel">Medication ID: </label></div>
<div class="indivPatDiv" style="text-align: right"><label class="buttonLabel">Prescription ID: </label></div>
</div>
<div class="patDiv">
<div class="indivPatDiv"><asp:TextBox runat="server" CssClass="defaultTXT" ID="txtRefillID"></asp:TextBox></div>
<div class="indivPatDiv"><asp:TextBox runat="server" CssClass="defaultTXT" ID="txtDate"></asp:TextBox></div>
<div class="indivPatDiv"><asp:TextBox runat="server" CssClass="defaultTXT" ID="txtPatID"></asp:TextBox></div>
<div class="indivPatDiv"><asp:TextBox runat="server" CssClass="defaultTXT" ID="txtMedID"></asp:TextBox></div>
<div class="indivPatDiv"><asp:TextBox runat="server" CssClass="defaultTXT" ID="txtPreID"></asp:TextBox></div>
</div>
</div>
</div>
<br/>
<br/>
<br/>
<div class="patDiv" style="margin-left: 500px">
<div style="margin-right: 10px; display: inline-block"><asp:Button runat="server" CssClass="standardbtn" ID="btnSaveRef" Text="Save" OnClick="btnSaveRef_OnClick"/></div>
<div style="display: inline-block"><asp:Button runat="server" CssClass="standardbtn" ID="btnCancelRef" Text="Cancel" OnClick="btnCancelRef_OnClick"/></div>
</div>
</asp:Content>

65
FWA_MAIN/RefEdit.aspx.cs Normal file
View File

@ -0,0 +1,65 @@
using System;
using System.Data;
using System.Diagnostics;
using System.Web.UI;
namespace FWA_MAIN
{
public partial class RefEdit : Page
{
protected string refID;
protected void Page_Load(object sender, EventArgs e)
{
txtMedID.Enabled = false;
txtPatID.Enabled = false;
txtPreID.Enabled = false;
txtRefillID.Enabled = false;
if (!IsPostBack)
{
refID = Crypt.Decrypt(Request.QueryString["ID"]);
FillRefill();
}
}
protected void FillRefill()
{
var ds = new DataSet();
ds = PharmacyDataTier.RefillSearch(refID);
txtRefillID.Text = ds.Tables[0].Rows[0]["Refill_id"].ToString();
DateTime date = DateTime.Parse(ds.Tables[0].Rows[0]["RefillDate"].ToString());
txtDate.Text = date.ToString("d");
txtPatID.Text = ds.Tables[0].Rows[0]["Patient_id"].ToString();
txtMedID.Text = ds.Tables[0].Rows[0]["Medication_id"].ToString();
txtPreID.Text = ds.Tables[0].Rows[0]["RxNum_id"].ToString();
}
protected void btnSaveRef_OnClick(object sender, EventArgs e)
{
PharmacyDataTier.UpdateRefill(
txtRefillID.Text,
Val.Date(txtDate),
txtPatID.Text,
txtMedID.Text,
txtPreID.Text
);
Response.Redirect("Refills.aspx" + "?" + "ID=" + Crypt.Encrypt(txtPreID.Text), false);
}
protected void btnCancelRef_OnClick(object sender, EventArgs e)
{
Response.Redirect("Refills.aspx" + "?" + "ID=" + Crypt.Encrypt(txtPreID.Text), false);
}
}
}

94
FWA_MAIN/RefEdit.aspx.designer.cs generated Normal file
View File

@ -0,0 +1,94 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace FWA_MAIN
{
public partial class RefEdit
{
/// <summary>
/// txtRefillID control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.TextBox txtRefillID;
/// <summary>
/// txtDate control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.TextBox txtDate;
/// <summary>
/// txtPatID control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.TextBox txtPatID;
/// <summary>
/// txtMedID control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.TextBox txtMedID;
/// <summary>
/// txtPreID control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.TextBox txtPreID;
/// <summary>
/// btnSaveRef control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Button btnSaveRef;
/// <summary>
/// btnCancelRef control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Button btnCancelRef;
/// <summary>
/// Master property.
/// </summary>
/// <remarks>
/// Auto-generated property.
/// </remarks>
public new FWA_MAIN.main Master
{
get
{
return ((FWA_MAIN.main)(base.Master));
}
}
}
}

113
FWA_MAIN/Refills.aspx Normal file
View File

@ -0,0 +1,113 @@
<%@ Page Title="Refills" Language="C#" EnableEventValidation="false" MasterPageFile="main.master" CodeBehind="Refills.aspx.cs" Inherits="FWA_MAIN.Refills" %>
<asp:Content runat="server" ContentPlaceHolderID="cph1">
<link type="text/css" href="main.css"/>
<h1 style="text-align: center; font-size: 44px">
Refills
</h1>
<div style="width: 80%; margin: 0 auto; align-content: center; horiz-align: center">
<asp:GridView runat="server" ID="gvRefills"
CssClass="gridview"
HeaderStyle-CssClass="headerstyle"
RowStyle-CssClass="rowstyle"
AlternatingRowStyle-CssClass="alternatingrowstyle"
SelectedRowStyle-CssClass="selectedrowstyle"
OnRowCommand="gvRefills_OnRowCommand"
AutoGenerateColumns="False"
OnRowDataBound="gvRefills_OnRowDataBound"
OnSelectedIndexChanged="gvRefills_SelectedIndexChanged">
<Columns>
<asp:BoundField DataField="Refill_id" HeaderText="Refill ID"/>
<asp:BoundField DataField="RefillDate" HeaderText="Refill Date" DataFormatString="{0:d}" HtmlEncode="False"/>
<asp:BoundField DataField="Patient_id" HeaderText="Patient ID"/>
<asp:BoundField DataField="Medication_id" HeaderText="Medication ID"/>
<asp:BoundField DataField="RxNum_id" HeaderText="Prescription ID"/>
</Columns>
</asp:GridView></div>
<br/>
<br/>
<br/>
<div class="patDiv" style="margin-left: 500px">
<div style="display: inline-block"><asp:Button runat="server" CssClass="standardbtn" ID="btnBack" Text="Back" OnClick="btnBack_OnClick"/></div>
</div>
<script type="text/javascript">
document.oncontextmenu = rightClick;
function rightClick(clickEvent) {
clickEvent.preventDefault();
// return false;
}
</script>
<div id="contextMenu" class="context-menu"
style="display: none; width: auto">
<ul>
<li style="height: 25px">
<asp:Button runat="server" CssClass="standardbtn" ID="btnRefEdit" Text="Edit" OnClick="btnRefEdit_OnClick"/>
</li>
<li style="height: 25px">
<asp:Button runat="server" CssClass="standardbtn" ID="btnRefDelete" Text="Delete" OnClick="btnRefDelete_OnClick"/>
</li>
</ul>
</div>
<script>
document.onclick = hideMenu;
document.oncontextmenu = rightClick;
function hideMenu() {
document.getElementById("contextMenu")
.style.display = "none"
}
function rightClick(e) {
e.preventDefault();
if (document.getElementById("contextMenu").style.display == "block")
hideMenu();
else{
var menu = document.getElementById("contextMenu")
menu.style.display = 'block';
menu.style.left = e.pageX + "px";
menu.style.top = e.pageY + "px";
}
}
</script>
<style type="text/css">
.context-menu {
position: absolute;
text-align: center;
background: lightgray;
border: 1px solid black;
}
.context-menu ul {
padding: 0px;
margin: 0px;
/*min-width: 150px; */
list-style: none;
}
.context-menu ul li {
/*padding-bottom: 7px; */
/*padding-top: 7px; */
/*border: 1px solid black; */
}
.context-menu ul li a {
text-decoration: none;
color: black;
}
.context-menu ul li:hover {
background: darkgray;
}
</style>
</asp:Content>

98
FWA_MAIN/Refills.aspx.cs Normal file
View File

@ -0,0 +1,98 @@
using System;
using System.Data;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace FWA_MAIN
{
public partial class Refills : Page
{
protected string preID;
protected void Page_Load(object sender, EventArgs e)
{
preID = Crypt.Decrypt(Request.QueryString["ID"]);
Fill();
}
protected void Fill()
{
var ds = new DataSet();
ds = PharmacyDataTier.GetRefill(preID);
gvRefills.DataSource = ds;
gvRefills.DataBind();
}
protected void btnRefEdit_OnClick(object sender, EventArgs e)
{
string refillID = "0";
try
{
refillID = Crypt.Encrypt(gvRefills.SelectedRow.Cells[0].Text);
Response.Redirect("RefEdit.aspx" + "?" + "ID=" + refillID, false);
}
catch (Exception exception)
{
}
}
protected void btnRefDelete_OnClick(object sender, EventArgs e)
{
PharmacyDataTier.DeleteRefill(gvRefills.SelectedRow.Cells[0].Text);
PharmacyDataTier.RefreshRefill(gvRefills.SelectedRow.Cells[4].Text);
Fill();
}
protected void gvRefills_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 (gvRefills.SelectedIndex == index)
{
// Deselect the row
gvRefills.SelectedIndex = -1;
}
else
{
// Select the row
gvRefills.SelectedIndex = index;
}
// Refresh the GridView to update the style
gvRefills.DataBind();
}
}
protected void gvRefills_OnRowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes["onclick"] = Page.ClientScript.GetPostBackClientHyperlink(gvRefills, "Select$" + e.Row.RowIndex);
e.Row.ToolTip = "Click to select this row.";
}
}
protected void gvRefills_SelectedIndexChanged(object sender, EventArgs e)
{
Fill();
}
protected void btnBack_OnClick(object sender, EventArgs e)
{
Response.Redirect("Prescription.aspx");
}
}
}

67
FWA_MAIN/Refills.aspx.designer.cs generated Normal file
View File

@ -0,0 +1,67 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace FWA_MAIN
{
public partial class Refills
{
/// <summary>
/// gvRefills control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.GridView gvRefills;
/// <summary>
/// btnBack control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Button btnBack;
/// <summary>
/// btnRefEdit control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Button btnRefEdit;
/// <summary>
/// btnRefDelete control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Button btnRefDelete;
/// <summary>
/// Master property.
/// </summary>
/// <remarks>
/// Auto-generated property.
/// </remarks>
public new FWA_MAIN.main Master
{
get
{
return ((FWA_MAIN.main)(base.Master));
}
}
}
}

Binary file not shown.

Binary file not shown.

View File

@ -1 +1 @@
5479b0a2d9bb058bd3c97a17c7db049615ea9c4f5a1d67c3c95c0256920315d2
8e9911070208912cc09443f3ed39db28706d92c028ebb520b053693deaaf19ef

Binary file not shown.

Binary file not shown.

View File

@ -50,6 +50,7 @@ namespace FWA_MAIN
DateTime end = Val.Date(txtEnd);
PharmacyDataTier.UpdatePrescription(rxnum,patid,medid,phyid,used,allow,start,end);
PharmacyDataTier.RefreshRefill(rxnum);
Response.Redirect("Prescription.aspx");

View File

@ -1,7 +1,17 @@
<%@ Page Title="New Prescription" Language="C#" MasterPageFile="main.master" CodeBehind="preNew.aspx.cs" Inherits="FWA_MAIN.preNew" %>
<asp:Content runat="server" ContentPlaceHolderID="cph1">
<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
$("#<%= btnSavePat.ClientID %>").click(); // Trigger the search button click
}
});
});
</script>
<link type="text/css" href="main.css"/>
<h1 style="text-align: center; font-size: 44px">New Prescription</h1>

View File

@ -32,6 +32,7 @@ namespace FWA_MAIN
DateTime end = Val.Date(txtEnd);
PharmacyDataTier.CreatePrescription2(rxnum,patid,medid,phyid,used,allow,start,end);
PharmacyDataTier.RefreshRefill(rxnum);
Response.Redirect("Prescription.aspx");
}