public void Aprobar_ReporteCloroAguaAutoclave(CC_CLORO_AGUA_AUTOCLAVE_CONTROL controlCloro, string Turno) { using (ASIS_PRODEntities db = new ASIS_PRODEntities()) { var model = db.CC_CLORO_AGUA_AUTOCLAVE_CONTROL.FirstOrDefault(x => x.IdCloroAguaAutoclaveControl == controlCloro.IdCloroAguaAutoclaveControl || (x.Fecha == controlCloro.Fecha && x.Turno == Turno && x.EstadoRegistro == clsAtributos.EstadoRegistroActivo)); if (model != null) { model.EstadoReporte = controlCloro.EstadoReporte; model.AprobadoPor = controlCloro.AprobadoPor; model.FechaAprobacion = controlCloro.FechaAprobacion; model.FechaModificacionLog = controlCloro.FechaIngresoLog; model.TerminalModificacionLog = controlCloro.TerminalIngresoLog; model.UsuarioModificacionLog = controlCloro.UsuarioIngresoLog; db.SaveChanges(); } } }
public ActionResult ReversarBandejaControl(CC_CLORO_AGUA_AUTOCLAVE_CONTROL model, string Turno) { try { lsUsuario = User.Identity.Name.Split('_'); if (string.IsNullOrEmpty(lsUsuario[0])) { return(Json("101", JsonRequestBehavior.AllowGet)); } ClsDCloroAguaAutoclave = new ClsDCloroAguaAutoclave(); model.FechaAprobacion = null; model.AprobadoPor = null; model.EstadoReporte = clsAtributos.EstadoReportePendiente; model.FechaIngresoLog = DateTime.Now; model.EstadoRegistro = clsAtributos.EstadoRegistroActivo; model.TerminalIngresoLog = Request.UserHostAddress; model.UsuarioIngresoLog = lsUsuario[0]; clsDPeriodo = new clsDPeriodo(); if (!clsDPeriodo.ValidaFechaPeriodo(model.Fecha)) { return(Json("800", JsonRequestBehavior.AllowGet)); } ClsDCloroAguaAutoclave.Aprobar_ReporteCloroAguaAutoclave(model, Turno); return(Json("Reporte reversado exitosamente", 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 GuardarModificarCloroAguaAutoclave(CC_CLORO_AGUA_AUTOCLAVE model, DateTime Fecha, string Turno) { using (ASIS_PRODEntities entities = new ASIS_PRODEntities()) { using (var transaction = entities.Database.BeginTransaction()) { CC_CLORO_AGUA_AUTOCLAVE_CONTROL poControlReporte = entities.CC_CLORO_AGUA_AUTOCLAVE_CONTROL.FirstOrDefault(x => x.Fecha == Fecha && x.Turno == Turno && x.EstadoRegistro == clsAtributos.EstadoRegistroActivo); var parametros = entities.CC_PARAMETRO_CALIDAD.AsNoTracking().FirstOrDefault(x => x.CodParametro == clsAtributos.CodigoParametroCloroAguaAutoclave); int idControl = 0; if (poControlReporte != null) { idControl = poControlReporte.IdCloroAguaAutoclaveControl; } else { CC_CLORO_AGUA_AUTOCLAVE_CONTROL control = new CC_CLORO_AGUA_AUTOCLAVE_CONTROL(); if (parametros != null) { control.Minimo = parametros.Minimo; control.Maximo = parametros.Maximo; } control.Fecha = Fecha; control.Turno = Turno; control.EstadoReporte = false; control.FechaIngresoLog = model.FechaIngresoLog; control.TerminalIngresoLog = model.TerminalIngresoLog; control.EstadoRegistro = clsAtributos.EstadoRegistroActivo; control.EstadoReporte = false; control.UsuarioIngresoLog = model.UsuarioIngresoLog; entities.CC_CLORO_AGUA_AUTOCLAVE_CONTROL.Add(control); entities.SaveChanges(); idControl = control.IdCloroAguaAutoclaveControl; } var poControl = entities.CC_CLORO_AGUA_AUTOCLAVE.FirstOrDefault(x => x.IdCloroAguaAutoclave == model.IdCloroAguaAutoclave); if (poControl != null) { poControl.Observacion = string.IsNullOrEmpty(model.Observacion)?model.Observacion: model.Observacion.ToUpper(); poControl.Hora = model.Hora; poControl.Parada = model.Parada; poControl.Autoclave = model.Autoclave; poControl.Producto = model.Producto.ToUpper(); poControl.TipoConserva = model.TipoConserva; poControl.Cloro = model.Cloro; poControl.Temperatura = model.Temperatura; poControl.TerminalModificacionLog = model.TerminalIngresoLog; poControl.UsuarioModificacionLog = model.UsuarioIngresoLog; poControl.FechaModificacionLog = model.FechaIngresoLog; } else { model.Producto = model.Producto.ToUpper();; model.Observacion = string.IsNullOrEmpty(model.Observacion) ? model.Observacion : model.Observacion.ToUpper(); model.IdCloroAguaAutoclaveControl = idControl; entities.CC_CLORO_AGUA_AUTOCLAVE.Add(model); } entities.SaveChanges(); transaction.Commit(); } } }