Working on add blocking functionality in the refill add form.

This commit is contained in:
Adam McCane 2024-02-20 01:24:59 -05:00
parent 8fad575e92
commit 263848a354
4 changed files with 115 additions and 65 deletions

View File

@ -529,6 +529,42 @@ namespace Louis__Pharmacy_CNSA212_FP
}
}
public static DataSet NumberofRefills(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 = "NumberofRefills";
// 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 static DataSet PhysicianInfoSearch(string fname,string lname, string phyID)
{

View File

@ -45,11 +45,6 @@ namespace Louis__Pharmacy_CNSA212_FP
this.bindingNavigatorSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this.rEFILLSBindingNavigatorSaveItem = new System.Windows.Forms.ToolStripButton();
this.dgvRefills = new System.Windows.Forms.DataGridView();
this.refillid = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.refilldate = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.patientid = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.medicationid = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.rxnumber = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.cmuRefill = new System.Windows.Forms.ContextMenuStrip(this.components);
this.cmuAdd = new System.Windows.Forms.ToolStripMenuItem();
this.cmuUpdate = new System.Windows.Forms.ToolStripMenuItem();
@ -60,6 +55,11 @@ namespace Louis__Pharmacy_CNSA212_FP
this.btnSearch = new System.Windows.Forms.Button();
this.lblPatientID = new System.Windows.Forms.Label();
this.lblDate = new System.Windows.Forms.Label();
this.refillid = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.refilldate = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.patientid = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.medicationid = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.rxnumber = new System.Windows.Forms.DataGridViewTextBoxColumn();
((System.ComponentModel.ISupportInitialize)(this.dgvRefills)).BeginInit();
this.cmuRefill.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
@ -147,39 +147,6 @@ namespace Louis__Pharmacy_CNSA212_FP
this.dgvRefills.Size = new System.Drawing.Size(625, 239);
this.dgvRefills.TabIndex = 0;
//
// refillid
//
this.refillid.DataPropertyName = "Refill_id";
this.refillid.HeaderText = "Refill ID";
this.refillid.Name = "refillid";
//
// refilldate
//
this.refilldate.DataPropertyName = "RefillDate";
dataGridViewCellStyle1.Format = "d";
dataGridViewCellStyle1.NullValue = null;
this.refilldate.DefaultCellStyle = dataGridViewCellStyle1;
this.refilldate.HeaderText = "Date of Refill";
this.refilldate.Name = "refilldate";
//
// patientid
//
this.patientid.DataPropertyName = "Patient_id";
this.patientid.HeaderText = "Patient ID";
this.patientid.Name = "patientid";
//
// medicationid
//
this.medicationid.DataPropertyName = "Medication_id";
this.medicationid.HeaderText = "Medication ID";
this.medicationid.Name = "medicationid";
//
// rxnumber
//
this.rxnumber.DataPropertyName = "RxNum";
this.rxnumber.HeaderText = "Rx Number";
this.rxnumber.Name = "rxnumber";
//
// cmuRefill
//
this.cmuRefill.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
@ -187,26 +154,26 @@ namespace Louis__Pharmacy_CNSA212_FP
this.cmuUpdate,
this.cmuDelete});
this.cmuRefill.Name = "contextMenuStrip1";
this.cmuRefill.Size = new System.Drawing.Size(181, 92);
this.cmuRefill.Size = new System.Drawing.Size(113, 70);
//
// cmuAdd
//
this.cmuAdd.Name = "cmuAdd";
this.cmuAdd.Size = new System.Drawing.Size(180, 22);
this.cmuAdd.Size = new System.Drawing.Size(112, 22);
this.cmuAdd.Text = "Add";
this.cmuAdd.Click += new System.EventHandler(this.cmuAdd_Click);
//
// cmuUpdate
//
this.cmuUpdate.Name = "cmuUpdate";
this.cmuUpdate.Size = new System.Drawing.Size(180, 22);
this.cmuUpdate.Size = new System.Drawing.Size(112, 22);
this.cmuUpdate.Text = "Update";
this.cmuUpdate.Click += new System.EventHandler(this.cmuUpdate_Click);
//
// cmuDelete
//
this.cmuDelete.Name = "cmuDelete";
this.cmuDelete.Size = new System.Drawing.Size(180, 22);
this.cmuDelete.Size = new System.Drawing.Size(112, 22);
this.cmuDelete.Text = "Delete";
this.cmuDelete.Click += new System.EventHandler(this.cmuDelete_Click);
//
@ -273,6 +240,39 @@ namespace Louis__Pharmacy_CNSA212_FP
this.lblDate.TabIndex = 0;
this.lblDate.Text = "Date of Refill:";
//
// refillid
//
this.refillid.DataPropertyName = "Refill_id";
this.refillid.HeaderText = "Refill ID";
this.refillid.Name = "refillid";
//
// refilldate
//
this.refilldate.DataPropertyName = "RefillDate";
dataGridViewCellStyle1.Format = "d";
dataGridViewCellStyle1.NullValue = null;
this.refilldate.DefaultCellStyle = dataGridViewCellStyle1;
this.refilldate.HeaderText = "Date of Refill";
this.refilldate.Name = "refilldate";
//
// patientid
//
this.patientid.DataPropertyName = "Patient_id";
this.patientid.HeaderText = "Patient ID";
this.patientid.Name = "patientid";
//
// medicationid
//
this.medicationid.DataPropertyName = "Medication_id";
this.medicationid.HeaderText = "Medication ID";
this.medicationid.Name = "medicationid";
//
// rxnumber
//
this.rxnumber.DataPropertyName = "RxNum_id";
this.rxnumber.HeaderText = "Rx Number ID";
this.rxnumber.Name = "rxnumber";
//
// frmRefill
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -324,11 +324,6 @@ namespace Louis__Pharmacy_CNSA212_FP
private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn14;
private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn15;
private System.Windows.Forms.DataGridView dgvRefills;
private System.Windows.Forms.DataGridViewTextBoxColumn refillid;
private System.Windows.Forms.DataGridViewTextBoxColumn refilldate;
private System.Windows.Forms.DataGridViewTextBoxColumn patientid;
private System.Windows.Forms.DataGridViewTextBoxColumn medicationid;
private System.Windows.Forms.DataGridViewTextBoxColumn rxnumber;
private System.Windows.Forms.ContextMenuStrip cmuRefill;
private System.Windows.Forms.ToolStripMenuItem cmuAdd;
private System.Windows.Forms.ToolStripMenuItem cmuUpdate;
@ -339,5 +334,10 @@ namespace Louis__Pharmacy_CNSA212_FP
private System.Windows.Forms.Button btnSearch;
private System.Windows.Forms.Label lblPatientID;
private System.Windows.Forms.Label lblDate;
private System.Windows.Forms.DataGridViewTextBoxColumn refillid;
private System.Windows.Forms.DataGridViewTextBoxColumn refilldate;
private System.Windows.Forms.DataGridViewTextBoxColumn patientid;
private System.Windows.Forms.DataGridViewTextBoxColumn medicationid;
private System.Windows.Forms.DataGridViewTextBoxColumn rxnumber;
}
}

