Beispiel #1
0
        protected void lbBorrar_Click(object sender, EventArgs e)
        {
            LinkButton  lb       = (LinkButton)sender;
            HiddenField hd       = (HiddenField)lb.FindControl("hfID");
            int         id       = Convert.ToInt32(hd.Value);
            Empleado    empleado = new Empleado();

            empleado.id = id;
            if (empleadoDatos.Delete(empleado))
            {
                Application["mensaje"] = funcion.mensaje("Registro borrado");
            }
            else
            {
                Application["mensaje"] = funcion.mensaje("Error");
            }
            Response.Redirect("~/Forms/Empleados/Index.aspx");
        }
        public ActionResult Borrar()
        {
            int    id    = Convert.ToInt32(Request["id"]);
            string texto = "";
            string tipo  = "";

            if (empleadoDatos.Delete(id))
            {
                texto = "El empleado ha sido borrado exitosamente";
                tipo  = "success";
            }
            else
            {
                texto = "Ha ocurrido un error en la base de funcion";
                tipo  = "error";
            }
            TempData["mensaje"] = funcion.mensaje("Empleados", texto, tipo);
            return(RedirectToAction("Index", "Empleados"));
        }