Пример #1
0
        public int getEmpXCredenciales(string userName, string password)
        {
            try
            {
                using (TeamCellContext _dbContext = new TeamCellContext())
                {
                    var user = _dbContext.User.FirstOrDefault(x => x.UserName == userName);
                    if (user != null)
                    {
                        byte[] hashedPassword = Cryptographic.HashPasswordWithSalt(Encoding.UTF8.GetBytes(password), user.Salt);

                        if (hashedPassword.SequenceEqual(user.Password))
                        {
                            return(user.IdEmployee);
                        }
                        else
                        {
                            return(0);
                        }
                    }
                    return(0);
                }
            }
            catch (Exception)
            {
                return(0);
            }
        }
Пример #2
0
        public List <object> StockGlobal()
        {
            try
            {
                using (TeamCellContext _BDContext = new TeamCellContext())
                {
                    List <Product> lstID = _BDContext.Product.ToList();

                    KardexController kardCont = new KardexController();
                    List <object>    result   = null;
                    foreach (Product i in lstID)
                    {
                        result.Add(new {
                            Codigo = i.Codigo,
                            Nombre = i.Name,
                            Stock  = kardCont.GetStockActual(i.IdProducto)
                        });
                    }

                    return(result);
                }
            }
            catch (Exception e)
            {
                return(new List <object>());
            }
        }
Пример #3
0
        public decimal getCalcularPromedioSimpre(int id)
        {
            try
            {
                using (TeamCellContext _DBContext = new TeamCellContext())
                {
                    var TotalMonto = (from k in _DBContext.Kardex
                                      join ct in _DBContext.CostingAverage
                                      on k.IdKardex equals ct.IdKardex
                                      where k.IdProducto == id
                                      select new { ct.Cost }).Sum(x => x.Cost);

                    var TotalCant = (from k in _DBContext.Kardex
                                     join ct in _DBContext.CostingAverage
                                     on k.IdKardex equals ct.IdKardex
                                     where k.IdProducto == id
                                     select new { ct.Cost }).Count();

                    return(TotalMonto / TotalCant);
                }
            }
            catch
            {
                return(0);
            }
        }
Пример #4
0
 public Client GetIdClient(int id)
 {
     try
     {
         using (TeamCellContext _DBContext = new TeamCellContext())
         {
             return(_DBContext.Client.Where(x => x.Id == id).FirstOrDefault());
         }
     }
     catch (Exception e)
     {
         return(new Client());
     }
 }
Пример #5
0
 public Country GetIdCountry(int id)
 {
     try
     {
         using (TeamCellContext _DBContext = new TeamCellContext())
         {
             return(_DBContext.Country.Where(x => x.IdCountry == id).FirstOrDefault());
         }
     }
     catch (Exception e)
     {
         return(new Country());
     }
 }
Пример #6
0
 public DetailPurchase GetdetailPurchase(int id)
 {
     try
     {
         using (TeamCellContext _DBContext = new TeamCellContext())
         {
             return(_DBContext.DetailPurchase.Where(x => x.IdDetailPurchase == id).FirstOrDefault());
         }
     }
     catch (Exception e)
     {
         return(new DetailPurchase());
     }
 }
Пример #7
0
 public Purchases GetIdPurchases(int id)
 {
     try
     {
         using (TeamCellContext _DBContext = new TeamCellContext())
         {
             return(_DBContext.Purchases.Where(x => x.IdPurchases == id).FirstOrDefault());
         }
     }
     catch (Exception e)
     {
         return(new Purchases());
     }
 }
Пример #8
0
 public CostingWeighted getCostingWeightedXId(int id)
 {
     try
     {
         using (TeamCellContext _DBContext = new TeamCellContext())
         {
             return(_DBContext.CostingWeighted.Where(x => x.IdCostingWeighted == id).FirstOrDefault());
         }
     }
     catch
     {
         return(new CostingWeighted());
     }
 }
Пример #9
0
 public Product getIdProduct(int id)
 {
     try
     {
         using (TeamCellContext _BDContext = new TeamCellContext())
         {
             return(_BDContext.Product.Where(x => x.IdProducto == id).FirstOrDefault());
         }
     }
     catch (Exception e)
     {
         return(new Product());
     }
 }
Пример #10
0
 public Provider getProviderXId(int id)
 {
     try
     {
         using (TeamCellContext _DBContext = new TeamCellContext())
         {
             return(_DBContext.Provider.Where(x => x.IdProvider == id).FirstOrDefault());
         }
     }
     catch
     {
         return(new Provider());
     }
 }
Пример #11
0
 public Employee getEmployeeXId(int id)
 {
     try
     {
         using (TeamCellContext _DBContext = new TeamCellContext())
         {
             return(_DBContext.Employee.Where(x => x.IdEmployee == id).FirstOrDefault());
         }
     }
     catch
     {
         return(new Employee());
     }
 }
Пример #12
0
 public Warehouse getWarehouseXId(int id)
 {
     try
     {
         using (TeamCellContext _DBContext = new TeamCellContext())
         {
             return(_DBContext.Warehouse.Where(x => x.IdWarehouse == id).FirstOrDefault());
         }
     }
     catch
     {
         return(new Warehouse());
     }
 }
Пример #13
0
 public Brand getBrandXId(int id)
 {
     try
     {
         using (TeamCellContext _DBContext = new TeamCellContext())
         {
             return(_DBContext.Brand.Where(x => x.IdBrand == id).FirstOrDefault());
         }
     }
     catch
     {
         return(new Brand());
     }
 }
