using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Louis__Pharmacy_CNSA212_FP { public partial class frmPrescription : Form { public frmPrescription() { InitializeComponent(); } private void btnPatientSearch_Click(object sender, EventArgs e) { string fname = ""; string lname = ""; string id = ""; DataSet ds = new DataSet(); if (txtPatientFirst.Text.Length + txtPatientLast.Text.Length + txtPatientRx.Text.Length > 0) { try { fname = txtPatientFirst.Text; try { lname = txtPatientLast.Text; try { id = txtPatientRx.Text; try { ds = PharmacyDataTier.PatientInfoSearch(id, lname, fname); if (ds.Tables[0].Rows.Count > 0) // There is a record. { dgvPrescriptions.Visible = true; // Get data source. dgvPrescriptions.DataSource = ds.Tables[0]; dgvPrescriptions.AlternatingRowsDefaultCellStyle.BackColor = Color.LightGreen; // Set the row and column header styles. dgvPrescriptions.ColumnHeadersDefaultCellStyle.ForeColor = Color.White; dgvPrescriptions.ColumnHeadersDefaultCellStyle.BackColor = Color.Green; } else { dgvPrescriptions.Visible = false; // Hide the DataGridView if no results are found. MessageBox.Show("No records found."); } } catch (Exception exception) { ep1.SetError(btnSearch, "Error Searching"); } } catch (Exception exception) { ep1.SetError(txtPatientRx, "Invalid Value"); } } catch (Exception exception) { ep1.SetError(txtPatientLast, "Invalid Value"); } } catch (Exception exception) { ep1.SetError(txtPatientFirst, "Invalid Value"); } } cmuPrescriptionEdit.Enabled = dgvPrescriptions.Rows.Count > 0; cmuPrescriptionDelete.Enabled = dgvPrescriptions.Rows.Count > 0; } private void btnPrescriptionSearch_Click(object sender, EventArgs e) { } private void btnPhysicianSearch_Click(object sender, EventArgs e) { } private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { } private void frmPrescription_Load(object sender, EventArgs e) { } private void frmPrescription_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 addToolStripMenuItem_Click(object sender, EventArgs e) { } } }