public ActionResult ControlPesoEnlatado(CONTROL_PESO_ENLATADO model) { try { lsUsuario = User.Identity.Name.Split('_'); if (string.IsNullOrEmpty(lsUsuario[0])) { return(Json("101", JsonRequestBehavior.AllowGet)); } if (string.IsNullOrEmpty(model.CodigoProducto) || string.IsNullOrEmpty(model.LineaEnlatado) || string.IsNullOrEmpty(model.Peso) || string.IsNullOrEmpty(model.Turno)) { return(Json("0", JsonRequestBehavior.AllowGet)); } clsDControlPesoEnlatado = new clsDControlPesoEnlatado(); model.EstadoRegistro = clsAtributos.EstadoRegistroActivo; model.FechaIngresoLog = DateTime.Now; model.TerminalIngresoLog = Request.UserHostAddress; model.UsuarioIngresoLog = lsUsuario[0]; if (!clsDControlPesoEnlatado.ValidaControlPesoEnlatado(model)) { return(Json("1", JsonRequestBehavior.AllowGet)); } clsDControlPesoEnlatado.GuardarModificarControlPesoEnlatado(model); return(Json("Registro Exitoso", JsonRequestBehavior.AllowGet)); } catch (DbEntityValidationException e) { Response.StatusCode = (int)HttpStatusCode.InternalServerError; 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); return(Json(Mensaje, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { Response.StatusCode = (int)HttpStatusCode.InternalServerError; 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); return(Json(Mensaje, JsonRequestBehavior.AllowGet)); } }
public void GuardarModificarControlPesoEnlatado(CONTROL_PESO_ENLATADO model) { using (ASIS_PRODEntities entities = new ASIS_PRODEntities()) { var control = entities.CONTROL_PESO_ENLATADO.FirstOrDefault(x => x.IdControlPesoEnlatado == model.IdControlPesoEnlatado); if (control != null) { control.EstadoRegistro = model.EstadoRegistro; control.FechaModificacionLog = DateTime.Now; control.UsuarioModificacionLog = model.UsuarioIngresoLog; control.TerminalModificacionLog = model.TerminalIngresoLog; } else { entities.CONTROL_PESO_ENLATADO.Add(model); } entities.SaveChanges(); } }
public bool ValidaControlPesoEnlatado(CONTROL_PESO_ENLATADO model) { var valida = true; using (ASIS_PRODEntities entities = new ASIS_PRODEntities()) { var control = entities.CONTROL_PESO_ENLATADO.FirstOrDefault(x => x.Fecha == model.Fecha && x.Peso == model.Peso && x.LineaEnlatado == model.LineaEnlatado && x.OrdenFabricacion == model.OrdenFabricacion && x.EstadoRegistro == clsAtributos.EstadoRegistroActivo); if (control != null) { valida = false; } } return(valida); }