diff --git a/.idea/.idea.Louis' Pharmacy/.idea/sqldialects.xml b/.idea/.idea.Louis' Pharmacy/.idea/sqldialects.xml deleted file mode 100644 index d6fa49f..0000000 --- a/.idea/.idea.Louis' Pharmacy/.idea/sqldialects.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs b/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs index de40a46..5f38112 100644 --- a/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs +++ b/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs @@ -434,7 +434,7 @@ namespace Louis__Pharmacy_CNSA212_FP } 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 { @@ -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( string RxNum, string Patient_id, diff --git a/Louis'-Pharmacy_CNSA212-FP/frmInfo.cs b/Louis'-Pharmacy_CNSA212-FP/frmInfo.cs index 11c384b..93ce7b8 100644 --- a/Louis'-Pharmacy_CNSA212-FP/frmInfo.cs +++ b/Louis'-Pharmacy_CNSA212-FP/frmInfo.cs @@ -502,7 +502,7 @@ namespace Louis__Pharmacy_CNSA212_FP if (dgvPatient.Rows.Count > 0) { - dgvPatient.DataSource = ds.Tables[0]; + // dgvPatient.DataSource = ds.Tables[0]; DataGridViewRow row = new DataGridViewRow(); row = dgvPatient.SelectedRows[0]; string patid = ""; @@ -557,7 +557,7 @@ namespace Louis__Pharmacy_CNSA212_FP if (dgvPhysician.Rows.Count > 0) { - dgvPhysician.DataSource = ds.Tables[0]; + // dgvPhysician.DataSource = ds.Tables[0]; DataGridViewRow row = new DataGridViewRow(); row = dgvPhysician.SelectedRows[0]; string phyID = ""; @@ -626,7 +626,7 @@ namespace Louis__Pharmacy_CNSA212_FP if (dgvPrescription.Rows.Count > 0) { - dgvPrescription.DataSource = ds.Tables[0]; + // dgvPrescription.DataSource = ds.Tables[0]; DataGridViewRow row = new DataGridViewRow(); row = dgvMedication.SelectedRows[0]; string medID = ""; @@ -664,7 +664,7 @@ namespace Louis__Pharmacy_CNSA212_FP if (dgvPrescription.Rows.Count > 0) { - dgvPrescription.DataSource = ds.Tables[0]; + //dgvPrescription.DataSource = ds.Tables[0]; // Console.WriteLine( dgvPatient.SelectedRows.Count); DataGridViewRow row = new DataGridViewRow(); row = dgvPrescription.SelectedRows[0]; @@ -688,7 +688,7 @@ namespace Louis__Pharmacy_CNSA212_FP if (dgvPrescription.Rows.Count > 0) { - dgvPrescription.DataSource = ds.Tables[0]; + // dgvPrescription.DataSource = ds.Tables[0]; DataGridViewRow row = new DataGridViewRow(); row = dgvPrescription.SelectedRows[0]; string PresID = ""; diff --git a/Louis'-Pharmacy_CNSA212-FP/frmPatient.cs b/Louis'-Pharmacy_CNSA212-FP/frmPatient.cs index 5008a09..157ec84 100644 --- a/Louis'-Pharmacy_CNSA212-FP/frmPatient.cs +++ b/Louis'-Pharmacy_CNSA212-FP/frmPatient.cs @@ -76,7 +76,8 @@ namespace Louis__Pharmacy_CNSA212_FP txtWeight.Text = ds.Tables[0].Rows[0]["lbs"].ToString(); txtHeightFt.Text = ds.Tables[0].Rows[0]["Height_feet"].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(); txtCity.Text = ds.Tables[0].Rows[0]["City"].ToString(); txtZip.Text = ds.Tables[0].Rows[0]["Zip"].ToString(); diff --git a/Louis'-Pharmacy_CNSA212-FP/frmPhysician.cs b/Louis'-Pharmacy_CNSA212-FP/frmPhysician.cs index 64c80fc..94e8805 100644 --- a/Louis'-Pharmacy_CNSA212-FP/frmPhysician.cs +++ b/Louis'-Pharmacy_CNSA212-FP/frmPhysician.cs @@ -1,7 +1,7 @@ using System; +using System.ComponentModel; using System.Data; using System.Windows.Forms; -using DateTime = System.DateTime; namespace Louis__Pharmacy_CNSA212_FP { @@ -119,8 +119,10 @@ namespace Louis__Pharmacy_CNSA212_FP { throw new Exception(); } - else - DOB = new DateTime(1753, 1, 1); + if (DOB > new DateTime(9999,1,1)) + { + throw new Exception(); + } } catch (Exception exception) { @@ -306,7 +308,8 @@ namespace Louis__Pharmacy_CNSA212_FP txtFirstName.Text = ds.Tables[0].Rows[0]["FirstName"].ToString(); txtLastName.Text = ds.Tables[0].Rows[0]["LastName"].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(); txtCity.Text = ds.Tables[0].Rows[0]["City"].ToString(); txtZip.Text = ds.Tables[0].Rows[0]["Zip"].ToString(); diff --git a/Louis'-Pharmacy_CNSA212-FP/frmRefill.Designer.cs b/Louis'-Pharmacy_CNSA212-FP/frmRefill.Designer.cs index b2539b7..ff10e53 100644 --- a/Louis'-Pharmacy_CNSA212-FP/frmRefill.Designer.cs +++ b/Louis'-Pharmacy_CNSA212-FP/frmRefill.Designer.cs @@ -29,6 +29,7 @@ namespace Louis__Pharmacy_CNSA212_FP /// private void InitializeComponent() { + this.components = new System.ComponentModel.Container(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmRefill)); this.bindingNavigatorAddNewItem = new System.Windows.Forms.ToolStripButton(); @@ -49,7 +50,12 @@ namespace Louis__Pharmacy_CNSA212_FP 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.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(); + this.cmuRefill.SuspendLayout(); this.SuspendLayout(); // // bindingNavigatorAddNewItem @@ -124,17 +130,21 @@ namespace Louis__Pharmacy_CNSA212_FP this.patientid, this.medicationid, this.rxnumber}); + this.dgvRefills.ContextMenuStrip = this.cmuRefill; this.dgvRefills.Location = new System.Drawing.Point(12, 12); this.dgvRefills.Name = "dgvRefills"; + this.dgvRefills.ReadOnly = true; this.dgvRefills.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.dgvRefills.Size = new System.Drawing.Size(613, 298); this.dgvRefills.TabIndex = 1; + this.dgvRefills.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgvRefills_CellDoubleClick); // // refillid // this.refillid.DataPropertyName = "Refill_id"; this.refillid.HeaderText = "Refill ID"; this.refillid.Name = "refillid"; + this.refillid.ReadOnly = true; // // refilldate // @@ -144,24 +154,58 @@ namespace Louis__Pharmacy_CNSA212_FP this.refilldate.DefaultCellStyle = dataGridViewCellStyle1; this.refilldate.HeaderText = "Date of Refill"; this.refilldate.Name = "refilldate"; + this.refilldate.ReadOnly = true; // // patientid // this.patientid.DataPropertyName = "Patient_id"; this.patientid.HeaderText = "Patient ID"; this.patientid.Name = "patientid"; + this.patientid.ReadOnly = true; // // medicationid // this.medicationid.DataPropertyName = "Medication_id"; this.medicationid.HeaderText = "Medication ID"; this.medicationid.Name = "medicationid"; + this.medicationid.ReadOnly = true; // // rxnumber // this.rxnumber.DataPropertyName = "RxNum_id"; this.rxnumber.HeaderText = "Rx Number ID"; 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 // @@ -174,6 +218,7 @@ namespace Louis__Pharmacy_CNSA212_FP this.Name = "frmRefill"; this.Text = "Louis\' Pharmacy - Prescription Refill"; ((System.ComponentModel.ISupportInitialize)(this.dgvRefills)).EndInit(); + this.cmuRefill.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 medicationid; 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; } } \ No newline at end of file diff --git a/Louis'-Pharmacy_CNSA212-FP/frmRefill.cs b/Louis'-Pharmacy_CNSA212-FP/frmRefill.cs index ce6b98c..2e69b6d 100644 --- a/Louis'-Pharmacy_CNSA212-FP/frmRefill.cs +++ b/Louis'-Pharmacy_CNSA212-FP/frmRefill.cs @@ -45,6 +45,58 @@ namespace Louis__Pharmacy_CNSA212_FP 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) //{ // string patientID = ""; @@ -52,14 +104,14 @@ namespace Louis__Pharmacy_CNSA212_FP // try // { - //DataSet ds = new DataSet(); - //PharmacyDataTier phaDT = new PharmacyDataTier(); + //DataSet ds = new DataSet(); + //PharmacyDataTier phaDT = new PharmacyDataTier(); - //patientID = txtPatientID.Text.Trim(); - //if (txtDate.Text.Trim().Length > 0) - //{ - //date = DateTime.Parse(txtDate.Text.Trim()); - //} + //patientID = txtPatientID.Text.Trim(); + //if (txtDate.Text.Trim().Length > 0) + //{ + //date = DateTime.Parse(txtDate.Text.Trim()); + //} // ds = PharmacyDataTier.RefillSearch(date, patientID); diff --git a/Louis'-Pharmacy_CNSA212-FP/frmRefill.resx b/Louis'-Pharmacy_CNSA212-FP/frmRefill.resx index a0d70f5..0a6275b 100644 --- a/Louis'-Pharmacy_CNSA212-FP/frmRefill.resx +++ b/Louis'-Pharmacy_CNSA212-FP/frmRefill.resx @@ -132,6 +132,9 @@ True + + 17, 17 + diff --git a/Louis'-Pharmacy_CNSA212-FP/frmRefillAdd.Designer.cs b/Louis'-Pharmacy_CNSA212-FP/frmRefillAdd.Designer.cs index d510f44..a205ad3 100644 --- a/Louis'-Pharmacy_CNSA212-FP/frmRefillAdd.Designer.cs +++ b/Louis'-Pharmacy_CNSA212-FP/frmRefillAdd.Designer.cs @@ -160,6 +160,7 @@ this.Controls.Add(this.lblRefillID); this.Name = "frmRefillAdd"; this.Text = "frmRefillAdd"; + //this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.frmRefillAdd_FormClosed); this.Load += new System.EventHandler(this.frmRefillAdd_Load); this.ResumeLayout(false); this.PerformLayout(); diff --git a/Louis'-Pharmacy_CNSA212-FP/frmRefillAdd.cs b/Louis'-Pharmacy_CNSA212-FP/frmRefillAdd.cs index d765f73..0e69812 100644 --- a/Louis'-Pharmacy_CNSA212-FP/frmRefillAdd.cs +++ b/Louis'-Pharmacy_CNSA212-FP/frmRefillAdd.cs @@ -15,6 +15,7 @@ namespace Louis__Pharmacy_CNSA212_FP { private static bool isAdd; public DataSet ds = new DataSet(); + public string currentID = ""; public frmRefillAdd(bool isNew) { @@ -59,6 +60,8 @@ namespace Louis__Pharmacy_CNSA212_FP 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_id"].ToString(); + + currentID = txtRxNumber.Text; } private void btnAdd_Click(object sender, EventArgs e) @@ -91,27 +94,37 @@ namespace Louis__Pharmacy_CNSA212_FP medicationID = txtMedicationID.Text.Trim(); rxNum = txtRxNumber.Text.Trim(); + frmRefill refill = new frmRefill(0); + PharmacyDataTier.UpdateRefill(refillID, date, patientID, medicationID, rxNum); + + if (currentID != rxNum) + { + PharmacyDataTier.DecrementPastRefills(currentID); + 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(); + //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); - } - } + // PharmacyDataTier.AddRefill(refillID, date, patientID, medicationID, rxNum); + // PharmacyDataTier.PastRefills(rxNum); + // } + //} } } catch (Exception exception)