Пример #14
0
 public CostingAverage getCostingAverageXId(int id)
 {
     try
     {
         using (TeamCellContext _DBContext = new TeamCellContext())
         {
             return(_DBContext.CostingAverage.Where(x => x.IdCostingAverage == id).FirstOrDefault());
         }
     }
     catch
     {
         return(new CostingAverage());
     }
 }
Пример #15
0
 public Kardex GetIdKardex(int id)
 {
     try
     {
         using (TeamCellContext _DBContext = new TeamCellContext())
         {
             return(_DBContext.Kardex.Where(x => x.IdKardex == id).FirstOrDefault());
         }
     }
     catch (Exception e)
     {
         return(new Kardex());
     }
 }
Пример #16
0
 public DetailBilling GetDetailBilling(int id)
 {
     try
     {
         using (TeamCellContext _DBContext = new TeamCellContext())
         {
             return(_DBContext.DetailBilling.Where(x => x.IdDetailBilling == id).FirstOrDefault());
         }
     }
     catch (Exception e)
     {
         return(new DetailBilling());
     }
 }
Пример #17
0
 public List <Country> getCountry()
 {
     try
     {
         using (TeamCellContext _BDContext = new TeamCellContext())
         {
             var result = _BDContext.Country.ToList();
             return(result);
         }
     }
     catch (Exception e)
     {
         return(new List <Country>());
     }
 }
Пример #18
0
 public List <Provider> getProvider()
 {
     try
     {
         using (TeamCellContext _DBContext = new TeamCellContext())
         {
             var result = _DBContext.Provider.ToList();
             return(result);
         }
     }
     catch
     {
         return(new List <Provider>());
     }
 }
Пример #19
0
 public List <Brand> getBrand()
 {
     try
     {
         using (TeamCellContext _BDContext = new TeamCellContext())
         {
             var result = _BDContext.Brand.ToList();
             return(result);
         }
     }
     catch (Exception e)
     {
         return(new List <Brand>());
     }
 }
Пример #20
0
 public List <CostingAverage> getCostingAverage()
 {
     try
     {
         using (TeamCellContext _BDContext = new TeamCellContext())
         {
             var result = _BDContext.CostingAverage.ToList();
             return(result);
         }
     }
     catch (Exception e)
     {
         return(new List <CostingAverage>());
     }
 }
Пример #21
0
 public decimal GetStockActual(int idProducto)
 {
     try
     {
         using (TeamCellContext _BDContext = new TeamCellContext())
         {
             decimal result = _BDContext.Kardex.Where(x => x.IdProducto == idProducto).Sum(x => x.EntryAmount - x.OutputAmount);
             return(result);
         }
     }
     catch (Exception)
     {
         return(0);
     }
 }
Пример #22
0
 public List <Product> getProduct()
 {
     try
     {
         using (TeamCellContext _BDContext = new TeamCellContext())
         {
             var result = _BDContext.Product.ToList();
             return(result);
         }
     }
     catch (Exception e)
     {
         return(new List <Product>());
     }
 }
Пример #23
0
 public List <DetailPurchase> getDetailsPurchases(int id)
 {
     try
     {
         using (TeamCellContext _BDContext = new TeamCellContext())
         {
             var result = _BDContext.DetailPurchase.Where(x => x.IdPurchases == id).ToList();
             return(result);
         }
     }
     catch (Exception e)
     {
         return(new List <DetailPurchase>());
     }
 }
Пример #24
0
 public List <Client> GetClient()
 {
     try
     {
         using (TeamCellContext _BDContext = new TeamCellContext())
         {
             var result = _BDContext.Client.ToList();
             return(result);
         }
     }
     catch (Exception)
     {
         return(new List <Client>());
     }
 }
Пример #25
0
 public List <DetailBilling> getDetailBilling(int id)
 {
     try
     {
         using (TeamCellContext _BDContext = new TeamCellContext())
         {
             var result = _BDContext.DetailBilling.Where(x => x.IdDetailBilling == id).ToList();
             return(result);
         }
     }
     catch (Exception e)
     {
         return(new List <DetailBilling>());
     }
 }
Пример #26
0
 public User getUserXId(int idUser)
 {
     try
     {
         using (TeamCellContext _dbContext = new TeamCellContext())
         {
             var user = _dbContext.User.Include(x => x.Employee).FirstOrDefault(x => x.IdUser == idUser);
             return(user);
         }
     }
     catch (Exception)
     {
         return(new User());
     }
 }
Пример #27
0
 public List <Purchases> getPurchases()
 {
     try
     {
         using (TeamCellContext _BDContext = new TeamCellContext())
         {
             var result = _BDContext.Purchases.ToList();
             return(result);
         }
     }
     catch (Exception e)
     {
         return(new List <Purchases>());
     }
 }
Пример #28
0
 public List <User> getUsersActive()
 {
     try
     {
         using (TeamCellContext _dbContext = new TeamCellContext())
         {
             var listUser = _dbContext.User.Include(x => x.Employee).Where(x => x.Status == true).ToList();
             return(listUser);
         }
     }
     catch (Exception ex)
     {
         return(new List <User>());
     }
 }
Пример #29
0
 public List <Warehouse> getWarehouse()
 {
     try
     {
         using (TeamCellContext _BDContext = new TeamCellContext())
         {
             var result = _BDContext.Warehouse.ToList();
             return(result);
         }
     }
     catch (Exception e)
     {
         return(new List <Warehouse>());
     }
 }
Пример #30
0
 public List <Employee> getEmployees()
 {
     try
     {
         using (TeamCellContext _DBContext = new TeamCellContext())
         {
             var result = _DBContext.Employee.ToList();
             return(result);
         }
     }
     catch
     {
         return(new List <Employee>());
     }
 }