This commit is contained in:
Adam McCane 2024-02-20 14:57:50 -05:00
commit a4c698d053

View File

@ -1,6 +1,7 @@
using System; using System;
using System.Data; using System.Data;
using System.Windows.Forms; using System.Windows.Forms;
using DateTime = System.DateTime;
namespace Louis__Pharmacy_CNSA212_FP namespace Louis__Pharmacy_CNSA212_FP
{ {
@ -60,7 +61,7 @@ namespace Louis__Pharmacy_CNSA212_FP
var City = ""; var City = "";
short Zip = 0; short Zip = 0;
var UsState = ""; var UsState = "";
var DOB = new DateTime(1753, 1, 1); DateTime DOB = new DateTime(1753, 1, 1);
var PhoneNumber = ""; var PhoneNumber = "";
var Gender = ""; var Gender = "";
var Speciality = ""; var Speciality = "";
@ -142,7 +143,7 @@ namespace Louis__Pharmacy_CNSA212_FP
try try
{ {
if (txtZip.Text.Length <= 5) if (txtZip.Text.Length <= 5 && txtZip.Text.Length > 0)
Zip = short.Parse(txtZip.Text); Zip = short.Parse(txtZip.Text);
else if (txtZip.Text.Length == 0) else if (txtZip.Text.Length == 0)
Zip = 0; Zip = 0;
@ -181,32 +182,39 @@ namespace Louis__Pharmacy_CNSA212_FP
hasFailed = true; hasFailed = true;
} }
try
if (txtLastName.Text.Length <= 30 && txtLastName.Text.Length>=1)
{ {
if (txtLastName.Text.Length <= 30)
LastName = txtLastName.Text; LastName = txtLastName.Text;
else }else if (txtLastName.Text.Length < 1)
throw new Exception(); {
epLocal.SetError(txtLastName, "Must Provide a Last Name");
hasFailed = true;
} }
catch (Exception exception) else
{ {
epLocal.SetError(txtLastName, "Invalid Value"); epLocal.SetError(txtLastName, "Invalid Value");
hasFailed = true; hasFailed = true;
} }
try
if (txtFirstName.Text.Length <= 30 && txtFirstName.Text.Length>=1)
{ {
if (txtFirstName.Text.Length <= 30)
FirstName = txtFirstName.Text; FirstName = txtFirstName.Text;
else }else if (txtFirstName.Text.Length < 1)
throw new Exception(); {
epLocal.SetError(txtFirstName, "Must Provide a First Name");
hasFailed = true;
} }
catch (Exception exception) else
{ {
epLocal.SetError(txtFirstName, "Invalid Value"); epLocal.SetError(txtFirstName, "Invalid Value");
hasFailed = true; hasFailed = true;
} }
try try
{ {
if (txtPhyID.Text.Length <= 8) if (txtPhyID.Text.Length <= 8)
@ -222,16 +230,6 @@ namespace Louis__Pharmacy_CNSA212_FP
hasFailed = true; hasFailed = true;
} }
try
{
Zip = short.Parse(txtZip.Text);
}
catch (Exception exception)
{
epLocal.SetError(txtZip, "Invalid Value");
hasFailed = true;
}
try 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) private void frmPhysician_Load(object sender, EventArgs e)