Added Physician search functionality
This commit is contained in:
		| @@ -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; | ||||
|   | ||||
							
								
								
									
										1
									
								
								Louis'-Pharmacy_CNSA212-FP/frmInfo.Designer.cs
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										1
									
								
								Louis'-Pharmacy_CNSA212-FP/frmInfo.Designer.cs
									
									
									
										generated
									
									
									
								
							| @@ -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 | ||||
|             //  | ||||
|   | ||||
| @@ -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"); | ||||
|                 } | ||||
|                  | ||||
|             } | ||||
|              | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user