CNSA-212-FP/Louis'-Pharmacy_CNSA212-FP/frmInfo.cs

954 lines
32 KiB
C#
Raw Normal View History

2024-01-31 12:05:11 -05:00
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
2024-01-31 12:05:11 -05:00
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
2024-02-14 18:21:17 -05:00
2024-01-31 12:05:11 -05:00
namespace Louis__Pharmacy_CNSA212_FP
{
2024-01-31 12:45:33 -05:00
public partial class frmInfo : Form
2024-01-31 12:05:11 -05:00
{
2024-02-16 11:32:00 -05:00
2024-02-14 18:21:17 -05:00
private ErrorProvider ep1 = new ErrorProvider();
2024-02-16 11:32:00 -05:00
public DataSet ds = new DataSet();
2024-01-31 12:45:33 -05:00
public frmInfo()
2024-01-31 12:05:11 -05:00
{
InitializeComponent();
dgvPatient.DoubleClick += cmuPatientEdit_Click;
2024-02-19 13:38:27 -05:00
dgvPhysician.DoubleClick += cmuPhysicianEdit_Click;
dgvPrescription.DoubleClick += cmuPrescriptionEdit_Click;
dgvMedication.DoubleClick += cmuMedicationEdit_Click;
tbcInfo.SelectedIndexChanged += frmInfoTabChange;
2024-01-31 12:05:11 -05:00
}
private void frmInfo_Load(object sender, EventArgs e)
{
2024-02-14 19:27:21 -05:00
KeyPreview = true;
KeyDown += frmInfo_KeyDown;
2024-02-15 12:04:26 -05:00
cmuPatientEdit.Enabled = false;
cmuPatientDelete.Enabled = false;
2024-02-19 21:24:58 -05:00
cmuPhysicianEdit.Enabled = false;
cmuPhysicianDelete.Enabled = false;
2024-02-20 10:06:03 -05:00
cmuMedicationEdit.Enabled = false;
cmuMedicationDelete.Enabled = false;
cmuPrescriptionEdit.Enabled = false;
cmuPrescriptionDelete.Enabled = false;
2024-02-21 00:27:38 -05:00
cmuPrescriptionRefillThis.Enabled = false;
cmuPrescriptionViewRefills.Enabled = false;
dgvMedication.Visible = false;
dgvPatient.Visible = false;
dgvPhysician.Visible = false;
dgvPrescription.Visible = false;
2024-02-15 12:04:26 -05:00
2024-02-16 19:36:56 -05:00
txtPatientFirst.Focus();
patientIsActive = true;
}
2024-02-19 16:27:27 -05:00
private bool physicianIsActive;
private bool patientIsActive;
private bool medicationIsActive;
2024-02-20 17:26:44 -05:00
private bool prescriptionIsActive;
private void frmInfoTabChange(object sender, EventArgs e)
{
Console.WriteLine(tbcInfo.SelectedIndex);
patientIsActive = false;
physicianIsActive = false;
2024-02-19 16:27:27 -05:00
medicationIsActive = false;
2024-02-20 17:26:44 -05:00
prescriptionIsActive = false;
2024-02-19 16:27:27 -05:00
if (tbcInfo.SelectedIndex == 0)
{
patientIsActive = true;
2024-02-19 16:27:27 -05:00
}
else if (tbcInfo.SelectedIndex == 1)
{
medicationIsActive = true;
}
else if (tbcInfo.SelectedIndex == 2)
{
physicianIsActive = true;
}
2024-02-20 17:26:44 -05:00
else if (tbcInfo.SelectedIndex == 3)
{
prescriptionIsActive = true;
}
}
2024-02-06 11:46:50 -05:00
2024-02-14 19:27:21 -05:00
private void frmInfo_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Escape)
{this.Close();
2024-02-14 19:27:21 -05:00
}
2024-02-19 16:27:27 -05:00
// if data grid view is not focused, run the search function
if (e.KeyCode == Keys.Enter && physicianIsActive && !dgvPhysician.Focused){
2024-02-19 10:47:16 -05:00
btnPhysicianSearch_Click(sender, e);
2024-02-14 19:27:21 -05:00
}
// if data grid view is focused, run the edit function
else if (e.KeyCode == Keys.Enter && physicianIsActive && dgvPhysician.Focused)
{
cmuPhysicianEdit_Click(sender, e);
}
if (patientIsActive && e.KeyCode == Keys.Delete)
{
cmuPatientDelete_Click(sender, e);
}
if (physicianIsActive && e.KeyCode == Keys.Delete)
{
cmuPhysicianDelete_Click(sender, e);
}
if (medicationIsActive && e.KeyCode == Keys.Delete)
{
cmuMedicationDelete_Click(sender, e);
}
2024-02-20 17:26:44 -05:00
if (prescriptionIsActive && e.KeyCode == Keys.Delete)
{
cmuPrescriptionDelete_Click(sender, e);
}
2024-02-19 16:27:27 -05:00
// if data grid view is not focused, run the search function
if (e.KeyCode == Keys.Enter && patientIsActive && !dgvPatient.Focused)
{
btnPatientSearch_Click(sender,e);
}
// if data grid view is focused, run the edit function
else if (e.KeyCode == Keys.Enter && patientIsActive && dgvPatient.Focused)
{
cmuPatientEdit_Click(sender,e);
2024-02-20 17:26:44 -05:00
}
// if data grid view is not focused, run the search function
if (e.KeyCode == Keys.Enter && prescriptionIsActive && !dgvPrescription.Focused)
{
btnPrescriptionSearch_Click(sender,e);
2024-02-20 17:26:44 -05:00
}
// if data grid view is focused, run the edit function
else if (e.KeyCode == Keys.Enter && prescriptionIsActive && dgvPrescription.Focused)
{
cmuPrescriptionEdit_Click(sender,e);
}
2024-02-14 19:27:21 -05:00
2024-02-19 16:27:27 -05:00
// if data grid view is not focused, run the search function
if (e.KeyCode == Keys.Enter && medicationIsActive && !dgvMedication.Focused)
2024-02-19 16:27:27 -05:00
{
btnMedicationSearch_Click(sender,e);
2024-02-19 16:27:27 -05:00
}
// if data grid view is focused, run the edit function
else if (e.KeyCode == Keys.Enter && medicationIsActive && dgvMedication.Focused)
2024-02-19 16:27:27 -05:00
{
cmuMedicationEdit_Click(sender,e);
2024-02-19 16:27:27 -05:00
}
2024-02-14 19:27:21 -05:00
}
2024-02-06 11:46:50 -05:00
private void addUpdatePatientAndPhysicianToolStripMenuItem_Click(object sender, EventArgs e)
{
}
private void pATIENTBindingNavigatorSaveItem_Click(object sender, EventArgs e)
{
2024-02-14 18:21:17 -05:00
}
public void btnPatientSearch_Click(object sender, EventArgs e)
2024-02-14 18:21:17 -05:00
{
string fname = "";
string lname = "";
string id = "";
2024-02-16 11:32:00 -05:00
2024-02-14 18:21:17 -05:00
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
{
2024-02-21 00:27:38 -05:00
2024-02-21 00:55:50 -05:00
dgvPatient.Visible = false; // Hide the DataGridView if no results are found.
2024-02-14 18:21:17 -05:00
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");
}
}
2024-02-15 12:04:26 -05:00
cmuPatientEdit.Enabled = dgvPatient.Rows.Count > 0;
cmuPatientDelete.Enabled = dgvPatient.Rows.Count > 0;
2024-02-21 00:51:28 -05:00
//dgvPatient.Visible = dgvPatient.Rows.Count > 0;
2024-02-14 18:21:17 -05:00
2024-02-21 00:27:38 -05:00
dgvPatient.Focus();
2024-02-14 18:21:17 -05:00
}
2024-02-14 19:27:21 -05:00
2024-02-20 17:26:44 -05:00
// public void btnPrescriptionSearch_Click(object sender, EventArgs e)
// {
// string medID = "";
// string medicationName = "";
//
//
// if (txtPrescriptionPatID.Text.Length+txtRxNumber.Text.Length > 0)
// {
//
//
// try
// {
//
// medicationName = txtPrescriptionPatID.Text;
//
// try
// {
//
// medID = txtRxNumber.Text;
//
// try
// {
//
//
// ds = PharmacyDataTier.MedicationInfoSearch(medID,medicationName);
//
//
// if (ds.Tables[0].Rows.Count > 0) // There is a record.
// {
// dgvRx.Visible = true;
// // Get data source.
// dgvRx.DataSource = ds.Tables[0];
// dgvRx.AlternatingRowsDefaultCellStyle.BackColor = Color.LightGreen;
//
// // Set the row and column header styles.
// dgvRx.ColumnHeadersDefaultCellStyle.ForeColor = Color.White;
// dgvRx.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(btnMedicationSearch, "Error Searching");
//
// }
//
//
// }
// catch (Exception exception)
// {
//
// ep1.SetError(txtRxNumber, "Invalid Value");
//
// }
//
// }
// catch (Exception exception)
// {
//
// ep1.SetError(txtPrescriptionPatID, "Invalid Value");
//
// }
// }
//
//
// cmuMedicationEdit.Enabled = dgvRx.Rows.Count > 0;
// cmuMedicationDelete.Enabled = dgvRx.Rows.Count > 0;
//
// dgvRx.Focus();
//
// }
2024-02-20 13:12:40 -05:00
2024-02-19 21:24:58 -05:00
public void btnPhysicianSearch_Click(object sender, EventArgs e)
2024-02-14 19:43:07 -05:00
{
2024-02-15 12:04:26 -05:00
2024-02-14 19:43:07 -05:00
string fname = "";
string lname = "";
string phyID = "";;
if (txtPhysicianFirst.Text.Length+txtPhysicianLast.Text.Length+txtPhysicianID.Text.Length > 0)
{
try
{
fname = txtPhysicianFirst.Text;
try
{
lname = txtPhysicianLast.Text;
try
{
phyID = txtPhysicianID.Text;
try
{
ds = PharmacyDataTier.PhysicianInfoSearch(fname, lname, phyID);
if (ds.Tables[0].Rows.Count > 0) // There is a record.
{
dgvPhysician.Visible = true;
// Get data source.
dgvPhysician.DataSource = ds.Tables[0];
dgvPhysician.AlternatingRowsDefaultCellStyle.BackColor = Color.LightGreen;
// Set the row and column header styles.
dgvPhysician.ColumnHeadersDefaultCellStyle.ForeColor = Color.White;
dgvPhysician.ColumnHeadersDefaultCellStyle.BackColor = Color.Green;
}
else
{
2024-02-21 00:55:50 -05:00
dgvPhysician.Visible = false; // Hide the DataGridView if no results are found.
2024-02-14 19:43:07 -05:00
MessageBox.Show("No records found.");
}
}
catch (Exception exception)
{
ep1.SetError(btnPhysicianSearch, "Error Searching");
}
}
catch (Exception exception)
{
ep1.SetError(txtPhysicianID, "Invalid Value");
}
}
catch (Exception exception)
{
ep1.SetError(txtPhysicianLast, "Invalid Value");
}
}
catch (Exception exception)
{
ep1.SetError(txtPhysicianFirst, "Invalid Value");
}
}
2024-02-19 21:24:58 -05:00
cmuPhysicianEdit.Enabled = dgvPhysician.Rows.Count > 0;
cmuPhysicianDelete.Enabled = dgvPhysician.Rows.Count > 0;
2024-02-21 00:55:50 -05:00
// dgvPhysician.Visible = dgvPhysician.Rows.Count > 0;
dgvPhysician.Focus();
2024-02-15 12:04:26 -05:00
2024-02-14 19:43:07 -05:00
}
private void cmuPatientNew_Click(object sender, EventArgs e)
{
2024-02-15 12:04:26 -05:00
frmPatient PatientAdd = new frmPatient(this, true);
2024-02-15 12:04:26 -05:00
PatientAdd.MdiParent = MdiParent;
PatientAdd.StartPosition = FormStartPosition.CenterScreen;
PatientAdd.Show();
PatientAdd.Focus();
}
private void cmuPatientEdit_Click(object sender, EventArgs e)
{
2024-02-15 12:04:26 -05:00
if (dgvPatient.Rows.Count > 0)
{
2024-02-16 11:32:00 -05:00
dgvPatient.DataSource = ds.Tables[0];
2024-02-16 10:12:36 -05:00
// Console.WriteLine( dgvPatient.SelectedRows.Count);
2024-02-16 11:32:00 -05:00
DataGridViewRow row = new DataGridViewRow();
row = dgvPatient.SelectedRows[0];
2024-02-16 10:12:36 -05:00
string patid = "";
patid = (row.Cells[3].Value).ToString();
frmPatient PatientAdd = new frmPatient(this, false);
2024-02-15 12:04:26 -05:00
PatientAdd.MdiParent = MdiParent;
PatientAdd.StartPosition = FormStartPosition.CenterScreen;
PatientAdd.Show();
PatientAdd.Focus();
2024-02-16 10:12:36 -05:00
PatientAdd.FillPatient(patid);
2024-02-15 12:04:26 -05:00
}
2024-02-16 10:12:36 -05:00
}
private void dgvPatient_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
2024-02-21 00:51:28 -05:00
//private void Panel1_Paint(object sender, PaintEventArgs e)
//{
2024-02-16 10:12:36 -05:00
2024-02-21 00:51:28 -05:00
//}
private void cmuPatientDelete_Click(object sender, EventArgs e)
{
if (dgvPatient.Rows.Count > 0)
{
dgvPatient.DataSource = ds.Tables[0];
DataGridViewRow row = new DataGridViewRow();
row = dgvPatient.SelectedRows[0];
string patid = "";
2024-02-19 14:37:25 -05:00
patid = (row.Cells[3].Value).ToString();
DialogResult dialogResult = MessageBox.Show("Are you sure you want to delete Patient: " + patid,
"Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (dialogResult == DialogResult.Yes)
{
PharmacyDataTier.DeletePatient(patid);
}
btnPatientSearch_Click(sender, e);
}
}
2024-02-16 20:13:30 -05:00
private void cmuPhysicianNew_Click(object sender, EventArgs e)
{
frmPhysician physicianAdd = new frmPhysician(this, true);
physicianAdd.MdiParent = MdiParent;
physicianAdd.StartPosition = FormStartPosition.CenterScreen;
physicianAdd.Show();
physicianAdd.Focus();
}
private void cmuPhysicianEdit_Click(object sender, EventArgs e)
{
2024-02-19 10:47:16 -05:00
if (dgvPhysician.Rows.Count > 0)
{
dgvPhysician.DataSource = ds.Tables[0];
DataGridViewRow row = new DataGridViewRow();
row = dgvPhysician.SelectedRows[0];
string phyID = "";
phyID = (row.Cells[0].Value).ToString();
2024-02-19 10:47:16 -05:00
frmPhysician PhysicianAdd = new frmPhysician(this, false);
PhysicianAdd.MdiParent = MdiParent;
PhysicianAdd.StartPosition = FormStartPosition.CenterScreen;
PhysicianAdd.Show();
PhysicianAdd.Focus();
PhysicianAdd.FillPhysician(phyID);
}
2024-02-16 20:13:30 -05:00
}
2024-02-19 13:11:10 -05:00
private void cmuPhysicianDelete_Click(object sender, EventArgs e)
{
if (dgvPhysician.Rows.Count > 0)
{
dgvPhysician.DataSource = ds.Tables[0];
DataGridViewRow row = new DataGridViewRow();
row = dgvPhysician.SelectedRows[0];
string phyID = "";
2024-02-19 14:37:25 -05:00
phyID = (row.Cells[0].Value).ToString();
DialogResult dialogResult = MessageBox.Show("Are you sure you want to delete Physician: " + phyID,
"Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (dialogResult == DialogResult.Yes)
{
PharmacyDataTier.DeletePhysician(phyID);
}
btnPhysicianSearch_Click(sender, e);
2024-02-19 13:11:10 -05:00
}
}
// private void PhysicianReset(object sender, EventArgs e)
// {
// txtPhysicianFirst.Text = "";
// txtPhysicianLast.Text = "";
// txtPhysicianID.Text = "";
// dgvPhysician.Visible = false;
// }
2024-02-19 21:24:58 -05:00
2024-02-19 13:11:10 -05:00
private void dgvPhysician_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
private void dgvPhysician_CellContentClick_1(object sender, DataGridViewCellEventArgs e)
{
}
2024-02-19 16:27:27 -05:00
private void cmuRxNew_Click(object sender, EventArgs e)
{
frmMedication medicationAdd = new frmMedication(this, true);
medicationAdd.MdiParent = MdiParent;
medicationAdd.StartPosition = FormStartPosition.CenterScreen;
medicationAdd.Show();
medicationAdd.Focus();
}
private void cmuMedicationEdit_Click(object sender, EventArgs e)
2024-02-19 16:27:27 -05:00
{
if (dgvMedication.Rows.Count > 0)
2024-02-19 16:27:27 -05:00
{
dgvMedication.DataSource = ds.Tables[0];
2024-02-19 16:27:27 -05:00
DataGridViewRow row = new DataGridViewRow();
row = dgvMedication.SelectedRows[0];
2024-02-19 16:27:27 -05:00
string rxID = "";
rxID = (row.Cells[0].Value).ToString();
frmMedication prescriptionAdd = new frmMedication(this, false);
prescriptionAdd.MdiParent = MdiParent;
prescriptionAdd.StartPosition = FormStartPosition.CenterScreen;
prescriptionAdd.Show();
prescriptionAdd.Focus();
prescriptionAdd.FillMedication(rxID);
}
}
private void cmuMedicationDelete_Click(object sender, EventArgs e)
2024-02-19 21:24:58 -05:00
{
if (dgvPrescription.Rows.Count > 0)
2024-02-19 21:24:58 -05:00
{
dgvPrescription.DataSource = ds.Tables[0];
2024-02-19 21:24:58 -05:00
DataGridViewRow row = new DataGridViewRow();
row = dgvMedication.SelectedRows[0];
2024-02-19 21:24:58 -05:00
string medID = "";
medID = (row.Cells[0].Value).ToString();
DialogResult dialogResult = MessageBox.Show("Are you sure you want to delete medication: " + medID,
"Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (dialogResult == DialogResult.Yes)
{
PharmacyDataTier.DeleteMedication(medID);
}
btnMedicationSearch_Click(sender, e);
2024-02-19 21:24:58 -05:00
}
}
private void lblDisMedicationNum_Click(object sender, EventArgs e)
2024-02-19 16:27:27 -05:00
{
}
2024-02-20 10:06:03 -05:00
private void Panel2_Paint(object sender, PaintEventArgs e)
{
}
private void cmuPrescriptionNew_Click(object sender, EventArgs e)
{
}
private void cmuPrescriptionEdit_Click(object sender, EventArgs e)
{
2024-02-20 17:26:44 -05:00
if (dgvPrescription.Rows.Count > 0)
2024-02-20 17:26:44 -05:00
{
2024-02-21 10:47:48 -05:00
//dgvPrescription.DataSource = ds.Tables[0];
2024-02-20 17:26:44 -05:00
// Console.WriteLine( dgvPatient.SelectedRows.Count);
DataGridViewRow row = new DataGridViewRow();
row = dgvPrescription.SelectedRows[0];
2024-02-20 17:26:44 -05:00
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);
}
2024-02-20 10:06:03 -05:00
}
private void cmuPrescriptionDelete_Click(object sender, EventArgs e)
{
if (dgvPrescription.Rows.Count > 0)
{
dgvPrescription.DataSource = ds.Tables[0];
DataGridViewRow row = new DataGridViewRow();
row = dgvPrescription.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);
}
btnPrescriptionSearch_Click(sender, e);
}
2024-02-20 10:06:03 -05:00
}
private void cmuPrescriptionNew_Click_1(object sender, EventArgs e)
{
frmPrescription medicationAdd = new frmPrescription(this, true);
medicationAdd.MdiParent = MdiParent;
medicationAdd.StartPosition = FormStartPosition.CenterScreen;
medicationAdd.Show();
medicationAdd.Focus();
}
2024-02-20 10:06:03 -05:00
public void btnPrescriptionSearch_Click(object sender, EventArgs e)
2024-02-20 10:06:03 -05:00
{
2024-02-20 13:12:40 -05:00
string rxNum = "";
string physID = "";
string medID = "";
string patID = "";
2024-02-20 17:26:44 -05:00
if (txtRxPatientID.Text.Length + txtRxPrescriptionID.Text.Length + txtRxPhysicianID.Text.Length + txtRxMedicationID.Text.Length> 0)
2024-02-20 13:12:40 -05:00
{
try
{
2024-02-20 17:26:44 -05:00
rxNum = txtRxPrescriptionID.Text;
medID = txtRxMedicationID.Text;
physID = txtRxPhysicianID.Text;
patID = txtRxPatientID.Text;
2024-02-20 13:12:40 -05:00
try
{
ds = PharmacyDataTier.PrescriptionInfoSearch(rxNum, patID, medID, physID);
2024-02-20 13:12:40 -05:00
if (ds.Tables[0].Rows.Count > 0) // There is a record.
{
dgvPrescription.Visible = true;
2024-02-20 13:12:40 -05:00
// Get data source.
dgvPrescription.DataSource = ds.Tables[0];
dgvPrescription.AlternatingRowsDefaultCellStyle.BackColor = Color.LightGreen;
2024-02-20 13:12:40 -05:00
// Set the row and column header styles.
dgvPrescription.ColumnHeadersDefaultCellStyle.ForeColor = Color.White;
dgvPrescription.ColumnHeadersDefaultCellStyle.BackColor = Color.Green;
2024-02-20 13:12:40 -05:00
}
else
{
2024-02-21 00:55:50 -05:00
dgvPrescription.Visible = false; // Hide the DataGridView if no results are found.
2024-02-20 13:12:40 -05:00
MessageBox.Show("No records found.");
}
}
catch (Exception exception)
{
ep1.SetError(btnMedicationSearch, "Error Searching");
}
}
catch (Exception exception)
{
2024-02-20 13:12:40 -05:00
ep1.SetError(txtMedicationName, "Invalid Value");
2024-02-20 13:12:40 -05:00
}
2024-02-20 13:12:40 -05:00
}
cmuPrescriptionEdit.Enabled = dgvPrescription.Rows.Count > 0;
cmuPrescriptionDelete.Enabled = dgvPrescription.Rows.Count > 0;
2024-02-21 00:27:38 -05:00
cmuPrescriptionRefillThis.Enabled = dgvPrescription.Rows.Count > 0;
cmuPrescriptionViewRefills.Enabled = dgvPrescription.Rows.Count > 0;
2024-02-21 00:41:58 -05:00
// dgvPrescription.Visible = dgvPrescription.Rows.Count > 0;
2024-02-20 13:12:40 -05:00
dgvPrescription.Focus();
2024-02-20 13:12:40 -05:00
2024-02-20 10:06:03 -05:00
}
2024-02-20 13:37:00 -05:00
private void txtRxPatientID_TextChanged(object sender, EventArgs e)
{
}
2024-02-20 17:26:44 -05:00
private void cmuPrescriptionRefillThis_Click(object sender, EventArgs e)
2024-02-20 16:57:25 -05:00
{
string refillID = "";
DateTime date = new DateTime();
string patientID = "";
string medicationID = "";
string rxNum = "";
2024-02-20 22:13:20 -05:00
string numRefills = "";
string pastNumRefills = "";
try
{
DataSet ds = new DataSet();
PharmacyDataTier phaDT = new PharmacyDataTier();
2024-02-20 22:13:20 -05:00
//dgvPrescription.DataSource = ds.Tables[0];
// Console.WriteLine( dgvPatient.SelectedRows.Count);
DataGridViewRow row = new DataGridViewRow();
row = dgvPrescription.SelectedRows[0];
rxNum = (row.Cells[0].Value).ToString();
2024-02-20 22:13:20 -05:00
numRefills = row.Cells[1].Value.ToString();
pastNumRefills = row.Cells[2].Value.ToString();
2024-02-20 22:23:32 -05:00
if (Int32.Parse(pastNumRefills) >= Int32.Parse(numRefills))
{
MessageBox.Show("This prescription has reached the maximum number of refills.", "Max Refill", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
refillID = PharmacyDataTier.GetNextRefillID().ToString();
2024-02-21 00:27:38 -05:00
while (refillID.Length < 10)
{
refillID = "0" + refillID;
}
date = DateTime.Now;
2024-02-20 22:13:20 -05:00
patientID = row.Cells[6].Value.ToString() ;
medicationID = row.Cells[5].Value.ToString() ;
PharmacyDataTier.AddRefill(refillID, date, patientID, medicationID, rxNum);
PharmacyDataTier.PastRefills(rxNum);
btnPrescriptionSearch_Click(sender,e);
}
}
catch (Exception exception)
{
2024-02-20 16:57:25 -05:00
}
2024-02-20 16:57:25 -05:00
}
2024-02-20 17:26:44 -05:00
private void dgvRx_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
public void btnMedicationSearch_Click(object sender, EventArgs e)
{
string medID = "";
string medicationName = "";
if (txtMedicationName.Text.Length+txtMedicationNumber.Text.Length > 0)
{
try
{
medicationName = txtMedicationName.Text;
try
{
medID = txtMedicationNumber.Text;
try
{
ds = PharmacyDataTier.MedicationInfoSearch(medID,medicationName);
if (ds.Tables[0].Rows.Count > 0) // There is a record.
{
dgvMedication.Visible = true;
// Get data source.
dgvMedication.DataSource = ds.Tables[0];
dgvMedication.AlternatingRowsDefaultCellStyle.BackColor = Color.LightGreen;
// Set the row and column header styles.
dgvMedication.ColumnHeadersDefaultCellStyle.ForeColor = Color.White;
dgvMedication.ColumnHeadersDefaultCellStyle.BackColor = Color.Green;
}
else
{
2024-02-21 00:55:50 -05:00
dgvMedication.Visible = false; // Hide the DataGridView if no results are found.
MessageBox.Show("No records found.");
}
}
catch (Exception exception)
{
ep1.SetError(btnMedicationSearch, "Error Searching");
}
}
catch (Exception exception)
{
ep1.SetError(txtMedicationNumber, "Invalid Value");
}
}
catch (Exception exception)
{
ep1.SetError(txtMedicationName, "Invalid Value");
}
}
cmuMedicationEdit.Enabled = dgvMedication.Rows.Count > 0;
cmuMedicationDelete.Enabled = dgvMedication.Rows.Count > 0;
2024-02-21 00:41:58 -05:00
// dgvMedication.Visible = dgvMedication.Rows.Count > 0;
dgvMedication.Focus();
}
2024-02-20 22:13:20 -05:00
2024-02-20 23:57:48 -05:00
public void cmuPrescriptionViewRefills_Click(object sender, EventArgs e)
2024-02-20 22:13:20 -05:00
{
2024-02-20 23:57:48 -05:00
DataGridViewRow row = new DataGridViewRow();
row = dgvPrescription.SelectedRows[0];
string rxNumString = (row.Cells[0].Value).ToString();
Int32 rxNum = Int32.Parse(rxNumString);
2024-02-20 22:13:20 -05:00
2024-02-20 23:57:48 -05:00
frmRefill refill = new frmRefill(rxNum);
2024-02-21 00:37:37 -05:00
refill.MdiParent = MdiParent;
refill.StartPosition = FormStartPosition.CenterScreen;
refill.Show();
refill.Focus();
2024-02-20 22:13:20 -05:00
}
2024-01-31 12:05:11 -05:00
}
}
2024-02-20 18:37:49 -05:00