コード例 #1
0
        public List <EmpleadoCuchilloViewModel> ConsultarEmpleadoCuchillo(EmpleadoCuchilloViewModel filtros, string Linea)
        {
            using (ASIS_PRODEntities entities = new ASIS_PRODEntities())
            {
                clsDEmpleado = new clsDEmpleado();
                List <spConsultaCuchilloEmpleado> EmpleadosCuchillos = new List <spConsultaCuchilloEmpleado>();


                if (!string.IsNullOrEmpty(filtros.Cedula))
                {
                    EmpleadosCuchillos = entities.spConsultaCuchilloEmpleado(filtros.Cedula, "").ToList();
                }
                else
                {
                    EmpleadosCuchillos = entities.spConsultaCuchilloEmpleado("0", Linea).ToList();
                }

                if (!string.IsNullOrEmpty(Linea))
                {
                    //EmpleadosCuchillos= EmpleadosCuchillos.Where(x=>x.linea)
                }

                List <EmpleadoCuchilloViewModel> Listado = (from c in EmpleadosCuchillos
                                                            select new EmpleadoCuchilloViewModel
                {
                    IdEmpleadoCuchillo = c.IdEmpleadoCuchillo,
                    Cedula = c.Cedula,
                    Nombre = c.Nombre,
                    CuchilloBlanco = c.CuchilloBlanco,
                    CuchilloRojo = c.CuchilloRojo,
                    CuchilloNegro = c.CuchilloNegro,
                    EstadoRegistro = c.EstadoRegistro,
                    FechaIngresoLog = c.FechaIngresoLog,
                    FechaModificacionLog = c.FechaModificacionLog,
                    TerminalIngresoLog = c.TerminalIngresoLog,
                    TerminalModificacionLog = c.TerminalModificacionLog,
                    UsuarioIngresoLog = c.UsuarioIngresoLog,
                    UsuarioModificacionLog = c.UsuarioModificacionLog
                }
                                                            ).ToList();


                return(Listado);
            }
        }
コード例 #2
0
 public ActionResult CuchilloEmpleado(EmpleadoCuchilloViewModel model)
 {
     try
     {
         lsUsuario = User.Identity.Name.Split('_');
         if (string.IsNullOrEmpty(lsUsuario[0]))
         {
             return(Json("101", JsonRequestBehavior.AllowGet));
         }
         if (!ModelState.IsValid)
         {
             return(Json("1", JsonRequestBehavior.AllowGet));
         }
         else
         {
             clsDCuchillo             = new clsDCuchillo();
             model.EstadoRegistro     = model.EstadoRegistro == "true" ? clsAtributos.EstadoRegistroActivo : clsAtributos.EstadoRegistroInactivo;
             model.FechaIngresoLog    = DateTime.Now;
             model.UsuarioIngresoLog  = lsUsuario[0];
             model.TerminalIngresoLog = Request.UserHostAddress;
             RespuestaGeneral respuesta = new RespuestaGeneral();
             respuesta = clsDCuchillo.GuardarModificarEmpleadoCuchillo(model);
             return(Json(respuesta, 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));
     }
 }
コード例 #3
0
        public RespuestaGeneral GuardarModificarEmpleadoCuchillo(EmpleadoCuchilloViewModel model)
        {
            using (ASIS_PRODEntities entities = new ASIS_PRODEntities())
            {
                if (model.CuchilloBlanco > 0)
                {
                    var validacion = entities.EMPLEADO_CUCHILLO.FirstOrDefault(x => x.CuchilloBlanco == model.CuchilloBlanco &&
                                                                               x.EstadoRegistro == clsAtributos.EstadoRegistroActivo && x.Cedula != model.Cedula);
                    if (validacion != null)
                    {
                        return new RespuestaGeneral
                               {
                                   Codigo      = 1,
                                   Respuesta   = false,
                                   Descripcion = "Cuchillo Blanco ya se encuentra asignado a otro empleado(" + validacion.Cedula + ")"
                               }
                    }
                    ;
                }
                if (model.CuchilloRojo > 0)
                {
                    var validacion = entities.EMPLEADO_CUCHILLO.FirstOrDefault(x => x.CuchilloRojo == model.CuchilloRojo &&
                                                                               x.EstadoRegistro == clsAtributos.EstadoRegistroActivo && x.Cedula != model.Cedula);
                    if (validacion != null)
                    {
                        return new RespuestaGeneral
                               {
                                   Codigo      = 1,
                                   Respuesta   = false,
                                   Descripcion = "Cuchillo Rojo ya se encuentra asignado a otro empleado(" + validacion.Cedula + ")"
                               }
                    }
                    ;
                }
                if (model.CuchilloNegro > 0)
                {
                    var validacion = entities.EMPLEADO_CUCHILLO.FirstOrDefault(x => x.CuchilloNegro == model.CuchilloNegro &&
                                                                               x.EstadoRegistro == clsAtributos.EstadoRegistroActivo && x.Cedula != model.Cedula);
                    if (validacion != null)
                    {
                        return new RespuestaGeneral
                               {
                                   Codigo      = 1,
                                   Respuesta   = false,
                                   Descripcion = "Cuchillo Negro ya se encuentra asignado a otro empleado(" + validacion.Cedula + ")"
                               }
                    }
                    ;
                }

                var EmpleadoCuchillo = entities.EMPLEADO_CUCHILLO.FirstOrDefault(x =>
                                                                                 x.IdEmpleadoCuchillo == model.IdEmpleadoCuchillo ||
                                                                                 (x.Cedula == model.Cedula)
                                                                                 );
                if (EmpleadoCuchillo != null)
                {
                    EmpleadoCuchillo.CuchilloBlanco          = model.CuchilloBlanco ?? 0;
                    EmpleadoCuchillo.CuchilloRojo            = model.CuchilloRojo ?? 0;
                    EmpleadoCuchillo.CuchilloNegro           = model.CuchilloNegro ?? 0;
                    EmpleadoCuchillo.UsuarioModificacionLog  = model.UsuarioIngresoLog;
                    EmpleadoCuchillo.TerminalModificacionLog = model.TerminalIngresoLog;
                    EmpleadoCuchillo.FechaModificacionLog    = model.FechaIngresoLog;
                    EmpleadoCuchillo.EstadoRegistro          = model.EstadoRegistro;
                }
                else
                {
                    entities.EMPLEADO_CUCHILLO.Add(new EMPLEADO_CUCHILLO
                    {
                        CuchilloBlanco     = model.CuchilloBlanco ?? 0,
                        CuchilloRojo       = model.CuchilloRojo ?? 0,
                        CuchilloNegro      = model.CuchilloNegro ?? 0,
                        Cedula             = model.Cedula,
                        FechaIngresoLog    = model.FechaIngresoLog,
                        TerminalIngresoLog = model.TerminalIngresoLog,
                        UsuarioIngresoLog  = model.UsuarioIngresoLog,
                        EstadoRegistro     = model.EstadoRegistro
                    });
                }
                entities.SaveChanges();
                return(new RespuestaGeneral
                {
                    Codigo = 2,
                    Respuesta = true,
                    Descripcion = clsAtributos.MsjRegistroGuardado
                });
            }
        }