コード例 #1
0
        public string AddProduct(Product product)
        {
            try
            {
                garageDBEntities.Products.Add(product);
                garageDBEntities.SaveChanges();

                return(product.Name + " is successfully added");
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #2
0
        public string AddPurchase(Purchase purchase)
        {
            try
            {
                garageDBEntities.Purchases.Add(purchase);
                garageDBEntities.SaveChanges();

                return("The Purchase: " + purchase.DatePurchased + " is successfully added");
            }
            catch (Exception e)
            {
                return(e.Message);
            }
        }
コード例 #3
0
 private void Change()
 {
     using (GarageDBEntities db = new GarageDBEntities())
     {
         var sel = DataGrid.SelectedItem as ViewJob;
         if (sel != null)
         {
             var result = db.ViewJob.Where(r => r.id == sel.id).FirstOrDefault();
             if (result != null)
             {
                 result.id = sel.id;
                 db.Entry(result).State = EntityState.Modified;
                 db.SaveChanges();
                 MessageBox.Show("Запись измнена!");
             }
             else
             {
                 MessageBox.Show("Нельзя изменть шфир оборудования!");
                 Load();
                 return;
             }
         }
         else
         {
             MessageBox.Show("Необходимо выбрать строку в таблице!");
             return;
         }
     }
 }
コード例 #4
0
    public void InsertUserInformation(UserInformation info)
    {
        GarageDBEntities db = new GarageDBEntities();

        db.UserInformations.Add(info);
        db.SaveChanges();
    }
コード例 #5
0
 private void Add()
 {
     using (GarageDBEntities db = new GarageDBEntities())
     {
         var sel = DataGrid.SelectedItem as ViewJob;
         if (sel != null)
         {
             var result = db.ViewJob.Where(r => r.id == sel.id).FirstOrDefault();
             if (result == null)
             {
                 db.ViewJob.Add(sel);
             }
             else
             {
                 result.id = sel.id;
                 db.Entry(result).State = EntityState.Added;
             }
             db.SaveChanges();
             MessageBox.Show("Запись добавлена");
         }
         else
         {
             MessageBox.Show("Необходимо выбрать строку в таблице!");
             return;
         }
     }
 }
コード例 #6
0
        public void updateQuantity(int id, int quantity)
        {
            GarageDBEntities db       = new GarageDBEntities();
            Purchase         purchase = db.Purchases.Find(id);

            purchase.Amount = quantity;
            db.SaveChanges();
        }
コード例 #7
0
    public void UpdateQuantity(int id, int quantity)
    {
        GarageDBEntities db = new GarageDBEntities();
        cart             p  = db.carts.Find(id);

        p.Amount = quantity;

        db.SaveChanges();
    }
コード例 #8
0
    public void UpdateQuantity(int id, int quantity)
    {       //Update the quantity of the selected product
        GarageDBEntities db = new GarageDBEntities();
        Cart             p  = db.Carts.Find(id);

        p.Amount = quantity;

        db.SaveChanges();
    }
コード例 #9
0
    public void MarkOrdersAsPaid(List <cart> carts)
    {
        GarageDBEntities db = new GarageDBEntities();

        if (carts != null)
        {
            foreach (cart cart in carts)
            {
                cart oldCart = db.carts.Find(cart.ID);
                oldCart.DatePurchased = DateTime.Now;
                oldCart.IsInCart      = false;
            }
            db.SaveChanges();
        }
    }
コード例 #10
0
    public string InsertCart(Cart cart)
    {
        try
        {
            GarageDBEntities db = new GarageDBEntities();
            db.Carts.Add(cart);
            db.SaveChanges();

            return("Order was succesfully inserted");
        }
        catch (Exception e)
        {
            return("Error:" + e);
        }
    }
コード例 #11
0
        public void markOrdersAsPaid(List <Purchase> purchases)
        {
            GarageDBEntities db = new GarageDBEntities();

            if (purchases != null)
            {
                foreach (Purchase purchase in purchases)
                {
                    Purchase oldPurchases = db.Purchases.Find(purchase.ID);
                    oldPurchases.Date     = DateTime.Now;
                    oldPurchases.IsInCart = false;
                }
                db.SaveChanges();
            }
        }
コード例 #12
0
    public string InsertCart(Cart cart)
    {
        try
        {
            GarageDBEntities db = new GarageDBEntities();
            db.Carts.Add(cart);     //Will add the carts from the DB
            db.SaveChanges();       // Save changes to the db entity.

            return(cart.DatePurchased + "Was successfully Inserted...");
        }
        catch (Exception e)
        {
            return("Error :" + e);
        }
    }
コード例 #13
0
    public void MarkOrdersAsPaid(List <Cart> carts)
    {       //List of cart objects to mark as paid
        GarageDBEntities db = new GarageDBEntities();

        if (carts != null)
        {
            foreach (Cart ct in carts)
            {
                Cart oldCart = db.Carts.Find(ct.ID);
                oldCart.DatePurchased = DateTime.Now;
                oldCart.IsInCart      = false;
            }
            db.SaveChanges();
        }
    }
コード例 #14
0
ファイル: CartModel.cs プロジェクト: SaifAsad/garager
    public string InsertCart(Cart cart)
    {
        try
        {
            GarageDBEntities db = new GarageDBEntities();
            db.Carts.Add(cart);
            db.SaveChanges();

            return "Order was succesfully inserted";
        }
        catch (Exception e)
        {
            return "Error:" + e;
        }
    }
コード例 #15
0
    public string InsertCart(cart cart)
    {
        try
        {
            GarageDBEntities db = new GarageDBEntities();
            db.carts.Add(cart);
            db.SaveChanges();

            return(cart.DatePurchased + " was successfully inserted");
        }
        catch (Exception e)
        {
            return("Error:" + e);
        }
    }
コード例 #16
0
        public string insertPurchase(Purchase purchase)
        {
            try
            {
                GarageDBEntities db = new GarageDBEntities();
                db.Purchases.Add(purchase);
                db.SaveChanges();

                return(purchase.Date + " was succesfully added to cart");
            }
            catch (Exception e)
            {
                return("Error:" + e);
            }
        }
コード例 #17
0
    public string InsertProduct(Product product)
    {
        try
        {
            GarageDBEntities db = new GarageDBEntities();
            db.Products.Add(product); //Will add the products from the DB
            db.SaveChanges();         // Save changes to the db entity.

            return(product.Name + "Was successfully Inserted...");
        }
        catch (Exception e)
        {
            return("Error :" + e);
        }
    }
コード例 #18
0
ファイル: ProductTypeModel.cs プロジェクト: SaifAsad/garager
    public string InsertProductType(ProductType productType)
    {
        try
        {
            GarageDBEntities db = new GarageDBEntities();
            db.ProductTypes.Add(productType);
            db.SaveChanges();

            return(productType.Name + "was succesfully inserted");
        }
        catch (Exception e)
        {
            return("Error:" + e);
        }
    }
コード例 #19
0
 private void Delete()
 {
     using (GarageDBEntities db = new GarageDBEntities())
     {
         var s       = dg.SelectedItem as Employess;
         var emS     = db.Employess.Where(r => r.Id == s.Id).FirstOrDefault();
         var newEmpl = db.NewEmployee.Where(t => t.id == emS.Id).FirstOrDefault();
         if (emS != null && newEmpl != null)
         {
             db.Entry(newEmpl).State = EntityState.Deleted;
             db.Entry(emS).State     = EntityState.Deleted;
             db.SaveChanges();
         }
     }
 }
コード例 #20
0
ファイル: ProductTypeModel.cs プロジェクト: SaifAsad/garager
    public string InsertProductType(ProductType productType)
    {
        try
        {
            GarageDBEntities db = new GarageDBEntities();
            db.ProductTypes.Add(productType);
            db.SaveChanges();

            return productType.Name + "was succesfully inserted";
        }
        catch (Exception e)
        {
            return "Error:" + e;
        }
    }
コード例 #21
0
    public string DeleteProduct(int id) // Delete from the primary key value
    {
        try
        {
            GarageDBEntities db = new GarageDBEntities();
            //First to find the objects to be deleted
            Product product = db.Products.Find(id);

            db.Products.Attach(product);
            db.Products.Remove(product);
            db.SaveChanges();
            return(product.Name + "was successfully Deleted...");
        }
        catch (Exception e)
        {
            return("Error :" + e);
        }
    }
コード例 #22
0
ファイル: ProductTypeModel.cs プロジェクト: SaifAsad/garager
    public string DeleteProductType(int id)
    {
        try
        {
            GarageDBEntities db = new GarageDBEntities();
            ProductType productType = db.ProductTypes.Find(id);

            db.ProductTypes.Attach(productType);
            db.ProductTypes.Remove(productType);
            db.SaveChanges();

            return productType.Name + "was succesfully deleted";
        }
        catch (Exception e)
        {
            return "Error:" + e;
        }
    }
コード例 #23
0
        public string deletePurchase(int id)
        {
            try
            {
                GarageDBEntities db       = new GarageDBEntities();
                Purchase         purchase = db.Purchases.Find(id);

                db.Purchases.Attach(purchase);
                db.Purchases.Remove(purchase);
                db.SaveChanges();

                return(purchase.Date + " was succesfully deleted");
            }
            catch (Exception e)
            {
                return("Error:" + e);
            }
        }
コード例 #24
0
    public string DeleteCart(int id) // Delete from the primary key value
    {
        try
        {
            GarageDBEntities db = new GarageDBEntities();
            //First to find the objects to be deleted
            Cart cart = db.Carts.Find(id);

            db.Carts.Attach(cart);
            db.Carts.Remove(cart);
            db.SaveChanges();
            return(cart.DatePurchased + "was successfully Deleted...");
        }
        catch (Exception e)
        {
            return("Error :" + e);
        }
    }
コード例 #25
0
ファイル: CartModel.cs プロジェクト: SaifAsad/garager
    public string DeleteCart(int id)
    {
        try
        {
            GarageDBEntities db = new GarageDBEntities();
            Cart cart = db.Carts.Find(id);

            db.Carts.Attach(cart);
            db.Carts.Remove(cart);
            db.SaveChanges();

            return cart.DatePurchased + "was succesfully deleted";
        }
        catch (Exception e)
        {
            return "Error:" + e;
        }
    }
コード例 #26
0
    public string DeleteCart(int id)
    {
        try
        {
            GarageDBEntities db   = new GarageDBEntities();
            cart             cart = db.carts.Find(id);

            db.carts.Attach(cart);
            db.carts.Remove(cart);
            db.SaveChanges();

            return(cart.DatePurchased + " was successfully deleted");
        }
        catch (Exception e)
        {
            return("Error:" + e);
        }
    }
コード例 #27
0
ファイル: ProductTypeModel.cs プロジェクト: SaifAsad/garager
    public string DeleteProductType(int id)
    {
        try
        {
            GarageDBEntities db          = new GarageDBEntities();
            ProductType      productType = db.ProductTypes.Find(id);

            db.ProductTypes.Attach(productType);
            db.ProductTypes.Remove(productType);
            db.SaveChanges();

            return(productType.Name + "was succesfully deleted");
        }
        catch (Exception e)
        {
            return("Error:" + e);
        }
    }
コード例 #28
0
ファイル: ProductTypeModel.cs プロジェクト: SaifAsad/garager
    public string UpdateProductType(int id, ProductType productType)
    {
        try
        {
            GarageDBEntities db = new GarageDBEntities();

            //Fetch object from db
            ProductType p = db.ProductTypes.Find(id);

            p.Name = productType.Name;

            db.SaveChanges();
            return(productType.Name + "was succesfully updated");
        }
        catch (Exception e)
        {
            return("Error:" + e);
        }
    }
コード例 #29
0
    public string UpdateProductType(int id, ProductType productType)
    {
        try
        {
            GarageDBEntities db = new GarageDBEntities();
            //To fetch productTypes from database
            ProductType p = db.ProductTypes.Find(id);   //find will return the entity with the given primary key values

            //To replace the data stored in object p by the data given in 'productType'.
            //We can actually update only the parameters in the 'productTypes'
            p.Name = productType.Name;

            db.SaveChanges();
            return(productType.Name + "was successfully updated...");
        }
        catch (Exception e)
        {
            return("Error :" + e);
        }
    }
コード例 #30
0
 private void AcceptChange()
 {
     using (GarageDBEntities db = new GarageDBEntities())
     {
         var getOrder = dataGistoryOrder.SelectedItem as History;
         if (getOrder != null)
         {
             var seekOrder = db.History.Where(r => r.id == getOrder.id).FirstOrDefault();
             seekOrder.Result          = true;
             db.Entry(seekOrder).State = EntityState.Modified;
             db.SaveChanges();
             GetData();
         }
         else
         {
             MessageBox.Show("Выберите строку с заказ-нарядом!");
             return;
         }
     }
 }
コード例 #31
0
ファイル: ProductTypeModel.cs プロジェクト: SaifAsad/garager
    public string UpdateProductType(int id, ProductType productType)
    {
        try
        {
            GarageDBEntities db = new GarageDBEntities();

            //Fetch object from db
            ProductType p = db.ProductTypes.Find(id);

            p.Name = productType.Name;

            db.SaveChanges();
            return productType.Name + "was succesfully updated";

        }
        catch (Exception e)
        {
            return "Error:" + e;
        }
    }
コード例 #32
0
    public string UpdateCart(int id, cart cart)
    {
        try
        {
            GarageDBEntities db = new GarageDBEntities();
            cart             p  = db.carts.Find(id);

            p.DatePurchased = cart.DatePurchased;
            p.ClientID      = cart.ClientID;
            p.Amount        = cart.Amount;
            p.IsInCart      = cart.IsInCart;
            p.ProductID     = cart.ProductID;

            db.SaveChanges();

            return(cart.DatePurchased + " was successfully updated");
        }
        catch (Exception e)
        {
            return("Error:" + e);
        }
    }
コード例 #33
0
        public string updatePurchase(int id, Purchase purchase)
        {
            try
            {
                GarageDBEntities db = new GarageDBEntities();

                Purchase p = db.Purchases.Find(id);

                p.Date       = purchase.Date;
                p.CustomerID = purchase.CustomerID;
                p.Amount     = purchase.Amount;
                p.IsInCart   = purchase.IsInCart;
                p.ProductID  = purchase.ProductID;

                db.SaveChanges();

                return(purchase.Date + " was succesfully updated");
            }
            catch (Exception e)
            {
                return("Error:" + e);
            }
        }
コード例 #34
0
    public string UpdateProduct(int id, Product product)
    {
        try
        {
            GarageDBEntities db = new GarageDBEntities();

            Product p = db.Products.Find(id);

            p.Name        = product.Name;
            p.Price       = product.Price;
            p.TypeId      = product.TypeId;
            p.Description = product.Description;
            p.Image       = product.Image;

            db.SaveChanges();

            return(product.Name + " was successfully updated");
        }
        catch (Exception e)
        {
            return("Error:" + e);
        }
    }
コード例 #35
0
    public string UpdateCart(int id, Cart cart)
    {
        try
        {
            GarageDBEntities db = new GarageDBEntities();
            //To fetch carts from database
            Cart p = db.Carts.Find(id);   //find will return the entity with the given primary key values

            //To replace the data stored in object p by the data given in 'cart'.
            //We can actually update only the parameters in the 'carts'
            p.DatePurchased = cart.DatePurchased;
            p.ClientID      = cart.ClientID;
            p.Amount        = cart.Amount;
            p.IsInCart      = cart.IsInCart;
            p.ProductID     = cart.ProductID;

            db.SaveChanges();
            return(cart.DatePurchased + "was successfully updated...");
        }
        catch (Exception e)
        {
            return("Error :" + e);
        }
    }
コード例 #36
0
ファイル: CartModel.cs プロジェクト: SaifAsad/garager
    //mark all the products in the shopping cart as paid
    //as soon as the user has completed the transaction
    public void MarkOrdersAsPaid(List<Cart> carts)
    {
        GarageDBEntities db = new GarageDBEntities();

        if (carts != null)
        {
            foreach (Cart cart in carts)
            {
                Cart oldCart = db.Carts.Find(cart.id);
                oldCart.DatePurchased = DateTime.Now;
                oldCart.IsInCart = false;
            }
            db.SaveChanges();
        }
    }
コード例 #37
0
ファイル: CartModel.cs プロジェクト: SaifAsad/garager
    public string UpdateCart(int id, Cart cart)
    {
        try
        {
            GarageDBEntities db = new GarageDBEntities();

            //Fetch object from db
            Cart p = db.Carts.Find(id);

            p.DatePurchased = cart.DatePurchased;
            p.ClientID = cart.ClientID;
            p.Amount = cart.Amount;
            p.IsInCart = cart.IsInCart;
            p.ProductID = cart.ProductID;

            db.SaveChanges();
            return cart.DatePurchased + " was succesfully updated";

        }
        catch (Exception e)
        {
            return "Error:" + e;
        }
    }
コード例 #38
0
ファイル: ProductModel.cs プロジェクト: SaifAsad/garager
    public string UpdateProduct(int id, Product product)
    {
        try
        {
            GarageDBEntities db = new GarageDBEntities();

            //Fetch object from db
            Product p = db.Products.Find(id);

            p.Name = product.Name;
            p.Price = product.Price;
            p.TypeID = product.TypeID;
            p.Description = product.Description;
            p.Image = product.Image;

            db.SaveChanges();
            return product.Name + " was succesfully updated";

        }
        catch (Exception e)
        {
            return "Error:" + e;
        }
    }
コード例 #39
0
ファイル: UserInfoModel.cs プロジェクト: SaifAsad/garager
 //this method will be called whenever a new user is created
 public void InsertUserDetail(UserInformation info)
 {
     GarageDBEntities db = new GarageDBEntities();
     db.UserInformations.Add(info);
     db.SaveChanges();
 }
コード例 #40
0
ファイル: CartModel.cs プロジェクト: SaifAsad/garager
    //update the quantity of a selected product in the shopping cart
    public void UpdateQuantity(int id, int quantity)
    {
        GarageDBEntities db = new GarageDBEntities();
        Cart p = db.Carts.Find(id);
        p.Amount = quantity;

        db.SaveChanges();
    }