private void buttonOk_Click(object sender, EventArgs e) { string log = this.textBoxLog.Text, pas = this.textBoxPas.Text; var rec = this.ticherTableAdapter1.GetData(); var filter = rec.Where(p => p.login == log && p.password == pas); if (filter.Count() == 0) { MessageBox.Show( "неверное имя или пароль", "ОШИБКА", MessageBoxButtons.OK, MessageBoxIcon.Warning ); } else { Information.idTicer = filter.ElementAt(0).idTicher; Information.nameTicher = filter.ElementAt(0).nameTicher; MessageBox.Show( "вы вошли как " + Information.nameTicher, "успешно", MessageBoxButtons.OK, MessageBoxIcon.Information ); //MainMenu main = new MainMenu(); ////main.toolStripStatusLabel1.Text = "вы вошли как " + Information.nameTicher; this.Hide(); CreateTest test = new CreateTest(); test.ShowDialog(); } }
private void buttonOk_Click(object sender, EventArgs e)//регистрация { if (check(this.textBoxName, this.textBoxPasword1, this.textBoxPasword2, this.textBoxLogin)) { if (textBoxPasword1.Text == textBoxPasword2.Text) { if (textBox1.Text != text) { MessageBox.Show( "неправельная капча ", "ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error ); } var rec = this.ticherTableAdapter1.GetData(); var filter = rec.Where(p => p.nameTicher == textBoxName.Text && p.login == textBoxLogin.Text); if (filter.Count() == 0) { try { this.ticherTableAdapter1.Insert(textBoxLogin.Text, textBoxPasword2.Text, textBoxName.Text); rec = this.ticherTableAdapter1.GetData(); Information.idTicer = rec.Last().idTicher; Information.nameTicher = rec.Last().nameTicher; MessageBox.Show( "вы зарегистрировались как " + Information.nameTicher, "успешно", MessageBoxButtons.OK, MessageBoxIcon.Information ); this.Hide(); CreateTest test = new CreateTest(); test.ShowDialog(); } catch { MessageBox.Show( "ПРОИЗОШЛА НЕПРЕДВИДДЕНАЯ ОШИБКА ", "ОШИБКА", MessageBoxButtons.OK, MessageBoxIcon.Error ); } } else { MessageBox.Show( "Преподаватель с этим именем или логином уже существует ", "ОШИБКА", MessageBoxButtons.OK, MessageBoxIcon.Error ); } } else { MessageBox.Show( "вы не верно вели пароль", "ОШИБКА", MessageBoxButtons.OK, MessageBoxIcon.Error ); } } }