示例#1
0
        private void btnQuitar_Click(object sender, EventArgs e)
        {
            try
            {
                if (MessageBox.Show("Desea eliminar este registro?", "Profit Expansion", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Yes)
                {
                    using (Profit_RGEntities context = new Profit_RGEntities())
                    {
                        switch (Porigen.Trim())
                        {
                        case "Usuarios":
                            context.pEliminarUsu_Prg(Cod.Trim(), Convert.ToInt32(grdDatos[0, grdDatos.CurrentCell.RowIndex].Value.ToString()));
                            break;

                        case "Programas":
                            context.pEliminarUsu_Prg(grdDatos[0, grdDatos.CurrentCell.RowIndex].Value.ToString(), Convert.ToInt32(Cod));
                            break;
                        }
                    }
                    CargarDatos();
                }
            }
            catch (EntityException ex)
            {
                MessageBox.Show(ex.InnerException.Message, "Profit Expansion", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ex1)
            {
                MessageBox.Show(ex1.Message, "Profit Expansion", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }