Esempio n. 1
0
        public void NewLocation(string name, string address, string city, int phone)
        {
            TLocation newLocation = new TLocation
            {
                Name    = name,
                Address = address,
                City    = city,
                Phone   = phone
            };

            db.TLocations.InsertOnSubmit(newLocation);

            // Submit the change to the database.
            try
            {
                db.SubmitChanges();
                MessageBox.Show("Successfully added new location");
            }
            catch (Exception e)
            {
                MessageBox.Show("Failed to insert the new location.");
                MessageBox.Show(e.ToString());
                db.SubmitChanges();
            }
        }
        public void InsertNewProduct(string name, decimal price, decimal tax, decimal discount, string description, int FKcategory, int FKbrand, string fullName, string shortName)
        {
            // Using 'using' to dispose connection after the new product
            // gets inserted into the database.

            using (DataLinqToSQLDataContext product = new DataLinqToSQLDataContext())
            {
                // instantiating a new object that will be inserted into database
                TProductGroup newProduct = new TProductGroup
                {
                    Name             = name,
                    Price            = price,
                    Tax              = tax,
                    Discount         = discount,
                    DESCRIPTION      = description,
                    CategoryID       = FKcategory,
                    BrandID          = FKbrand,
                    FullProductName  = fullName,
                    ShortProductName = shortName
                };

                product.TProductGroups.InsertOnSubmit(newProduct);
                product.SubmitChanges();
            }
        }
        public void UpdateCategory(int categoryId, string cateName)
        {
            using (DataLinqToSQLDataContext category = new DataLinqToSQLDataContext())
            {
                TCategory editCategory = category.TCategories.SingleOrDefault(x => x.CategoryID == categoryId);

                editCategory.Name = cateName;

                category.SubmitChanges();
            }
        }
Esempio n. 4
0
        public void UpdateBrand(int brandId, string name)
        {
            // Updating product information

            using (DataLinqToSQLDataContext brands = new DataLinqToSQLDataContext())
            {
                TBrand editBrand = brands.TBrands.SingleOrDefault(x => x.BrandID == brandId);

                editBrand.Name = name;

                brands.SubmitChanges();
            }
        }
Esempio n. 5
0
        public void InsertNewBrand(string brandName)
        {
            using (DataLinqToSQLDataContext brands = new DataLinqToSQLDataContext())
            {
                TBrand newBrand = new TBrand
                {
                    Name = brandName
                };

                brands.TBrands.InsertOnSubmit(newBrand);
                brands.SubmitChanges();
            }
        }
        public void InsertCategory(string categoryName)
        {
            using (DataLinqToSQLDataContext category = new DataLinqToSQLDataContext())
            {
                TCategory newCategory = new TCategory
                {
                    Name = categoryName
                };

                category.TCategories.InsertOnSubmit(newCategory);
                category.SubmitChanges();
            }
        }
Esempio n. 7
0
        //edit stock item
        public void StockToEdit(int barcode, int location, int quantity)
        {
            var query = from stock in db.TInStocks where stock.BarcodeID == barcode && stock.LocationID == location
                        select stock;

            foreach (TInStock stock in query)
            {
                stock.Quantity = quantity;
            }

            //submit changes
            try
            {
                db.SubmitChanges();
                MessageBox.Show("Item edited successfully.");
            }
            catch (Exception e)
            {
                MessageBox.Show("An error has occured trying to edit this stock item");
                MessageBox.Show(e.ToString());
            }
        }
Esempio n. 8
0
        //new stock item
        public void NewReturnedItem(int barcode, int location, int quantity)
        {
            TReturned newReturn = new TReturned
            {
                BarcodeID  = barcode,
                LocationID = location,
                Quantity   = quantity
            };

            // Add the new object to the Orders collection.
            db.TReturneds.InsertOnSubmit(newReturn);

            // Submit the change to the database.
            try
            {
                db.SubmitChanges();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());

                db.SubmitChanges();
            }
        }
        public void UpdateProduct(int barcode, string name, decimal price, decimal tax, decimal discount, string description, int category, int brand, string fullName, string shortName)
        {
            // Updating product information

            using (DataLinqToSQLDataContext product = new DataLinqToSQLDataContext())
            {
                TProductGroup editProduct = product.TProductGroups.SingleOrDefault(x => x.Barcode == barcode);

                editProduct.Name             = name;
                editProduct.Price            = price;
                editProduct.Tax              = tax;
                editProduct.Discount         = discount;
                editProduct.DESCRIPTION      = description;
                editProduct.CategoryID       = category;
                editProduct.BrandID          = brand;
                editProduct.FullProductName  = fullName;
                editProduct.ShortProductName = shortName;

                product.SubmitChanges();
            }
        }
Esempio n. 10
0
        //new stock item
        public void NewStockItem(int barcode, int location, int quantity, string totalcost, DateTime date)
        {
            DataLinqToSQLDataContext connect = new DataLinqToSQLDataContext();

            TInStock newStock = new TInStock
            {
                BarcodeID  = barcode,
                LocationID = location,
                Quantity   = quantity
            };

            TPurchaseLog newLog = new TPurchaseLog
            {
                BarcodeID  = barcode,
                LocationID = location,
                Quantity   = quantity,
                Date       = date,
                TotalCost  = Convert.ToDecimal(totalcost)
            };

            // Add the new object to the Orders collection.
            connect.TInStocks.InsertOnSubmit(newStock);
            connect.TPurchaseLogs.InsertOnSubmit(newLog);

            // Submit the change to the database.
            try
            {
                connect.SubmitChanges();

                MessageBox.Show("Item added to stock successfully.");
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }