コード例 #1
0
        //перегрузка конструктора формы, в которую передается ссылка на форму-родителя(чет не рабит)
        //public Sign_in_form(Main_form _mainform)
        //{
        //  InitializeComponent();
        //  mainform = _mainform;
        //}
        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())
            {
              var accounts = db.Accounts;

              foreach (Account u in accounts)
              {
            if(u.email == textBox1.Text & u.password == textBox2.Text)
            {
              Main_form.UserName = u.name;

              //обращение к главной форме через объект
              mainform = this.Owner as Main_form; //можно и так)
              mainform.toolStripStatusLabel4.Text = u.name;
              //toolStripStatusLabel4.Text = u.name; //нельзя ибо нестатическое поле
              //А еще очень даже неплохо воспользоваться событиями.
              MessageBox.Show("Вход выполнен успешно"); //нет ли двух попаданий?
            }
              }
              //смешной костыль
              if(Main_form.UserName == "No User Registered")
              {
            MessageBox.Show("Неверный логин или пароль");
              }
            }
              }
              this.Close();
        }
コード例 #2
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();
        }
コード例 #3
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();
              }
        }