Example #1
0
 private void LoadCategories()
 {
     using (DB_Model db = new DB_Model())
     {
         List_Category = db.Product_Category
                         .ToList();
     }
 }
        public ActionResult Delete()
        {
            DB_Model db = new DB_Model();

            db.tableData.RemoveRange(db.tableData);
            db.SaveChanges();
            return(RedirectToAction("CurrentDataPage", "CurrentDataPage"));
        }
 private void AddRecordToDataBase(Product product)
 {
     using (DB_Model db = new DB_Model())
     {
         db.Product.Add(product);
         db.SaveChanges();
     }
     this.DialogResult = DialogResult.OK;
     this.Close();
 }
Example #4
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (_db_Model != null)
         {
             _db_Model.Dispose();
             _db_Model = null;
         }
     }
     base.Dispose(disposing);
 }
Example #5
0
        public void test_method()
        {
            Product_Category cat = new Product_Category();

            using (DB_Model db = new DB_Model())
            {
                cat = db.Product_Category
                      .Where(x => x.Id == 1)
                      .FirstOrDefault();

                MessageBox.Show(cat.Name);
            }
        }
Example #6
0
 private List <Product> SearchProductsWithoutCategory()
 {
     using (DB_Model db = new DB_Model())
     {
         var products = db.Product
                        .Where(x => x.Name.ToLower().Contains(Product_Textbox.Text.ToLower())) //dorobic walidacje nulla
                        .ToList();
         if (products.Count == 0)
         {
             NoProductFound();
         }
         return(products);
     }
 }
Example #7
0
        private void RemoveProductFromDB(object sender, EventArgs e)
        {
            Product           product = ((sender as MetroButton).Parent as SearchedProducts_Control).Product;
            GiveUserInfo_Form form    = new GiveUserInfo_Form("Czy chcesz trwale usunąć element '" + product.Name
                                                              + "' z bazy?");

            if (form.DialogResult == DialogResult.OK)
            {
                using (var db = new DB_Model())
                {
                    db.Entry(product).State = EntityState.Deleted;
                    db.SaveChanges();
                }
                splitContainer1.Panel2.Controls.Clear();
            }
        }
Example #8
0
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                using (DB_Model db = new DB_Model())
                {
                    DB_Functions.Add_User(collection["Password"], collection["ContactNickname"]);
                }

                return(RedirectToAction("Success"));
            }
            catch
            {
                return(View());
            }
        }
Example #9
0
 public MasterController()
 {
     db  = new DB_Model();
     sql = new MySqlDatabaseInteraction();
 }
Example #10
0
        public ActionResult Index()
        {
            var data = new DB_Model();

            return(View(data.Locations.AsEnumerable <Locations>()));
        }