From 1c1f1659e3522339c9e65ea154a7b988204ac949 Mon Sep 17 00:00:00 2001 From: EggMan20339 <99349302+EggMan20339@users.noreply.github.com> Date: Wed, 14 Feb 2024 17:35:35 -0500 Subject: [PATCH 1/5] added datatier and updated connection string --- Louis'-Pharmacy_CNSA212-FP/App.config | 2 +- .../Louis'-Pharmacy_CNSA212-FP.csproj | 1 + Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs | 7 +++++++ 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs diff --git a/Louis'-Pharmacy_CNSA212-FP/App.config b/Louis'-Pharmacy_CNSA212-FP/App.config index baa7298..57109bf 100644 --- a/Louis'-Pharmacy_CNSA212-FP/App.config +++ b/Louis'-Pharmacy_CNSA212-FP/App.config @@ -3,7 +3,7 @@ - diff --git a/Louis'-Pharmacy_CNSA212-FP/Louis'-Pharmacy_CNSA212-FP.csproj b/Louis'-Pharmacy_CNSA212-FP/Louis'-Pharmacy_CNSA212-FP.csproj index b4c7b19..a30432b 100644 --- a/Louis'-Pharmacy_CNSA212-FP/Louis'-Pharmacy_CNSA212-FP.csproj +++ b/Louis'-Pharmacy_CNSA212-FP/Louis'-Pharmacy_CNSA212-FP.csproj @@ -88,6 +88,7 @@ frmWelcome.cs + diff --git a/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs b/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs new file mode 100644 index 0000000..a4d9796 --- /dev/null +++ b/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs @@ -0,0 +1,7 @@ +namespace Louis__Pharmacy_CNSA212_FP +{ + public class PharmacyDataTier + { + + } +} \ No newline at end of file From d257715541d962d182aeeeb1c0dbbec631570a36 Mon Sep 17 00:00:00 2001 From: EggMan20339 <99349302+EggMan20339@users.noreply.github.com> Date: Wed, 14 Feb 2024 17:40:16 -0500 Subject: [PATCH 2/5] updated datatier --- .../Louis'-Pharmacy_CNSA212-FP.csproj | 1 + .../PharmacyDataTier.cs | 89 ++++++++++++++++++- 2 files changed, 89 insertions(+), 1 deletion(-) diff --git a/Louis'-Pharmacy_CNSA212-FP/Louis'-Pharmacy_CNSA212-FP.csproj b/Louis'-Pharmacy_CNSA212-FP/Louis'-Pharmacy_CNSA212-FP.csproj index a30432b..914ecde 100644 --- a/Louis'-Pharmacy_CNSA212-FP/Louis'-Pharmacy_CNSA212-FP.csproj +++ b/Louis'-Pharmacy_CNSA212-FP/Louis'-Pharmacy_CNSA212-FP.csproj @@ -34,6 +34,7 @@ + diff --git a/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs b/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs index a4d9796..0d91156 100644 --- a/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs +++ b/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs @@ -1,7 +1,94 @@ -namespace Louis__Pharmacy_CNSA212_FP +using System; +using System.Configuration; +using System.Data; +using System.Windows.Forms; +using System.Data.SqlClient; + +namespace Louis__Pharmacy_CNSA212_FP { public class PharmacyDataTier { + + static String connString = ConfigurationManager.ConnectionStrings["ConnString"].ConnectionString; + static SqlConnection myConn = new SqlConnection(connString); + static System.Data.SqlClient.SqlCommand cmdString = new System.Data.SqlClient.SqlCommand(); + public DataSet GetStudents(string studid, string lname, DateTime dob) + { + try + { + // open connection + myConn.Open(); + //clear any parameters + cmdString.Parameters.Clear(); + // command + cmdString.Connection = myConn; + cmdString.CommandType = CommandType.StoredProcedure; + cmdString.CommandTimeout = 1500; + cmdString.CommandText = "SearchStudent"; + // Define input parameter + cmdString.Parameters.Add("@studentid", SqlDbType.VarChar, 6).Value = studid; + cmdString.Parameters.Add("@lname", SqlDbType.VarChar, 25).Value = lname; + cmdString.Parameters.Add("@dob", SqlDbType.Date).Value = dob; + // adapter and dataset + SqlDataAdapter aAdapter = new SqlDataAdapter(); + aAdapter.SelectCommand = cmdString; + DataSet aDataSet = new DataSet(); + + // fill adapter + aAdapter.Fill(aDataSet); + + // return dataSet + return aDataSet; + } + catch (Exception ex) + { + throw new ArgumentException(ex.Message); + } + finally + { + myConn.Close(); + } + } + + + public DataSet GetStudents(string StuID) + { + + + try + { + // open connection + myConn.Open(); + //clear any parameters + cmdString.Parameters.Clear(); + // command + cmdString.Connection = myConn; + cmdString.CommandType = CommandType.StoredProcedure; + cmdString.CommandTimeout = 1500; + cmdString.CommandText = "GetByStudentIDS"; + // Define input parameter + cmdString.Parameters.Add("@studentid", SqlDbType.VarChar, 6).Value = StuID; + // adapter and dataset + SqlDataAdapter aAdapter = new SqlDataAdapter(); + aAdapter.SelectCommand = cmdString; + DataSet aDataSet = new DataSet(); + + // fill adapter + aAdapter.Fill(aDataSet); + + // return dataSet + return aDataSet; + } + catch (Exception ex) + { + throw new ArgumentException(ex.Message); + } + finally + { + myConn.Close(); + } + } + } } \ No newline at end of file From f6c2540b769c5c53ee80a7db99da6d20f8ecc80c Mon Sep 17 00:00:00 2001 From: EggMan20339 <99349302+EggMan20339@users.noreply.github.com> Date: Wed, 14 Feb 2024 18:21:17 -0500 Subject: [PATCH 3/5] Made Patient Search funtional --- .../PharmacyDataTier.cs | 10 +-- .../frmInfo.Designer.cs | 41 +-------- Louis'-Pharmacy_CNSA212-FP/frmInfo.cs | 90 +++++++++++++++++++ 3 files changed, 99 insertions(+), 42 deletions(-) diff --git a/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs b/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs index 0d91156..365bb56 100644 --- a/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs +++ b/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs @@ -13,7 +13,7 @@ namespace Louis__Pharmacy_CNSA212_FP static SqlConnection myConn = new SqlConnection(connString); static System.Data.SqlClient.SqlCommand cmdString = new System.Data.SqlClient.SqlCommand(); - public DataSet GetStudents(string studid, string lname, DateTime dob) + public static DataSet PatientInfoSearch(string id, string lname, string fname) { try { @@ -25,11 +25,11 @@ namespace Louis__Pharmacy_CNSA212_FP cmdString.Connection = myConn; cmdString.CommandType = CommandType.StoredProcedure; cmdString.CommandTimeout = 1500; - cmdString.CommandText = "SearchStudent"; + cmdString.CommandText = "PatientInfoSearch"; // Define input parameter - cmdString.Parameters.Add("@studentid", SqlDbType.VarChar, 6).Value = studid; - cmdString.Parameters.Add("@lname", SqlDbType.VarChar, 25).Value = lname; - cmdString.Parameters.Add("@dob", SqlDbType.Date).Value = dob; + cmdString.Parameters.Add("@patientID", SqlDbType.VarChar, 6).Value = id; + cmdString.Parameters.Add("@lname", SqlDbType.VarChar, 30).Value = lname; + cmdString.Parameters.Add("@fname", SqlDbType.VarChar, 30).Value = fname; // 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 397e575..91fd4ae 100644 --- a/Louis'-Pharmacy_CNSA212-FP/frmInfo.Designer.cs +++ b/Louis'-Pharmacy_CNSA212-FP/frmInfo.Designer.cs @@ -240,28 +240,14 @@ namespace Louis__Pharmacy_CNSA212_FP this.btnPatientSearch.TabIndex = 4; this.btnPatientSearch.Text = "Search"; this.btnPatientSearch.UseVisualStyleBackColor = false; + this.btnPatientSearch.Click += new System.EventHandler(this.btnPatientSearch_Click); // // dgvPatient // this.dgvPatient.AllowUserToAddRows = false; this.dgvPatient.AllowUserToDeleteRows = false; this.dgvPatient.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.dgvPatient.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { - this.pat_id, - this.FirstName, - this.LastName, - this.MiddleInitials, - this.City, - this.UsState, - this.Zip, - this.Ibs, - this.Height_feet, - this.Height_inches, - this.Ailment, - this.DOB, - this.PhoneNumber, - this.Gender, - this.Medications}); + this.dgvPatient.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.pat_id, this.FirstName, this.LastName, this.MiddleInitials, this.City, this.UsState, this.Zip, this.Ibs, this.Height_feet, this.Height_inches, this.Ailment, this.DOB, this.PhoneNumber, this.Gender, this.Medications }); this.dgvPatient.Location = new System.Drawing.Point(3, 3); this.dgvPatient.Name = "dgvPatient"; this.dgvPatient.ReadOnly = true; @@ -455,14 +441,7 @@ namespace Louis__Pharmacy_CNSA212_FP this.dgvPrescription.AllowUserToAddRows = false; this.dgvPrescription.AllowUserToDeleteRows = false; this.dgvPrescription.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.dgvPrescription.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { - this.RxNum_id, - this.numRefills, - this.pastNumRefills, - this.PrescribedBy, - this.Physician_id, - this.Medication_id, - this.Patient_id}); + this.dgvPrescription.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.RxNum_id, this.numRefills, this.pastNumRefills, this.PrescribedBy, this.Physician_id, this.Medication_id, this.Patient_id }); this.dgvPrescription.Location = new System.Drawing.Point(3, 3); this.dgvPrescription.Name = "dgvPrescription"; this.dgvPrescription.Size = new System.Drawing.Size(652, 195); @@ -592,18 +571,7 @@ namespace Louis__Pharmacy_CNSA212_FP this.dgvPhysician.AllowUserToAddRows = false; this.dgvPhysician.AllowUserToDeleteRows = false; this.dgvPhysician.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.dgvPhysician.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { - this.Phys_id, - this.namefirst, - this.namelast, - this.initialsmiddle, - this.cit, - this.state, - this.zipp, - this.dobb, - this.numberphone, - this.gennder, - this.Specialty}); + this.dgvPhysician.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.Phys_id, this.namefirst, this.namelast, this.initialsmiddle, this.cit, this.state, this.zipp, this.dobb, this.numberphone, this.gennder, this.Specialty }); this.dgvPhysician.Location = new System.Drawing.Point(3, 3); this.dgvPhysician.Name = "dgvPhysician"; this.dgvPhysician.ReadOnly = true; @@ -724,7 +692,6 @@ namespace Louis__Pharmacy_CNSA212_FP this.splcPhysician.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.dgvPhysician)).EndInit(); this.ResumeLayout(false); - } #endregion diff --git a/Louis'-Pharmacy_CNSA212-FP/frmInfo.cs b/Louis'-Pharmacy_CNSA212-FP/frmInfo.cs index a306288..6b2a686 100644 --- a/Louis'-Pharmacy_CNSA212-FP/frmInfo.cs +++ b/Louis'-Pharmacy_CNSA212-FP/frmInfo.cs @@ -8,10 +8,13 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; + namespace Louis__Pharmacy_CNSA212_FP { public partial class frmInfo : Form { + private ErrorProvider ep1 = new ErrorProvider(); + public frmInfo() { InitializeComponent(); @@ -30,6 +33,93 @@ namespace Louis__Pharmacy_CNSA212_FP private void pATIENTBindingNavigatorSaveItem_Click(object sender, EventArgs e) { + } + + private void btnPatientSearch_Click(object sender, EventArgs e) + { + string fname = ""; + string lname = ""; + string id = ""; + + DataSet ds = new DataSet(); + + if (txtPatientFirst.Text.Length + txtPatientLast.Text.Length + txtPatientID.Text.Length > 0) + { + + try + { + + fname = txtPatientFirst.Text; + + try + { + + lname = txtPatientLast.Text; + + try + { + + id = txtPatientID.Text; + + try + { + + + ds = PharmacyDataTier.PatientInfoSearch(id,lname,fname); + + + if (ds.Tables[0].Rows.Count > 0) // There is a record. + { + dgvPatient.Visible = true; + // Get data source. + dgvPatient.DataSource = ds.Tables[0]; + dgvPatient.AlternatingRowsDefaultCellStyle.BackColor = Color.LightGreen; + + // Set the row and column header styles. + dgvPatient.ColumnHeadersDefaultCellStyle.ForeColor = Color.White; + dgvPatient.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(btnPatientSearch, "Error Searching"); + + } + + + } + catch (Exception exception) + { + + ep1.SetError(txtPatientID, "Invalid Value"); + + } + + } + catch (Exception exception) + { + + ep1.SetError(txtPatientLast, "Invalid Value"); + + } + + } + catch (Exception exception) + { + ep1.SetError(txtPatientFirst, "Invalid Value"); + } + + } + + } } } From 6d2692fbcd279ada77e5737a1614d112d7846af1 Mon Sep 17 00:00:00 2001 From: EggMan20339 <99349302+EggMan20339@users.noreply.github.com> Date: Wed, 14 Feb 2024 19:27:21 -0500 Subject: [PATCH 4/5] added funtionality to rx search --- .../PharmacyDataTier.cs | 38 ++++++++ .../frmInfo.Designer.cs | 1 + Louis'-Pharmacy_CNSA212-FP/frmInfo.cs | 89 +++++++++++++++++++ 3 files changed, 128 insertions(+) diff --git a/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs b/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs index 365bb56..b3b51e3 100644 --- a/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs +++ b/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs @@ -51,6 +51,44 @@ namespace Louis__Pharmacy_CNSA212_FP } } + + public static DataSet PrescriptionInfoSearch(string rxID, string patientID) + { + try + { + // open connection + myConn.Open(); + //clear any parameters + cmdString.Parameters.Clear(); + // command + cmdString.Connection = myConn; + cmdString.CommandType = CommandType.StoredProcedure; + cmdString.CommandTimeout = 1500; + cmdString.CommandText = "PerscriptionInfoSearch"; + // Define input parameter + cmdString.Parameters.Add("@rxID", SqlDbType.VarChar, 11).Value = rxID; + cmdString.Parameters.Add("@patientID", SqlDbType.VarChar, 8).Value = patientID; + // adapter and dataset + SqlDataAdapter aAdapter = new SqlDataAdapter(); + aAdapter.SelectCommand = cmdString; + DataSet aDataSet = new DataSet(); + + // fill adapter + aAdapter.Fill(aDataSet); + + // return dataSet + return aDataSet; + } + catch (Exception ex) + { + throw new ArgumentException(ex.Message); + } + finally + { + myConn.Close(); + } + } + public DataSet GetStudents(string StuID) { diff --git a/Louis'-Pharmacy_CNSA212-FP/frmInfo.Designer.cs b/Louis'-Pharmacy_CNSA212-FP/frmInfo.Designer.cs index 91fd4ae..bf9189c 100644 --- a/Louis'-Pharmacy_CNSA212-FP/frmInfo.Designer.cs +++ b/Louis'-Pharmacy_CNSA212-FP/frmInfo.Designer.cs @@ -402,6 +402,7 @@ namespace Louis__Pharmacy_CNSA212_FP this.btnPrescriptionSearch.TabIndex = 4; this.btnPrescriptionSearch.Text = "Search"; this.btnPrescriptionSearch.UseVisualStyleBackColor = true; + this.btnPrescriptionSearch.Click += new System.EventHandler(this.btnPrescriptionSearch_Click); // // txtPrescriptionPatID // diff --git a/Louis'-Pharmacy_CNSA212-FP/frmInfo.cs b/Louis'-Pharmacy_CNSA212-FP/frmInfo.cs index 6b2a686..d730c01 100644 --- a/Louis'-Pharmacy_CNSA212-FP/frmInfo.cs +++ b/Louis'-Pharmacy_CNSA212-FP/frmInfo.cs @@ -23,8 +23,24 @@ namespace Louis__Pharmacy_CNSA212_FP private void frmInfo_Load(object sender, EventArgs e) { + KeyPreview = true; + KeyDown += frmInfo_KeyDown; + } + private void frmInfo_KeyDown(object sender, KeyEventArgs e) + { + // esc not funtional + if (e.KeyCode == Keys.Escape) // Check if the pressed key is Escape + {this.Close(); // Close the form + } + + if (e.KeyCode == Keys.Enter){ + btnPatientSearch_Click(sender, e); + } + + } + private void addUpdatePatientAndPhysicianToolStripMenuItem_Click(object sender, EventArgs e) { @@ -121,5 +137,78 @@ namespace Louis__Pharmacy_CNSA212_FP } + + private void btnPrescriptionSearch_Click(object sender, EventArgs e) + { + string rxID = ""; + string patientID = ""; + + DataSet ds = new DataSet(); + + if (txtPrescriptionPatID.Text.Length+txtRxNumber.Text.Length > 0) + { + + + try + { + + patientID = txtPrescriptionPatID.Text; + + try + { + + rxID = txtRxNumber.Text; + + try + { + + + ds = PharmacyDataTier.PrescriptionInfoSearch(rxID, patientID); + + + if (ds.Tables[0].Rows.Count > 0) // There is a record. + { + dgvPrescription.Visible = true; + // Get data source. + dgvPrescription.DataSource = ds.Tables[0]; + dgvPrescription.AlternatingRowsDefaultCellStyle.BackColor = Color.LightGreen; + + // Set the row and column header styles. + dgvPrescription.ColumnHeadersDefaultCellStyle.ForeColor = Color.White; + dgvPrescription.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(btnPrescriptionSearch, "Error Searching"); + + } + + + } + catch (Exception exception) + { + + ep1.SetError(txtRxNumber, "Invalid Value"); + + } + + } + catch (Exception exception) + { + + ep1.SetError(txtPrescriptionPatID, "Invalid Value"); + + } + } + } } } 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 5/5] 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"); + } + + } + + } } }