private bool Save(int type, string desc, DateTime startDate, float balance) { try { if (db == null) { db = new MainDBEntities2(); } var Account = new Account() { Type = type, Description = desc, DateTime = startDate, Balance = balance }; db.Accounts.Add(Account); db.SaveChanges(); MessageBox.Show("Account \"" + desc + "\" successfully added!"); BindDGView(db.Accounts.ToList()); return(true); } catch (Exception e) { MessageBox.Show(e.Message); return(false); } }
public AccountsSetup() { InitializeComponent(); db = new MainDBEntities2(); BindDGView(db.Accounts.ToList()); }