コード例 #1
0
 public JsonResult GuardarBandejaModificarLavadoCisterna(CC_LAVADO_CISTERNA model, int siAprobar)
 {
     try
     {
         lsUsuario = User.Identity.Name.Split('_');
         if (!User.Identity.IsAuthenticated)
         {
             return(Json("101", JsonRequestBehavior.AllowGet));
         }
         clsDControlLavadoCisterna = new clsDControlLavadoCisterna();
         model.FechaIngresoLog     = DateTime.Now;
         model.TerminalIngresoLog  = Request.UserHostAddress;
         model.EstadoRegistro      = clsAtributos.EstadoRegistroActivo;
         model.UsuarioIngresoLog   = lsUsuario[0];
         var valor = clsDControlLavadoCisterna.GuardarModificarLavadoCisterna(model, siAprobar);
         if (valor == 0)
         {
             return(Json("0", JsonRequestBehavior.AllowGet));
         }
         else if (valor == 1)
         {
             return(Json("1", JsonRequestBehavior.AllowGet));
         }
         else
         {
             return(Json("2", 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));
     }
 }
コード例 #2
0
        public JsonResult GuardarModificarLavadoCisterna(CC_LAVADO_CISTERNA model, string idMantCisterna, List <string> idIntermedia, int siAprobar, DateTime fechaDesde)
        {
            var splitIdMantCisterna = idMantCisterna.Split(';');

            try
            {
                lsUsuario = User.Identity.Name.Split('_');
                if (!User.Identity.IsAuthenticated)
                {
                    return(Json("101", JsonRequestBehavior.AllowGet));
                }
                clsDControlLavadoCisterna = new clsDControlLavadoCisterna();
                var  consultarEstadoReporte = clsDControlLavadoCisterna.ConsultarLavadoCisterna(fechaDesde, Convert.ToDateTime("01-01-2020"), model.IdLavadoCisterna, 4);
                bool estadoReporte          = false;
                if (consultarEstadoReporte.Count != 0)
                {
                    estadoReporte = consultarEstadoReporte[0].EstadoReporteCab;
                }
                if (estadoReporte == false)
                {
                    model.FechaIngresoLog    = DateTime.Now;
                    model.EstadoRegistro     = clsAtributos.EstadoRegistroActivo;
                    model.TerminalIngresoLog = Request.UserHostAddress;
                    model.UsuarioIngresoLog  = lsUsuario[0];
                    var valor = clsDControlLavadoCisterna.GuardarModificarLavadoCisterna(model, siAprobar);
                    //GUARDAR EN LA TABLA INTERMEDIA
                    int idCisterna = model.IdLavadoCisterna;
                    foreach (var item in splitIdMantCisterna)
                    {
                        if (!string.IsNullOrWhiteSpace(item))
                        {
                            CC_INTERMEDIA_CTRL_MANT_CISTERNA modelIntermedia = new CC_INTERMEDIA_CTRL_MANT_CISTERNA();
                            modelIntermedia.IdCtrlLavadoCisterna = Convert.ToInt32(idCisterna);
                            modelIntermedia.IdMantCisterna       = Convert.ToInt32(item);
                            modelIntermedia.FechaIngresoLog      = DateTime.Now;
                            modelIntermedia.EstadoRegistro       = clsAtributos.EstadoRegistroActivo;
                            modelIntermedia.TerminalIngresoLog   = Request.UserHostAddress;
                            modelIntermedia.UsuarioIngresoLog    = lsUsuario[0];
                            var guardar = clsDControlLavadoCisterna.GuardarModificarLavadoCisternaIntermedia(modelIntermedia);
                        }
                    }
                    //ELIMINO TODOS LOS REGISTROS DE LA TABLA INTERMEDIA QUE CORESPONDAN AL ITEM A ACTUALIZAR. SEGUN LA LISTA idIntermedia PARAMETRO DE ENTRADA
                    //HAGO ESTO YA QUE ES COMPLICADO ATUALIZAR UNO POR UNO, Y PEOR CUANDO EL USUARIO INGRESA 5 CISTERNAS Y LUEGO ACTUALIZA A 1.
                    if (idIntermedia != null)
                    {
                        foreach (var item in idIntermedia)
                        {
                            CC_INTERMEDIA_CTRL_MANT_CISTERNA modelIntermedia = new CC_INTERMEDIA_CTRL_MANT_CISTERNA();
                            modelIntermedia.IdIntermedia       = Convert.ToInt32(item);
                            modelIntermedia.FechaIngresoLog    = DateTime.Now;
                            modelIntermedia.EstadoRegistro     = clsAtributos.EstadoRegistroInactivo;
                            modelIntermedia.TerminalIngresoLog = Request.UserHostAddress;
                            modelIntermedia.UsuarioIngresoLog  = lsUsuario[0];
                            var guardar = clsDControlLavadoCisterna.EliminarLavadoCisternaIntermedia(modelIntermedia);
                        }
                    }
                    if (valor == 0)
                    {
                        return(Json("0", JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        return(Json("1", JsonRequestBehavior.AllowGet));
                    }
                }
                else
                {
                    return(Json("2", 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));
            }
        }