CNSA-212-FP/Louis'-Pharmacy_CNSA212-FP/frmInfo.cs
2024-02-14 18:21:17 -05:00

126 lines
3.7 KiB
C#

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 frmInfo : Form
{
private ErrorProvider ep1 = new ErrorProvider();
public frmInfo()
{
InitializeComponent();
}
private void frmInfo_Load(object sender, EventArgs e)
{
}
private void addUpdatePatientAndPhysicianToolStripMenuItem_Click(object sender, EventArgs e)
{
}
private void pATIENTBindingNavigatorSaveItem_Click(object sender, EventArgs e)
{
}
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 + txtPatientID.Text.Length > 0)
{
try
{
fname = txtPatientFirst.Text;
try
{
lname = txtPatientLast.Text;
try
{
id = txtPatientID.Text;
try
{
ds = PharmacyDataTier.PatientInfoSearch(id,lname,fname);
if (ds.Tables[0].Rows.Count > 0) // There is a record.
{
dgvPatient.Visible = true;
// Get data source.
dgvPatient.DataSource = ds.Tables[0];
dgvPatient.AlternatingRowsDefaultCellStyle.BackColor = Color.LightGreen;
// Set the row and column header styles.
dgvPatient.ColumnHeadersDefaultCellStyle.ForeColor = Color.White;
dgvPatient.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(btnPatientSearch, "Error Searching");
}
}
catch (Exception exception)
{
ep1.SetError(txtPatientID, "Invalid Value");
}
}
catch (Exception exception)
{
ep1.SetError(txtPatientLast, "Invalid Value");
}
}
catch (Exception exception)
{
ep1.SetError(txtPatientFirst, "Invalid Value");
}
}
}
}
}