Merge remote-tracking branch 'origin/master'

This commit is contained in:
EggMan20339 2024-02-23 12:57:35 -05:00
commit 8d24db6807
10 changed files with 184 additions and 40 deletions

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="SqlDialectMappings">
<file url="dbSrc:///505d1dbd/8ad1107e-d5b4-4250-a780-1ee9739c8bad/database/FinalProjectOfficialPharmacy/schema/dbo/routine/PastRefills.sql" dialect="GenericSQL" />
</component>
</project>

View File

@ -434,7 +434,7 @@ namespace Louis__Pharmacy_CNSA212_FP
} }
catch (Exception ex) catch (Exception ex)
{ {
MessageBox.Show(precID + " Has an Associated Prescriptions. Could Not Delete", "Error", MessageBoxButtons.OK); MessageBox.Show(precID + " Has an Associated Refill. Could Not Delete", "Error", MessageBoxButtons.OK);
} }
finally finally
{ {
@ -1235,6 +1235,34 @@ namespace Louis__Pharmacy_CNSA212_FP
} }
} }
public static void DecrementPastRefills(string rxNum)
{
try
{
myConn.Open();
cmdString.Parameters.Clear();
cmdString.Connection = myConn;
cmdString.CommandType = CommandType.StoredProcedure;
cmdString.CommandTimeout = 1500;
cmdString.CommandText = "DecrementPastRefills";
cmdString.Parameters.Add("@Prescription_id", SqlDbType.VarChar, 11).Value = rxNum;
cmdString.ExecuteNonQuery();
}
catch (Exception ex)
{
throw new ArgumentException(ex.Message);
}
finally
{
myConn.Close();
}
}
public static void CreatePrescription( public static void CreatePrescription(
string RxNum, string RxNum,
string Patient_id, string Patient_id,

View File

@ -502,7 +502,7 @@ namespace Louis__Pharmacy_CNSA212_FP
if (dgvPatient.Rows.Count > 0) if (dgvPatient.Rows.Count > 0)
{ {
dgvPatient.DataSource = ds.Tables[0]; // dgvPatient.DataSource = ds.Tables[0];
DataGridViewRow row = new DataGridViewRow(); DataGridViewRow row = new DataGridViewRow();
row = dgvPatient.SelectedRows[0]; row = dgvPatient.SelectedRows[0];
string patid = ""; string patid = "";
@ -557,7 +557,7 @@ namespace Louis__Pharmacy_CNSA212_FP
if (dgvPhysician.Rows.Count > 0) if (dgvPhysician.Rows.Count > 0)
{ {
dgvPhysician.DataSource = ds.Tables[0]; // dgvPhysician.DataSource = ds.Tables[0];
DataGridViewRow row = new DataGridViewRow(); DataGridViewRow row = new DataGridViewRow();
row = dgvPhysician.SelectedRows[0]; row = dgvPhysician.SelectedRows[0];
string phyID = ""; string phyID = "";
@ -626,7 +626,7 @@ namespace Louis__Pharmacy_CNSA212_FP
if (dgvPrescription.Rows.Count > 0) if (dgvPrescription.Rows.Count > 0)
{ {
dgvPrescription.DataSource = ds.Tables[0]; // dgvPrescription.DataSource = ds.Tables[0];
DataGridViewRow row = new DataGridViewRow(); DataGridViewRow row = new DataGridViewRow();
row = dgvMedication.SelectedRows[0]; row = dgvMedication.SelectedRows[0];
string medID = ""; string medID = "";
@ -664,7 +664,7 @@ namespace Louis__Pharmacy_CNSA212_FP
if (dgvPrescription.Rows.Count > 0) if (dgvPrescription.Rows.Count > 0)
{ {
dgvPrescription.DataSource = ds.Tables[0]; //dgvPrescription.DataSource = ds.Tables[0];
// Console.WriteLine( dgvPatient.SelectedRows.Count); // Console.WriteLine( dgvPatient.SelectedRows.Count);
DataGridViewRow row = new DataGridViewRow(); DataGridViewRow row = new DataGridViewRow();
row = dgvPrescription.SelectedRows[0]; row = dgvPrescription.SelectedRows[0];
@ -688,7 +688,7 @@ namespace Louis__Pharmacy_CNSA212_FP
if (dgvPrescription.Rows.Count > 0) if (dgvPrescription.Rows.Count > 0)
{ {
dgvPrescription.DataSource = ds.Tables[0]; // dgvPrescription.DataSource = ds.Tables[0];
DataGridViewRow row = new DataGridViewRow(); DataGridViewRow row = new DataGridViewRow();
row = dgvPrescription.SelectedRows[0]; row = dgvPrescription.SelectedRows[0];
string PresID = ""; string PresID = "";

View File

@ -76,7 +76,8 @@ namespace Louis__Pharmacy_CNSA212_FP
txtWeight.Text = ds.Tables[0].Rows[0]["lbs"].ToString(); txtWeight.Text = ds.Tables[0].Rows[0]["lbs"].ToString();
txtHeightFt.Text = ds.Tables[0].Rows[0]["Height_feet"].ToString(); txtHeightFt.Text = ds.Tables[0].Rows[0]["Height_feet"].ToString();
txtHeightIn.Text = ds.Tables[0].Rows[0]["Height_inches"].ToString(); txtHeightIn.Text = ds.Tables[0].Rows[0]["Height_inches"].ToString();
txtDOB.Text = ds.Tables[0].Rows[0]["DOB"].ToString(); DateTime date = DateTime.Parse(ds.Tables[0].Rows[0]["DOB"].ToString());
txtDOB.Text = date.ToString("d");
cboGender.Text = ds.Tables[0].Rows[0]["Gender"].ToString(); cboGender.Text = ds.Tables[0].Rows[0]["Gender"].ToString();
txtCity.Text = ds.Tables[0].Rows[0]["City"].ToString(); txtCity.Text = ds.Tables[0].Rows[0]["City"].ToString();
txtZip.Text = ds.Tables[0].Rows[0]["Zip"].ToString(); txtZip.Text = ds.Tables[0].Rows[0]["Zip"].ToString();

View File

@ -1,7 +1,7 @@
using System; using System;
using System.ComponentModel;
using System.Data; using System.Data;
using System.Windows.Forms; using System.Windows.Forms;
using DateTime = System.DateTime;
namespace Louis__Pharmacy_CNSA212_FP namespace Louis__Pharmacy_CNSA212_FP
{ {
@ -119,8 +119,10 @@ namespace Louis__Pharmacy_CNSA212_FP
{ {
throw new Exception(); throw new Exception();
} }
else if (DOB > new DateTime(9999,1,1))
DOB = new DateTime(1753, 1, 1); {
throw new Exception();
}
} }
catch (Exception exception) catch (Exception exception)
{ {
@ -306,7 +308,8 @@ namespace Louis__Pharmacy_CNSA212_FP
txtFirstName.Text = ds.Tables[0].Rows[0]["FirstName"].ToString(); txtFirstName.Text = ds.Tables[0].Rows[0]["FirstName"].ToString();
txtLastName.Text = ds.Tables[0].Rows[0]["LastName"].ToString(); txtLastName.Text = ds.Tables[0].Rows[0]["LastName"].ToString();
txtMiddleInit.Text = ds.Tables[0].Rows[0]["MiddleIntials"].ToString(); txtMiddleInit.Text = ds.Tables[0].Rows[0]["MiddleIntials"].ToString();
txtDOB.Text = ds.Tables[0].Rows[0]["DOB"].ToString(); DateTime date = DateTime.Parse(ds.Tables[0].Rows[0]["DOB"].ToString());
txtDOB.Text = date.ToString("d");
txtGender.Text = ds.Tables[0].Rows[0]["Gender"].ToString(); txtGender.Text = ds.Tables[0].Rows[0]["Gender"].ToString();
txtCity.Text = ds.Tables[0].Rows[0]["City"].ToString(); txtCity.Text = ds.Tables[0].Rows[0]["City"].ToString();
txtZip.Text = ds.Tables[0].Rows[0]["Zip"].ToString(); txtZip.Text = ds.Tables[0].Rows[0]["Zip"].ToString();

View File

@ -29,6 +29,7 @@ namespace Louis__Pharmacy_CNSA212_FP
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.components = new System.ComponentModel.Container();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmRefill)); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmRefill));
this.bindingNavigatorAddNewItem = new System.Windows.Forms.ToolStripButton(); this.bindingNavigatorAddNewItem = new System.Windows.Forms.ToolStripButton();
@ -49,7 +50,12 @@ namespace Louis__Pharmacy_CNSA212_FP
this.patientid = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.patientid = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.medicationid = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.medicationid = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.rxnumber = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.rxnumber = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.cmuRefill = new System.Windows.Forms.ContextMenuStrip(this.components);
this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.deleteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.cmuRefresh = new System.Windows.Forms.ToolStripMenuItem();
((System.ComponentModel.ISupportInitialize)(this.dgvRefills)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dgvRefills)).BeginInit();
this.cmuRefill.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
// bindingNavigatorAddNewItem // bindingNavigatorAddNewItem
@ -124,17 +130,21 @@ namespace Louis__Pharmacy_CNSA212_FP
this.patientid, this.patientid,
this.medicationid, this.medicationid,
this.rxnumber}); this.rxnumber});
this.dgvRefills.ContextMenuStrip = this.cmuRefill;
this.dgvRefills.Location = new System.Drawing.Point(12, 12); this.dgvRefills.Location = new System.Drawing.Point(12, 12);
this.dgvRefills.Name = "dgvRefills"; this.dgvRefills.Name = "dgvRefills";
this.dgvRefills.ReadOnly = true;
this.dgvRefills.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.dgvRefills.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
this.dgvRefills.Size = new System.Drawing.Size(613, 298); this.dgvRefills.Size = new System.Drawing.Size(613, 298);
this.dgvRefills.TabIndex = 1; this.dgvRefills.TabIndex = 1;
this.dgvRefills.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgvRefills_CellDoubleClick);
// //
// refillid // refillid
// //
this.refillid.DataPropertyName = "Refill_id"; this.refillid.DataPropertyName = "Refill_id";
this.refillid.HeaderText = "Refill ID"; this.refillid.HeaderText = "Refill ID";
this.refillid.Name = "refillid"; this.refillid.Name = "refillid";
this.refillid.ReadOnly = true;
// //
// refilldate // refilldate
// //
@ -144,24 +154,58 @@ namespace Louis__Pharmacy_CNSA212_FP
this.refilldate.DefaultCellStyle = dataGridViewCellStyle1; this.refilldate.DefaultCellStyle = dataGridViewCellStyle1;
this.refilldate.HeaderText = "Date of Refill"; this.refilldate.HeaderText = "Date of Refill";
this.refilldate.Name = "refilldate"; this.refilldate.Name = "refilldate";
this.refilldate.ReadOnly = true;
// //
// patientid // patientid
// //
this.patientid.DataPropertyName = "Patient_id"; this.patientid.DataPropertyName = "Patient_id";
this.patientid.HeaderText = "Patient ID"; this.patientid.HeaderText = "Patient ID";
this.patientid.Name = "patientid"; this.patientid.Name = "patientid";
this.patientid.ReadOnly = true;
// //
// medicationid // medicationid
// //
this.medicationid.DataPropertyName = "Medication_id"; this.medicationid.DataPropertyName = "Medication_id";
this.medicationid.HeaderText = "Medication ID"; this.medicationid.HeaderText = "Medication ID";
this.medicationid.Name = "medicationid"; this.medicationid.Name = "medicationid";
this.medicationid.ReadOnly = true;
// //
// rxnumber // rxnumber
// //
this.rxnumber.DataPropertyName = "RxNum_id"; this.rxnumber.DataPropertyName = "RxNum_id";
this.rxnumber.HeaderText = "Rx Number ID"; this.rxnumber.HeaderText = "Rx Number ID";
this.rxnumber.Name = "rxnumber"; this.rxnumber.Name = "rxnumber";
this.rxnumber.ReadOnly = true;
//
// cmuRefill
//
this.cmuRefill.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.editToolStripMenuItem,
this.deleteToolStripMenuItem,
this.cmuRefresh});
this.cmuRefill.Name = "cmuRefill";
this.cmuRefill.Size = new System.Drawing.Size(181, 92);
//
// editToolStripMenuItem
//
this.editToolStripMenuItem.Name = "editToolStripMenuItem";
this.editToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.editToolStripMenuItem.Text = "Edit";
this.editToolStripMenuItem.Click += new System.EventHandler(this.editToolStripMenuItem_Click);
//
// deleteToolStripMenuItem
//
this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem";
this.deleteToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.deleteToolStripMenuItem.Text = "Delete";
this.deleteToolStripMenuItem.Click += new System.EventHandler(this.deleteToolStripMenuItem_Click);
//
// cmuRefresh
//
this.cmuRefresh.Name = "cmuRefresh";
this.cmuRefresh.Size = new System.Drawing.Size(180, 22);
this.cmuRefresh.Text = "Refresh";
this.cmuRefresh.Click += new System.EventHandler(this.cmuRefresh_Click);
// //
// frmRefill // frmRefill
// //
@ -174,6 +218,7 @@ namespace Louis__Pharmacy_CNSA212_FP
this.Name = "frmRefill"; this.Name = "frmRefill";
this.Text = "Louis\' Pharmacy - Prescription Refill"; this.Text = "Louis\' Pharmacy - Prescription Refill";
((System.ComponentModel.ISupportInitialize)(this.dgvRefills)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dgvRefills)).EndInit();
this.cmuRefill.ResumeLayout(false);
this.ResumeLayout(false); this.ResumeLayout(false);
} }
@ -212,5 +257,9 @@ namespace Louis__Pharmacy_CNSA212_FP
private System.Windows.Forms.DataGridViewTextBoxColumn patientid; private System.Windows.Forms.DataGridViewTextBoxColumn patientid;
private System.Windows.Forms.DataGridViewTextBoxColumn medicationid; private System.Windows.Forms.DataGridViewTextBoxColumn medicationid;
private System.Windows.Forms.DataGridViewTextBoxColumn rxnumber; private System.Windows.Forms.DataGridViewTextBoxColumn rxnumber;
private System.Windows.Forms.ContextMenuStrip cmuRefill;
private System.Windows.Forms.ToolStripMenuItem editToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem deleteToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem cmuRefresh;
} }
} }

