Exemplo n.º 1
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                ClassLibrary.SupplierOrder sorder = new ClassLibrary.SupplierOrder();

                object  id          = dataGridView1.CurrentRow.Cells["SORDER_id"].Value;
                DataRow selectedRow = dtSOrder.Rows.Find(id);

                DialogResult dlgResult = MessageBox.Show
                                             ("Are you sure you want to delete \nselected order with id of " + id,
                                             "Continue?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

                if (dlgResult == DialogResult.Yes)
                {
                    sorder.Id = Convert.ToInt32(id);
                    sorder.Delete();
                    DisplayAllSOrders();
                }
            }
            catch (Exception ex)
            {
                DialogResult dlgResult = MessageBox.Show
                                             ("Cant delete the record!",
                                             "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }