have basic functionalityto add, update, and delete prec

This commit is contained in:
EggMan20339 2024-02-20 20:05:18 -05:00
parent 3cb55ac80b
commit 161c794162
5 changed files with 167 additions and 71 deletions

View File

@ -413,6 +413,36 @@ namespace Louis__Pharmacy_CNSA212_FP
}
public static void DeletePrescription(string precID)
{
try
{
// open connection
myConn.Open();
//clear any parameters
cmdString.Parameters.Clear();
// command
cmdString.Connection = myConn;
cmdString.CommandType = CommandType.StoredProcedure;
cmdString.CommandTimeout = 1500;
cmdString.CommandText = "DeletePrescription";
// Define input parameter
cmdString.Parameters.Add("@RxID", SqlDbType.VarChar, 11).Value = precID;
cmdString.ExecuteNonQuery();
}
catch (Exception ex)
{
throw new ArgumentException(ex.Message);
}
finally
{
myConn.Close();
}
}
public static DataSet PatientInfoSearch(string id, string lname, string fname)

View File

@ -285,22 +285,7 @@ namespace Louis__Pharmacy_CNSA212_FP
this.dgvPatient.AllowUserToAddRows = false;
this.dgvPatient.AllowUserToDeleteRows = false;
this.dgvPatient.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dgvPatient.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.pat_id,
this.FirstName,
this.LastName,
this.MiddleInitials,
this.City,
this.UsState,
this.Zip,
this.Ibs,
this.Height_feet,
this.Height_inches,
this.Ailment,
this.DOB,
this.PhoneNumber,
this.Gender,
this.Medications});
this.dgvPatient.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.pat_id, this.FirstName, this.LastName, this.MiddleInitials, this.City, this.UsState, this.Zip, this.Ibs, this.Height_feet, this.Height_inches, this.Ailment, this.DOB, this.PhoneNumber, this.Gender, this.Medications });
this.dgvPatient.ContextMenuStrip = this.cmuPatient;
this.dgvPatient.EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically;
this.dgvPatient.Location = new System.Drawing.Point(0, 0);
@ -454,10 +439,7 @@ namespace Louis__Pharmacy_CNSA212_FP
// cmuPatient
//
this.cmuPatient.ImageScalingSize = new System.Drawing.Size(20, 20);
this.cmuPatient.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.cmuPatientNew,
this.cmuPatientEdit,
this.cmuPatientDelete});
this.cmuPatient.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.cmuPatientNew, this.cmuPatientEdit, this.cmuPatientDelete });
this.cmuPatient.Name = "contextMenuStrip1";
this.cmuPatient.Size = new System.Drawing.Size(108, 70);
//
@ -562,14 +544,7 @@ namespace Louis__Pharmacy_CNSA212_FP
this.dgvPrescription.AllowUserToAddRows = false;
this.dgvPrescription.AllowUserToDeleteRows = false;
this.dgvPrescription.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dgvPrescription.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.Medication_id,
this.MedicationName,
this.IntakeMethod,
this.Frequency,
this.Dosage,
this.Purpose,
this.RxNum});
this.dgvPrescription.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.Medication_id, this.MedicationName, this.IntakeMethod, this.Frequency, this.Dosage, this.Purpose, this.RxNum });
this.dgvPrescription.ContextMenuStrip = this.cmuMedication;
this.dgvPrescription.Location = new System.Drawing.Point(3, 3);
this.dgvPrescription.Name = "dgvPrescription";
@ -645,10 +620,7 @@ namespace Louis__Pharmacy_CNSA212_FP
// cmuMedication
//
this.cmuMedication.ImageScalingSize = new System.Drawing.Size(20, 20);
this.cmuMedication.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.cmuMedicationNew,
this.cmuMedicationEdit,
this.cmuMedicationDelete});
this.cmuMedication.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.cmuMedicationNew, this.cmuMedicationEdit, this.cmuMedicationDelete });
this.cmuMedication.Name = "cmuMedication";
this.cmuMedication.Size = new System.Drawing.Size(108, 70);
//
@ -757,18 +729,7 @@ namespace Louis__Pharmacy_CNSA212_FP
this.dgvPhysician.AllowUserToAddRows = false;
this.dgvPhysician.AllowUserToDeleteRows = false;
this.dgvPhysician.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dgvPhysician.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.Phys_id,
this.namefirst,
this.namelast,
this.initialsmiddle,
this.cit,
this.state,
this.zipp,
this.dobb,
this.numberphone,
this.gennder,
this.Specialty});
this.dgvPhysician.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.Phys_id, this.namefirst, this.namelast, this.initialsmiddle, this.cit, this.state, this.zipp, this.dobb, this.numberphone, this.gennder, this.Specialty });
this.dgvPhysician.ContextMenuStrip = this.cmuPhysician;
this.dgvPhysician.Location = new System.Drawing.Point(0, 3);
this.dgvPhysician.Name = "dgvPhysician";
@ -884,10 +845,7 @@ namespace Louis__Pharmacy_CNSA212_FP
// cmuPhysician
//
this.cmuPhysician.ImageScalingSize = new System.Drawing.Size(20, 20);
this.cmuPhysician.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.cmuPhysicianNew,
this.cmuPhysicianEdit,
this.cmuPhysicianDelete});
this.cmuPhysician.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.cmuPhysicianNew, this.cmuPhysicianEdit, this.cmuPhysicianDelete });
this.cmuPhysician.Name = "cmuPhysician";
this.cmuPhysician.Size = new System.Drawing.Size(108, 70);
//
@ -1013,6 +971,7 @@ namespace Louis__Pharmacy_CNSA212_FP
this.dgvRx.ContextMenuStrip = this.cmuPrescription;
this.dgvRx.Location = new System.Drawing.Point(0, 236);
this.dgvRx.Name = "dgvRx";
this.dgvRx.ReadOnly = true;
this.dgvRx.RowHeadersWidth = 51;
this.dgvRx.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
this.dgvRx.Size = new System.Drawing.Size(730, 248);
@ -1022,14 +981,9 @@ namespace Louis__Pharmacy_CNSA212_FP
// cmuPrescription
//
this.cmuPrescription.ImageScalingSize = new System.Drawing.Size(20, 20);
this.cmuPrescription.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.cmuPrescriptionNew,
this.cmuPrescriptionEdit,
this.cmuPrescriptionDelete,
this.cmuPrescriptionRefillThis,
this.cmuPrescriptionViewRefills});
this.cmuPrescription.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.cmuPrescriptionNew, this.cmuPrescriptionEdit, this.cmuPrescriptionDelete, this.cmuPrescriptionRefillThis, this.cmuPrescriptionViewRefills });
this.cmuPrescription.Name = "cmuPrescription";
this.cmuPrescription.Size = new System.Drawing.Size(244, 136);
this.cmuPrescription.Size = new System.Drawing.Size(244, 114);
//
// cmuPrescriptionNew
//
@ -1106,7 +1060,6 @@ namespace Louis__Pharmacy_CNSA212_FP
((System.ComponentModel.ISupportInitialize)(this.dgvRx)).EndInit();
this.cmuPrescription.ResumeLayout(false);
this.ResumeLayout(false);
}
private System.Windows.Forms.ToolStripMenuItem cmuPrescriptionViewRefills;

