Exemple #1
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {//BOTON GUARDAR
            btnCancelar.Enabled = true;
            btnGuardar.Enabled  = true;
            try
            {
                Secciones sec = new Secciones()
                {
                    // Id = int.Parse(txtCodigo.Text),
                    Nombre = txtNombreSeccion.Text,
                    Nivel  = (Capa.Entidades.Nivel)cboNivel.SelectedItem
                };
                dgvSecciones.DataSource = sec;

                logica.Guardar(sec);
                MessageBox.Show("  Datos guardados con exito ");
                bindingSource1.Add(sec);
                dgvSecciones.DataSource = bindingSource1;
                Refrescar();
                Limpiar();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message, "Error al guardar la seccion"
                                , MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }