private void btn1_Click(object sender, RoutedEventArgs e) { //string constr = @"Data Source=DESKTOP-GM2O70F\MSSQLDEV;Initial Catalog=GosSoviet;Integrated Security=True"; SQLWork work = new SQLWork(); if (work.FindUser(tbLog.Text, tbPass.Text)) { Loading ld = new Loading(); this.Hide(); ld.Show(); } else { MessageBox.Show("Неправильный логин или пороль", "", MessageBoxButton.OK, MessageBoxImage.Exclamation); } }
private void Button_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(tbSurname.Text) || string.IsNullOrEmpty(tbFathername.Text) || string.IsNullOrEmpty(tbName.Text) || string.IsNullOrEmpty(tbLogin.Text) || string.IsNullOrEmpty(tbPass.Text) || dataPickerDeputy.SelectedDate == null) { MessageBox.Show("Введите все данные"); } else if (work.FindUser(tbLogin.Text)) { MessageBox.Show("Такой логин уже существует"); } else { Deputy deputy = new Deputy { Surname = tbSurname.Text, Fathername = tbFathername.Text, Name = tbName.Text, Login = tbLogin.Text, Password = tbPass.Text, Birthday = dataPickerDeputy.SelectedDate, Dostup = (bool)checkBoxDeputy.IsChecked }; db.Add(deputy); db.SaveChanges(); MessageBox.Show("Депутат успешно добавлен"); tbSurname.Text = ""; tbFathername.Text = ""; tbName.Text = ""; tbLogin.Text = ""; dataPickerDeputy.SelectedDate = null; tbPass.Text = ""; } }