Esempio n. 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);
            }
        }
Esempio n. 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>());
            }
        }
Esempio n. 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);
            }
        }
Esempio n. 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());
     }
 }
Esempio n. 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());
     }
 }
Esempio n. 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());
     }
 }
Esempio n. 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());
     }
 }
Esempio n. 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());
     }
 }
Esempio n. 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());
     }
 }
Esempio n. 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());
     }
 }
Esempio n. 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());
     }
 }
Esempio n. 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());
     }
 }
Esempio n. 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());
     }
 }
Esempio n. 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());
     }
 }
Esempio n. 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());
     }
 }
Esempio n. 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());
     }
 }
Esempio n. 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>());
     }
 }
Esempio n. 18
0
 public List <Provider> getProvider()
 {
     try
     {
         using (TeamCellContext _DBContext = new TeamCellContext())
         {
             var result = _DBContext.Provider.ToList();
             return(result);
         }
     }
     catch
     {
         return(new List <Provider>());
     }
 }
Esempio n. 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>());
     }
 }
Esempio n. 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>());
     }
 }
Esempio n. 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);
     }
 }
Esempio n. 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>());
     }
 }
Esempio n. 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>());
     }
 }
Esempio n. 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>());
     }
 }
Esempio n. 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>());
     }
 }
Esempio n. 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());
     }
 }
Esempio n. 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>());
     }
 }
Esempio n. 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>());
     }
 }
Esempio n. 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>());
     }
 }
Esempio n. 30
0
 public List <Employee> getEmployees()
 {
     try
     {
         using (TeamCellContext _DBContext = new TeamCellContext())
         {
             var result = _DBContext.Employee.ToList();
             return(result);
         }
     }
     catch
     {
         return(new List <Employee>());
     }
 }