From c0d15fed57469f89c7f75e626b3de03f777adeff Mon Sep 17 00:00:00 2001 From: Adam McCane Date: Tue, 20 Feb 2024 23:57:48 -0500 Subject: [PATCH] Refill view functionality working. --- .../PharmacyDataTier.cs | 36 +++++++++++++++++++ Louis'-Pharmacy_CNSA212-FP/frmInfo.cs | 9 ++++- Louis'-Pharmacy_CNSA212-FP/frmMain.cs | 10 +++--- Louis'-Pharmacy_CNSA212-FP/frmRefill.cs | 21 ++++++++--- 4 files changed, 65 insertions(+), 11 deletions(-) diff --git a/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs b/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs index 4711c92..8cc429e 100644 --- a/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs +++ b/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs @@ -600,6 +600,42 @@ namespace Louis__Pharmacy_CNSA212_FP } } + public static DataSet GetRefill(string rxID) + { + try + { + // open connection + myConn.Open(); + //clear any parameters + cmdString.Parameters.Clear(); + // command + cmdString.Connection = myConn; + cmdString.CommandType = CommandType.StoredProcedure; + cmdString.CommandTimeout = 1500; + cmdString.CommandText = "GetRefills"; + // Define input parameter + cmdString.Parameters.Add("@rxID", SqlDbType.VarChar, 11).Value = rxID; + // adapter and dataset + SqlDataAdapter aAdapter = new SqlDataAdapter(); + aAdapter.SelectCommand = cmdString; + DataSet aDataSet = new DataSet(); + + // fill adapter + aAdapter.Fill(aDataSet); + + // return dataSet + return aDataSet; + } + catch (Exception ex) + { + throw new ArgumentException(ex.Message); + } + finally + { + myConn.Close(); + } + } + public DataSet NumberofRefills(string rxID) { try diff --git a/Louis'-Pharmacy_CNSA212-FP/frmInfo.cs b/Louis'-Pharmacy_CNSA212-FP/frmInfo.cs index 324ce50..af052f4 100644 --- a/Louis'-Pharmacy_CNSA212-FP/frmInfo.cs +++ b/Louis'-Pharmacy_CNSA212-FP/frmInfo.cs @@ -921,9 +921,16 @@ namespace Louis__Pharmacy_CNSA212_FP dgvMedication.Focus(); } - private void cmuPrescriptionViewRefills_Click(object sender, EventArgs e) + public void cmuPrescriptionViewRefills_Click(object sender, EventArgs e) { + DataGridViewRow row = new DataGridViewRow(); + row = dgvPrescription.SelectedRows[0]; + string rxNumString = (row.Cells[0].Value).ToString(); + Int32 rxNum = Int32.Parse(rxNumString); + frmRefill refill = new frmRefill(rxNum); + refill.ShowDialog(); + } } } diff --git a/Louis'-Pharmacy_CNSA212-FP/frmMain.cs b/Louis'-Pharmacy_CNSA212-FP/frmMain.cs index 9cac1ba..b837f17 100644 --- a/Louis'-Pharmacy_CNSA212-FP/frmMain.cs +++ b/Louis'-Pharmacy_CNSA212-FP/frmMain.cs @@ -67,12 +67,12 @@ namespace Louis__Pharmacy_CNSA212_FP private void mnuNavigationAURRefill_Click(object sender, EventArgs e) { - frmRefill formRefill = new frmRefill(); + //frmRefill formRefill = new frmRefill(); - formRefill.MdiParent = this; - formRefill.StartPosition = FormStartPosition.CenterScreen; - formRefill.Show(); - formRefill.Focus(); + //formRefill.MdiParent = this; + //formRefill.StartPosition = FormStartPosition.CenterScreen; + //formRefill.Show(); + //formRefill.Focus(); mnuNavigationAURRefill.Checked = true; } diff --git a/Louis'-Pharmacy_CNSA212-FP/frmRefill.cs b/Louis'-Pharmacy_CNSA212-FP/frmRefill.cs index e0d9cab..ce6b98c 100644 --- a/Louis'-Pharmacy_CNSA212-FP/frmRefill.cs +++ b/Louis'-Pharmacy_CNSA212-FP/frmRefill.cs @@ -18,10 +18,13 @@ namespace Louis__Pharmacy_CNSA212_FP public partial class frmRefill : Form { public DataSet ds = new DataSet(); + private int rxNum = 0; - public frmRefill() + public frmRefill(int thisRxID) { InitializeComponent(); + rxNum = thisRxID; + frmRefill_Load(null, null); } //private void rEFILLSBindingNavigatorSaveItem_Click(object sender, EventArgs e) @@ -29,10 +32,18 @@ namespace Louis__Pharmacy_CNSA212_FP //} - //private void frmRefill_Load(object sender, EventArgs e) - //{ - // dgvRefills.Visible = false; - //} + private void frmRefill_Load(object sender, EventArgs e) + { + int rxID = 0; + + DataGridViewRow row = new DataGridViewRow(); + rxID = rxNum; + + DataSet ds = new DataSet(); + ds = PharmacyDataTier.GetRefill(rxID.ToString()); + + dgvRefills.DataSource = ds.Tables[0]; + } //private void btnSearch_Click(object sender, EventArgs e) //{