From c645029540b7c4ff6bf6f8373bd90c3ea6497e8c Mon Sep 17 00:00:00 2001 From: Adam McCane Date: Fri, 16 Feb 2024 18:41:12 -0500 Subject: [PATCH] Did more work on the add/update functionality. --- .../PharmacyDataTier.cs | 22 ++++--------------- Louis'-Pharmacy_CNSA212-FP/frmRefillAdd.cs | 12 +++------- 2 files changed, 7 insertions(+), 27 deletions(-) diff --git a/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs b/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs index 281950b..9775fcc 100644 --- a/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs +++ b/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs @@ -473,7 +473,7 @@ namespace Louis__Pharmacy_CNSA212_FP } } - public DataSet AddRefill(string refillID, DateTime date, string patientID, string medicationID, string rxNum) + public static void AddRefill(string refillID, DateTime date, string patientID, string medicationID, string rxNum) { try { @@ -493,14 +493,7 @@ namespace Louis__Pharmacy_CNSA212_FP cmdString.Parameters.Add("@medicationID", SqlDbType.VarChar, 7).Value = medicationID; cmdString.Parameters.Add("@rxNum", SqlDbType.VarChar, 11).Value = rxNum; - SqlDataAdapter aAdapter = new SqlDataAdapter(); - - aAdapter.SelectCommand = cmdString; - DataSet aDataSet = new DataSet(); - - aAdapter.Fill(aDataSet); - - return aDataSet; + cmdString.ExecuteNonQuery(); } catch (Exception ex) { @@ -512,7 +505,7 @@ namespace Louis__Pharmacy_CNSA212_FP } } - public DataSet UpdateRefill(string refillID, DateTime date, string patientID, string medicationID, string rxNum) + public static void UpdateRefill(string refillID, DateTime date, string patientID, string medicationID, string rxNum) { try { @@ -532,14 +525,7 @@ namespace Louis__Pharmacy_CNSA212_FP cmdString.Parameters.Add("@medicationID", SqlDbType.VarChar, 7).Value = medicationID; cmdString.Parameters.Add("@rxNum", SqlDbType.VarChar, 11).Value = rxNum; - SqlDataAdapter aAdapter = new SqlDataAdapter(); - - aAdapter.SelectCommand = cmdString; - DataSet aDataSet = new DataSet(); - - aAdapter.Fill(aDataSet); - - return aDataSet; + cmdString.ExecuteNonQuery(); } catch (Exception ex) { diff --git a/Louis'-Pharmacy_CNSA212-FP/frmRefillAdd.cs b/Louis'-Pharmacy_CNSA212-FP/frmRefillAdd.cs index 71a7f59..3a58acf 100644 --- a/Louis'-Pharmacy_CNSA212-FP/frmRefillAdd.cs +++ b/Louis'-Pharmacy_CNSA212-FP/frmRefillAdd.cs @@ -46,8 +46,8 @@ namespace Louis__Pharmacy_CNSA212_FP { DataSet ds = new DataSet(); - txtRefillID.Text = ds.Tables[0].Rows[0]["Refill_id"].ToString(); FillRefill(refillID); + txtRefillID.Text = ds.Tables[0].Rows[0]["Refill_id"].ToString(); } } @@ -80,10 +80,7 @@ namespace Louis__Pharmacy_CNSA212_FP medicationID= txtMedicationID.Text.Trim(); rxNum = txtRxNumber.Text.Trim(); - DataSet ds = new DataSet(); - PharmacyDataTier phaDT = new PharmacyDataTier(); - - ds = phaDT.AddRefill(refillID, date, patientID, medicationID, rxNum); + PharmacyDataTier.AddRefill(refillID, date, patientID, medicationID, rxNum); } else { @@ -93,10 +90,7 @@ namespace Louis__Pharmacy_CNSA212_FP medicationID = txtMedicationID.Text.Trim(); rxNum = txtRxNumber.Text.Trim(); - DataSet ds = new DataSet(); - PharmacyDataTier phaDT = new PharmacyDataTier(); - - ds = phaDT.UpdateRefill(refillID, date, patientID, medicationID, rxNum); + PharmacyDataTier.UpdateRefill(refillID, date, patientID, medicationID, rxNum); } } }