Ejemplo n.º 1
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            Empleado empleado = new Empleado();

            empleado.Apellido = txtApellidos.Text;
            empleado.Nombre   = txtNombre.Text;
            empleado.DNI      = Convert.ToInt32(txtDNI.Text);

            EmpleadoBLL empleadosBLL = new EmpleadoBLL();

            if (id <= 0)
            {
                try
                {
                    empleadosBLL.Guardar(empleado);
                    this.Close();
                }
                catch (RestauranteDataException)
                {
                    MessageBox.Show("Ha ocurrido un error en la base de datos");
                }
                catch (RestauranteValidacionException)
                {
                    MessageBox.Show("Verifique los datos ingresados");
                }
            }
            else
            {
                empleado.Id = id;
                empleadosBLL.Editar(empleado);
                this.Close();
            }
        }
        public ActionResult Modificar(Empleado empleado)
        {
            try
            {
                EmpleadoBLL.Editar(empleado);

                return(Json(new { ok = true, toRedirect = Url.Action("Index") }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new { ok = false, msg = "Ocurrió un error al modificar el empleado. " + ex.Message }, JsonRequestBehavior.AllowGet));
            }
        }