From 1e7dc8b35c3f8b1f1565bf7eff31418fcb7f1f60 Mon Sep 17 00:00:00 2001 From: Adam McCane Date: Wed, 21 Feb 2024 10:47:48 -0500 Subject: [PATCH 1/8] Made edit functionality for refills. --- Louis'-Pharmacy_CNSA212-FP/frmInfo.cs | 2 +- .../frmRefill.Designer.cs | 38 +++++++++++++++++++ Louis'-Pharmacy_CNSA212-FP/frmRefill.cs | 36 ++++++++++++++---- Louis'-Pharmacy_CNSA212-FP/frmRefill.resx | 3 ++ 4 files changed, 71 insertions(+), 8 deletions(-) diff --git a/Louis'-Pharmacy_CNSA212-FP/frmInfo.cs b/Louis'-Pharmacy_CNSA212-FP/frmInfo.cs index 11c384b..1b19174 100644 --- a/Louis'-Pharmacy_CNSA212-FP/frmInfo.cs +++ b/Louis'-Pharmacy_CNSA212-FP/frmInfo.cs @@ -664,7 +664,7 @@ namespace Louis__Pharmacy_CNSA212_FP if (dgvPrescription.Rows.Count > 0) { - dgvPrescription.DataSource = ds.Tables[0]; + //dgvPrescription.DataSource = ds.Tables[0]; // Console.WriteLine( dgvPatient.SelectedRows.Count); DataGridViewRow row = new DataGridViewRow(); row = dgvPrescription.SelectedRows[0]; diff --git a/Louis'-Pharmacy_CNSA212-FP/frmRefill.Designer.cs b/Louis'-Pharmacy_CNSA212-FP/frmRefill.Designer.cs index b2539b7..156ca58 100644 --- a/Louis'-Pharmacy_CNSA212-FP/frmRefill.Designer.cs +++ b/Louis'-Pharmacy_CNSA212-FP/frmRefill.Designer.cs @@ -29,6 +29,7 @@ namespace Louis__Pharmacy_CNSA212_FP /// private void InitializeComponent() { + this.components = new System.ComponentModel.Container(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmRefill)); this.bindingNavigatorAddNewItem = new System.Windows.Forms.ToolStripButton(); @@ -49,7 +50,11 @@ namespace Louis__Pharmacy_CNSA212_FP this.patientid = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.medicationid = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.rxnumber = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.cmuRefill = new System.Windows.Forms.ContextMenuStrip(this.components); + this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.deleteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); ((System.ComponentModel.ISupportInitialize)(this.dgvRefills)).BeginInit(); + this.cmuRefill.SuspendLayout(); this.SuspendLayout(); // // bindingNavigatorAddNewItem @@ -124,17 +129,21 @@ namespace Louis__Pharmacy_CNSA212_FP this.patientid, this.medicationid, this.rxnumber}); + this.dgvRefills.ContextMenuStrip = this.cmuRefill; this.dgvRefills.Location = new System.Drawing.Point(12, 12); this.dgvRefills.Name = "dgvRefills"; + this.dgvRefills.ReadOnly = true; this.dgvRefills.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.dgvRefills.Size = new System.Drawing.Size(613, 298); this.dgvRefills.TabIndex = 1; + this.dgvRefills.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgvRefills_CellDoubleClick); // // refillid // this.refillid.DataPropertyName = "Refill_id"; this.refillid.HeaderText = "Refill ID"; this.refillid.Name = "refillid"; + this.refillid.ReadOnly = true; // // refilldate // @@ -144,24 +153,49 @@ namespace Louis__Pharmacy_CNSA212_FP this.refilldate.DefaultCellStyle = dataGridViewCellStyle1; this.refilldate.HeaderText = "Date of Refill"; this.refilldate.Name = "refilldate"; + this.refilldate.ReadOnly = true; // // patientid // this.patientid.DataPropertyName = "Patient_id"; this.patientid.HeaderText = "Patient ID"; this.patientid.Name = "patientid"; + this.patientid.ReadOnly = true; // // medicationid // this.medicationid.DataPropertyName = "Medication_id"; this.medicationid.HeaderText = "Medication ID"; this.medicationid.Name = "medicationid"; + this.medicationid.ReadOnly = true; // // rxnumber // this.rxnumber.DataPropertyName = "RxNum_id"; this.rxnumber.HeaderText = "Rx Number ID"; this.rxnumber.Name = "rxnumber"; + this.rxnumber.ReadOnly = true; + // + // cmuRefill + // + this.cmuRefill.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.editToolStripMenuItem, + this.deleteToolStripMenuItem}); + this.cmuRefill.Name = "cmuRefill"; + this.cmuRefill.Size = new System.Drawing.Size(108, 48); + // + // editToolStripMenuItem + // + this.editToolStripMenuItem.Name = "editToolStripMenuItem"; + this.editToolStripMenuItem.Size = new System.Drawing.Size(107, 22); + this.editToolStripMenuItem.Text = "Edit"; + this.editToolStripMenuItem.Click += new System.EventHandler(this.editToolStripMenuItem_Click); + // + // deleteToolStripMenuItem + // + this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem"; + this.deleteToolStripMenuItem.Size = new System.Drawing.Size(107, 22); + this.deleteToolStripMenuItem.Text = "Delete"; // // frmRefill // @@ -174,6 +208,7 @@ namespace Louis__Pharmacy_CNSA212_FP this.Name = "frmRefill"; this.Text = "Louis\' Pharmacy - Prescription Refill"; ((System.ComponentModel.ISupportInitialize)(this.dgvRefills)).EndInit(); + this.cmuRefill.ResumeLayout(false); this.ResumeLayout(false); } @@ -212,5 +247,8 @@ namespace Louis__Pharmacy_CNSA212_FP private System.Windows.Forms.DataGridViewTextBoxColumn patientid; private System.Windows.Forms.DataGridViewTextBoxColumn medicationid; private System.Windows.Forms.DataGridViewTextBoxColumn rxnumber; + private System.Windows.Forms.ContextMenuStrip cmuRefill; + private System.Windows.Forms.ToolStripMenuItem editToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem deleteToolStripMenuItem; } } \ No newline at end of file diff --git a/Louis'-Pharmacy_CNSA212-FP/frmRefill.cs b/Louis'-Pharmacy_CNSA212-FP/frmRefill.cs index ce6b98c..d0e2567 100644 --- a/Louis'-Pharmacy_CNSA212-FP/frmRefill.cs +++ b/Louis'-Pharmacy_CNSA212-FP/frmRefill.cs @@ -45,6 +45,28 @@ namespace Louis__Pharmacy_CNSA212_FP dgvRefills.DataSource = ds.Tables[0]; } + private void editToolStripMenuItem_Click(object sender, EventArgs e) + { + string refillID = ""; + + DataGridViewRow row = new DataGridViewRow(); + row = dgvRefills.SelectedRows[0]; + + refillID = (row.Cells[0].Value).ToString(); + + frmRefillAdd add = new frmRefillAdd(false); + add.MdiParent = MdiParent; + add.StartPosition = FormStartPosition.CenterScreen; + add.Show(); + add.Focus(); + add.FillRefill(refillID); + } + + private void dgvRefills_CellDoubleClick(object sender, DataGridViewCellEventArgs e) + { + editToolStripMenuItem_Click(sender, e); + } + //private void btnSearch_Click(object sender, EventArgs e) //{ // string patientID = ""; @@ -52,14 +74,14 @@ namespace Louis__Pharmacy_CNSA212_FP // try // { - //DataSet ds = new DataSet(); - //PharmacyDataTier phaDT = new PharmacyDataTier(); + //DataSet ds = new DataSet(); + //PharmacyDataTier phaDT = new PharmacyDataTier(); - //patientID = txtPatientID.Text.Trim(); - //if (txtDate.Text.Trim().Length > 0) - //{ - //date = DateTime.Parse(txtDate.Text.Trim()); - //} + //patientID = txtPatientID.Text.Trim(); + //if (txtDate.Text.Trim().Length > 0) + //{ + //date = DateTime.Parse(txtDate.Text.Trim()); + //} // ds = PharmacyDataTier.RefillSearch(date, patientID); diff --git a/Louis'-Pharmacy_CNSA212-FP/frmRefill.resx b/Louis'-Pharmacy_CNSA212-FP/frmRefill.resx index a0d70f5..0a6275b 100644 --- a/Louis'-Pharmacy_CNSA212-FP/frmRefill.resx +++ b/Louis'-Pharmacy_CNSA212-FP/frmRefill.resx @@ -132,6 +132,9 @@ True + + 17, 17 + From 799d21647409586aecc1f0310ff98d0b27c1efcb Mon Sep 17 00:00:00 2001 From: caschick221 Date: Wed, 21 Feb 2024 10:57:51 -0500 Subject: [PATCH 2/8] made some small changes to fix a bug relating to how dgvs are updated when searches are preformed in other tabs --- .idea/.idea.Louis' Pharmacy/.idea/sqldialects.xml | 6 ------ Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs | 2 +- Louis'-Pharmacy_CNSA212-FP/frmInfo.cs | 8 ++++---- 3 files changed, 5 insertions(+), 11 deletions(-) delete mode 100644 .idea/.idea.Louis' Pharmacy/.idea/sqldialects.xml diff --git a/.idea/.idea.Louis' Pharmacy/.idea/sqldialects.xml b/.idea/.idea.Louis' Pharmacy/.idea/sqldialects.xml deleted file mode 100644 index d6fa49f..0000000 --- a/.idea/.idea.Louis' Pharmacy/.idea/sqldialects.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs b/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs index de40a46..575a1b6 100644 --- a/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs +++ b/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs @@ -434,7 +434,7 @@ namespace Louis__Pharmacy_CNSA212_FP } catch (Exception ex) { - MessageBox.Show(precID + " Has an Associated Prescriptions. Could Not Delete", "Error", MessageBoxButtons.OK); + MessageBox.Show(precID + " Has an Associated Refill. Could Not Delete", "Error", MessageBoxButtons.OK); } finally { diff --git a/Louis'-Pharmacy_CNSA212-FP/frmInfo.cs b/Louis'-Pharmacy_CNSA212-FP/frmInfo.cs index 11c384b..239c802 100644 --- a/Louis'-Pharmacy_CNSA212-FP/frmInfo.cs +++ b/Louis'-Pharmacy_CNSA212-FP/frmInfo.cs @@ -502,7 +502,7 @@ namespace Louis__Pharmacy_CNSA212_FP if (dgvPatient.Rows.Count > 0) { - dgvPatient.DataSource = ds.Tables[0]; + // dgvPatient.DataSource = ds.Tables[0]; DataGridViewRow row = new DataGridViewRow(); row = dgvPatient.SelectedRows[0]; string patid = ""; @@ -557,7 +557,7 @@ namespace Louis__Pharmacy_CNSA212_FP if (dgvPhysician.Rows.Count > 0) { - dgvPhysician.DataSource = ds.Tables[0]; + // dgvPhysician.DataSource = ds.Tables[0]; DataGridViewRow row = new DataGridViewRow(); row = dgvPhysician.SelectedRows[0]; string phyID = ""; @@ -626,7 +626,7 @@ namespace Louis__Pharmacy_CNSA212_FP if (dgvPrescription.Rows.Count > 0) { - dgvPrescription.DataSource = ds.Tables[0]; + // dgvPrescription.DataSource = ds.Tables[0]; DataGridViewRow row = new DataGridViewRow(); row = dgvMedication.SelectedRows[0]; string medID = ""; @@ -688,7 +688,7 @@ namespace Louis__Pharmacy_CNSA212_FP if (dgvPrescription.Rows.Count > 0) { - dgvPrescription.DataSource = ds.Tables[0]; + // dgvPrescription.DataSource = ds.Tables[0]; DataGridViewRow row = new DataGridViewRow(); row = dgvPrescription.SelectedRows[0]; string PresID = ""; From 748c6e08fbedcf8c862383032bf748c66c8c8cfb Mon Sep 17 00:00:00 2001 From: caschick221 Date: Wed, 21 Feb 2024 13:10:30 -0500 Subject: [PATCH 3/8] Made Physicician DOB format short --- Louis'-Pharmacy_CNSA212-FP/frmPhysician.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Louis'-Pharmacy_CNSA212-FP/frmPhysician.cs b/Louis'-Pharmacy_CNSA212-FP/frmPhysician.cs index 64c80fc..94e8805 100644 --- a/Louis'-Pharmacy_CNSA212-FP/frmPhysician.cs +++ b/Louis'-Pharmacy_CNSA212-FP/frmPhysician.cs @@ -1,7 +1,7 @@ using System; +using System.ComponentModel; using System.Data; using System.Windows.Forms; -using DateTime = System.DateTime; namespace Louis__Pharmacy_CNSA212_FP { @@ -119,8 +119,10 @@ namespace Louis__Pharmacy_CNSA212_FP { throw new Exception(); } - else - DOB = new DateTime(1753, 1, 1); + if (DOB > new DateTime(9999,1,1)) + { + throw new Exception(); + } } catch (Exception exception) { @@ -306,7 +308,8 @@ namespace Louis__Pharmacy_CNSA212_FP txtFirstName.Text = ds.Tables[0].Rows[0]["FirstName"].ToString(); txtLastName.Text = ds.Tables[0].Rows[0]["LastName"].ToString(); txtMiddleInit.Text = ds.Tables[0].Rows[0]["MiddleIntials"].ToString(); - txtDOB.Text = ds.Tables[0].Rows[0]["DOB"].ToString(); + DateTime date = DateTime.Parse(ds.Tables[0].Rows[0]["DOB"].ToString()); + txtDOB.Text = date.ToString("d"); txtGender.Text = ds.Tables[0].Rows[0]["Gender"].ToString(); txtCity.Text = ds.Tables[0].Rows[0]["City"].ToString(); txtZip.Text = ds.Tables[0].Rows[0]["Zip"].ToString(); From 64edeb203befc7ab897ec2e80d92922e9572e59f Mon Sep 17 00:00:00 2001 From: caschick221 Date: Wed, 21 Feb 2024 13:11:24 -0500 Subject: [PATCH 4/8] made DOB format short in patients --- Louis'-Pharmacy_CNSA212-FP/frmPatient.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Louis'-Pharmacy_CNSA212-FP/frmPatient.cs b/Louis'-Pharmacy_CNSA212-FP/frmPatient.cs index 5008a09..157ec84 100644 --- a/Louis'-Pharmacy_CNSA212-FP/frmPatient.cs +++ b/Louis'-Pharmacy_CNSA212-FP/frmPatient.cs @@ -76,7 +76,8 @@ namespace Louis__Pharmacy_CNSA212_FP txtWeight.Text = ds.Tables[0].Rows[0]["lbs"].ToString(); txtHeightFt.Text = ds.Tables[0].Rows[0]["Height_feet"].ToString(); txtHeightIn.Text = ds.Tables[0].Rows[0]["Height_inches"].ToString(); - txtDOB.Text = ds.Tables[0].Rows[0]["DOB"].ToString(); + DateTime date = DateTime.Parse(ds.Tables[0].Rows[0]["DOB"].ToString()); + txtDOB.Text = date.ToString("d"); cboGender.Text = ds.Tables[0].Rows[0]["Gender"].ToString(); txtCity.Text = ds.Tables[0].Rows[0]["City"].ToString(); txtZip.Text = ds.Tables[0].Rows[0]["Zip"].ToString(); From 03e71852251e67782223b5c750203ab1c36aef98 Mon Sep 17 00:00:00 2001 From: Adam McCane Date: Wed, 21 Feb 2024 15:51:39 -0500 Subject: [PATCH 5/8] Created delete functionality for view refill form. --- Louis'-Pharmacy_CNSA212-FP/frmRefillAdd.cs | 36 ++++++++++++---------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/Louis'-Pharmacy_CNSA212-FP/frmRefillAdd.cs b/Louis'-Pharmacy_CNSA212-FP/frmRefillAdd.cs index d765f73..1a6954f 100644 --- a/Louis'-Pharmacy_CNSA212-FP/frmRefillAdd.cs +++ b/Louis'-Pharmacy_CNSA212-FP/frmRefillAdd.cs @@ -91,27 +91,31 @@ namespace Louis__Pharmacy_CNSA212_FP medicationID = txtMedicationID.Text.Trim(); rxNum = txtRxNumber.Text.Trim(); + frmRefill refill = new frmRefill(0); + PharmacyDataTier.UpdateRefill(refillID, date, patientID, medicationID, rxNum); + refill.Controls.Clear(); + refill.Activate(); } else { - if (numRefills == pastNumRefills) - { - MessageBox.Show("This prescription has reached the maximum number of refills.", "Max Refill", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - else - { - if (isAdd) - { - refillID = txtRefillID.Text.Trim(); - date = DateTime.Parse(txtRefillDate.Text.Trim()); - patientID = txtPatientID.Text.Trim(); - medicationID = txtMedicationID.Text.Trim(); + //if (numRefills == pastNumRefills) + //{ + // MessageBox.Show("This prescription has reached the maximum number of refills.", "Max Refill", MessageBoxButtons.OK, MessageBoxIcon.Error); + //} + //else + //{ + // if (isAdd) + // { + // refillID = txtRefillID.Text.Trim(); + // date = DateTime.Parse(txtRefillDate.Text.Trim()); + // patientID = txtPatientID.Text.Trim(); + // medicationID = txtMedicationID.Text.Trim(); - PharmacyDataTier.AddRefill(refillID, date, patientID, medicationID, rxNum); - PharmacyDataTier.PastRefills(rxNum); - } - } + // PharmacyDataTier.AddRefill(refillID, date, patientID, medicationID, rxNum); + // PharmacyDataTier.PastRefills(rxNum); + // } + //} } } catch (Exception exception) From ea7474900fe0b4b13fe2645bcf3805479e360eb9 Mon Sep 17 00:00:00 2001 From: Adam McCane Date: Wed, 21 Feb 2024 16:56:17 -0500 Subject: [PATCH 6/8] Merge --- .../PharmacyDataTier.cs | 28 +++++++++++++++++++ .../frmRefill.Designer.cs | 7 +++-- Louis'-Pharmacy_CNSA212-FP/frmRefill.cs | 15 ++++++++++ 3 files changed, 47 insertions(+), 3 deletions(-) diff --git a/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs b/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs index de40a46..11a2d1a 100644 --- a/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs +++ b/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs @@ -1235,6 +1235,34 @@ namespace Louis__Pharmacy_CNSA212_FP } } + public static void DecrementPastRefills(string rxNum) + { + try + { + myConn.Open(); + + cmdString.Parameters.Clear(); + + cmdString.Connection = myConn; + cmdString.CommandType = CommandType.StoredProcedure; + cmdString.CommandTimeout = 1500; + + cmdString.CommandText = "DecrementPastRefills"; + + cmdString.Parameters.Add("@Prescription_id", SqlDbType.VarChar, 11).Value = rxNum; + + cmdString.ExecuteNonQuery(); + } + catch (Exception ex) + { + throw new ArgumentException(ex.Message); + } + finally + { + myConn.Close(); + } + } + public static void CreatePrescription( string RxNum, string Patient_id, diff --git a/Louis'-Pharmacy_CNSA212-FP/frmRefill.Designer.cs b/Louis'-Pharmacy_CNSA212-FP/frmRefill.Designer.cs index 156ca58..5a985e2 100644 --- a/Louis'-Pharmacy_CNSA212-FP/frmRefill.Designer.cs +++ b/Louis'-Pharmacy_CNSA212-FP/frmRefill.Designer.cs @@ -182,20 +182,21 @@ namespace Louis__Pharmacy_CNSA212_FP this.editToolStripMenuItem, this.deleteToolStripMenuItem}); this.cmuRefill.Name = "cmuRefill"; - this.cmuRefill.Size = new System.Drawing.Size(108, 48); + this.cmuRefill.Size = new System.Drawing.Size(181, 70); // // editToolStripMenuItem // this.editToolStripMenuItem.Name = "editToolStripMenuItem"; - this.editToolStripMenuItem.Size = new System.Drawing.Size(107, 22); + this.editToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.editToolStripMenuItem.Text = "Edit"; this.editToolStripMenuItem.Click += new System.EventHandler(this.editToolStripMenuItem_Click); // // deleteToolStripMenuItem // this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem"; - this.deleteToolStripMenuItem.Size = new System.Drawing.Size(107, 22); + this.deleteToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.deleteToolStripMenuItem.Text = "Delete"; + this.deleteToolStripMenuItem.Click += new System.EventHandler(this.deleteToolStripMenuItem_Click); // // frmRefill // diff --git a/Louis'-Pharmacy_CNSA212-FP/frmRefill.cs b/Louis'-Pharmacy_CNSA212-FP/frmRefill.cs index d0e2567..44050f5 100644 --- a/Louis'-Pharmacy_CNSA212-FP/frmRefill.cs +++ b/Louis'-Pharmacy_CNSA212-FP/frmRefill.cs @@ -67,6 +67,21 @@ namespace Louis__Pharmacy_CNSA212_FP editToolStripMenuItem_Click(sender, e); } + private void deleteToolStripMenuItem_Click(object sender, EventArgs e) + { + string refillID = ""; + string rxID = ""; + + DataGridViewRow row = new DataGridViewRow(); + row = dgvRefills.SelectedRows[0]; + + refillID = (row.Cells[0].Value).ToString(); + rxID = (row.Cells[4].Value).ToString(); + + PharmacyDataTier.DeleteRefill(refillID); + PharmacyDataTier.DecrementPastRefills(rxID); + } + //private void btnSearch_Click(object sender, EventArgs e) //{ // string patientID = ""; From a1f2fd1fe2c6067094d509b1a4a60cc49b1790eb Mon Sep 17 00:00:00 2001 From: Adam McCane Date: Thu, 22 Feb 2024 22:19:12 -0500 Subject: [PATCH 7/8] Added code to allow refill edit to modify prescription refill values successfully. --- Louis'-Pharmacy_CNSA212-FP/frmRefillAdd.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Louis'-Pharmacy_CNSA212-FP/frmRefillAdd.cs b/Louis'-Pharmacy_CNSA212-FP/frmRefillAdd.cs index 1a6954f..c29e32a 100644 --- a/Louis'-Pharmacy_CNSA212-FP/frmRefillAdd.cs +++ b/Louis'-Pharmacy_CNSA212-FP/frmRefillAdd.cs @@ -15,6 +15,7 @@ namespace Louis__Pharmacy_CNSA212_FP { private static bool isAdd; public DataSet ds = new DataSet(); + public string currentID = ""; public frmRefillAdd(bool isNew) { @@ -59,6 +60,8 @@ namespace Louis__Pharmacy_CNSA212_FP txtPatientID.Text = ds.Tables[0].Rows[0]["Patient_id"].ToString(); txtMedicationID.Text = ds.Tables[0].Rows[0]["Medication_id"].ToString(); txtRxNumber.Text = ds.Tables[0].Rows[0]["RxNum_id"].ToString(); + + currentID = txtRxNumber.Text; } private void btnAdd_Click(object sender, EventArgs e) @@ -94,6 +97,13 @@ namespace Louis__Pharmacy_CNSA212_FP frmRefill refill = new frmRefill(0); PharmacyDataTier.UpdateRefill(refillID, date, patientID, medicationID, rxNum); + + if (currentID != rxNum) + { + PharmacyDataTier.DecrementPastRefills(currentID); + PharmacyDataTier.PastRefills(rxNum); + } + refill.Controls.Clear(); refill.Activate(); } From 5622be21fd52a3792cf3fd964e4a9999dbb8233f Mon Sep 17 00:00:00 2001 From: Adam McCane Date: Fri, 23 Feb 2024 02:23:31 -0500 Subject: [PATCH 8/8] Refresh funtionality added to cmu of view refill form. --- Louis'-Pharmacy_CNSA212-FP/frmRefill.Designer.cs | 14 ++++++++++++-- Louis'-Pharmacy_CNSA212-FP/frmRefill.cs | 15 +++++++++++++++ .../frmRefillAdd.Designer.cs | 1 + Louis'-Pharmacy_CNSA212-FP/frmRefillAdd.cs | 3 +-- 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/Louis'-Pharmacy_CNSA212-FP/frmRefill.Designer.cs b/Louis'-Pharmacy_CNSA212-FP/frmRefill.Designer.cs index 5a985e2..ff10e53 100644 --- a/Louis'-Pharmacy_CNSA212-FP/frmRefill.Designer.cs +++ b/Louis'-Pharmacy_CNSA212-FP/frmRefill.Designer.cs @@ -53,6 +53,7 @@ namespace Louis__Pharmacy_CNSA212_FP this.cmuRefill = new System.Windows.Forms.ContextMenuStrip(this.components); this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.deleteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.cmuRefresh = new System.Windows.Forms.ToolStripMenuItem(); ((System.ComponentModel.ISupportInitialize)(this.dgvRefills)).BeginInit(); this.cmuRefill.SuspendLayout(); this.SuspendLayout(); @@ -180,9 +181,10 @@ namespace Louis__Pharmacy_CNSA212_FP // this.cmuRefill.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.editToolStripMenuItem, - this.deleteToolStripMenuItem}); + this.deleteToolStripMenuItem, + this.cmuRefresh}); this.cmuRefill.Name = "cmuRefill"; - this.cmuRefill.Size = new System.Drawing.Size(181, 70); + this.cmuRefill.Size = new System.Drawing.Size(181, 92); // // editToolStripMenuItem // @@ -198,6 +200,13 @@ namespace Louis__Pharmacy_CNSA212_FP this.deleteToolStripMenuItem.Text = "Delete"; this.deleteToolStripMenuItem.Click += new System.EventHandler(this.deleteToolStripMenuItem_Click); // + // cmuRefresh + // + this.cmuRefresh.Name = "cmuRefresh"; + this.cmuRefresh.Size = new System.Drawing.Size(180, 22); + this.cmuRefresh.Text = "Refresh"; + this.cmuRefresh.Click += new System.EventHandler(this.cmuRefresh_Click); + // // frmRefill // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -251,5 +260,6 @@ namespace Louis__Pharmacy_CNSA212_FP private System.Windows.Forms.ContextMenuStrip cmuRefill; private System.Windows.Forms.ToolStripMenuItem editToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem deleteToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem cmuRefresh; } } \ No newline at end of file diff --git a/Louis'-Pharmacy_CNSA212-FP/frmRefill.cs b/Louis'-Pharmacy_CNSA212-FP/frmRefill.cs index 44050f5..2e69b6d 100644 --- a/Louis'-Pharmacy_CNSA212-FP/frmRefill.cs +++ b/Louis'-Pharmacy_CNSA212-FP/frmRefill.cs @@ -82,6 +82,21 @@ namespace Louis__Pharmacy_CNSA212_FP PharmacyDataTier.DecrementPastRefills(rxID); } + public void refreshrefills(object sender, EventArgs e) + { + DataGridViewRow row = new DataGridViewRow(); + row = dgvRefills.SelectedRows[0]; + string rxNumString = (row.Cells[4].Value).ToString(); + Int32 rxNum = Int32.Parse(rxNumString); + + frmRefill_Load(null, null); + } + + private void cmuRefresh_Click(object sender, EventArgs e) + { + refreshrefills(sender, e); + } + //private void btnSearch_Click(object sender, EventArgs e) //{ // string patientID = ""; diff --git a/Louis'-Pharmacy_CNSA212-FP/frmRefillAdd.Designer.cs b/Louis'-Pharmacy_CNSA212-FP/frmRefillAdd.Designer.cs index d510f44..a205ad3 100644 --- a/Louis'-Pharmacy_CNSA212-FP/frmRefillAdd.Designer.cs +++ b/Louis'-Pharmacy_CNSA212-FP/frmRefillAdd.Designer.cs @@ -160,6 +160,7 @@ this.Controls.Add(this.lblRefillID); this.Name = "frmRefillAdd"; this.Text = "frmRefillAdd"; + //this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.frmRefillAdd_FormClosed); this.Load += new System.EventHandler(this.frmRefillAdd_Load); this.ResumeLayout(false); this.PerformLayout(); diff --git a/Louis'-Pharmacy_CNSA212-FP/frmRefillAdd.cs b/Louis'-Pharmacy_CNSA212-FP/frmRefillAdd.cs index c29e32a..0e69812 100644 --- a/Louis'-Pharmacy_CNSA212-FP/frmRefillAdd.cs +++ b/Louis'-Pharmacy_CNSA212-FP/frmRefillAdd.cs @@ -104,8 +104,7 @@ namespace Louis__Pharmacy_CNSA212_FP PharmacyDataTier.PastRefills(rxNum); } - refill.Controls.Clear(); - refill.Activate(); + } else {