private void btnEliminar_Click(object sender, EventArgs e) { if (dataGridView1.SelectedRows.Count > 0) { DialogResult k = MessageBox.Show("Estas seguro de eliminar este registro?", "aviso", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); int rpta = 0; if (k == DialogResult.Yes) { //capturar la fila del id para poder eliminar int id = (int)dataGridView1.CurrentRow.Cells["ID"].Value; rpta = new LCategorias().Delete(id); if (rpta > 0) { MessageBox.Show("datos eliminados correctamente", "aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning); mostrarDatos(); } } } else { MessageBox.Show("debe seleccionar un elemento"); } }
private void btnGuardar_Click(object sender, EventArgs e) { ECategorias obj = new ECategorias { ID = lblID.Text.Length == 0 ? 0 : int.Parse(lblID.Text), Nombre = txtNombre.Text.Trim().ToUpper(), Descripcion = txtDescripcion.Text.Trim().ToUpper(), Estado = chkEstado.Checked }; int rpta = 0; if (operacion == (byte)MisConstantes.OPERACION.Insercion) { rpta = new LCategorias().Create(obj); } else { rpta = new LCategorias().Update(obj); } if (rpta > 0) { MessageBox.Show("operacion realizada correctamente", "AVISO", MessageBoxButtons.OK, MessageBoxIcon.Information); this.DialogResult = DialogResult.OK; this.Close(); } else { MessageBox.Show("la categoria ya existe"); } }
public CategoriasController(ApplicationDbContext context, SignInManager <IdentityUser> signInManager) { _signInManager = signInManager; _lcategoria = new LCategorias(context); }
public CursosController(ApplicationDbContext context, SignInManager <IdentityUser> signInManager, IWebHostEnvironment environment) { _signInManager = signInManager; _lcategoria = new LCategorias(context); _curso = new LCursos(context, environment); }