コード例 #1
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            var confirmResult = MessageBox.Show("This will also delete all fulfillments attached to this prescription. Are you sure you want to delete this prescription?", "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.DeletePrescription(myPrescriptionID);
                    MessageBox.Show("prescription sucesfully deleted", "Completed", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
                catch (Exception ex)
                {
                    string myException = ex.ToString();
                    MessageBox.Show(myException, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
            }
        }
コード例 #2
0
        private void removeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var confirmResult = MessageBox.Show("This will also delete all fulfillments attached to this prescription. Are you sure you want to delete this prescription?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (confirmResult == DialogResult.Yes)
            {
                try
                {
                    if (dgvPrescriptions.Rows.Count > 0)
                    {
                        DataGridViewRow row = dgvPrescriptions.SelectedRows[0];
                        myPrescriptionID = row.Cells[0].Value.ToString();
                        //Send it throug the datatier
                        PharmacyDataTier bPharm = new PharmacyDataTier();
                        DataSet          ds1    = new DataSet();
                        ds1 = bPharm.DeletePrescription(myPrescriptionID);
                        MessageBox.Show("Prescription deleted successfully", "Completed", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        UpdatePrescriptionDGV();
                    }
                    else
                    {
                        MessageBox.Show("Please select a row to delete", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                catch (Exception ex)
                {
                    string myException = ex.ToString();
                    MessageBox.Show(myException, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
            }
        }