made cmuPrescription Edit pull data

This commit is contained in:
EggMan20339 2024-02-20 17:26:44 -05:00
parent 1334430e94
commit f716bf0e54
4 changed files with 183 additions and 84 deletions

View File

@ -531,6 +531,45 @@ namespace Louis__Pharmacy_CNSA212_FP
} }
} }
public static DataSet PrescriptionInfoSearch(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 = "PerscriptionInfoSearch";
// Define input parameter
cmdString.Parameters.Add("@rxID", SqlDbType.VarChar, 11).Value = rxID;
cmdString.Parameters.Add("@patientID", SqlDbType.VarChar, 8).Value = "%";
cmdString.Parameters.Add("@physicianID", SqlDbType.VarChar, 8).Value = "%";
cmdString.Parameters.Add("@medID", SqlDbType.VarChar, 8).Value = "%";
// 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 DataSet NumberofRefills(string rxID) public DataSet NumberofRefills(string rxID)
{ {
try try

View File

@ -968,19 +968,21 @@ namespace Louis__Pharmacy_CNSA212_FP
// dgvRx // dgvRx
// //
this.dgvRx.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dgvRx.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dgvRx.ContextMenuStrip = this.cmuPrescription;
this.dgvRx.Location = new System.Drawing.Point(0, 236); this.dgvRx.Location = new System.Drawing.Point(0, 236);
this.dgvRx.Name = "dgvRx"; this.dgvRx.Name = "dgvRx";
this.dgvRx.RowHeadersWidth = 51; this.dgvRx.RowHeadersWidth = 51;
this.dgvRx.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.dgvRx.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
this.dgvRx.Size = new System.Drawing.Size(730, 248); this.dgvRx.Size = new System.Drawing.Size(730, 248);
this.dgvRx.TabIndex = 0; this.dgvRx.TabIndex = 0;
this.dgvRx.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgvRx_CellContentClick);
// //
// cmuPrescription // cmuPrescription
// //
this.cmuPrescription.ImageScalingSize = new System.Drawing.Size(20, 20); 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.Name = "cmuPrescription";
this.cmuPrescription.Size = new System.Drawing.Size(244, 136); this.cmuPrescription.Size = new System.Drawing.Size(244, 114);
// //
// cmuPrescriptionNew // cmuPrescriptionNew
// //

View File

@ -53,6 +53,7 @@ namespace Louis__Pharmacy_CNSA212_FP
private bool physicianIsActive; private bool physicianIsActive;
private bool patientIsActive; private bool patientIsActive;
private bool medicationIsActive; private bool medicationIsActive;
private bool prescriptionIsActive;
private void frmInfoTabChange(object sender, EventArgs e) private void frmInfoTabChange(object sender, EventArgs e)
{ {
@ -61,6 +62,7 @@ namespace Louis__Pharmacy_CNSA212_FP
patientIsActive = false; patientIsActive = false;
physicianIsActive = false; physicianIsActive = false;
medicationIsActive = false; medicationIsActive = false;
prescriptionIsActive = false;
if (tbcInfo.SelectedIndex == 0) if (tbcInfo.SelectedIndex == 0)
@ -75,6 +77,10 @@ namespace Louis__Pharmacy_CNSA212_FP
{ {
physicianIsActive = true; physicianIsActive = true;
} }
else if (tbcInfo.SelectedIndex == 3)
{
prescriptionIsActive = true;
}
} }
@ -108,6 +114,10 @@ namespace Louis__Pharmacy_CNSA212_FP
{ {
cmuMedicationDelete_Click(sender, e); cmuMedicationDelete_Click(sender, e);
} }
if (prescriptionIsActive && e.KeyCode == Keys.Delete)
{
cmuPrescriptionDelete_Click(sender, e);
}
@ -123,6 +133,17 @@ namespace Louis__Pharmacy_CNSA212_FP
cmuPatientEdit_Click(sender,e); cmuPatientEdit_Click(sender,e);
} }
// if data grid view is not focused, run the search function
if (e.KeyCode == Keys.Enter && prescriptionIsActive && !dgvPrescription.Focused)
{
btnPatientSearch_Click(sender,e);
}
// if data grid view is focused, run the edit function
else if (e.KeyCode == Keys.Enter && prescriptionIsActive && dgvPrescription.Focused)
{
cmuPrescriptionEdit_Click(sender,e);
}
// if data grid view is not focused, run the search function // if data grid view is not focused, run the search function
@ -242,84 +263,84 @@ namespace Louis__Pharmacy_CNSA212_FP
} }
//public void btnPrescriptionSearch_Click(object sender, EventArgs e) // public void btnPrescriptionSearch_Click(object sender, EventArgs e)
//{ // {
// string medID = ""; // string medID = "";
// string medicationName = ""; // string medicationName = "";
//
//
// if (txtPrescriptionPatID.Text.Length+txtRxNumber.Text.Length > 0) // if (txtPrescriptionPatID.Text.Length+txtRxNumber.Text.Length > 0)
// { // {
//
//
// try // try
// { // {
//
// medicationName = txtPrescriptionPatID.Text; // medicationName = txtPrescriptionPatID.Text;
//
// try // try
// { // {
//
// medID = txtRxNumber.Text; // medID = txtRxNumber.Text;
//
// try // try
// { // {
//
//
// ds = PharmacyDataTier.MedicationInfoSearch(medID,medicationName); // ds = PharmacyDataTier.MedicationInfoSearch(medID,medicationName);
//
//
// if (ds.Tables[0].Rows.Count > 0) // There is a record. // if (ds.Tables[0].Rows.Count > 0) // There is a record.
// { // {
// dgvRx.Visible = true; // dgvRx.Visible = true;
// // Get data source. // // Get data source.
// dgvRx.DataSource = ds.Tables[0]; // dgvRx.DataSource = ds.Tables[0];
// dgvRx.AlternatingRowsDefaultCellStyle.BackColor = Color.LightGreen; // dgvRx.AlternatingRowsDefaultCellStyle.BackColor = Color.LightGreen;
//
// // Set the row and column header styles. // // Set the row and column header styles.
// dgvRx.ColumnHeadersDefaultCellStyle.ForeColor = Color.White; // dgvRx.ColumnHeadersDefaultCellStyle.ForeColor = Color.White;
// dgvRx.ColumnHeadersDefaultCellStyle.BackColor = Color.Green; // dgvRx.ColumnHeadersDefaultCellStyle.BackColor = Color.Green;
// } // }
// else // else
// { // {
// dgvPatient.Visible = false; // Hide the DataGridView if no results are found. // dgvPatient.Visible = false; // Hide the DataGridView if no results are found.
// MessageBox.Show("No records found."); // MessageBox.Show("No records found.");
// } // }
//
//
// } // }
// catch (Exception exception) // catch (Exception exception)
// { // {
//
// ep1.SetError(btnMedicationSearch, "Error Searching"); // ep1.SetError(btnMedicationSearch, "Error Searching");
//
// } // }
//
//
// } // }
// catch (Exception exception) // catch (Exception exception)
// { // {
//
// ep1.SetError(txtRxNumber, "Invalid Value"); // ep1.SetError(txtRxNumber, "Invalid Value");
//
// } // }
//
// } // }
// catch (Exception exception) // catch (Exception exception)
// { // {
//
// ep1.SetError(txtPrescriptionPatID, "Invalid Value"); // ep1.SetError(txtPrescriptionPatID, "Invalid Value");
//
// } // }
// } // }
//
//
// cmuMedicationEdit.Enabled = dgvRx.Rows.Count > 0; // cmuMedicationEdit.Enabled = dgvRx.Rows.Count > 0;
// cmuMedicationDelete.Enabled = dgvRx.Rows.Count > 0; // cmuMedicationDelete.Enabled = dgvRx.Rows.Count > 0;
//
// dgvRx.Focus(); // dgvRx.Focus();
//
//} // }
@ -624,6 +645,24 @@ namespace Louis__Pharmacy_CNSA212_FP
private void cmuPrescriptionEdit_Click(object sender, EventArgs e) private void cmuPrescriptionEdit_Click(object sender, EventArgs e)
{ {
if (dgvRx.Rows.Count > 0)
{
dgvRx.DataSource = ds.Tables[0];
// Console.WriteLine( dgvPatient.SelectedRows.Count);
DataGridViewRow row = new DataGridViewRow();
row = dgvRx.SelectedRows[0];
string prescID = "";
prescID = (row.Cells[0].Value).ToString();
frmPrescription PrescriptionAdd = new frmPrescription(this, false);
PrescriptionAdd.MdiParent = MdiParent;
PrescriptionAdd.StartPosition = FormStartPosition.CenterScreen;
PrescriptionAdd.Show();
PrescriptionAdd.Focus();
PrescriptionAdd.FillPrescription(prescID);
}
} }
private void cmuPrescriptionDelete_Click(object sender, EventArgs e) private void cmuPrescriptionDelete_Click(object sender, EventArgs e)
@ -639,16 +678,16 @@ namespace Louis__Pharmacy_CNSA212_FP
string patID = ""; string patID = "";
if (txtRxPatientID.Text.Length + txtRxNumber.Text.Length > 0) if (txtRxPatientID.Text.Length + txtRxPrescriptionID.Text.Length + txtRxPhysicianID.Text.Length + txtRxMedicationID.Text.Length> 0)
{ {
try try
{ {
rxNum = txtRxPrescriptionID.Text; rxNum = txtRxPrescriptionID.Text;
medID = txtRxMedicationID.Text; medID = txtRxMedicationID.Text;
physID = txtRxPhysicianID.Text; physID = txtRxPhysicianID.Text;
patID = txtRxPatientID.Text; patID = txtRxPatientID.Text;
@ -706,5 +745,10 @@ namespace Louis__Pharmacy_CNSA212_FP
{ {
} }
private void dgvRx_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
} }
} }

