private void button22_Click(object sender, EventArgs e) { DBContext myDb = null; try { myDb = new DBContext(); StoreModels.FinancialTransaction ft = myDb.FinancialTransactions.Where(i => i.Code == 2).FirstOrDefault(); myDb.FinancialTransactions.Attach(ft); myDb.delete(ft); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void button7_Click(object sender, EventArgs e) { try { StoreModels.FinancialTransaction ft = new StoreModels.FinancialTransaction() { CreationDate = DateTime.Now, IsPersonal = true, TotalPrice = 10000, Type = StoreModels.FinancialTransaction.FTTypes.Talab, PayType = StoreModels.Transaction.PaymentTypes.Naghd }; DBContext myDB = new DBContext(); myDB.save(ft); } catch (Exception ex) { MessageBox.Show(ex.Message); //throw; } }