Changed how frmPatient grabs the values from the textboxes

This commit is contained in:
EggMan20339 2024-02-20 11:28:32 -05:00
parent a3a2fa780e
commit b363edb8e6
4 changed files with 328 additions and 360 deletions

View File

@ -628,7 +628,7 @@ namespace Louis__Pharmacy_CNSA212_FP
this.cmuMedicationDelete.Name = "cmuMedicationDelete";
this.cmuMedicationDelete.Size = new System.Drawing.Size(107, 22);
this.cmuMedicationDelete.Text = "Delete";
this.cmuMedicationDelete.Click += new System.EventHandler(this.cmuRxDelete_Click);
this.cmuMedicationDelete.Click += new System.EventHandler(this.cmuMedicationDelete_Click);
//
// tbpPhysician
//

View File

@ -96,6 +96,20 @@ namespace Louis__Pharmacy_CNSA212_FP
cmuPhysicianEdit_Click(sender, e);
}
if (patientIsActive && e.KeyCode == Keys.Delete)
{
cmuPatientDelete_Click(sender, e);
}
if (physicianIsActive && e.KeyCode == Keys.Delete)
{
cmuPhysicianDelete_Click(sender, e);
}
if (medicationIsActive && e.KeyCode == Keys.Delete)
{
cmuMedicationDelete_Click(sender, e);
}
// if data grid view is not focused, run the search function
@ -454,7 +468,13 @@ namespace Louis__Pharmacy_CNSA212_FP
row = dgvPatient.SelectedRows[0];
string patid = "";
patid = (row.Cells[3].Value).ToString();
PharmacyDataTier.DeletePatient(patid);
DialogResult dialogResult = MessageBox.Show("Are you sure you want to delete Patient: " + patid,
"Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (dialogResult == DialogResult.Yes)
{
PharmacyDataTier.DeletePatient(patid);
}
btnPatientSearch_Click(sender, e);
}
@ -503,18 +523,25 @@ namespace Louis__Pharmacy_CNSA212_FP
row = dgvPhysician.SelectedRows[0];
string phyID = "";
phyID = (row.Cells[0].Value).ToString();
PharmacyDataTier.DeletePhysician(phyID);
PhysicianReset(sender, e);
DialogResult dialogResult = MessageBox.Show("Are you sure you want to delete Physician: " + phyID,
"Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (dialogResult == DialogResult.Yes)
{
PharmacyDataTier.DeletePhysician(phyID);
}
btnPhysicianSearch_Click(sender, e);
}
}
private void PhysicianReset(object sender, EventArgs e)
{
txtPhysicianFirst.Text = "";
txtPhysicianLast.Text = "";
txtPhysicianID.Text = "";
dgvPhysician.Visible = false;
}
// private void PhysicianReset(object sender, EventArgs e)
// {
// txtPhysicianFirst.Text = "";
// txtPhysicianLast.Text = "";
// txtPhysicianID.Text = "";
// dgvPhysician.Visible = false;
// }
private void dgvPhysician_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
@ -552,9 +579,11 @@ namespace Louis__Pharmacy_CNSA212_FP
}
}
private void cmuRxDelete_Click(object sender, EventArgs e)
private void cmuMedicationDelete_Click(object sender, EventArgs e)
{
if (dgvPrescription.Rows.Count > 0)
{
@ -563,7 +592,13 @@ namespace Louis__Pharmacy_CNSA212_FP
row = dgvPrescription.SelectedRows[0];
string medID = "";
medID = (row.Cells[0].Value).ToString();
PharmacyDataTier.DeleteMedication(medID);
DialogResult dialogResult = MessageBox.Show("Are you sure you want to delete medication: " + medID,
"Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (dialogResult == DialogResult.Yes)
{
PharmacyDataTier.DeleteMedication(medID);
}
btnPrescriptionSearch_Click(sender, e);
}

View File

@ -186,6 +186,7 @@ namespace Louis__Pharmacy_CNSA212_FP
this.txtPatientID.Name = "txtPatientID";
this.txtPatientID.Size = new System.Drawing.Size(100, 20);
this.txtPatientID.TabIndex = 1;
this.txtPatientID.TextChanged += new System.EventHandler(this.txtPatientID_TextChanged);
//
// txtFname
//
@ -193,6 +194,7 @@ namespace Louis__Pharmacy_CNSA212_FP
this.txtFname.Name = "txtFname";
this.txtFname.Size = new System.Drawing.Size(100, 20);
this.txtFname.TabIndex = 2;
this.txtFname.TextChanged += new System.EventHandler(this.txtFname_TextChanged);
//
// txtLname
//
@ -200,6 +202,7 @@ namespace Louis__Pharmacy_CNSA212_FP
this.txtLname.Name = "txtLname";
this.txtLname.Size = new System.Drawing.Size(100, 20);
this.txtLname.TabIndex = 3;
this.txtLname.TextChanged += new System.EventHandler(this.txtLname_TextChanged);
//
// txtMidInit
//
@ -207,6 +210,7 @@ namespace Louis__Pharmacy_CNSA212_FP
this.txtMidInit.Name = "txtMidInit";
this.txtMidInit.Size = new System.Drawing.Size(100, 20);
this.txtMidInit.TabIndex = 4;
this.txtMidInit.TextChanged += new System.EventHandler(this.txtMidInit_TextChanged);
//
// txtWeight
//
@ -214,6 +218,7 @@ namespace Louis__Pharmacy_CNSA212_FP
this.txtWeight.Name = "txtWeight";
this.txtWeight.Size = new System.Drawing.Size(100, 20);
this.txtWeight.TabIndex = 5;
this.txtWeight.TextChanged += new System.EventHandler(this.txtWeight_TextChanged);
//
// txtHeightFt
//
@ -221,6 +226,7 @@ namespace Louis__Pharmacy_CNSA212_FP
this.txtHeightFt.Name = "txtHeightFt";
this.txtHeightFt.Size = new System.Drawing.Size(100, 20);
this.txtHeightFt.TabIndex = 6;
this.txtHeightFt.TextChanged += new System.EventHandler(this.txtHeightFt_TextChanged);
//
// txtHeightIn
//
@ -228,6 +234,7 @@ namespace Louis__Pharmacy_CNSA212_FP
this.txtHeightIn.Name = "txtHeightIn";
this.txtHeightIn.Size = new System.Drawing.Size(100, 20);
this.txtHeightIn.TabIndex = 7;
this.txtHeightIn.TextChanged += new System.EventHandler(this.txtHeightIn_TextChanged);
//
// txtDOB
//
@ -235,6 +242,7 @@ namespace Louis__Pharmacy_CNSA212_FP
this.txtDOB.Name = "txtDOB";
this.txtDOB.Size = new System.Drawing.Size(100, 20);
this.txtDOB.TabIndex = 8;
this.txtDOB.TextChanged += new System.EventHandler(this.txtDOB_TextChanged);
//
// txtCity
//
@ -242,6 +250,7 @@ namespace Louis__Pharmacy_CNSA212_FP
this.txtCity.Name = "txtCity";
this.txtCity.Size = new System.Drawing.Size(100, 20);
this.txtCity.TabIndex = 10;
this.txtCity.TextChanged += new System.EventHandler(this.txtCity_TextChanged);
//
// txtZip
//
@ -249,6 +258,7 @@ namespace Louis__Pharmacy_CNSA212_FP
this.txtZip.Name = "txtZip";
this.txtZip.Size = new System.Drawing.Size(100, 20);
this.txtZip.TabIndex = 11;
this.txtZip.TextChanged += new System.EventHandler(this.txtZip_TextChanged);
//
// txtState
//
@ -256,6 +266,7 @@ namespace Louis__Pharmacy_CNSA212_FP
this.txtState.Name = "txtState";
this.txtState.Size = new System.Drawing.Size(100, 20);
this.txtState.TabIndex = 12;
this.txtState.TextChanged += new System.EventHandler(this.txtState_TextChanged);
//
// txtPhone
//
@ -263,6 +274,7 @@ namespace Louis__Pharmacy_CNSA212_FP
this.txtPhone.Name = "txtPhone";
this.txtPhone.Size = new System.Drawing.Size(100, 20);
this.txtPhone.TabIndex = 13;
this.txtPhone.TextChanged += new System.EventHandler(this.txtPhone_TextChanged);
//
// lblDisPurpose
//
@ -304,6 +316,7 @@ namespace Louis__Pharmacy_CNSA212_FP
this.cboGender.Name = "cboGender";
this.cboGender.Size = new System.Drawing.Size(100, 21);
this.cboGender.TabIndex = 27;
this.cboGender.SelectedIndexChanged += new System.EventHandler(this.cboGender_SelectedIndexChanged);
//
// frmPatient
//

View File

@ -41,6 +41,8 @@ namespace Louis__Pharmacy_CNSA212_FP
Close();
if (e.KeyCode == Keys.Enter) btnGO_Click(sender, e);
}
@ -82,9 +84,9 @@ namespace Louis__Pharmacy_CNSA212_FP
txtPhone.Text = ds.Tables[0].Rows[0]["PhoneNumber"].ToString();
}
ErrorProvider epLocal = new ErrorProvider();
private void btnGO_Click(object sender, EventArgs e)
{
var epLocal = new ErrorProvider();
var Patient_id = txtPatientID.Text;
var FirstName = txtFname.Text;
@ -92,369 +94,287 @@ namespace Louis__Pharmacy_CNSA212_FP
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;
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= "";
var parseHasFailed = false;
int intLimit = 2147483647;
if (!isAdd)
try
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)
{
Patient_id = "0" + Patient_id;
}
}
try
{
if (txtPhone.Text.Length>0)
{
PhoneNumber = txtPhone.Text;
if (PhoneNumber.Length > 14)
{
throw new Exception();
}
}
}
catch (Exception exception)
{
epLocal.SetError(txtPhone, "Invalid value");
parseHasFailed = true;
}
try
{
if (txtState.Text.Length > 0)
{
UsState = txtState.Text.ToUpper();
if (UsState.Length > 2)
{
throw new Exception();
}
}
}
catch (Exception exception)
{
epLocal.SetError(txtState, "Invalid value");
parseHasFailed = true;
}
try
{
if (txtZip.Text.Length > 0)
{
Zip = short.Parse(txtZip.Text);
}
}
catch (Exception exception)
{
epLocal.SetError(txtZip, "Invalid value");
parseHasFailed = true;
}
try
{
Gender = cboGender.Text;
if (Gender != "M" && Gender != "F")
{
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)
{
throw new Exception();
}
}
}
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)
{
throw new Exception();
}
}
}
catch (Exception exception)
{
epLocal.SetError(txtHeightFt, "Invalid value");
parseHasFailed = true;
}
try
{
if (txtWeight.Text.Length > 0)
{
lbs = int.Parse(txtWeight.Text);
try
if (lbs > intLimit || lbs < 0)
{
Height_feet = int.Parse(txtHeightFt.Text);
try
{
Height_inches = int.Parse(txtHeightIn.Text);
try
{
DOB = DateTime.Parse(txtDOB.Text);
try
{
Gender = cboGender.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();
}
while (Patient_id.Length < 8) Patient_id = "0" + Patient_id;
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();
}
MiddleIntials = MiddleIntials.ToUpper();
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();
}
UsState = UsState.ToUpper();
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(cboGender, "Error");
throw new Exception();
}
Gender = Gender.ToUpper();
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(SourceForm, e);
Close();
}
catch (Exception exception)
{
epLocal.SetError(btnGO, "Error Creating Patient");
}
}
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(cboGender, "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");
throw new Exception();
}
}
catch (Exception ex)
{
epLocal.SetError(txtWeight, "Invalid Value");
}
else if (isAdd)
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 = cboGender.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();
}
while (Patient_id.Length < 8) Patient_id = "0" + Patient_id;
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();
}
MiddleIntials = MiddleIntials.ToUpper();
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();
}
UsState = UsState.ToUpper();
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(cboGender, "Error");
throw new Exception();
}
Gender = Gender.ToUpper();
PharmacyDataTier.CreatePatient(
Patient_id,
FirstName,
LastName,
MiddleIntials,
lbs,
Height_feet,
Height_inches,
DOB,
Gender,
City,
Zip,
UsState,
PhoneNumber);
}
catch (Exception exception)
{
epLocal.SetError(txtWeight, "Invalid value");
parseHasFailed = true;
}
SourceForm.txtPatientID.Text = Patient_id;
SourceForm.btnPatientSearch_Click(SourceForm, e);
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();
}
Close();
}
catch (Exception exception)
{
epLocal.SetError(btnGO, "Error Creating Patient");
}
}
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(cboGender, "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");
}
}
private void btnClose_Click(object sender, EventArgs e)
{
Close();
}
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, "");
}
}
}