public bool queryUpdateTechCard(TechnologicalCard c)
        {
            if (LoginInfo.Position == 1 || LoginInfo.Position == 2 || LoginInfo.Position == 3)
            {
                using (DataBaseContext db = new DataBaseContext())
                {
                    try
                    {
                        int IdCard             = c.Id;
                        TechnologicalCard card = db.TechnologicalCards.Find(IdCard);

                        card.Date  = c.Date;
                        card.Title = c.Title;

                        db.ProductTechCards.RemoveRange(card.ProductTechCards);
                        card.ProductTechCards = c.ProductTechCards;
                        db.SaveChanges();
                    }
                    catch (Exception e)
                    {
                        return(false);
                    }
                    return(true);
                }
            }
            return(false);
        }
 public TechCardsTable queryFindTechCardById(int Id)
 {
     if (LoginInfo.Position == 1 || LoginInfo.Position == 2 || LoginInfo.Position == 3)
     {
         using (DataBaseContext db = new DataBaseContext())
         {
             TechnologicalCard s = db.TechnologicalCards.Find(Id);
             //List<ProductTechCard> lsp = db.ProductTechCards.Select(it => new ProductTechCard() { Id = it.Id, ProductId = it.ProductId, Amount = it.Amount, Type = it.Type }).Where(r => r.TechCardId == Id).ToList();
             List <ProductTechCard> lsp   = s.ProductTechCards;
             TechCardsTable         table = new TechCardsTable(s, lsp);
             return(table);
         }
     }
     return(null);
 }
 public bool queryAddTechCard(TechnologicalCard c)
 {
     if (LoginInfo.Position == 1 || LoginInfo.Position == 2 || LoginInfo.Position == 3)
     {
         using (DataBaseContext db = new DataBaseContext())
         {
             try
             {
                 db.TechnologicalCards.Add(c);
                 db.SaveChanges();
             }
             catch (Exception e)
             {
                 return(false);
             }
             return(true);
         }
     }
     return(false);
 }
 public bool queryDeleteTechCard(int Id)
 {
     if (LoginInfo.Position == 1 || LoginInfo.Position == 2 || LoginInfo.Position == 3)
     {
         using (DataBaseContext db = new DataBaseContext())
         {
             try
             {
                 TechnologicalCard      card = db.TechnologicalCards.Find(Id);
                 List <ProductTechCard> lsp  = card.ProductTechCards;
                 db.ProductTechCards.RemoveRange(lsp);
                 db.TechnologicalCards.Remove(card);
                 db.SaveChanges();
             }
             catch (Exception e)
             {
                 return(false);
             }
             return(true);
         }
     }
     return(false);
 }
Exemple #5
0
 public TechCardsTable(TechnologicalCard technologicalCard, List <ProductTechCard> productTechCard)
 {
     this.technologicalCard = technologicalCard;
     this.productTechCard   = productTechCard;
 }