private void btnDelete_Click(object sender, EventArgs e)
        {
            var confirmResult = MessageBox.Show("This will also delete all prescriptions and refills attached to this patient. Are you sure you want to delete this patient?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (confirmResult == DialogResult.Yes)
            {
                try
                {
                    //Send it throug the datatier
                    PharmacyDataTier bPharm = new PharmacyDataTier();
                    DataSet          ds1    = new DataSet();
                    ds1 = bPharm.DeletePatient(myPatientID);
                    MessageBox.Show("Patient deleted successfully", "Completed", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
                catch (Exception ex)
                {
                    string myException = ex.ToString();
                    MessageBox.Show(myException, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
            }
        }
Ejemplo n.º 2
0
        private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var confirmResult = MessageBox.Show("This will also delete all prescriptions and refills attached to this patient. Are you sure you want to delete this patient?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (confirmResult == DialogResult.Yes)
            {
                try
                {
                    DataGridViewRow row = dgvPatients.SelectedRows[0];
                    string          patientID;
                    patientID = row.Cells[0].Value.ToString();
                    //Send it throug the datatier
                    PharmacyDataTier bPharm = new PharmacyDataTier();
                    DataSet          ds1    = new DataSet();
                    ds1 = bPharm.DeletePatient(patientID);
                    MessageBox.Show("Patient deleted successfully", "Completed", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    try
                    {
                        //get the values
                        string fname      = txtPatientFName.Text.Trim();
                        string lname      = txtPatientLName.Text.Trim();
                        string patientID2 = txtPatientID.Text.Trim();

                        //Fill patient datagrid
                        PharmacyDataTier cPharm = new PharmacyDataTier();
                        DataSet          ds2    = new DataSet();
                        ds1 = bPharm.GetPatient(fname, lname, patientID2);

                        dgvPatients.DataSource = ds1.Tables[0];
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                catch (Exception ex)
                {
                    string myException = ex.ToString();
                    MessageBox.Show(myException, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
            }
        }