示例#1
0
        public static int processEmployees(int company, int location, int area, List <Puesto_trabajo> lst)
        {
            int procesados = 0;

            try
            {
                using (var data = new DB_SISTEMAS_DAWEntities())
                {
                    foreach (var item in lst)
                    {
                        Puesto_trabajo stored = data.Puesto_trabajo.Where(
                            x => x.Documento_identidad == item.Documento_identidad &&
                            x.Id_Loc == location &&
                            x.Id_Ar == area
                            ).FirstOrDefault();

                        stored.ResultadoMedidaVisual   = item.ResultadoMedidaVisual;
                        stored.ResultadoMedidaAuditiva = item.ResultadoMedidaAuditiva;
                        stored.MedidaVisual            = item.MedidaVisual;
                        stored.MedidaAuditiva          = item.MedidaAuditiva;
                        data.SaveChanges();
                        procesados++;
                    }
                }
            }
            catch
            {
                procesados = -1;
            }

            return(procesados);
        }
示例#2
0
        public static int loadEmployees(int company, int location, int area, List <Puesto_trabajo> lst)
        {
            int procesados = 0;

            try
            {
                using (var data = new DB_SISTEMAS_DAWEntities())
                {
                    foreach (var item in lst)
                    {
                        item.Id_Ar  = area;
                        item.Id_Em  = company;
                        item.Id_Loc = location;
                        data.Puesto_trabajo.Add(item);
                        data.SaveChanges();
                        procesados++;
                    }
                }
            }
            catch
            {
                procesados = -1;
            }

            return(procesados);
        }
示例#3
0
 public static int addArea(Area a)
 {
     try
     {
         using (var data = new DB_SISTEMAS_DAWEntities())
         {
             data.Area.Add(a);
             return(data.SaveChanges());
         }
     }
     catch
     {
         return(-1);
     }
 }
示例#4
0
 public static int addLocal(Local param)
 {
     try
     {
         using (var data = new DB_SISTEMAS_DAWEntities())
         {
             param.Telefono = "00";
             data.Local.Add(param);
             return(data.SaveChanges());
         }
     }
     catch (Exception ex)
     {
         throw ex;
         //return -1;
     }
 }
示例#5
0
 public static int addUser(Usuario param)
 {
     try
     {
         using (var data = new DB_SISTEMAS_DAWEntities())
         {
             data.Usuario.Add(param);
             data.SaveChanges();
             return(param.Id_Usu);
         }
     }
     catch (Exception ex)
     {
         throw ex;
         //return -1;
     }
 }
示例#6
0
        public static Usuario validateUser(string user, string password)
        {
            Usuario retorno = null;

            try
            {
                using (var data = new DB_SISTEMAS_DAWEntities())
                {
                    retorno = data.Usuario.Where(x => x.usuario1 == user && x.clave == password).FirstOrDefault();
                    return(retorno);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            //return retorno;
        }
示例#7
0
 public static int addCompany(Empresa e)
 {
     try
     {
         using (var data = new DB_SISTEMAS_DAWEntities())
         {
             data.Configuration.LazyLoadingEnabled = false;
             data.Empresa.Add(e);
             data.SaveChanges();
             return(e.Id_Em);
         }
     }
     catch (Exception ex)
     {
         throw ex;
         //return -1;
     }
 }
示例#8
0
        public static Empresa getByName(string name)
        {
            Empresa retorno = null;

            try
            {
                using (var data = new DB_SISTEMAS_DAWEntities())
                {
                    retorno = data.Empresa.Where(x => x.Razon_social == name).FirstOrDefault();
                    return(retorno);
                }
            }
            catch (Exception ex)
            {
                // throw ex;
            }
            return(retorno);
        }
示例#9
0
        public static Empresa getById(int id)
        {
            Empresa retorno = null;

            try
            {
                using (var data = new DB_SISTEMAS_DAWEntities())
                {
                    retorno = data.Empresa.Where(x => x.Id_Em == id).FirstOrDefault();
                    return(retorno);
                }
            }
            catch (Exception ex)
            {
                // throw ex;
            }
            return(retorno);
        }
示例#10
0
        public static Local getLocationById(int localId)
        {
            Local retorno = null;

            try
            {
                using (var data = new DB_SISTEMAS_DAWEntities())
                {
                    data.Configuration.LazyLoadingEnabled = false;
                    retorno = data.Local.Where(x => x.Id_Loc == localId).FirstOrDefault();
                    return(retorno);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(retorno);
        }
示例#11
0
        public static List <Local> getLocationByCompanyId(int company)
        {
            List <Local> retorno = null;

            try
            {
                using (var data = new DB_SISTEMAS_DAWEntities())
                {
                    data.Configuration.LazyLoadingEnabled = false;
                    retorno = data.Local.Where(x => x.Id_Em == company).ToList();
                    return(retorno);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(retorno);
        }
示例#12
0
        public static List <Area> getAreaByLocationId(int locationId)
        {
            List <Area> retorno = null;

            try
            {
                using (var data = new DB_SISTEMAS_DAWEntities())
                {
                    data.Configuration.LazyLoadingEnabled = false;
                    retorno = data.Area.Where(x => x.Id_Loc == locationId).ToList();
                    return(retorno);
                }
            }
            catch (Exception ex)
            {
                // throw ex;
            }
            return(retorno);
        }
示例#13
0
        public static int updateLocal(Local param)
        {
            try
            {
                using (var data = new DB_SISTEMAS_DAWEntities())
                {
                    Local localActual = data.Local.Where(x => x.Id_Loc == param.Id_Loc).FirstOrDefault();

                    localActual.Nombre    = param.Nombre;
                    localActual.Direccion = param.Direccion;
                    localActual.Telefono  = param.Telefono;
                    localActual.Encargado = param.Encargado;
                    return(data.SaveChanges());
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#14
0
        public static List <Puesto_trabajo> getReportByParams(string dni, string name)
        {
            List <Puesto_trabajo> retorno = null;

            try
            {
                using (var data = new DB_SISTEMAS_DAWEntities())
                {
                    data.Configuration.LazyLoadingEnabled = false;

                    if (string.IsNullOrEmpty(dni) && string.IsNullOrEmpty(name))
                    {
                        retorno = data.Puesto_trabajo.ToList();
                        return(retorno);
                    }
                    else if (string.IsNullOrEmpty(dni) && !string.IsNullOrEmpty(name))
                    {
                        retorno = data.Puesto_trabajo.Where(x => x.NombreCompleto.ToLower().Contains(name)).ToList();
                        return(retorno);
                    }
                    else if (!string.IsNullOrEmpty(dni) && string.IsNullOrEmpty(name))
                    {
                        retorno = data.Puesto_trabajo.Where(x => x.Documento_identidad.ToLower().Contains(dni)).ToList();
                        return(retorno);
                    }
                    else
                    {
                        retorno = data.Puesto_trabajo.Where(x => x.Documento_identidad.Contains(dni) ||
                                                            x.NombreCompleto.ToLower().Contains(name)).ToList();
                        return(retorno);
                    }
                }
            }
            catch (Exception ex)
            {
                //throw ex;
            }
            return(retorno);
        }