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
|
|
|
|
|
{
|
2024-02-16 19:41:26 -05:00
|
|
|
|
public partial class frmPatient : Form
|
2024-02-15 08:55:05 -05:00
|
|
|
|
{
|
|
|
|
|
private static bool isAdd;
|
2024-02-16 13:57:58 -05:00
|
|
|
|
|
2024-02-19 14:19:36 -05:00
|
|
|
|
private readonly frmInfo SourceForm;
|
2024-02-16 16:08:18 -05:00
|
|
|
|
|
2024-02-16 20:13:30 -05:00
|
|
|
|
public frmPatient(frmInfo sourceForm, bool isNew)
|
2024-02-15 08:55:05 -05:00
|
|
|
|
{
|
2024-02-16 20:13:30 -05:00
|
|
|
|
SourceForm = sourceForm;
|
2024-02-19 14:19:36 -05:00
|
|
|
|
|
2024-02-15 08:55:05 -05:00
|
|
|
|
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-19 14:19:36 -05:00
|
|
|
|
|
|
|
|
|
KeyPreview = true;
|
|
|
|
|
KeyDown += frmPatient_KeyDown;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void frmPatient_KeyDown(object sender, KeyEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.KeyCode == Keys.Escape)
|
|
|
|
|
Close();
|
|
|
|
|
|
|
|
|
|
if (e.KeyCode == Keys.Enter) btnGO_Click(sender, e);
|
2024-02-20 11:28:32 -05:00
|
|
|
|
|
|
|
|
|
|
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-19 22:24:03 -05:00
|
|
|
|
|
|
|
|
|
PharmacyDataTier.FillComboBox("GENDER","*","GenderValue",cboGender);
|
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();
|
2024-02-19 22:24:03 -05:00
|
|
|
|
cboGender.Text = ds.Tables[0].Rows[0]["Gender"].ToString();
|
2024-02-15 12:04:26 -05:00
|
|
|
|
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
|
|
|
|
|
2024-02-20 11:28:32 -05:00
|
|
|
|
ErrorProvider epLocal = new ErrorProvider();
|
2024-02-16 13:57:58 -05:00
|
|
|
|
private void btnGO_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var Patient_id = txtPatientID.Text;
|
|
|
|
|
var FirstName = txtFname.Text;
|
|
|
|
|
var LastName = txtLname.Text;
|
|
|
|
|
var MiddleIntials = txtMidInit.Text;
|
|
|
|
|
var City = txtCity.Text;
|
|
|
|
|
|
2024-02-20 11:28:32 -05:00
|
|
|
|
int lbs = 0;
|
|
|
|
|
int Height_feet = 0;
|
|
|
|
|
int Height_inches = 0;
|
|
|
|
|
DateTime DOB = new DateTime(1753,1,1);
|
|
|
|
|
string Gender = "";
|
|
|
|
|
short Zip = 0;
|
|
|
|
|
string UsState = "";
|
|
|
|
|
string PhoneNumber= "";
|
2024-02-16 13:57:58 -05:00
|
|
|
|
|
|
|
|
|
var parseHasFailed = false;
|
|
|
|
|
|
2024-02-20 11:28:32 -05:00
|
|
|
|
int intLimit = 2147483647;
|
2024-02-16 13:57:58 -05:00
|
|
|
|
|
2024-02-20 11:28:32 -05:00
|
|
|
|
|
|
|
|
|
if (City.Length > 30)
|
|
|
|
|
{
|
|
|
|
|
epLocal.SetError(txtCity, "Invalid Value");
|
|
|
|
|
parseHasFailed = true;
|
|
|
|
|
}
|
|
|
|
|
if (MiddleIntials.Length > 1)
|
|
|
|
|
{
|
|
|
|
|
epLocal.SetError(txtMidInit, "Invalid Value");
|
|
|
|
|
parseHasFailed = true;
|
|
|
|
|
}
|
|
|
|
|
if (LastName.Length > 30)
|
|
|
|
|
{
|
|
|
|
|
epLocal.SetError(txtLname, "Invalid Value");
|
|
|
|
|
parseHasFailed = true;
|
|
|
|
|
}
|
|
|
|
|
if (FirstName.Length > 30)
|
|
|
|
|
{
|
|
|
|
|
epLocal.SetError(txtFname, "Invalid Value");
|
|
|
|
|
parseHasFailed = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Patient_id.Length > 8)
|
|
|
|
|
{
|
|
|
|
|
epLocal.SetError(txtPatientID, "Invalid Value");
|
|
|
|
|
parseHasFailed = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
while (Patient_id.Length < 8)
|
2024-02-16 13:57:58 -05:00
|
|
|
|
{
|
2024-02-20 11:28:32 -05:00
|
|
|
|
Patient_id = "0" + Patient_id;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (txtPhone.Text.Length>0)
|
|
|
|
|
{
|
|
|
|
|
PhoneNumber = txtPhone.Text;
|
|
|
|
|
if (PhoneNumber.Length > 14)
|
2024-02-16 13:57:58 -05:00
|
|
|
|
{
|
2024-02-20 11:28:32 -05:00
|
|
|
|
throw new Exception();
|
2024-02-16 16:08:18 -05:00
|
|
|
|
}
|
2024-02-20 11:28:32 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception exception)
|
|
|
|
|
{
|
|
|
|
|
epLocal.SetError(txtPhone, "Invalid value");
|
|
|
|
|
parseHasFailed = true;
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (txtState.Text.Length > 0)
|
|
|
|
|
{
|
|
|
|
|
UsState = txtState.Text.ToUpper();
|
|
|
|
|
|
|
|
|
|
if (UsState.Length > 2)
|
2024-02-16 16:08:18 -05:00
|
|
|
|
{
|
2024-02-20 11:28:32 -05:00
|
|
|
|
throw new Exception();
|
2024-02-16 16:08:18 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
2024-02-20 11:28:32 -05:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception exception)
|
|
|
|
|
{
|
|
|
|
|
epLocal.SetError(txtState, "Invalid value");
|
|
|
|
|
parseHasFailed = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (txtZip.Text.Length > 0)
|
2024-02-16 16:08:18 -05:00
|
|
|
|
{
|
2024-02-20 11:28:32 -05:00
|
|
|
|
Zip = short.Parse(txtZip.Text);
|
|
|
|
|
|
2024-02-16 16:08:18 -05:00
|
|
|
|
}
|
2024-02-20 11:28:32 -05:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception exception)
|
|
|
|
|
{
|
|
|
|
|
epLocal.SetError(txtZip, "Invalid value");
|
|
|
|
|
parseHasFailed = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
Gender = cboGender.Text;
|
|
|
|
|
|
|
|
|
|
if (Gender != "M" && Gender != "F")
|
2024-02-16 16:08:18 -05:00
|
|
|
|
{
|
2024-02-20 11:28:32 -05:00
|
|
|
|
throw new Exception();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception exception)
|
|
|
|
|
{
|
|
|
|
|
epLocal.SetError(cboGender, "Invalid value");
|
|
|
|
|
parseHasFailed = true;
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (txtDOB.Text.Length > 0)
|
|
|
|
|
{
|
|
|
|
|
DOB = DateTime.Parse(txtDOB.Text);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception exception)
|
|
|
|
|
{
|
|
|
|
|
epLocal.SetError(txtDOB, "Invalid value");
|
|
|
|
|
parseHasFailed = true;
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (txtHeightIn.Text.Length > 0)
|
|
|
|
|
{
|
|
|
|
|
Height_inches = int.Parse(txtHeightIn.Text);
|
|
|
|
|
if (Height_inches > 11 || Height_inches < 0)
|
2024-02-16 16:08:18 -05:00
|
|
|
|
{
|
2024-02-20 11:28:32 -05:00
|
|
|
|
throw new Exception();
|
2024-02-16 13:57:58 -05:00
|
|
|
|
}
|
2024-02-20 11:28:32 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception exception)
|
|
|
|
|
{
|
|
|
|
|
epLocal.SetError(txtHeightIn, "Invalid value");
|
|
|
|
|
parseHasFailed = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (txtHeightFt.Text.Length > 0)
|
|
|
|
|
{
|
|
|
|
|
Height_feet = int.Parse(txtHeightFt.Text);
|
|
|
|
|
if (Height_feet > 11 || Height_feet < 0)
|
2024-02-16 13:57:58 -05:00
|
|
|
|
{
|
2024-02-20 11:28:32 -05:00
|
|
|
|
throw new Exception();
|
2024-02-16 13:57:58 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
2024-02-20 11:28:32 -05:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception exception)
|
|
|
|
|
{
|
|
|
|
|
epLocal.SetError(txtHeightFt, "Invalid value");
|
|
|
|
|
parseHasFailed = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (txtWeight.Text.Length > 0)
|
2024-02-16 13:57:58 -05:00
|
|
|
|
{
|
2024-02-20 11:28:32 -05:00
|
|
|
|
lbs = int.Parse(txtWeight.Text);
|
|
|
|
|
if (lbs > intLimit || lbs < 0)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception();
|
|
|
|
|
}
|
2024-02-16 13:57:58 -05:00
|
|
|
|
}
|
2024-02-20 11:28:32 -05:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception exception)
|
|
|
|
|
{
|
|
|
|
|
epLocal.SetError(txtWeight, "Invalid value");
|
|
|
|
|
parseHasFailed = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isAdd && !parseHasFailed)
|
|
|
|
|
{
|
|
|
|
|
PharmacyDataTier.CreatePatient(Patient_id, FirstName, LastName, MiddleIntials, lbs, Height_feet, Height_inches, DOB, Gender, City, Zip, UsState, PhoneNumber);
|
|
|
|
|
|
|
|
|
|
SourceForm.txtPatientID.Text = Patient_id;
|
|
|
|
|
SourceForm.btnPatientSearch_Click(sender,e);
|
|
|
|
|
Close();
|
|
|
|
|
}
|
|
|
|
|
else if (!isAdd && !parseHasFailed)
|
|
|
|
|
{
|
|
|
|
|
PharmacyDataTier.UpdatePatient(Patient_id, FirstName, LastName, MiddleIntials, lbs, Height_feet, Height_inches, DOB, Gender, City, Zip, UsState, PhoneNumber);
|
|
|
|
|
|
|
|
|
|
SourceForm.txtPatientID.Text = Patient_id;
|
|
|
|
|
SourceForm.btnPatientSearch_Click(sender,e);
|
|
|
|
|
Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2024-02-16 16:08:18 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnClose_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Close();
|
2024-02-16 13:57:58 -05:00
|
|
|
|
}
|
2024-02-20 11:28:32 -05:00
|
|
|
|
|
|
|
|
|
private void txtPatientID_TextChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
epLocal.SetError(txtPatientID, "");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void txtFname_TextChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
epLocal.SetError(txtFname, "");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void txtLname_TextChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
epLocal.SetError(txtLname, "");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void txtMidInit_TextChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
epLocal.SetError(txtMidInit, "");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void txtWeight_TextChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
epLocal.SetError(txtWeight, "");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void txtHeightFt_TextChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
epLocal.SetError(txtHeightFt, "");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void txtHeightIn_TextChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
epLocal.SetError(txtHeightIn, "");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void txtDOB_TextChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
epLocal.SetError(txtDOB, "");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void txtCity_TextChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
epLocal.SetError(txtCity, "");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void cboGender_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
epLocal.SetError(cboGender, "");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void txtZip_TextChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
epLocal.SetError(txtZip, "");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void txtState_TextChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
epLocal.SetError(txtState, "");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void txtPhone_TextChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
epLocal.SetError(txtPhone, "");
|
|
|
|
|
}
|
2024-02-15 08:55:05 -05:00
|
|
|
|
}
|
|
|
|
|
}
|