private void btnLog_Click(object sender, RoutedEventArgs e) { if (Captch.Text == txtCaptch.Text) { a++; var user = Ent.Context.Users.ToList(). Where(p => p.Login == txtLog.Text && p.Password == txtPass.Password).FirstOrDefault(); if (user != null) { User.LName = user.LName; User.Login = user.Login; User.Password = user.Password; User.Phone = user.Phone; User.IdRole = user.IdRole; User.IdGEnder = user.IdGender; if (boxSave.IsChecked == true) { using (StreamWriter sw = new StreamWriter(Paths.Pathsignup)) { string log = txtLog.Text; string pas = txtPass.Password; sw.WriteLine(txtLog.Text + "\n" + txtPass.Password); sw.Close(); } } WindowMain mainWindowew = new WindowMain(); switch (user.IdRole) { case 1: mainWindowew.btnUsers.Visibility = Visibility.Visible; break; case 2: break; case 3: mainWindowew.btnUsers.Visibility = Visibility.Visible; break; } MessageBox.Show("Добро пожаловать"); this.Close(); mainWindowew.ShowDialog(); } else { MessageBox.Show("Неверные данные"); if (a > 2) { Captch.Text = Capthacs.Capcha(); Captch.Visibility = 0; txtCaptch.Visibility = 0; btnCapth.Visibility = 0; imgcapth.Visibility = 0; brdCapth.Visibility = 0; } } } else { MessageBox.Show("Неправильная капча"); } }
private void btnCapth_Click(object sender, RoutedEventArgs e) { Captch.Text = Capthacs.Capcha(); }