2024-02-15 08:55:05 -05:00
|
|
|
|
using System;
|
2024-02-15 12:04:26 -05:00
|
|
|
|
using System.Data;
|
2024-02-16 13:57:58 -05:00
|
|
|
|
using System.Windows.Forms;
|
2024-02-15 08:55:05 -05:00
|
|
|
|
|
|
|
|
|
namespace Louis__Pharmacy_CNSA212_FP
|
|
|
|
|
{
|
|
|
|
|
public partial class frmPatientAdd : Form
|
|
|
|
|
{
|
|
|
|
|
private static bool isAdd;
|
2024-02-16 13:57:58 -05:00
|
|
|
|
|
2024-02-15 08:55:05 -05:00
|
|
|
|
public frmPatientAdd(bool isNew)
|
|
|
|
|
{
|
|
|
|
|
isAdd = isNew;
|
|
|
|
|
InitializeComponent();
|
2024-02-16 13:57:58 -05:00
|
|
|
|
|
|
|
|
|
txtState.MaxLength = 2;
|
|
|
|
|
|
2024-02-15 08:55:05 -05:00
|
|
|
|
if (isNew)
|
|
|
|
|
{
|
|
|
|
|
lblDisPurpose.Text = "Add Patient";
|
2024-02-15 12:04:26 -05:00
|
|
|
|
btnGO.Text = "Create";
|
2024-02-15 08:55:05 -05:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
lblDisPurpose.Text = "Edit Patient";
|
2024-02-15 12:04:26 -05:00
|
|
|
|
btnGO.Text = "Update";
|
2024-02-15 08:55:05 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-16 13:57:58 -05:00
|
|
|
|
|
2024-02-15 08:55:05 -05:00
|
|
|
|
private void label1_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void frmPatientAdd_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
txtPatientID.Enabled = false;
|
|
|
|
|
|
|
|
|
|
if (isAdd)
|
|
|
|
|
{
|
2024-02-16 13:57:58 -05:00
|
|
|
|
var nextID = PharmacyDataTier.GetNextPatientID();
|
2024-02-15 12:04:26 -05:00
|
|
|
|
txtPatientID.Text = nextID.ToString();
|
2024-02-15 08:55:05 -05:00
|
|
|
|
}
|
2024-02-15 12:04:26 -05:00
|
|
|
|
}
|
2024-02-15 08:55:05 -05:00
|
|
|
|
|
2024-02-15 12:04:26 -05:00
|
|
|
|
public void FillPatient(string patID)
|
|
|
|
|
{
|
2024-02-16 13:57:58 -05:00
|
|
|
|
var ds = new DataSet();
|
|
|
|
|
var data = new PharmacyDataTier();
|
2024-02-15 12:04:26 -05:00
|
|
|
|
|
|
|
|
|
ds = PharmacyDataTier.PatientInfoSearch(patID);
|
|
|
|
|
txtPatientID.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();
|
2024-02-16 11:32:00 -05:00
|
|
|
|
txtMidInit.Text = ds.Tables[0].Rows[0]["MiddleIntials"].ToString();
|
2024-02-15 12:04:26 -05:00
|
|
|
|
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();
|
|
|
|
|
txtDOB.Text = ds.Tables[0].Rows[0]["DOB"].ToString();
|
|
|
|
|
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();
|
|
|
|
|
txtPhone.Text = ds.Tables[0].Rows[0]["PhoneNumber"].ToString();
|
2024-02-15 08:55:05 -05:00
|
|
|
|
}
|
2024-02-16 13:57:58 -05:00
|
|
|
|
|
|
|
|
|
private void btnGO_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var epLocal = new ErrorProvider();
|
|
|
|
|
|
|
|
|
|
var Patient_id = txtPatientID.Text;
|
|
|
|
|
var FirstName = txtFname.Text;
|
|
|
|
|
var LastName = txtLname.Text;
|
|
|
|
|
var MiddleIntials = txtMidInit.Text;
|
|
|
|
|
var City = txtCity.Text;
|
|
|
|
|
|
|
|
|
|
int lbs;
|
|
|
|
|
int Height_feet;
|
|
|
|
|
int Height_inches;
|
|
|
|
|
DateTime DOB;
|
|
|
|
|
string Gender;
|
|
|
|
|
short Zip;
|
|
|
|
|
string UsState;
|
|
|
|
|
string PhoneNumber;
|
|
|
|
|
|
|
|
|
|
var parseHasFailed = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
lbs = int.Parse(txtWeight.Text);
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Height_feet = int.Parse(txtHeightFt.Text);
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Height_inches = int.Parse(txtHeightIn.Text);
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
DOB = DateTime.Parse(txtDOB.Text);
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Gender = txtGender.Text;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Zip = short.Parse(txtZip.Text);
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
UsState = txtState.Text;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
PhoneNumber = txtPhone.Text;
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (Patient_id.Length > 8)
|
|
|
|
|
{
|
|
|
|
|
epLocal.SetError(txtPatientID, "Error");
|
|
|
|
|
throw new Exception();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (FirstName.Length > 30)
|
|
|
|
|
{
|
|
|
|
|
epLocal.SetError(txtFname, "Error");
|
|
|
|
|
throw new Exception();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (LastName.Length > 30)
|
|
|
|
|
{
|
|
|
|
|
epLocal.SetError(txtLname, "Error");
|
|
|
|
|
throw new Exception();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (MiddleIntials.Length > 1)
|
|
|
|
|
{
|
|
|
|
|
epLocal.SetError(txtMidInit, "Error");
|
|
|
|
|
throw new Exception();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Zip > 65535)
|
|
|
|
|
{
|
|
|
|
|
epLocal.SetError(txtZip, "Error");
|
|
|
|
|
throw new Exception();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (City.Length > 30)
|
|
|
|
|
{
|
|
|
|
|
epLocal.SetError(txtCity, "Error");
|
|
|
|
|
throw new Exception();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (UsState.Length > 2)
|
|
|
|
|
{
|
|
|
|
|
epLocal.SetError(txtState, "Error");
|
|
|
|
|
throw new Exception();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (lbs > 2147483647)
|
|
|
|
|
{
|
|
|
|
|
epLocal.SetError(txtWeight, "Error");
|
|
|
|
|
throw new Exception();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Height_feet > 2147483647)
|
|
|
|
|
{
|
|
|
|
|
epLocal.SetError(txtHeightFt, "Error");
|
|
|
|
|
throw new Exception();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Height_inches > 2147483647)
|
|
|
|
|
{
|
|
|
|
|
epLocal.SetError(txtHeightIn, "Error");
|
|
|
|
|
throw new Exception();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (PhoneNumber.Length > 14)
|
|
|
|
|
{
|
|
|
|
|
epLocal.SetError(txtPhone, "Error");
|
|
|
|
|
throw new Exception();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Gender.Length > 1)
|
|
|
|
|
{
|
|
|
|
|
epLocal.SetError(txtGender, "Error");
|
|
|
|
|
throw new Exception();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PharmacyDataTier.UpdatePatient(
|
|
|
|
|
Patient_id,
|
|
|
|
|
FirstName,
|
|
|
|
|
LastName,
|
|
|
|
|
MiddleIntials,
|
|
|
|
|
lbs,
|
|
|
|
|
Height_feet,
|
|
|
|
|
Height_inches,
|
|
|
|
|
DOB,
|
|
|
|
|
Gender,
|
|
|
|
|
City,
|
|
|
|
|
Zip,
|
|
|
|
|
UsState,
|
|
|
|
|
PhoneNumber);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception exception)
|
|
|
|
|
{
|
|
|
|
|
epLocal.SetError(btnGO, "Error Updating Patient Info");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
epLocal.SetError(txtPhone, "Invalid Value");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
epLocal.SetError(txtState, "Invalid Value");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
epLocal.SetError(txtZip, "Invalid Value");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
epLocal.SetError(txtGender, "Invalid Value");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
epLocal.SetError(txtDOB, "Invalid Value");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
epLocal.SetError(txtHeightIn, "Invalid Value");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
epLocal.SetError(txtHeightFt, "Invalid Value");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
epLocal.SetError(txtWeight, "Invalid Value");
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-02-15 08:55:05 -05:00
|
|
|
|
}
|
|
|
|
|
}
|