From 6b0ffde53e9946202d5879539a0b0235a1926bcc Mon Sep 17 00:00:00 2001 From: Adam McCane Date: Sat, 17 Feb 2024 00:22:25 -0500 Subject: [PATCH] Finished refill add and update functionality. --- .../PharmacyDataTier.cs | 7 +++-- .../frmRefill.Designer.cs | 10 ++++--- Louis'-Pharmacy_CNSA212-FP/frmRefill.cs | 30 ++++++++++++++++++- Louis'-Pharmacy_CNSA212-FP/frmRefillAdd.cs | 4 --- 4 files changed, 39 insertions(+), 12 deletions(-) diff --git a/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs b/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs index 9775fcc..ddf8342 100644 --- a/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs +++ b/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs @@ -373,7 +373,7 @@ namespace Louis__Pharmacy_CNSA212_FP cmdString.CommandText = "SearchRefills"; // Define input parameter cmdString.Parameters.Add("@date", SqlDbType.Date).Value = date; - cmdString.Parameters.Add("@ID", SqlDbType.VarChar, 8).Value = id; + cmdString.Parameters.Add("@ID", SqlDbType.VarChar, 10).Value = id; // adapter and dataset SqlDataAdapter aAdapter = new SqlDataAdapter(); aAdapter.SelectCommand = cmdString; @@ -407,9 +407,10 @@ namespace Louis__Pharmacy_CNSA212_FP cmdString.Connection = myConn; cmdString.CommandType = CommandType.StoredProcedure; cmdString.CommandTimeout = 1500; - cmdString.CommandText = "SearchRefills"; + cmdString.CommandText = "SearchRefills2"; // Define input parameter - cmdString.Parameters.Add("@ID", SqlDbType.VarChar, 8).Value = id; + cmdString.Parameters.Add("@ID", SqlDbType.VarChar, 10).Value = id; + //cmdString.Parameters.Add("@date", SqlDbType.Date).Value = ""; // adapter and dataset SqlDataAdapter aAdapter = new SqlDataAdapter(); aAdapter.SelectCommand = cmdString; diff --git a/Louis'-Pharmacy_CNSA212-FP/frmRefill.Designer.cs b/Louis'-Pharmacy_CNSA212-FP/frmRefill.Designer.cs index 7977919..ee771d2 100644 --- a/Louis'-Pharmacy_CNSA212-FP/frmRefill.Designer.cs +++ b/Louis'-Pharmacy_CNSA212-FP/frmRefill.Designer.cs @@ -187,24 +187,26 @@ namespace Louis__Pharmacy_CNSA212_FP this.cmuUpdate, this.cmuDelete}); this.cmuRefill.Name = "contextMenuStrip1"; - this.cmuRefill.Size = new System.Drawing.Size(113, 70); + this.cmuRefill.Size = new System.Drawing.Size(181, 92); // // cmuAdd // this.cmuAdd.Name = "cmuAdd"; - this.cmuAdd.Size = new System.Drawing.Size(112, 22); + this.cmuAdd.Size = new System.Drawing.Size(180, 22); this.cmuAdd.Text = "Add"; + this.cmuAdd.Click += new System.EventHandler(this.cmuAdd_Click); // // cmuUpdate // this.cmuUpdate.Name = "cmuUpdate"; - this.cmuUpdate.Size = new System.Drawing.Size(112, 22); + this.cmuUpdate.Size = new System.Drawing.Size(180, 22); this.cmuUpdate.Text = "Update"; + this.cmuUpdate.Click += new System.EventHandler(this.cmuUpdate_Click); // // cmuDelete // this.cmuDelete.Name = "cmuDelete"; - this.cmuDelete.Size = new System.Drawing.Size(112, 22); + this.cmuDelete.Size = new System.Drawing.Size(180, 22); this.cmuDelete.Text = "Delete"; // // splitContainer1 diff --git a/Louis'-Pharmacy_CNSA212-FP/frmRefill.cs b/Louis'-Pharmacy_CNSA212-FP/frmRefill.cs index 8e8813c..14a6534 100644 --- a/Louis'-Pharmacy_CNSA212-FP/frmRefill.cs +++ b/Louis'-Pharmacy_CNSA212-FP/frmRefill.cs @@ -17,6 +17,8 @@ namespace Louis__Pharmacy_CNSA212_FP { public partial class frmRefill : Form { + public DataSet ds = new DataSet(); + public frmRefill() { InitializeComponent(); @@ -39,7 +41,7 @@ namespace Louis__Pharmacy_CNSA212_FP try { - DataSet ds = new DataSet(); + //DataSet ds = new DataSet(); //PharmacyDataTier phaDT = new PharmacyDataTier(); patientID = txtPatientID.Text.Trim(); @@ -69,5 +71,31 @@ namespace Louis__Pharmacy_CNSA212_FP } } + + private void cmuAdd_Click(object sender, EventArgs e) + { + frmRefillAdd refillAdd = new frmRefillAdd(true); + refillAdd.MdiParent = MdiParent; + refillAdd.StartPosition = FormStartPosition.CenterScreen; + refillAdd.Show(); + refillAdd.Focus(); + } + + private void cmuUpdate_Click(object sender, EventArgs e) + { + string refillID = ""; + + dgvRefills.DataSource = ds.Tables[0]; + DataGridViewRow row = new DataGridViewRow(); + row = dgvRefills.SelectedRows[0]; + refillID = (row.Cells[0].Value).ToString(); + + frmRefillAdd refillUpdate = new frmRefillAdd(false); + refillUpdate.MdiParent = MdiParent; + refillUpdate.StartPosition = FormStartPosition.CenterScreen; + refillUpdate.Show(); + refillUpdate.Focus(); + refillUpdate.FillRefill(refillID); + } } } diff --git a/Louis'-Pharmacy_CNSA212-FP/frmRefillAdd.cs b/Louis'-Pharmacy_CNSA212-FP/frmRefillAdd.cs index 3a58acf..8d41aee 100644 --- a/Louis'-Pharmacy_CNSA212-FP/frmRefillAdd.cs +++ b/Louis'-Pharmacy_CNSA212-FP/frmRefillAdd.cs @@ -35,7 +35,6 @@ namespace Louis__Pharmacy_CNSA212_FP private void frmRefillAdd_Load(object sender, EventArgs e) { txtRefillID.Enabled = false; - string refillID = ""; if (isAdd) { @@ -44,10 +43,7 @@ namespace Louis__Pharmacy_CNSA212_FP } else { - DataSet ds = new DataSet(); - FillRefill(refillID); - txtRefillID.Text = ds.Tables[0].Rows[0]["Refill_id"].ToString(); } }