Example #1
0
        public bool queryUpdateContractSupply(ContractSupply c)
        {
            if (LoginInfo.Position == 1 || LoginInfo.Position == 3) //Начальник или Кладовщик
            {
                using (DataBaseContext db = new DataBaseContext())
                {
                    try
                    {
                        ContractSupply contract = db.ContractSupplys.Find(c.Id);

                        contract.ContractorId   = c.ContractorId;
                        contract.numberOfSupply = c.numberOfSupply;
                        contract.wasReceived    = c.wasReceived;
                        contract.Date           = c.Date;
                        db.SupplyProducts.RemoveRange(contract.SupplyProducts);
                        contract.SupplyProducts = c.SupplyProducts;
                        db.SaveChanges();
                    }
                    catch (Exception e)
                    {
                        return(false);
                    }
                    return(true);
                }
            }
            return(false);
        }
Example #2
0
        public ContractSupply queryFindContractSupplyById(int Id)
        {
            if (LoginInfo.Position == 1 || LoginInfo.Position == 2 || LoginInfo.Position == 3)
            {
                using (DataBaseContext db = new DataBaseContext())
                {
                    ContractSupply s = db.ContractSupplys.Find(Id);
                    //List<SupplyProduct> lsp = db.SupplyProducts.Select(it => new SupplyProduct() { Id = it.Id, ProductId = it.ProductId, Amount = it.Amount, ContractSupplyId = it.ContractSupplyId }).Where(r => r.ContractSupplyId == Id).ToList();
                    s.SupplyProducts = s.SupplyProducts;

                    return(s);
                }
            }

            return(null);
        }
Example #3
0
 public bool queryAddContractSupply(ContractSupply c)
 {
     if (LoginInfo.Position == 1 || LoginInfo.Position == 3) //Начальник или Кладовщик
     {
         using (DataBaseContext db = new DataBaseContext())
         {
             try
             {
                 db.ContractSupplys.Add(c);
                 db.SaveChanges();
             }
             catch (Exception e)
             {
                 return(false);
             }
             return(true);
         }
     }
     return(false);
 }
Example #4
0
        public bool queryDeleteContractSupply(int Id)
        {
            if (LoginInfo.Position == 1 || LoginInfo.Position == 3) //Начальник или Кладовщик
            {
                using (DataBaseContext db = new DataBaseContext())
                {
                    try
                    {
                        ContractSupply       contract = db.ContractSupplys.Find(Id);
                        List <SupplyProduct> sp       = contract.SupplyProducts;
                        db.SupplyProducts.RemoveRange(sp);
                        db.ContractSupplys.Remove(contract);

                        db.SaveChanges();
                    }
                    catch (Exception e)
                    {
                        return(false);
                    }
                    return(true);
                }
            }
            return(false);
        }
Example #5
0
 public ContractSupplyTable(ContractSupply contractSupply, Contractor contractor)
 {
     this.contractSupply = contractSupply;
     this.contractor     = contractor;
 }
Example #6
0
 public ContractSupplyTable(ContractSupply contractSupply, List <SupplyProduct> productList)
 {
     this.contractSupply = contractSupply;
     this.productList    = productList;
 }