View File

@ -41,7 +41,7 @@ namespace Louis__Pharmacy_CNSA212_FP
try
{
//DataSet ds = new DataSet();
DataSet ds = new DataSet();
//PharmacyDataTier phaDT = new PharmacyDataTier();
patientID = txtPatientID.Text.Trim();
@ -105,7 +105,7 @@ namespace Louis__Pharmacy_CNSA212_FP
{
string refillID = "";
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

@ -67,14 +67,27 @@ namespace Louis__Pharmacy_CNSA212_FP
string patientID = "";
string medicationID = "";
string rxNum = "";
string numRefills = "";
string pastNumRefills = "";
rxNum = txtRxNumber.Text.Trim();
DataSet ds = new DataSet();
ds = PharmacyDataTier.NumberofRefills(rxNum);
if (ds.Tables[0].Columns[0] == ds.Tables[0].Columns[1])
{
MessageBox.Show("This prescription has reached the maximum number of refills.", "Max Refill", MessageBoxButtons.OK, MessageBoxIcon.Error );
}
else
{
if (isAdd)
{
refillID = txtRefillID.Text.Trim();
date = DateTime.Parse(txtRefillDate.Text.Trim());
patientID = txtPatientID.Text.Trim();
medicationID = txtMedicationID.Text.Trim();
rxNum = txtRxNumber.Text.Trim();
PharmacyDataTier.AddRefill(refillID, date, patientID, medicationID, rxNum);
PharmacyDataTier.PastRefills(rxNum);
@ -92,4 +105,5 @@ namespace Louis__Pharmacy_CNSA212_FP
}
}
}
}