From d6dc5b52b002d7acd22e2b5f1b093f3e59b2faf3 Mon Sep 17 00:00:00 2001 From: EggMan20339 <99349302+EggMan20339@users.noreply.github.com> Date: Tue, 13 Feb 2024 16:59:13 -0500 Subject: [PATCH] done db3 --- Database3/StudentDataTier.cs | 2 +- Database3/frmSearch.cs | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Database3/StudentDataTier.cs b/Database3/StudentDataTier.cs index 536a929..0441c17 100644 --- a/Database3/StudentDataTier.cs +++ b/Database3/StudentDataTier.cs @@ -18,7 +18,7 @@ namespace Database3 static SqlConnection myConn = new SqlConnection(connString); 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 { diff --git a/Database3/frmSearch.cs b/Database3/frmSearch.cs index ac604ed..f5287fc 100644 --- a/Database3/frmSearch.cs +++ b/Database3/frmSearch.cs @@ -33,24 +33,33 @@ namespace Database3 { string studentid = "9999999999"; string lname = "9999999999"; - string dob = null; + DateTime dob = new DateTime(1/1/1111); + + ErrorProvider ep1 = new ErrorProvider(); try { DataSet ds = new DataSet(); StudentDataTier stuDT = new StudentDataTier(); - try - { studentid = txtStuID.Text; lname = txtlname.Text; - dob = txtDOB.Text; + try + { + dob = DateTime.Parse(txtDOB.Text); } 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.