2024-02-16 12:41:14 -05:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Linq;
|
2024-02-16 18:23:41 -05:00
|
|
|
|
using System.Net.NetworkInformation;
|
2024-02-16 12:41:14 -05:00
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
namespace Louis__Pharmacy_CNSA212_FP
|
|
|
|
|
{
|
|
|
|
|
public partial class frmRefillAdd : Form
|
|
|
|
|
{
|
2024-02-16 18:23:41 -05:00
|
|
|
|
private static bool isAdd;
|
|
|
|
|
|
|
|
|
|
public frmRefillAdd(bool isNew)
|
2024-02-16 12:41:14 -05:00
|
|
|
|
{
|
2024-02-16 18:23:41 -05:00
|
|
|
|
isAdd = isNew;
|
2024-02-16 12:41:14 -05:00
|
|
|
|
InitializeComponent();
|
2024-02-16 18:23:41 -05:00
|
|
|
|
|
|
|
|
|
if (isNew)
|
|
|
|
|
{
|
|
|
|
|
lblPurpose.Text = "Add Refill";
|
|
|
|
|
btnAdd.Text = "Add";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
lblPurpose.Text = "Edit Refill";
|
|
|
|
|
btnAdd.Text = "Edit";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void frmRefillAdd_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
txtRefillID.Enabled = false;
|
|
|
|
|
|
|
|
|
|
if (isAdd)
|
|
|
|
|
{
|
|
|
|
|
double nextID = PharmacyDataTier.GetNextRefillID();
|
|
|
|
|
txtRefillID.Text = nextID.ToString();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void FillRefill(string refillID)
|
|
|
|
|
{
|
|
|
|
|
DataSet ds = new DataSet();
|
|
|
|
|
PharmacyDataTier data = new PharmacyDataTier();
|
|
|
|
|
|
|
|
|
|
ds = PharmacyDataTier.RefillSearch(refillID);
|
|
|
|
|
txtRefillID.Text = ds.Tables[0].Rows[0]["Refill_id"].ToString();
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnAdd_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
string refillID = "";
|
|
|
|
|
DateTime date = new DateTime();
|
|
|
|
|
string patientID = "";
|
|
|
|
|
string medicationID = "";
|
|
|
|
|
string rxNum = "";
|
2024-02-20 01:24:59 -05:00
|
|
|
|
string numRefills = "";
|
|
|
|
|
string pastNumRefills = "";
|
2024-02-16 18:23:41 -05:00
|
|
|
|
|
2024-02-20 01:24:59 -05:00
|
|
|
|
rxNum = txtRxNumber.Text.Trim();
|
|
|
|
|
|
|
|
|
|
DataSet ds = new DataSet();
|
|
|
|
|
|
|
|
|
|
ds = PharmacyDataTier.NumberofRefills(rxNum);
|
|
|
|
|
|
|
|
|
|
if (ds.Tables[0].Columns[0] == ds.Tables[0].Columns[1])
|
2024-02-16 18:23:41 -05:00
|
|
|
|
{
|
2024-02-20 01:24:59 -05:00
|
|
|
|
MessageBox.Show("This prescription has reached the maximum number of refills.", "Max Refill", MessageBoxButtons.OK, MessageBoxIcon.Error );
|
2024-02-16 18:23:41 -05:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2024-02-20 01:24:59 -05:00
|
|
|
|
if (isAdd)
|
|
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
refillID = txtRefillID.Text.Trim();
|
|
|
|
|
date = DateTime.Parse(txtRefillDate.Text.Trim());
|
|
|
|
|
patientID = txtPatientID.Text.Trim();
|
|
|
|
|
medicationID = txtMedicationID.Text.Trim();
|
|
|
|
|
rxNum = txtRxNumber.Text.Trim();
|
2024-02-16 18:23:41 -05:00
|
|
|
|
|
2024-02-20 01:24:59 -05:00
|
|
|
|
PharmacyDataTier.UpdateRefill(refillID, date, patientID, medicationID, rxNum);
|
|
|
|
|
}
|
2024-02-16 18:23:41 -05:00
|
|
|
|
}
|
2024-02-16 12:41:14 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-02-16 18:23:41 -05:00
|
|
|
|
|