View File

@ -65,6 +65,20 @@ namespace Louis__Pharmacy_CNSA212_FP
txtCompletedRefills.Text = ds.Tables[0].Rows[0]["Completed_refills"].ToString(); txtCompletedRefills.Text = ds.Tables[0].Rows[0]["Completed_refills"].ToString();
txtMaxRefills.Text = ds.Tables[0].Rows[0]["Max_refills"].ToString(); txtMaxRefills.Text = ds.Tables[0].Rows[0]["Max_refills"].ToString();
} }
public void FillPrescription(string rxNum)
{
var ds = new DataSet();
var data = new PharmacyDataTier();
ds = PharmacyDataTier.PrescriptionInfoSearch(rxNum);
txtRxNum.Text = ds.Tables[0].Rows[0]["RxNum_id"].ToString();
txtPatID.Text = ds.Tables[0].Rows[0]["Patient_id"].ToString();
txtMedID.Text = ds.Tables[0].Rows[0]["Medication_id"].ToString();
txtPhysName.Text = ds.Tables[0].Rows[0]["PrescribedBy"].ToString();
txtPhysID.Text = ds.Tables[0].Rows[0]["Physician_id"].ToString();
txtCompletedRefills.Text = ds.Tables[0].Rows[0]["pastNumRefills"].ToString();
txtMaxRefills.Text = ds.Tables[0].Rows[0]["numRefills"].ToString();
}
private void btnCancel_Click(object sender, EventArgs e) private void btnCancel_Click(object sender, EventArgs e)
{ {