From ce58723152f6410f3f453f45bd25041bb4afea1b Mon Sep 17 00:00:00 2001 From: caschick221 Date: Tue, 20 Feb 2024 14:50:47 -0500 Subject: [PATCH] little fixes --- Louis'-Pharmacy_CNSA212-FP/frmPhysician.cs | 50 +++++++++++----------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/Louis'-Pharmacy_CNSA212-FP/frmPhysician.cs b/Louis'-Pharmacy_CNSA212-FP/frmPhysician.cs index 26b4616..e0a8fcb 100644 --- a/Louis'-Pharmacy_CNSA212-FP/frmPhysician.cs +++ b/Louis'-Pharmacy_CNSA212-FP/frmPhysician.cs @@ -1,6 +1,7 @@ using System; using System.Data; using System.Windows.Forms; +using DateTime = System.DateTime; namespace Louis__Pharmacy_CNSA212_FP { @@ -60,7 +61,7 @@ namespace Louis__Pharmacy_CNSA212_FP var City = ""; short Zip = 0; var UsState = ""; - var DOB = new DateTime(1753, 1, 1); + DateTime DOB = new DateTime(1753, 1, 1); var PhoneNumber = ""; var Gender = ""; var Speciality = ""; @@ -142,7 +143,7 @@ namespace Louis__Pharmacy_CNSA212_FP try { - if (txtZip.Text.Length <= 5) + if (txtZip.Text.Length <= 5 && txtZip.Text.Length > 0) Zip = short.Parse(txtZip.Text); else if (txtZip.Text.Length == 0) Zip = 0; @@ -181,31 +182,38 @@ namespace Louis__Pharmacy_CNSA212_FP hasFailed = true; } - try + + if (txtLastName.Text.Length <= 30 && txtLastName.Text.Length>=1) { - if (txtLastName.Text.Length <= 30) - LastName = txtLastName.Text; - else - throw new Exception(); + LastName = txtLastName.Text; + }else if (txtLastName.Text.Length < 1) + { + epLocal.SetError(txtLastName, "Must Provide a Last Name"); + hasFailed = true; } - catch (Exception exception) + else { epLocal.SetError(txtLastName, "Invalid Value"); hasFailed = true; } - try + + + if (txtFirstName.Text.Length <= 30 && txtFirstName.Text.Length>=1) { - if (txtFirstName.Text.Length <= 30) - FirstName = txtFirstName.Text; - else - throw new Exception(); + FirstName = txtFirstName.Text; + }else if (txtFirstName.Text.Length < 1) + { + epLocal.SetError(txtFirstName, "Must Provide a First Name"); + hasFailed = true; } - catch (Exception exception) + else { epLocal.SetError(txtFirstName, "Invalid Value"); hasFailed = true; } + + try { @@ -222,16 +230,6 @@ namespace Louis__Pharmacy_CNSA212_FP hasFailed = true; } - try - { - Zip = short.Parse(txtZip.Text); - } - catch (Exception exception) - { - epLocal.SetError(txtZip, "Invalid Value"); - hasFailed = true; - } - try { } @@ -281,6 +279,10 @@ namespace Louis__Pharmacy_CNSA212_FP } } + else + { + MessageBox.Show("You Must Enter Some Information!", "", MessageBoxButtons.OK); + } } private void frmPhysician_Load(object sender, EventArgs e)