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"); + } + + } + + } } }