public string GuardarModificarCuchillo(CUCHILLO model) { using (ASIS_PRODEntities entities = new ASIS_PRODEntities()) { var Listado = entities.CUCHILLO.FirstOrDefault(x => x.NumeroCuchillo == model.NumeroCuchillo && x.ColorCuchillo == model.ColorCuchillo); if (Listado != null) { Listado.EstadoRegistro = model.EstadoRegistro; Listado.FechaModificacionLog = model.FechaIngresoLog; Listado.TerminalModificacionLog = model.TerminalIngresoLog; Listado.UsuarioModificacionLog = model.UsuarioIngresoLog; } else { entities.CUCHILLO.Add(model); } entities.SaveChanges(); return(clsAtributos.MsjRegistroGuardado); } }
public List <CUCHILLO> ConsultarCuchillos(CUCHILLO filtros) { using (ASIS_PRODEntities entities = new ASIS_PRODEntities()) { IEnumerable <CUCHILLO> Cuchillos = entities.CUCHILLO; if (filtros.NumeroCuchillo > 0) { Cuchillos = Cuchillos.Where(x => x.NumeroCuchillo == filtros.NumeroCuchillo); } if (!string.IsNullOrEmpty(filtros.ColorCuchillo)) { Cuchillos = Cuchillos.Where(x => x.ColorCuchillo == filtros.ColorCuchillo); } IEnumerable <CUCHILLO> Listado = (from c in Cuchillos join color in entities.CLASIFICADOR on c.ColorCuchillo equals color.Codigo where color.Grupo == clsAtributos.CodigoGrupoColorCuchillo select new CUCHILLO { ColorCuchillo = color.Descripcion, EstadoRegistro = c.EstadoRegistro, FechaIngresoLog = c.FechaIngresoLog, FechaModificacionLog = c.FechaModificacionLog, NumeroCuchillo = c.NumeroCuchillo, TerminalIngresoLog = c.TerminalIngresoLog, TerminalModificacionLog = c.TerminalModificacionLog, UsuarioIngresoLog = c.UsuarioIngresoLog, UsuarioModificacionLog = c.UsuarioModificacionLog } ); return(Listado.ToList()); } }
// GET: Asistencia/Cuchillo public ActionResult Cuchillo(CUCHILLO model) { try { if (model.NumeroCuchillo == 0) { return(Json("1", JsonRequestBehavior.AllowGet)); } clsDCuchillo = new clsDCuchillo(); lsUsuario = User.Identity.Name.Split('_'); model.EstadoRegistro = model.EstadoRegistro == "true" ? clsAtributos.EstadoRegistroActivo : clsAtributos.EstadoRegistroInactivo; model.FechaIngresoLog = DateTime.Now; model.UsuarioIngresoLog = lsUsuario[0]; model.TerminalIngresoLog = Request.UserHostAddress; var Respuesta = clsDCuchillo.GuardarModificarCuchillo(model); // SetSuccessMessage(Respuesta); // return RedirectToAction("Cuchillo"); return(Json(Respuesta, JsonRequestBehavior.AllowGet)); } catch (DbEntityValidationException e) { clsDError = new clsDError(); lsUsuario = User.Identity.Name.Split('_'); string Mensaje = clsDError.ControlError(lsUsuario[0], Request.UserHostAddress, this.ControllerContext.RouteData.Values["controller"].ToString(), "Metodo: " + this.ControllerContext.RouteData.Values["action"].ToString(), null, e); SetErrorMessage(Mensaje); return(RedirectToAction("Home", "Home")); } catch (Exception ex) { clsDError = new clsDError(); lsUsuario = User.Identity.Name.Split('_'); string Mensaje = clsDError.ControlError(lsUsuario[0], Request.UserHostAddress, this.ControllerContext.RouteData.Values["controller"].ToString(), "Metodo: " + this.ControllerContext.RouteData.Values["action"].ToString(), ex, null); SetErrorMessage(Mensaje); return(RedirectToAction("Home", "Home")); } }