Fixed update refill bug.

This commit is contained in:
Adam McCane 2024-02-20 14:57:03 -05:00
parent 545cd84540
commit c328e47946
2 changed files with 22 additions and 18 deletions

View File

@ -87,7 +87,7 @@ namespace Louis__Pharmacy_CNSA212_FP
if (dgvRefills.Rows.Count > 0)
{
dgvRefills.DataSource = ds.Tables[0];
//dgvRefills.DataSource = ds.Tables[0];
DataGridViewRow row = new DataGridViewRow();
row = dgvRefills.SelectedRows[0];
refillID = (row.Cells[0].Value).ToString();

View File

@ -14,6 +14,7 @@ namespace Louis__Pharmacy_CNSA212_FP
public partial class frmRefillAdd : Form
{
private static bool isAdd;
public DataSet ds = new DataSet();
public frmRefillAdd(bool isNew)
{
@ -57,7 +58,7 @@ namespace Louis__Pharmacy_CNSA212_FP
txtRefillDate.Text = ds.Tables[0].Rows[0]["RefillDate"].ToString();
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"].ToString();
txtRxNumber.Text = ds.Tables[0].Rows[0]["RxNum_id"].ToString();
}
private void btnAdd_Click(object sender, EventArgs e)
@ -82,6 +83,18 @@ namespace Louis__Pharmacy_CNSA212_FP
numRefills = Int32.Parse(ds.Tables[0].Rows[0]["numRefills"].ToString());
pastNumRefills = Int32.Parse(ds.Tables[0].Rows[0]["pastNumRefills"].ToString());
if (isAdd != true)
{
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);
}
else
{
if (numRefills == pastNumRefills)
{
MessageBox.Show("This prescription has reached the maximum number of refills.", "Max Refill", MessageBoxButtons.OK, MessageBoxIcon.Error);
@ -98,15 +111,6 @@ namespace Louis__Pharmacy_CNSA212_FP
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);
}
}
}