From e6fcc33b17b60e38435bcd0ebf8d52b828f30678 Mon Sep 17 00:00:00 2001 From: EggMan20339 <99349302+EggMan20339@users.noreply.github.com> Date: Wed, 14 Feb 2024 19:43:07 -0500 Subject: [PATCH] Added Physician search functionality --- .../PharmacyDataTier.cs | 9 +- .../frmInfo.Designer.cs | 1 + Louis'-Pharmacy_CNSA212-FP/frmInfo.cs | 86 +++++++++++++++++++ 3 files changed, 93 insertions(+), 3 deletions(-) diff --git a/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs b/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs index b3b51e3..c2d1a9d 100644 --- a/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs +++ b/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs @@ -3,6 +3,7 @@ using System.Configuration; using System.Data; using System.Windows.Forms; using System.Data.SqlClient; +using System.Runtime.Versioning; namespace Louis__Pharmacy_CNSA212_FP { @@ -90,7 +91,7 @@ namespace Louis__Pharmacy_CNSA212_FP } - public DataSet GetStudents(string StuID) + public static DataSet PhysicianInfoSearch(string fname,string lname, string phyID) { @@ -104,9 +105,11 @@ namespace Louis__Pharmacy_CNSA212_FP cmdString.Connection = myConn; cmdString.CommandType = CommandType.StoredProcedure; cmdString.CommandTimeout = 1500; - cmdString.CommandText = "GetByStudentIDS"; + cmdString.CommandText = "PhysicianInfoSearch"; // Define input parameter - cmdString.Parameters.Add("@studentid", SqlDbType.VarChar, 6).Value = StuID; + cmdString.Parameters.Add("@fname", SqlDbType.VarChar, 11).Value = fname; + cmdString.Parameters.Add("@lname", SqlDbType.VarChar, 8).Value = lname; + cmdString.Parameters.Add("@phyID", SqlDbType.VarChar, 8).Value = phyID; // adapter and dataset SqlDataAdapter aAdapter = new SqlDataAdapter(); aAdapter.SelectCommand = cmdString; diff --git a/Louis'-Pharmacy_CNSA212-FP/frmInfo.Designer.cs b/Louis'-Pharmacy_CNSA212-FP/frmInfo.Designer.cs index bf9189c..247b07a 100644 --- a/Louis'-Pharmacy_CNSA212-FP/frmInfo.Designer.cs +++ b/Louis'-Pharmacy_CNSA212-FP/frmInfo.Designer.cs @@ -566,6 +566,7 @@ namespace Louis__Pharmacy_CNSA212_FP this.btnPhysicianSearch.TabIndex = 4; this.btnPhysicianSearch.Text = "Search"; this.btnPhysicianSearch.UseVisualStyleBackColor = true; + this.btnPhysicianSearch.Click += new System.EventHandler(this.btnPhysicianSearch_Click); // // dgvPhysician // diff --git a/Louis'-Pharmacy_CNSA212-FP/frmInfo.cs b/Louis'-Pharmacy_CNSA212-FP/frmInfo.cs index d730c01..2d91add 100644 --- a/Louis'-Pharmacy_CNSA212-FP/frmInfo.cs +++ b/Louis'-Pharmacy_CNSA212-FP/frmInfo.cs @@ -210,5 +210,91 @@ namespace Louis__Pharmacy_CNSA212_FP } } } + + private void btnPhysicianSearch_Click(object sender, EventArgs e) + { + string fname = ""; + string lname = ""; + string phyID = "";; + + DataSet ds = new DataSet(); + + if (txtPhysicianFirst.Text.Length+txtPhysicianLast.Text.Length+txtPhysicianID.Text.Length > 0) + { + + try + { + + fname = txtPhysicianFirst.Text; + + try + { + + lname = txtPhysicianLast.Text; + + try + { + + phyID = txtPhysicianID.Text; + + try + { + + + ds = PharmacyDataTier.PhysicianInfoSearch(fname, lname, phyID); + + + if (ds.Tables[0].Rows.Count > 0) // There is a record. + { + dgvPhysician.Visible = true; + // Get data source. + dgvPhysician.DataSource = ds.Tables[0]; + dgvPhysician.AlternatingRowsDefaultCellStyle.BackColor = Color.LightGreen; + + // Set the row and column header styles. + dgvPhysician.ColumnHeadersDefaultCellStyle.ForeColor = Color.White; + dgvPhysician.ColumnHeadersDefaultCellStyle.BackColor = Color.Green; + } + else + { + dgvPatient.Visible = false; // Hide the DataGridView if no results are found. + MessageBox.Show("No records found."); + } + + + } + catch (Exception exception) + { + + ep1.SetError(btnPhysicianSearch, "Error Searching"); + + } + + + } + catch (Exception exception) + { + + ep1.SetError(txtPhysicianID, "Invalid Value"); + + } + + } + catch (Exception exception) + { + + ep1.SetError(txtPhysicianLast, "Invalid Value"); + + } + + } + catch (Exception exception) + { + ep1.SetError(txtPhysicianFirst, "Invalid Value"); + } + + } + + } } }