View File

@ -45,6 +45,58 @@ namespace Louis__Pharmacy_CNSA212_FP
dgvRefills.DataSource = ds.Tables[0]; dgvRefills.DataSource = ds.Tables[0];
} }
private void editToolStripMenuItem_Click(object sender, EventArgs e)
{
string refillID = "";
DataGridViewRow row = new DataGridViewRow();
row = dgvRefills.SelectedRows[0];
refillID = (row.Cells[0].Value).ToString();
frmRefillAdd add = new frmRefillAdd(false);
add.MdiParent = MdiParent;
add.StartPosition = FormStartPosition.CenterScreen;
add.Show();
add.Focus();
add.FillRefill(refillID);
}
private void dgvRefills_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
editToolStripMenuItem_Click(sender, e);
}
private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
{
string refillID = "";
string rxID = "";
DataGridViewRow row = new DataGridViewRow();
row = dgvRefills.SelectedRows[0];
refillID = (row.Cells[0].Value).ToString();
rxID = (row.Cells[4].Value).ToString();
PharmacyDataTier.DeleteRefill(refillID);
PharmacyDataTier.DecrementPastRefills(rxID);
}
public void refreshrefills(object sender, EventArgs e)
{
DataGridViewRow row = new DataGridViewRow();
row = dgvRefills.SelectedRows[0];
string rxNumString = (row.Cells[4].Value).ToString();
Int32 rxNum = Int32.Parse(rxNumString);
frmRefill_Load(null, null);
}
private void cmuRefresh_Click(object sender, EventArgs e)
{
refreshrefills(sender, e);
}
//private void btnSearch_Click(object sender, EventArgs e) //private void btnSearch_Click(object sender, EventArgs e)
//{ //{
// string patientID = ""; // string patientID = "";

