JAPWT / View / AuthorizationPages / ForgotPasswordPage.xaml.cs
ForgotPasswordPage.xaml.cs
Raw
using MyApp.ExampleDataSetTableAdapters;
using System.Data;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Navigation;

namespace MyApp
{
    public partial class ForgotPasswordPage : Page
    {
        UsersTableAdapter usersTableAdapter = new UsersTableAdapter();
        public ForgotPasswordPage()
        {
            InitializeComponent();
        }

        private void EnterButton_Click(object sender, RoutedEventArgs e)
        {
            if (LoginTB.Text == "Логин/Почта") { return; }
            if (LoginTB.Text != "")
            {
                bool DBContainLogin = false;
                var Data = usersTableAdapter.GetData();
                foreach (DataRow row in Data.Rows)
                {
                    if (row["LoginUser"].ToString() == LoginTB.Text) { DBContainLogin = true; break; }
                }
                if (DBContainLogin == false) { SendedOrNotTB.TextAlignment = TextAlignment.Center; SendedOrNotTB.Text = "Аккаунт не найден!"; SendedOrNotTB.Visibility = Visibility.Visible; return; }
                if (DBContainLogin == true) { SendedOrNotTB.Text = "Инструкция по восстановлению доступа к аккаунта выслана на вашу почту!"; SendedOrNotTB.Visibility = Visibility.Visible; return; }
            }
        }

        //Навигация
        private void AuthorizationPageButton_Click(object sender, RoutedEventArgs e)
        {
            NavigationService.Navigate(new AuthorizationPage());
        }
        private void RegistrationPageButton_Click(object sender, RoutedEventArgs e)
        {
            NavigationService.Navigate(new RegistrationPage());
        }

        //Прочие события
        private void LoginTB_MouseEnter(object sender, MouseEventArgs e)
        {
            if (LoginTB.Text == "Логин/Почта") { LoginTB.Text = ""; LoginTB.Foreground = Brushes.White; }
        }

        private void LoginTB_MouseLeave(object sender, MouseEventArgs e)
        {
            if (LoginTB.Text == "") { LoginTB.Text = "Логин/Почта"; SolidColorBrush sb = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#6BFFFFFF")); LoginTB.Foreground = sb; }
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Window ownerWindow = Application.Current.Windows.OfType<Window>().SingleOrDefault(w => w.Title == "MainWindow");
            ownerWindow.Close();
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            Window ownerWindow = Application.Current.Windows.OfType<Window>().SingleOrDefault(w => w.Title == "MainWindow");
            ownerWindow.WindowState = WindowState.Minimized;
        }
    }
}