diff --git a/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs b/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs index b05bb67..ed85b86 100644 --- a/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs +++ b/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs @@ -529,7 +529,7 @@ namespace Louis__Pharmacy_CNSA212_FP } } - public static DataSet NumberofRefills(string rxID) + public DataSet NumberofRefills(string rxID) { try { diff --git a/Louis'-Pharmacy_CNSA212-FP/frmAbout.Designer.cs b/Louis'-Pharmacy_CNSA212-FP/frmAbout.Designer.cs index b65440d..245d17f 100644 --- a/Louis'-Pharmacy_CNSA212-FP/frmAbout.Designer.cs +++ b/Louis'-Pharmacy_CNSA212-FP/frmAbout.Designer.cs @@ -137,8 +137,8 @@ this.textBoxDescription.Size = new System.Drawing.Size(271, 126); this.textBoxDescription.TabIndex = 23; this.textBoxDescription.TabStop = false; - this.textBoxDescription.Text = "This application is designed to efficiently update and add information into our d" + - "atabase."; + this.textBoxDescription.Text = "This application is designed to efficiently manipulate database information regar" + + "ding patients, physicians, prescriptions, medications, and refills."; // // okButton // diff --git a/Louis'-Pharmacy_CNSA212-FP/frmRefillAdd.cs b/Louis'-Pharmacy_CNSA212-FP/frmRefillAdd.cs index b0338a3..b59238e 100644 --- a/Louis'-Pharmacy_CNSA212-FP/frmRefillAdd.cs +++ b/Louis'-Pharmacy_CNSA212-FP/frmRefillAdd.cs @@ -67,42 +67,53 @@ namespace Louis__Pharmacy_CNSA212_FP string patientID = ""; string medicationID = ""; string rxNum = ""; - string numRefills = ""; - string pastNumRefills = ""; + Int32 numRefills = 0; + Int32 pastNumRefills = 0; rxNum = txtRxNumber.Text.Trim(); - DataSet ds = new DataSet(); - - ds = PharmacyDataTier.NumberofRefills(rxNum); - - if (ds.Tables[0].Columns[0] == ds.Tables[0].Columns[1]) + try { - MessageBox.Show("This prescription has reached the maximum number of refills.", "Max Refill", MessageBoxButtons.OK, MessageBoxIcon.Error ); - } - else - { - if (isAdd) + DataSet ds = new DataSet(); + PharmacyDataTier phaDT = new PharmacyDataTier(); + + ds = phaDT.NumberofRefills(rxNum); + + numRefills = Int32.Parse(ds.Tables[0].Rows[0]["numRefills"].ToString()); + pastNumRefills = Int32.Parse(ds.Tables[0].Rows[0]["pastNumRefills"].ToString()); + + if (numRefills == pastNumRefills) { - 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); + MessageBox.Show("This prescription has reached the maximum number of refills.", "Max Refill", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { - refillID = txtRefillID.Text.Trim(); - date = DateTime.Parse(txtRefillDate.Text.Trim()); - patientID = txtPatientID.Text.Trim(); - medicationID = txtMedicationID.Text.Trim(); - rxNum = txtRxNumber.Text.Trim(); + if (isAdd) + { + refillID = txtRefillID.Text.Trim(); + date = DateTime.Parse(txtRefillDate.Text.Trim()); + patientID = txtPatientID.Text.Trim(); + medicationID = txtMedicationID.Text.Trim(); - PharmacyDataTier.UpdateRefill(refillID, date, patientID, medicationID, rxNum); + PharmacyDataTier.AddRefill(refillID, date, patientID, medicationID, rxNum); + PharmacyDataTier.PastRefills(rxNum); + } + else + { + refillID = txtRefillID.Text.Trim(); + date = DateTime.Parse(txtRefillDate.Text.Trim()); + patientID = txtPatientID.Text.Trim(); + medicationID = txtMedicationID.Text.Trim(); + rxNum = txtRxNumber.Text.Trim(); + + PharmacyDataTier.UpdateRefill(refillID, date, patientID, medicationID, rxNum); + } } } + catch (Exception exception) + { + + } } } }