View File

@ -132,6 +132,9 @@
<metadata name="rxnumber.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="rxnumber.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>
<metadata name="cmuRefill.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> <assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value> <value>

View File

@ -160,6 +160,7 @@
this.Controls.Add(this.lblRefillID); this.Controls.Add(this.lblRefillID);
this.Name = "frmRefillAdd"; this.Name = "frmRefillAdd";
this.Text = "frmRefillAdd"; this.Text = "frmRefillAdd";
//this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.frmRefillAdd_FormClosed);
this.Load += new System.EventHandler(this.frmRefillAdd_Load); this.Load += new System.EventHandler(this.frmRefillAdd_Load);
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();

View File

@ -15,6 +15,7 @@ namespace Louis__Pharmacy_CNSA212_FP
{ {
private static bool isAdd; private static bool isAdd;
public DataSet ds = new DataSet(); public DataSet ds = new DataSet();
public string currentID = "";
public frmRefillAdd(bool isNew) public frmRefillAdd(bool isNew)
{ {
@ -59,6 +60,8 @@ namespace Louis__Pharmacy_CNSA212_FP
txtPatientID.Text = ds.Tables[0].Rows[0]["Patient_id"].ToString(); txtPatientID.Text = ds.Tables[0].Rows[0]["Patient_id"].ToString();
txtMedicationID.Text = ds.Tables[0].Rows[0]["Medication_id"].ToString(); txtMedicationID.Text = ds.Tables[0].Rows[0]["Medication_id"].ToString();
txtRxNumber.Text = ds.Tables[0].Rows[0]["RxNum_id"].ToString(); txtRxNumber.Text = ds.Tables[0].Rows[0]["RxNum_id"].ToString();
currentID = txtRxNumber.Text;
} }
private void btnAdd_Click(object sender, EventArgs e) private void btnAdd_Click(object sender, EventArgs e)
@ -91,27 +94,37 @@ namespace Louis__Pharmacy_CNSA212_FP
medicationID = txtMedicationID.Text.Trim(); medicationID = txtMedicationID.Text.Trim();
rxNum = txtRxNumber.Text.Trim(); rxNum = txtRxNumber.Text.Trim();
PharmacyDataTier.UpdateRefill(refillID, date, patientID, medicationID, rxNum); frmRefill refill = new frmRefill(0);
}
else
{
if (numRefills == pastNumRefills)
{
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();
PharmacyDataTier.AddRefill(refillID, date, patientID, medicationID, rxNum); PharmacyDataTier.UpdateRefill(refillID, date, patientID, medicationID, rxNum);
if (currentID != rxNum)
{
PharmacyDataTier.DecrementPastRefills(currentID);
PharmacyDataTier.PastRefills(rxNum); PharmacyDataTier.PastRefills(rxNum);
} }
} }
else
{
//if (numRefills == pastNumRefills)
//{
// 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();
// PharmacyDataTier.AddRefill(refillID, date, patientID, medicationID, rxNum);
// PharmacyDataTier.PastRefills(rxNum);
// }
//}
} }
} }
catch (Exception exception) catch (Exception exception)