Пример #1
0
        public void UpdateBeer(BeerData beerData, BeerBarcode beerBarData, double productArticle) //Info passed back to Form1 where it is linked to the textboxes
        {
            //LINQ query to the database where the products in the update textboxes are populated back to the DB
            using (var context = new GroceryTestDBEntities())
            {
                var query = from s in context.BeerDatas
                            where s.Article == productArticle
                            select s;
                var query1 = from s in context.BeerBarcodes
                             where s.Article == productArticle
                             select s;
                var beerProducts            = query.FirstOrDefault();
                var beerProductswithBarcode = query1.FirstOrDefault();

                beerProducts.Article             = beerData.Article;
                beerProducts.Article_Description = beerData.Article_Description;
                beerProductswithBarcode.Article  = beerBarData.Article;
                beerProductswithBarcode.Barcode  = beerBarData.Barcode;
                beerProducts.Storage_Bin         = beerData.Storage_Bin;
                beerProducts.Department          = beerData.Department;
                beerProducts.Sub_Department      = beerData.Sub_Department;

                context.SaveChanges();
            }
        }
Пример #2
0
        private void UpdateBeerProduct()
        {
            // Update the products in the DB based off what is entered into the update textboxes
            BeerData    beerProducts            = new BeerData();
            BeerBarcode beerProductsWithBarcode = new BeerBarcode();
            double      article = Convert.ToDouble(txtUpdateArticle.Text);

            beerProducts.Article             = Convert.ToDouble(txtUpdateArticle.Text);
            beerProducts.Article_Description = txtUpdateDesc.Text;
            beerProductsWithBarcode.Article  = Convert.ToDouble(txtUpdateArticle.Text);
            beerProductsWithBarcode.Barcode  = Convert.ToDouble(txtUpdateBarcode.Text);
            beerProducts.Storage_Bin         = txtUpdateStorage.Text;
            beerProducts.Department          = txtUpdateDept.Text;
            beerProducts.Sub_Department      = txtUpdateSubDept.Text;

            myLinqUpdateCalls.UpdateBeer(beerProducts, beerProductsWithBarcode, article);
            ClearAddTextBoxes();
            ClearUpdateTextBoxes();
            RefreshDGV();
        }
Пример #3
0
        private void AddBeerProduct()
        {
            // Adds products to the DB based off what is entered into the text boxes
            using (var context = new GroceryTestDBEntities())
            {
                var products       = new BeerData();
                var productbarcode = new BeerBarcode();
                products.Article             = Convert.ToDouble(txtAddArticle.Text);
                products.Article_Description = txtAddDesc.Text;
                productbarcode.Article       = Convert.ToDouble(txtAddArticle.Text);
                productbarcode.Barcode       = Convert.ToDouble(txtAddBarcode.Text);
                products.Storage_Bin         = txtAddStorage.Text;
                products.Department          = txtAddDept.Text;
                products.Sub_Department      = txtAddSubDept.Text;
                MessageBox.Show(products.Article_Description + " was added to the Database.");

                context.BeerDatas.Add(products);
                context.BeerBarcodes.Add(productbarcode);
                context.SaveChanges();

                ClearAddTextBoxes();
            }
        }