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

78 lines
2.8 KiB
C#

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("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");
}
}
}