예제 #1
0
        public void UpdateFrozen(FrozenData frozenData, FrozenBarcode frozenBarData, 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.FrozenDatas
                            where s.Article == productArticle
                            select s;
                var query1 = from s in context.FrozenBarcodes
                             where s.Article == productArticle
                             select s;
                var frozenProducts            = query.FirstOrDefault();
                var frozenProductsWithBarcode = query1.FirstOrDefault();

                frozenProducts.Article             = frozenData.Article;
                frozenProducts.Article_Description = frozenData.Article_Description;
                frozenProductsWithBarcode.Article  = frozenBarData.Article;
                frozenProductsWithBarcode.Barcode  = frozenBarData.Barcode;
                frozenProducts.Storage_Bin         = frozenData.Storage_Bin;
                frozenProducts.Department          = frozenData.Department;
                frozenProducts.Sub_Department      = frozenData.Sub_Department;

                context.SaveChanges();
            }
        }
예제 #2
0
        private void UpdateFrozenProduct()
        {
            // Update the products in the DB based off what is entered into the update textboxes
            FrozenData    frozenProducts            = new FrozenData();
            FrozenBarcode frozenProductsWithBarcode = new FrozenBarcode();
            double        article = Convert.ToDouble(txtUpdateArticle.Text);

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

            myLinqUpdateCalls.UpdateFrozen(frozenProducts, frozenProductsWithBarcode, article);
            ClearAddTextBoxes();
            ClearUpdateTextBoxes();
            RefreshDGV();
        }
예제 #3
0
        private void AddFrozenProduct()
        {
            // Adds products to the DB based off what is entered into the text boxes
            using (var context = new GroceryTestDBEntities())
            {
                var products       = new FrozenData();
                var productbarcode = new FrozenBarcode();
                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.FrozenDatas.Add(products);
                context.FrozenBarcodes.Add(productbarcode);
                context.SaveChanges();

                ClearAddTextBoxes();
            }
        }