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; using Microsoft.VisualBasic; using System.Configuration; using System.Collections; using System.Data.SqlClient; namespace Louis__Pharmacy_CNSA212_FP { public partial class frmRefill : Form { public DataSet ds = new DataSet(); private int rxNum = 0; private frmInfo SourceForm = new frmInfo(); public frmRefill(int thisRxID, frmInfo SenderForm) { SourceForm = SenderForm; InitializeComponent(); rxNum = thisRxID; frmRefill_Load(null, null); } //private void rEFILLSBindingNavigatorSaveItem_Click(object sender, EventArgs e) //{ //} private void frmRefill_Load(object sender, EventArgs e) { int rxID = 0; DataGridViewRow row = new DataGridViewRow(); rxID = rxNum; DataSet ds = new DataSet(); ds = PharmacyDataTier.GetRefill(rxID.ToString()); dgvRefills.DataSource = ds.Tables[0]; } public void frmRefill_reLoad(object sender, EventArgs e) { int rxID = 0; DataGridViewRow row = new DataGridViewRow(); rxID = rxNum; DataSet ds = new DataSet(); ds = PharmacyDataTier.GetRefill(rxID.ToString()); dgvRefills.DataSource = ds.Tables[0]; } private void editToolStripMenuItem_Click(object sender, EventArgs e) { string refillID = ""; DataGridViewRow row = new DataGridViewRow(); row = dgvRefills.SelectedRows[0]; refillID = (row.Cells[0].Value).ToString(); frmRefillAdd add = new frmRefillAdd(false, this); add.MdiParent = MdiParent; add.StartPosition = FormStartPosition.CenterScreen; add.Show(); add.Focus(); add.FillRefill(refillID); } private void dgvRefills_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { editToolStripMenuItem_Click(sender, e); } private void deleteToolStripMenuItem_Click(object sender, EventArgs e) { string refillID = ""; string rxID = ""; DataGridViewRow row = new DataGridViewRow(); row = dgvRefills.SelectedRows[0]; refillID = (row.Cells[0].Value).ToString(); rxID = (row.Cells[4].Value).ToString(); PharmacyDataTier.DeleteRefill(refillID); PharmacyDataTier.DecrementPastRefills(rxID); frmRefill_reLoad(sender, e); SourceForm.btnPrescriptionSearch_Click(sender,e); } public void refreshrefills(object sender, EventArgs e) { DataGridViewRow row = new DataGridViewRow(); row = dgvRefills.SelectedRows[0]; string rxNumString = (row.Cells[4].Value).ToString(); Int32 rxNum = Int32.Parse(rxNumString); frmRefill_Load(null, null); } private void cmuRefresh_Click(object sender, EventArgs e) { refreshrefills(sender, e); } //private void btnSearch_Click(object sender, EventArgs e) //{ // string patientID = ""; // DateTime date = new DateTime(); // try // { //DataSet ds = new DataSet(); //PharmacyDataTier phaDT = new PharmacyDataTier(); //patientID = txtPatientID.Text.Trim(); //if (txtDate.Text.Trim().Length > 0) //{ //date = DateTime.Parse(txtDate.Text.Trim()); //} // ds = PharmacyDataTier.RefillSearch(date, patientID); // if (ds.Tables[0].Rows.Count > 0 ) // { // dgvRefills.Visible = true; // dgvRefills.DataSource = ds.Tables[0]; // dgvRefills.AlternatingRowsDefaultCellStyle.BackColor = Color.Black; // dgvRefills.AlternatingRowsDefaultCellStyle.ForeColor = Color.White; // } // else // { // dgvRefills.Visible = false; // MessageBox.Show("No records found"); // } // } // catch (Exception ex) // { // } //} //private void cmuAdd_Click(object sender, EventArgs e) //{ // frmRefillAdd refillAdd = new frmRefillAdd(true); // refillAdd.MdiParent = MdiParent; // refillAdd.StartPosition = FormStartPosition.CenterScreen; // refillAdd.Show(); // refillAdd.Focus(); //} //private void cmuUpdate_Click(object sender, EventArgs e) //{ // string refillID = ""; // if (dgvRefills.Rows.Count > 0) // { // //dgvRefills.DataSource = ds.Tables[0]; // DataGridViewRow row = new DataGridViewRow(); // row = dgvRefills.SelectedRows[0]; // refillID = (row.Cells[0].Value).ToString(); // frmRefillAdd refillUpdate = new frmRefillAdd(false); // refillUpdate.MdiParent = MdiParent; // refillUpdate.StartPosition = FormStartPosition.CenterScreen; // refillUpdate.Show(); // refillUpdate.Focus(); // refillUpdate.FillRefill(refillID); // } //} //private void cmuDelete_Click(object sender, EventArgs e) //{ // string refillID = ""; // //dgvRefills.DataSource = ds.Tables[0]; // DataGridViewRow row = new DataGridViewRow(); // row = dgvRefills.SelectedRows[0]; // refillID = (row.Cells[0].Value).ToString(); // PharmacyDataTier.DeleteRefill(refillID); // btnSearch_Click(sender, e); //} } }