This commit is contained in:
EggMan20339 2024-02-13 16:59:13 -05:00
parent 9212fe4650
commit d6dc5b52b0
2 changed files with 15 additions and 6 deletions

View File

@ -18,7 +18,7 @@ namespace Database3
static SqlConnection myConn = new SqlConnection(connString); static SqlConnection myConn = new SqlConnection(connString);
static System.Data.SqlClient.SqlCommand cmdString = new System.Data.SqlClient.SqlCommand(); static System.Data.SqlClient.SqlCommand cmdString = new System.Data.SqlClient.SqlCommand();
public DataSet GetStudents(string studid, string lname, string dob) public DataSet GetStudents(string studid, string lname, DateTime dob)
{ {
try try
{ {

View File

@ -33,24 +33,33 @@ namespace Database3
{ {
string studentid = "9999999999"; string studentid = "9999999999";
string lname = "9999999999"; string lname = "9999999999";
string dob = null; DateTime dob = new DateTime(1/1/1111);
ErrorProvider ep1 = new ErrorProvider();
try try
{ {
DataSet ds = new DataSet(); DataSet ds = new DataSet();
StudentDataTier stuDT = new StudentDataTier(); StudentDataTier stuDT = new StudentDataTier();
try
{
studentid = txtStuID.Text; studentid = txtStuID.Text;
lname = txtlname.Text; lname = txtlname.Text;
dob = txtDOB.Text; try
{
dob = DateTime.Parse(txtDOB.Text);
} }
catch (Exception exception) catch (Exception exception)
{ {
MessageBox.Show("Error Parsing Search Parameters","Error", MessageBoxButtons.OK); ep1.SetError(txtDOB, "Non valid value, but that's ok");
}
if (string.IsNullOrWhiteSpace(txtStuID.Text) &&
string.IsNullOrWhiteSpace(txtlname.Text) &&
string.IsNullOrWhiteSpace(txtDOB.Text))
{
throw new Exception("Must Enter at least one value");
} }
// Get the dataset using all three search parameters. // Get the dataset using all three search parameters.