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(); }
protected override void Dispose(bool disposing) { if (disposing) { if (_db_Model != null) { _db_Model.Dispose(); _db_Model = null; } } base.Dispose(disposing); }
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); } }
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); } }
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(); } }
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()); } }
public MasterController() { db = new DB_Model(); sql = new MySqlDatabaseInteraction(); }
public ActionResult Index() { var data = new DB_Model(); return(View(data.Locations.AsEnumerable <Locations>())); }