From 9bb5379c2921bd059a8ee8dcd53ac25803730f75 Mon Sep 17 00:00:00 2001 From: EggMan20339 <99349302+EggMan20339@users.noreply.github.com> Date: Tue, 20 Feb 2024 20:56:43 -0500 Subject: [PATCH] fixed some confusing rx vs medication names and made medication form work again --- .../frmInfo.Designer.cs | 65 +++++------ Louis'-Pharmacy_CNSA212-FP/frmInfo.cs | 104 +++++++++++++++--- Louis'-Pharmacy_CNSA212-FP/frmMedication.cs | 4 +- Louis'-Pharmacy_CNSA212-FP/frmPrescription.cs | 2 +- 4 files changed, 127 insertions(+), 48 deletions(-) diff --git a/Louis'-Pharmacy_CNSA212-FP/frmInfo.Designer.cs b/Louis'-Pharmacy_CNSA212-FP/frmInfo.Designer.cs index 0ffb127..6c11cf9 100644 --- a/Louis'-Pharmacy_CNSA212-FP/frmInfo.Designer.cs +++ b/Louis'-Pharmacy_CNSA212-FP/frmInfo.Designer.cs @@ -68,11 +68,11 @@ namespace Louis__Pharmacy_CNSA212_FP this.tbpMedication = new System.Windows.Forms.TabPage(); this.splcPrescription = new System.Windows.Forms.SplitContainer(); this.btnMedicationSearch = new System.Windows.Forms.Button(); - this.txtPrescriptionPatID = new System.Windows.Forms.TextBox(); - this.txtRxNumber = new System.Windows.Forms.TextBox(); + this.txtMedicationName = new System.Windows.Forms.TextBox(); + this.txtMedicationNumber = new System.Windows.Forms.TextBox(); this.lblPrescriptionPatID = new System.Windows.Forms.Label(); this.lblDisMedicationNum = new System.Windows.Forms.Label(); - this.dgvPrescription = new System.Windows.Forms.DataGridView(); + this.dgvMedication = new System.Windows.Forms.DataGridView(); this.Medication_id = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.MedicationName = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.IntakeMethod = new System.Windows.Forms.DataGridViewTextBoxColumn(); @@ -141,7 +141,7 @@ namespace Louis__Pharmacy_CNSA212_FP this.splcPrescription.Panel1.SuspendLayout(); this.splcPrescription.Panel2.SuspendLayout(); this.splcPrescription.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.dgvPrescription)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.dgvMedication)).BeginInit(); this.cmuMedication.SuspendLayout(); this.tbpPhysician.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.splcPhysician)).BeginInit(); @@ -484,14 +484,14 @@ namespace Louis__Pharmacy_CNSA212_FP // splcPrescription.Panel1 // this.splcPrescription.Panel1.Controls.Add(this.btnMedicationSearch); - this.splcPrescription.Panel1.Controls.Add(this.txtPrescriptionPatID); - this.splcPrescription.Panel1.Controls.Add(this.txtRxNumber); + this.splcPrescription.Panel1.Controls.Add(this.txtMedicationName); + this.splcPrescription.Panel1.Controls.Add(this.txtMedicationNumber); this.splcPrescription.Panel1.Controls.Add(this.lblPrescriptionPatID); this.splcPrescription.Panel1.Controls.Add(this.lblDisMedicationNum); // // splcPrescription.Panel2 // - this.splcPrescription.Panel2.Controls.Add(this.dgvPrescription); + this.splcPrescription.Panel2.Controls.Add(this.dgvMedication); this.splcPrescription.Size = new System.Drawing.Size(733, 484); this.splcPrescription.SplitterDistance = 241; this.splcPrescription.TabIndex = 0; @@ -504,20 +504,21 @@ namespace Louis__Pharmacy_CNSA212_FP this.btnMedicationSearch.TabIndex = 4; this.btnMedicationSearch.Text = "Search"; this.btnMedicationSearch.UseVisualStyleBackColor = true; + this.btnMedicationSearch.Click += new System.EventHandler(this.btnMedicationSearch_Click); // // txtPrescriptionPatID // - this.txtPrescriptionPatID.Location = new System.Drawing.Point(184, 74); - this.txtPrescriptionPatID.Name = "txtPrescriptionPatID"; - this.txtPrescriptionPatID.Size = new System.Drawing.Size(100, 20); - this.txtPrescriptionPatID.TabIndex = 3; + this.txtMedicationName.Location = new System.Drawing.Point(184, 74); + this.txtMedicationName.Name = "txtMedicationName"; + this.txtMedicationName.Size = new System.Drawing.Size(100, 20); + this.txtMedicationName.TabIndex = 3; // // txtRxNumber // - this.txtRxNumber.Location = new System.Drawing.Point(184, 51); - this.txtRxNumber.Name = "txtRxNumber"; - this.txtRxNumber.Size = new System.Drawing.Size(100, 20); - this.txtRxNumber.TabIndex = 2; + this.txtMedicationNumber.Location = new System.Drawing.Point(184, 51); + this.txtMedicationNumber.Name = "txtMedicationNumber"; + this.txtMedicationNumber.Size = new System.Drawing.Size(100, 20); + this.txtMedicationNumber.TabIndex = 2; // // lblPrescriptionPatID // @@ -541,18 +542,18 @@ namespace Louis__Pharmacy_CNSA212_FP // // dgvPrescription // - 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.Medication_id, this.MedicationName, this.IntakeMethod, this.Frequency, this.Dosage, this.Purpose, this.RxNum }); - this.dgvPrescription.ContextMenuStrip = this.cmuMedication; - this.dgvPrescription.Location = new System.Drawing.Point(3, 3); - this.dgvPrescription.Name = "dgvPrescription"; - this.dgvPrescription.ReadOnly = true; - this.dgvPrescription.RowHeadersWidth = 51; - this.dgvPrescription.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; - this.dgvPrescription.Size = new System.Drawing.Size(730, 237); - this.dgvPrescription.TabIndex = 0; + this.dgvMedication.AllowUserToAddRows = false; + this.dgvMedication.AllowUserToDeleteRows = false; + this.dgvMedication.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dgvMedication.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.Medication_id, this.MedicationName, this.IntakeMethod, this.Frequency, this.Dosage, this.Purpose, this.RxNum }); + this.dgvMedication.ContextMenuStrip = this.cmuMedication; + this.dgvMedication.Location = new System.Drawing.Point(3, 3); + this.dgvMedication.Name = "dgvMedication"; + this.dgvMedication.ReadOnly = true; + this.dgvMedication.RowHeadersWidth = 51; + this.dgvMedication.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.dgvMedication.Size = new System.Drawing.Size(730, 237); + this.dgvMedication.TabIndex = 0; // // Medication_id // @@ -636,7 +637,7 @@ namespace Louis__Pharmacy_CNSA212_FP this.cmuMedicationEdit.Name = "cmuMedicationEdit"; this.cmuMedicationEdit.Size = new System.Drawing.Size(107, 22); this.cmuMedicationEdit.Text = "Edit"; - this.cmuMedicationEdit.Click += new System.EventHandler(this.cmuRxEdit_Click); + this.cmuMedicationEdit.Click += new System.EventHandler(this.cmuMedicationEdit_Click); // // cmuMedicationDelete // @@ -1045,7 +1046,7 @@ namespace Louis__Pharmacy_CNSA212_FP this.splcPrescription.Panel2.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.splcPrescription)).EndInit(); this.splcPrescription.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.dgvPrescription)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.dgvMedication)).EndInit(); this.cmuMedication.ResumeLayout(false); this.tbpPhysician.ResumeLayout(false); this.splcPhysician.Panel1.ResumeLayout(false); @@ -1108,10 +1109,10 @@ namespace Louis__Pharmacy_CNSA212_FP private System.Windows.Forms.SplitContainer splcPatient; private System.Windows.Forms.SplitContainer splcPrescription; private System.Windows.Forms.Button btnPatientSearch; - public System.Windows.Forms.TextBox txtRxNumber; + public System.Windows.Forms.TextBox txtMedicationNumber; private System.Windows.Forms.Label lblPrescriptionPatID; private System.Windows.Forms.Label lblDisMedicationNum; - private System.Windows.Forms.TextBox txtPrescriptionPatID; + private System.Windows.Forms.TextBox txtMedicationName; private System.Windows.Forms.Button btnMedicationSearch; private System.Windows.Forms.Button btnPhysicianSearch; private System.Windows.Forms.TextBox txtPatientLast; @@ -1120,7 +1121,7 @@ namespace Louis__Pharmacy_CNSA212_FP private System.Windows.Forms.TextBox txtPhysicianLast; private System.Windows.Forms.TextBox txtPhysicianFirst; private System.Windows.Forms.DataGridView dgvPhysician; - private System.Windows.Forms.DataGridView dgvPrescription; + private System.Windows.Forms.DataGridView dgvMedication; private System.Windows.Forms.DataGridViewTextBoxColumn pat_id; private System.Windows.Forms.DataGridViewTextBoxColumn FirstName; private System.Windows.Forms.DataGridViewTextBoxColumn LastName; diff --git a/Louis'-Pharmacy_CNSA212-FP/frmInfo.cs b/Louis'-Pharmacy_CNSA212-FP/frmInfo.cs index c383aa8..f7e4327 100644 --- a/Louis'-Pharmacy_CNSA212-FP/frmInfo.cs +++ b/Louis'-Pharmacy_CNSA212-FP/frmInfo.cs @@ -24,7 +24,7 @@ namespace Louis__Pharmacy_CNSA212_FP dgvPatient.DoubleClick += cmuPatientEdit_Click; dgvPhysician.DoubleClick += cmuPhysicianEdit_Click; - dgvRx.DoubleClick += cmuRxEdit_Click; + dgvRx.DoubleClick += cmuMedicationEdit_Click; tbcInfo.SelectedIndexChanged += frmInfoTabChange; @@ -134,12 +134,12 @@ namespace Louis__Pharmacy_CNSA212_FP } // if data grid view is not focused, run the search function - if (e.KeyCode == Keys.Enter && prescriptionIsActive && !dgvPrescription.Focused) + if (e.KeyCode == Keys.Enter && prescriptionIsActive && !dgvMedication.Focused) { - btnPatientSearch_Click(sender,e); + btnRxSearch_Click(sender,e); } // if data grid view is focused, run the edit function - else if (e.KeyCode == Keys.Enter && prescriptionIsActive && dgvPrescription.Focused) + else if (e.KeyCode == Keys.Enter && prescriptionIsActive && dgvMedication.Focused) { cmuPrescriptionEdit_Click(sender,e); } @@ -147,14 +147,14 @@ namespace Louis__Pharmacy_CNSA212_FP // if data grid view is not focused, run the search function - if (e.KeyCode == Keys.Enter && medicationIsActive && !dgvRx.Focused) + if (e.KeyCode == Keys.Enter && medicationIsActive && !dgvMedication.Focused) { - btnRxSearch_Click(sender,e); + btnMedicationSearch_Click(sender,e); } // if data grid view is focused, run the edit function - else if (e.KeyCode == Keys.Enter && medicationIsActive && dgvRx.Focused) + else if (e.KeyCode == Keys.Enter && medicationIsActive && dgvMedication.Focused) { - cmuRxEdit_Click(sender,e); + cmuMedicationEdit_Click(sender,e); } @@ -583,14 +583,14 @@ namespace Louis__Pharmacy_CNSA212_FP medicationAdd.Focus(); } - private void cmuRxEdit_Click(object sender, EventArgs e) + private void cmuMedicationEdit_Click(object sender, EventArgs e) { - if (dgvRx.Rows.Count > 0) + if (dgvMedication.Rows.Count > 0) { - dgvRx.DataSource = ds.Tables[0]; + dgvMedication.DataSource = ds.Tables[0]; DataGridViewRow row = new DataGridViewRow(); - row = dgvRx.SelectedRows[0]; + row = dgvMedication.SelectedRows[0]; string rxID = ""; rxID = (row.Cells[0].Value).ToString(); frmMedication prescriptionAdd = new frmMedication(this, false); @@ -756,7 +756,7 @@ namespace Louis__Pharmacy_CNSA212_FP catch (Exception exception) { - ep1.SetError(txtPrescriptionPatID, "Invalid Value"); + ep1.SetError(txtMedicationName, "Invalid Value"); } } @@ -822,6 +822,84 @@ namespace Louis__Pharmacy_CNSA212_FP } + public void btnMedicationSearch_Click(object sender, EventArgs e) + { + + string medID = ""; + string medicationName = ""; + + + if (txtMedicationName.Text.Length+txtMedicationNumber.Text.Length > 0) + { + + + try + { + + medicationName = txtMedicationName.Text; + + try + { + + medID = txtMedicationNumber.Text; + + try + { + + + ds = PharmacyDataTier.MedicationInfoSearch(medID,medicationName); + + + if (ds.Tables[0].Rows.Count > 0) // There is a record. + { + dgvMedication.Visible = true; + // Get data source. + dgvMedication.DataSource = ds.Tables[0]; + dgvMedication.AlternatingRowsDefaultCellStyle.BackColor = Color.LightGreen; + + // Set the row and column header styles. + dgvMedication.ColumnHeadersDefaultCellStyle.ForeColor = Color.White; + dgvMedication.ColumnHeadersDefaultCellStyle.BackColor = Color.Green; + } + else + { + dgvMedication.Visible = false; // Hide the DataGridView if no results are found. + MessageBox.Show("No records found."); + } + + + } + catch (Exception exception) + { + + ep1.SetError(btnMedicationSearch, "Error Searching"); + + } + + + } + catch (Exception exception) + { + + ep1.SetError(txtMedicationNumber, "Invalid Value"); + + } + + } + catch (Exception exception) + { + + ep1.SetError(txtMedicationName, "Invalid Value"); + + } + } + + + cmuMedicationEdit.Enabled = dgvMedication.Rows.Count > 0; + cmuMedicationDelete.Enabled = dgvMedication.Rows.Count > 0; + + dgvMedication.Focus(); + } } } diff --git a/Louis'-Pharmacy_CNSA212-FP/frmMedication.cs b/Louis'-Pharmacy_CNSA212-FP/frmMedication.cs index 2291412..13b0482 100644 --- a/Louis'-Pharmacy_CNSA212-FP/frmMedication.cs +++ b/Louis'-Pharmacy_CNSA212-FP/frmMedication.cs @@ -216,8 +216,8 @@ namespace Louis__Pharmacy_CNSA212_FP RxNum); } - SourceForm.txtRxNumber.Text = Medication_id; - //SourceForm.btnPrescriptionSearch_Click(sender, e); + SourceForm.txtMedicationNumber.Text = Medication_id; + SourceForm.btnMedicationSearch_Click(sender, e); Close(); diff --git a/Louis'-Pharmacy_CNSA212-FP/frmPrescription.cs b/Louis'-Pharmacy_CNSA212-FP/frmPrescription.cs index 39e52a0..b78a2c3 100644 --- a/Louis'-Pharmacy_CNSA212-FP/frmPrescription.cs +++ b/Louis'-Pharmacy_CNSA212-FP/frmPrescription.cs @@ -225,7 +225,7 @@ namespace Louis__Pharmacy_CNSA212_FP Max_refills); } - SourceForm.txtRxNumber.Text = RxNum; + SourceForm.txtMedicationNumber.Text = RxNum; //SourceForm.btnRxSearch_Click(sender, e); Close();