finished patEdit.aspx mostly

This commit is contained in:
caschick221 2024-03-28 15:04:52 -04:00
parent 2586a83af8
commit 389ac65817
18 changed files with 350 additions and 45 deletions

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
<data-source source="LOCAL" name="College2@sql.eggtech.net" uuid="c2de8ef4-059e-44b0-a7e0-cca90bba5cf4">
<driver-ref>sqlserver.jb</driver-ref>
<synchronize>true</synchronize>
<configured-by-url>true</configured-by-url>
<jdbc-driver>com.jetbrains.jdbc.sqlserver.SqlServerDriver</jdbc-driver>
<jdbc-url>Server=sql.eggtech.net;Database=College2;User Id=admin;Password=delirium-purveyor-overall-backboned-approval-amino;</jdbc-url>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
<data-source source="LOCAL" name="FinalProjectOfficialPharmacy@sql.eggtech.net" uuid="e9b9e528-a4c2-4f75-8a99-51124912d950">
<driver-ref>sqlserver.jb</driver-ref>
<synchronize>true</synchronize>
<configured-by-url>true</configured-by-url>
<jdbc-driver>com.jetbrains.jdbc.sqlserver.SqlServerDriver</jdbc-driver>
<jdbc-url>Server=sql.eggtech.net;Database=FinalProjectOfficialPharmacy;User Id=admin;Password=delirium-purveyor-overall-backboned-approval-amino;</jdbc-url>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
</component>
</project>

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

@ -1,7 +1,77 @@
namespace FWA_MAIN
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Web.UI.WebControls;
using System;
using System.IO;
using System.Security.Cryptography;
using System.Text;
using System.Web;
namespace FWA_MAIN
{
public class Crypt
{
static private string encryptKey =
"CXvA@xsFmBik#E4#7tf4zY7JK^qaTUwFYw^QuC7sipSyBPfkS$qFFU%ZQmRb5GY85unfCmEw@dK7Bhiyt%3asL62yygk6x6D@@D8CUnJfF8@F$C9vtJgGwNhmSxvo#Lh";
static private string encryptSalt =
"gab-purgatory-studio-atlantic-ladle-challenge-slaw-unshaken-eastward-caring-deftly-devious-crudeness-walrus-glorifier-unsteady-sauciness-feminist-jailbreak-upside";
static public string Encrypt(string cleartext)
{
byte[] plainText = Encoding.UTF8.GetBytes(cleartext);
using (RijndaelManaged rijndaelCipher = new RijndaelManaged())
{
PasswordDeriveBytes secretKey = new PasswordDeriveBytes(Encoding.ASCII.GetBytes(encryptKey),
Encoding.ASCII.GetBytes(encryptSalt));
using (ICryptoTransform encryptor =
rijndaelCipher.CreateEncryptor(secretKey.GetBytes(32), secretKey.GetBytes(16)))
{
using (MemoryStream memoryStream = new MemoryStream())
{
using (CryptoStream cryptoStream =
new CryptoStream(memoryStream, encryptor, CryptoStreamMode.Write))
{
cryptoStream.Write(plainText, 0, plainText.Length);
cryptoStream.FlushFinalBlock();
string base64 = Convert.ToBase64String(memoryStream.ToArray());
// Generate a string that won't get screwed up when passed as a query string.
string urlEncoded = HttpUtility.UrlEncode(base64);
return urlEncoded;
}
}
}
}
}
static public string Decrypt(string cleartext)
{
byte[] encryptedData = Convert.FromBase64String(cleartext);
PasswordDeriveBytes secretKey = new PasswordDeriveBytes(Encoding.ASCII.GetBytes(encryptKey),
Encoding.ASCII.GetBytes(encryptSalt));
using (RijndaelManaged rijndaelCipher = new RijndaelManaged())
{
using (ICryptoTransform decryptor =
rijndaelCipher.CreateDecryptor(secretKey.GetBytes(32), secretKey.GetBytes(16)))
{
using (MemoryStream memoryStream = new MemoryStream(encryptedData))
{
using (CryptoStream cryptoStream =
new CryptoStream(memoryStream, decryptor, CryptoStreamMode.Read))
{
byte[] plainText = new byte[encryptedData.Length];
cryptoStream.Read(plainText, 0, plainText.Length);
string utf8 = Encoding.UTF8.GetString(plainText);
return utf8.Trim('\0');
}
}
}
}
}
}
}

