コード例 #1
0
 public ActionResult AddMaster(master_table data)
 {
     db.master_table.RemoveRange(db.master_table);
     db.master_table.Add(data);
     db.SaveChanges();
     return(RedirectToAction("Master", "Master"));
 }
コード例 #2
0
        public ActionResult Delete()
        {
            DB_Model db = new DB_Model();

            db.tableData.RemoveRange(db.tableData);
            db.SaveChanges();
            return(RedirectToAction("CurrentDataPage", "CurrentDataPage"));
        }
コード例 #3
0
 private void AddRecordToDataBase(Product product)
 {
     using (DB_Model db = new DB_Model())
     {
         db.Product.Add(product);
         db.SaveChanges();
     }
     this.DialogResult = DialogResult.OK;
     this.Close();
 }
コード例 #4
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();
            }
        }