View File

@ -668,6 +668,25 @@ namespace Louis__Pharmacy_CNSA212_FP
private void cmuPrescriptionDelete_Click(object sender, EventArgs e)
{
if (dgvRx.Rows.Count > 0)
{
dgvRx.DataSource = ds.Tables[0];
DataGridViewRow row = new DataGridViewRow();
row = dgvRx.SelectedRows[0];
string PresID = "";
PresID = (row.Cells[0].Value).ToString();
DialogResult dialogResult = MessageBox.Show("Are you sure you want to delete Prescription: " + PresID,
"Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (dialogResult == DialogResult.Yes)
{
PharmacyDataTier.DeletePrescription(PresID);
}
btnRxSearch_Click(sender, e);
}
}
private void cmuPrescriptionNew_Click_1(object sender, EventArgs e)

View File

@ -51,58 +51,65 @@ namespace Louis__Pharmacy_CNSA212_FP
// txtMaxRefills
//
this.txtMaxRefills.Location = new System.Drawing.Point(325, 282);
this.txtMaxRefills.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.txtMaxRefills.Margin = new System.Windows.Forms.Padding(2);
this.txtMaxRefills.Name = "txtMaxRefills";
this.txtMaxRefills.Size = new System.Drawing.Size(123, 20);
this.txtMaxRefills.TabIndex = 33;
this.txtMaxRefills.TextChanged += new System.EventHandler(this.txtMaxRefills_TextChanged_1);
//
// txtCompletedRefills
//
this.txtCompletedRefills.Location = new System.Drawing.Point(325, 254);
this.txtCompletedRefills.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.txtCompletedRefills.Margin = new System.Windows.Forms.Padding(2);
this.txtCompletedRefills.Name = "txtCompletedRefills";
this.txtCompletedRefills.Size = new System.Drawing.Size(123, 20);
this.txtCompletedRefills.TabIndex = 32;
this.txtCompletedRefills.TextChanged += new System.EventHandler(this.txtCompletedRefills_TextChanged_1);
//
// txtPhysID
//
this.txtPhysID.Location = new System.Drawing.Point(325, 227);
this.txtPhysID.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.txtPhysID.Margin = new System.Windows.Forms.Padding(2);
this.txtPhysID.Name = "txtPhysID";
this.txtPhysID.Size = new System.Drawing.Size(123, 20);
this.txtPhysID.TabIndex = 31;
this.txtPhysID.TextChanged += new System.EventHandler(this.txtPhysID_TextChanged_1);
//
// txtPhysName
//
this.txtPhysName.Location = new System.Drawing.Point(325, 198);
this.txtPhysName.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.txtPhysName.Margin = new System.Windows.Forms.Padding(2);
this.txtPhysName.Name = "txtPhysName";
this.txtPhysName.Size = new System.Drawing.Size(123, 20);
this.txtPhysName.TabIndex = 30;
this.txtPhysName.TextChanged += new System.EventHandler(this.txtPhysName_TextChanged_1);
//
// txtMedID
//
this.txtMedID.Location = new System.Drawing.Point(325, 171);
this.txtMedID.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.txtMedID.Margin = new System.Windows.Forms.Padding(2);
this.txtMedID.Name = "txtMedID";
this.txtMedID.Size = new System.Drawing.Size(123, 20);
this.txtMedID.TabIndex = 29;
this.txtMedID.TextChanged += new System.EventHandler(this.txtMedID_TextChanged_1);
//
// txtPatID
//
this.txtPatID.Location = new System.Drawing.Point(325, 142);
this.txtPatID.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.txtPatID.Margin = new System.Windows.Forms.Padding(2);
this.txtPatID.Name = "txtPatID";
this.txtPatID.Size = new System.Drawing.Size(123, 20);
this.txtPatID.TabIndex = 28;
this.txtPatID.TextChanged += new System.EventHandler(this.txtPatID_TextChanged);
//
// txtRxNum
//
this.txtRxNum.Location = new System.Drawing.Point(325, 115);
this.txtRxNum.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.txtRxNum.Margin = new System.Windows.Forms.Padding(2);
this.txtRxNum.Name = "txtRxNum";
this.txtRxNum.Size = new System.Drawing.Size(123, 20);
this.txtRxNum.TabIndex = 27;
this.txtRxNum.TextChanged += new System.EventHandler(this.txtRxNum_TextChanged_1);
//
// lblDisPurpose
//
@ -118,7 +125,7 @@ namespace Louis__Pharmacy_CNSA212_FP
// btnCancel
//
this.btnCancel.Location = new System.Drawing.Point(586, 376);
this.btnCancel.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.btnCancel.Margin = new System.Windows.Forms.Padding(2);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(67, 23);
this.btnCancel.TabIndex = 25;
@ -128,7 +135,7 @@ namespace Louis__Pharmacy_CNSA212_FP
// btnGO
//
this.btnGO.Location = new System.Drawing.Point(500, 376);
this.btnGO.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.btnGO.Margin = new System.Windows.Forms.Padding(2);
this.btnGO.Name = "btnGO";
this.btnGO.Size = new System.Drawing.Size(67, 23);
this.btnGO.TabIndex = 24;
@ -227,7 +234,7 @@ namespace Louis__Pharmacy_CNSA212_FP
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.Margin = new System.Windows.Forms.Padding(2);
this.Name = "frmPrescription";
this.Text = "frmPrescription";
this.Load += new System.EventHandler(this.frmPrescription_Load);

View File

@ -104,16 +104,42 @@ namespace Louis__Pharmacy_CNSA212_FP
if (txtMedID.Text.Length + txtPhysName.Text.Length + txtMedID.Text.Length + txtPhysID.Text.Length + txtCompletedRefills.Text.Length + txtMaxRefills.Text.Length + txtRxNum.Text.Length > 0)
{
try
{
Patient_id = txtPatID.Text;
if (Patient_id.Length > 8)
{
throw new Exception();
}else
while (Patient_id.Length < 8)
{
Patient_id = "0" + Patient_id;
}
}
catch (Exception exception)
{
epLocal.SetError(txtPatID, "Invalid Value");
hasFailed = true;
}
try
{
RxNum = txtRxNum.Text;
if (RxNum.Length > 30)
if (RxNum.Length > 11)
{
throw new Exception();
}
else
{
while (RxNum.Length < 11)
{
RxNum = "0" + RxNum;
}
}
}
catch (Exception exception)
@ -129,6 +155,10 @@ namespace Louis__Pharmacy_CNSA212_FP
if (Physician_id.Length > 8)
{
throw new Exception();
}else
while (Physician_id.Length < 8)
{
Physician_id = "0" + Physician_id;
}
}
@ -144,6 +174,7 @@ namespace Louis__Pharmacy_CNSA212_FP
{
throw new Exception();
}
}
catch (Exception exception)
{
@ -161,7 +192,7 @@ namespace Louis__Pharmacy_CNSA212_FP
while (Medication_id.Length < 7)
{
RxNum = "0" + RxNum;
Medication_id = "0" + Medication_id;
}
}
catch (Exception exception)
@ -300,6 +331,11 @@ namespace Louis__Pharmacy_CNSA212_FP
epLocal.SetError(txtPatID, "Patient Does Not Exist");
}
}
else
{
hasFailed = true;
epLocal.SetError(txtPatID, "Must Enter A Patient ID");
}
if (txtMedID.Text.Length > 0)
{
@ -311,6 +347,11 @@ namespace Louis__Pharmacy_CNSA212_FP
epLocal.SetError(txtMedID, "Medication Does Not Exist");
}
}
else
{
hasFailed = true;
epLocal.SetError(txtMedID, "Must Enter a Medication ID");
}
if (txtPhysID.Text.Length > 0)
{
@ -322,6 +363,11 @@ namespace Louis__Pharmacy_CNSA212_FP
epLocal.SetError(txtPhysID, "Physician Does Not Exist");
}
}
else
{
hasFailed = true;
epLocal.SetError(txtPhysID, "Must Enter a Physician ID");
}
try
{
@ -330,6 +376,7 @@ namespace Louis__Pharmacy_CNSA212_FP
{
pastNumRefills = int.Parse(txtCompletedRefills.Text);
}
else throw new Exception();
}
catch (Exception exception)
@ -344,7 +391,7 @@ namespace Louis__Pharmacy_CNSA212_FP
{
numRefills = int.Parse(txtMaxRefills.Text);
}
if (numRefills < 0)
if (numRefills <= 0)
{
throw new Exception();
}
@ -396,5 +443,45 @@ namespace Louis__Pharmacy_CNSA212_FP
}
private void txtRxNum_TextChanged_1(object sender, EventArgs e)
{
epLocal.SetError(txtRxNum,"");
}
private void txtPatID_TextChanged(object sender, EventArgs e)
{
epLocal.SetError(txtPatID,"");
}
private void txtMedID_TextChanged_1(object sender, EventArgs e)
{
epLocal.SetError(txtMedID,"");
}
private void txtPhysName_TextChanged_1(object sender, EventArgs e)
{
epLocal.SetError(txtPhysName,"");
}
private void txtPhysID_TextChanged_1(object sender, EventArgs e)
{
epLocal.SetError(txtPhysID,"");
}
private void txtCompletedRefills_TextChanged_1(object sender, EventArgs e)
{
epLocal.SetError(txtCompletedRefills,"");
}
private void txtMaxRefills_TextChanged_1(object sender, EventArgs e)
{
epLocal.SetError(txtMaxRefills,"");
}
}
}