View File

@ -207,6 +207,7 @@
<Compile Include="Default.aspx.designer.cs">
<DependentUpon>Default.aspx</DependentUpon>
</Compile>
<Compile Include="Val.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="cmutemplate.html" />

View File

@ -831,7 +831,7 @@ namespace FWA_MAIN
}
public static double GetNextPatientID()
public static string GetNextPatientID()
{
try
{
@ -845,7 +845,6 @@ namespace FWA_MAIN
cmdString.CommandTimeout = 1500;
cmdString.CommandText = "GetNextPatientID";
// Define input parameter
cmdString.Parameters.Add("@TableName", SqlDbType.NVarChar, 128).Value = "PATIENT";
object result = cmdString.ExecuteScalar();
double value = 0;
@ -858,10 +857,16 @@ namespace FWA_MAIN
{
// MessageBox.Show("Error Getting next Patient ID","ERROR",MessageBoxButtons.OK);
}
string stringval = value.ToString();
while (stringval.Length < 8)
{
stringval = "0" + stringval;
}
// return dataSet
return value;
return stringval;
}
catch (Exception ex)
{

73
FWA_MAIN/Val.cs Normal file
View File

@ -0,0 +1,73 @@
using System;
using System.Web.UI.WebControls;
namespace FWA_MAIN
{
public class Val
{
public static string varchar(TextBox box, int length)
{
if (box.Text.Length <= length)
{
return box.Text.Trim();
}
else
{
return "";
}
}
public static int IntType(TextBox box)
{
return int.Parse(box.Text.Trim());
}
public static short SmallIntType(TextBox box)
{
try
{
if (box.Text.Length > 0)
{
if (double.Parse(box.Text) < 65535 && double.Parse(box.Text) >= 0)
{
return short.Parse(box.Text.Trim());
}
else
{
return 0;
}
}
else
{
return 0;
}
}
catch (Exception e)
{
return 0;
}
}
public static DateTime Date(TextBox box)
{
try
{
DateTime date = DateTime.Parse(box.Text.Trim());
return date;
}
catch (Exception e)
{
return new DateTime(3000, 1, 1);
}
}
}
}

Binary file not shown.

Binary file not shown.

View File

@ -114,7 +114,7 @@
font-size: 16px;
color: white;
/*border: 2px solid #0056b3;*/
}

View File

@ -1 +1 @@
7074ecee9fd5e988b38acde16901b0d6290276e5479ece72dfea267de554eaeb
e89e31cdadf20fe7db48ef132bf217873437f194debfb0966ea84327b2ae8615

Binary file not shown.

Binary file not shown.

View File

@ -47,7 +47,7 @@
</div>
<br/>
<div class="patDiv" style="margin-left: 500px">
<div style="margin-right: 10px; display: inline-block"><asp:Button runat="server" CssClass="standardbtn" ID="btnSavePat" Text="Save"/></div>
<div style="margin-right: 10px; display: inline-block"><asp:Button runat="server" CssClass="standardbtn" ID="btnSavePat" Text="Save" OnClick="btnSavePat_OnClick"/></div>
<div style="display: inline-block"><asp:Button runat="server" CssClass="standardbtn" ID="btnCancelPat" Text="Cancel" OnClick="btnCancelPat_OnClick"/></div>
</div>
</asp:Content>

View File

@ -1,18 +1,78 @@
using System;
using System.Web.UI;
using System.Data;
namespace FWA_MAIN
{
public partial class patEdit : Page
{
protected string patID;
protected void Page_Load(object sender, EventArgs e)
{
patID = Crypt.Decrypt(Request.QueryString["ID"]);
txtPatID.Enabled = false;
if (!IsPostBack)
{
FillPatient(patID);
}
}
protected void FillPatient(string id)
{
var ds = new DataSet();
ds = PharmacyDataTier.PatientInfoSearch(patID);
txtPatID.Text = ds.Tables[0].Rows[0]["Patient_id"].ToString();
txtFNAME.Text = ds.Tables[0].Rows[0]["FirstName"].ToString();
txtLNAME.Text = ds.Tables[0].Rows[0]["LastName"].ToString();
txtMidInit.Text = ds.Tables[0].Rows[0]["MiddleIntials"].ToString();
txtWeight.Text = ds.Tables[0].Rows[0]["lbs"].ToString();
txtHeightFt.Text = ds.Tables[0].Rows[0]["Height_feet"].ToString();
txtHeightIn.Text = ds.Tables[0].Rows[0]["Height_inches"].ToString();
DateTime date = DateTime.Parse(ds.Tables[0].Rows[0]["DOB"].ToString());
txtDOB.Text = date.ToString("d");
txtGender.Text = ds.Tables[0].Rows[0]["Gender"].ToString();
txtCity.Text = ds.Tables[0].Rows[0]["City"].ToString();
txtZip.Text = ds.Tables[0].Rows[0]["Zip"].ToString();
txtState.Text = ds.Tables[0].Rows[0]["UsState"].ToString();
txtPhoneNum.Text = ds.Tables[0].Rows[0]["PhoneNumber"].ToString();
}
protected void btnCancelPat_OnClick(object sender, EventArgs e)
{
Response.Redirect("patient.aspx");
Response.Redirect("patSearch.aspx");
}
protected void btnSavePat_OnClick(object sender, EventArgs e)
{
string id = Val.varchar(txtPatID, 8);
string FNAME = Val.varchar(txtFNAME, 30);
string LNAME = Val.varchar(txtLNAME, 30);
string MidInit = Val.varchar(txtMidInit, 1);
int Weight = Val.IntType(txtWeight);
int HeightFt = Val.IntType(txtHeightFt);
int HeightIn = Val.IntType(txtHeightIn);
DateTime date = Val.Date(txtDOB);
string gender = Val.varchar(txtGender, 1);
string city = Val.varchar(txtCity, 30);
short zip = Val.SmallIntType(txtZip);
string state = Val.varchar(txtState, 2);
string phone = Val.varchar(txtPhoneNum, 14);
PharmacyDataTier.UpdatePatient(id,FNAME,LNAME,MidInit,Weight,HeightFt,HeightIn,date,gender,city,zip,state,phone);
Response.Redirect("patSearch.aspx");
}
}
}

View File

@ -79,14 +79,14 @@
<div id="contextMenu" class="context-menu"
style="display: none; width: auto">
<ul>
<li>
<asp:Button runat="server" CssClass="standardbtn"/>
<li style="height: 25px">
<asp:Button runat="server" CssClass="standardbtn" ID="btnPatNew" Text="New" OnClick="btnPatNew_OnClick"/>
</li>
<li>
<asp:Button runat="server" CssClass="standardbtn"/>
<li style="height: 25px">
<asp:Button runat="server" CssClass="standardbtn" ID="bntPatEdit" Text="Edit" OnClick="bntPatEdit_OnClick"/>
</li>
<li>
<asp:Button runat="server" CssClass="standardbtn"/>
<li style="height: 25px">
<asp:Button runat="server" CssClass="standardbtn" ID="btnPatDelete" Text="Delete" OnClick="btnPatDelete_OnClick"/>
</li>
<%-- <asp:Button runat="server" Text="New" OnClick="btnNew_OnClick" /> --%>
@ -133,9 +133,9 @@
}
.context-menu ul li {
padding-bottom: 7px;
padding-top: 7px;
border: 1px solid black;
/*padding-bottom: 7px; */
/*padding-top: 7px; */
/*border: 1px solid black; */
}
.context-menu ul li a {

View File

@ -11,6 +11,17 @@ namespace FWA_MAIN
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
txtPatID.Text = Convert.ToString(Session["vPatID"]);
txtFNAME.Text = Convert.ToString(Session["vFNAME"]);
txtLNAME.Text = Convert.ToString(Session["vLNAME"]);
btnPatSearch_OnClick(sender,e);
}
}
protected void btnNew_OnClick(object sender, EventArgs e)
@ -87,36 +98,11 @@ namespace FWA_MAIN
e.Row.Attributes["onclick"] = Page.ClientScript.GetPostBackClientHyperlink(gvPatient, "Select$" + e.Row.RowIndex);
e.Row.ToolTip = "Click to select this row.";
}
// if (e.Row.RowType == DataControlRowType.DataRow)
// {
// // Clear any previous selection style
// e.Row.Style.Remove(HtmlTextWriterStyle.BackgroundColor);
//
// if (e.Row.RowIndex == gvPatient.SelectedIndex)
// {
// // Apply the selected style
// e.Row.Style.Add(HtmlTextWriterStyle.BackgroundColor, "LightBlue");
// }
// }
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
foreach (GridViewRow row in gvPatient.Rows)
{
// if (row.RowIndex == gvPatient.SelectedIndex)
// {
// row.BackColor = Color.Aqua;
// row.ToolTip = string.Empty;
// }
// else
// {
// row.BackColor = Color.Black;
// row.ToolTip = "Click to select this row.";
// }
}
BindData();
}
protected void gvPatient_OnRowCommand(object sender, GridViewCommandEventArgs e)
@ -142,5 +128,67 @@ namespace FWA_MAIN
gvPatient.DataBind();
}
}
protected void btnPatNew_OnClick(object sender, EventArgs e)
{
string patientID;
try
{
Session["vPatID"] = txtPatID.Text.Trim();
Session["vFNAME"] = txtFNAME.Text.Trim();
Session["vLNAME"] = txtLNAME.Text.Trim();
patientID = PharmacyDataTier.GetNextPatientID();
patientID = Crypt.Encrypt(patientID);
// Use the patientID value as needed
Response.Redirect("patNew.aspx" + "?" + "ID=" + patientID, false);
}
catch (Exception ex)
{
throw new Exception(ex.Message, ex.InnerException);
}
}
protected void bntPatEdit_OnClick(object sender, EventArgs e)
{
string patientID = "0";
Int64 mEditedRecord = 0;
System.Text.StringBuilder sb = new System.Text.StringBuilder();
try
{
Session["vPatID"] = txtPatID.Text.Trim();
Session["vFNAME"] = txtFNAME.Text.Trim();
Session["vLNAME"] = txtLNAME.Text.Trim();
if (gvPatient.SelectedIndex >= 0) // Check if a row is selected
{
patientID = Crypt.Encrypt(gvPatient.SelectedRow.Cells[0].Text);
// Use the patientID value as needed
}
else
{
throw new Exception();
}
Response.Redirect("patEdit.aspx" + "?" + "ID=" + patientID, false);
}
catch (Exception ex)
{
throw new Exception(ex.Message, ex.InnerException);
}
}
protected void btnPatDelete_OnClick(object sender, EventArgs e)
{
}
}
}

View File

@ -59,6 +59,33 @@ namespace FWA_MAIN
/// </remarks>
protected global::System.Web.UI.WebControls.GridView gvPatient;
/// <summary>
/// btnPatNew 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 btnPatNew;
/// <summary>
/// bntPatEdit 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 bntPatEdit;
/// <summary>
/// btnPatDelete 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 btnPatDelete;
/// <summary>
/// Master property.
/// </summary>