示例#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>());
     }
 }