added funtionality to rx search

This commit is contained in:
EggMan20339 2024-02-14 19:27:21 -05:00
parent f6c2540b76
commit 6d2692fbcd
3 changed files with 128 additions and 0 deletions

View File

@ -51,6 +51,44 @@ namespace Louis__Pharmacy_CNSA212_FP
}
}
public static DataSet PrescriptionInfoSearch(string rxID, string patientID)
{
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 = patientID;
// 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 GetStudents(string StuID)
{

View File

@ -402,6 +402,7 @@ namespace Louis__Pharmacy_CNSA212_FP
this.btnPrescriptionSearch.TabIndex = 4;
this.btnPrescriptionSearch.Text = "Search";
this.btnPrescriptionSearch.UseVisualStyleBackColor = true;
this.btnPrescriptionSearch.Click += new System.EventHandler(this.btnPrescriptionSearch_Click);
//
// txtPrescriptionPatID
//

View File

@ -23,8 +23,24 @@ namespace Louis__Pharmacy_CNSA212_FP
private void frmInfo_Load(object sender, EventArgs e)
{
KeyPreview = true;
KeyDown += frmInfo_KeyDown;
}
private void frmInfo_KeyDown(object sender, KeyEventArgs e)
{
// esc not funtional
if (e.KeyCode == Keys.Escape) // Check if the pressed key is Escape
{this.Close(); // Close the form
}
if (e.KeyCode == Keys.Enter){
btnPatientSearch_Click(sender, e);
}
}
private void addUpdatePatientAndPhysicianToolStripMenuItem_Click(object sender, EventArgs e)
{
@ -121,5 +137,78 @@ namespace Louis__Pharmacy_CNSA212_FP
}
private void btnPrescriptionSearch_Click(object sender, EventArgs e)
{
string rxID = "";
string patientID = "";
DataSet ds = new DataSet();
if (txtPrescriptionPatID.Text.Length+txtRxNumber.Text.Length > 0)
{
try
{
patientID = txtPrescriptionPatID.Text;
try
{
rxID = txtRxNumber.Text;
try
{
ds = PharmacyDataTier.PrescriptionInfoSearch(rxID, patientID);
if (ds.Tables[0].Rows.Count > 0) // There is a record.
{
dgvPrescription.Visible = true;
// Get data source.
dgvPrescription.DataSource = ds.Tables[0];
dgvPrescription.AlternatingRowsDefaultCellStyle.BackColor = Color.LightGreen;
// Set the row and column header styles.
dgvPrescription.ColumnHeadersDefaultCellStyle.ForeColor = Color.White;
dgvPrescription.ColumnHeadersDefaultCellStyle.BackColor = Color.Green;
}
else
{
dgvPatient.Visible = false; // Hide the DataGridView if no results are found.
MessageBox.Show("No records found.");
}
}
catch (Exception exception)
{
ep1.SetError(btnPrescriptionSearch, "Error Searching");
}
}
catch (Exception exception)
{
ep1.SetError(txtRxNumber, "Invalid Value");
}
}
catch (Exception exception)
{
ep1.SetError(txtPrescriptionPatID, "Invalid Value");
}
}
}
}
}