Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            MessageBoxButtons buttons = MessageBoxButtons.YesNo;

              DialogResult result = MessageBox.Show("Do you confirm your choice?", "confirm", buttons);

              if(result == DialogResult.Yes)
              {
            using(AccountContext db = new AccountContext())
            {
              Account account = new Account
              {
            name = textBox1.Text,
            email = textBox4.Text,
            password = textBox5.Text
              };
              db.Accounts.Add(account);
              db.SaveChanges();
            }
              }
              this.Close();
        }
Пример #2
0
        private void стеретьВсеДанныеToolStripMenuItem_Click(object sender, EventArgs e)
        {
            using(AccountContext db = new AccountContext())
              {
            var accounts = db.Accounts;

            foreach(Account u in accounts)
            {
              db.Accounts.Remove(u);
            }
            db.SaveChanges();
              }
        }