Exemplo n.º 1
0
 /// <summary>
 ///     Инициализация страницы авторизации
 /// </summary>
 public LoginPage()
 {
     InitializeComponent();
     LoginBox.Text        = ConfigManager.Config.RegData.Username;
     PasswordBox.Password = ConfigManager.Config.RegData.Password;
     LoginBox.Focus(FocusState.Programmatic);
 }
Exemplo n.º 2
0
 private void EnterButton_Click(object sender, RoutedEventArgs e)
 {
     if (new ValidationClass().CheckIfNotEmpty(LoginBox.Text, PasswordBox.Password))
     {
         PasskeeperModelContext db = new PasskeeperModelContext();
         try
         {
             var findUser = db.Users.FirstOrDefault(u => u.Username == LoginBox.Text);
             if (findUser != null && PasswordProtect.ValidatePassword(PasswordBox.Password, findUser.MasterPassword))
             {
                 MainWindow.LoggedUser = findUser.UserId;
                 MainWindow.Secret     = findUser.Username;
                 DialogResult          = true;
             }
             else
             {
                 MessageBox.Show("Wrong login or password!");
                 PasswordBox.Password = "";
                 LoginBox.Focus();
             }
         }
         catch (Exception err)
         {
             MessageBox.Show(err.ToString());
         }
     }
     else
     {
         MessageBox.Show("Please populate all fields!");
     }
 }
Exemplo n.º 3
0
        private void SignUp_Click(object sender, EventArgs e)
        {
            if (LoginBox.Text.Length == 0)
            {
                Message.Warning("Empty login!", Text);
                return;
            }
            if (PasswordBox.Text.Length == 0)
            {
                Message.Warning("Empty password!", Text);
                return;
            }
            bool result = DB.CheckLogin(LoginBox.Text);

            if (!result)
            {
                Message.Error(DB.Status, Text);
            }
            else
            {
                result = DB.Register(LoginBox.Text, PasswordBox.Text);
                if (!result)
                {
                    Message.Error(DB.Status, Text);
                }
                else
                {
                    Message.Info("You have successfully registered!" + Environment.NewLine + "Log in using the registration data.", Text);
                }
                Journal.Append(String.Format("{0} registered", LoginBox.Text));
            }
            LoginBox.Clear();
            PasswordBox.Clear();
            LoginBox.Focus();
        }
Exemplo n.º 4
0
 public LogIn()
 {
     InitializeComponent();
     WindowHelper.SmallWindowSettings(this);
     UserCredentials.Clear();
     LoginFailed.Visibility = Visibility.Hidden;
     LoginBox.Focus();
 }
Exemplo n.º 5
0
 public MainWindow()
 {
     if (!InstanceAlreadyRunning())
     {
         InitializeComponent();
         LoginBox.Focus();
     }
 }
 public AdministrationLoginWindow(MainWindow mainWindow)
 {
     InitializeComponent();
     _dataManager = new DataManager();
     _mainWindow  = mainWindow;
     succes       = false;
     LoginBox.Focus();
 }
Exemplo n.º 7
0
 public Login()
 {
     InitializeComponent();
     Client = new ClientViewModel(new Client());
     Client.AuthorizationSucceeded += () => Do(() => NavigationService.Navigate(new MainPage(Client)));
     Client.AuthorizationFailed    += message => Do(() => MessageBox.Show(message));
     Client.RegistrationSucceeded  += () => Do(() =>
     {
         MessageBox.Show("Успешная регистрация");
         Client.AuthorizationCommand.Execute((LoginBox.Text, PasswordBox.Password));
     });
     Client.RegistrationFailed += message => Do(() => MessageBox.Show(message));
     DataContext = Client;
     LoginBox.Focus();
 }
Exemplo n.º 8
0
 private void CaptchaBox_OnKeyDown(object sender, Windows.UI.Xaml.Input.KeyRoutedEventArgs e)
 {
     if (e.Key == VirtualKey.Enter)
     {
         if (!string.IsNullOrWhiteSpace(CaptchaBox.Text))
         {
             if (string.IsNullOrWhiteSpace(LoginBox.Text))
             {
                 LoginBox.Focus(FocusState.Keyboard);
             }
             else if (string.IsNullOrWhiteSpace(PasswordBox.Password))
             {
                 PasswordBox.Focus(FocusState.Keyboard);
             }
             else
             {
                 ViewModel.LoginCommand.Execute(null);
             }
         }
     }
 }
Exemplo n.º 9
0
 private void PasswordBox_OnKeyDown(object sender, KeyRoutedEventArgs e)
 {
     if (e.Key == VirtualKey.Enter)
     {
         if (!string.IsNullOrWhiteSpace(PasswordBox.Password))
         {
             if (string.IsNullOrWhiteSpace(LoginBox.Text))
             {
                 LoginBox.Focus(FocusState.Keyboard);
             }
             else if (CaptchaForm.Visibility == Visibility.Visible && string.IsNullOrWhiteSpace(CaptchaBox.Text))
             {
                 CaptchaBox.Focus(FocusState.Keyboard);
             }
             else
             {
                 ((LoginViewModel)DataContext).LoginCommand.Execute(null);
             }
         }
     }
 }
Exemplo n.º 10
0
        public MainWindow()
        {
            // APP init:
            InitializeComponent();
            LoginBox.Focus();
            ContextFactory.SetConnectionParameters("localhost", "admin", "", "cashierbase"); // LOCAL access

            _docNum = GetDocNum();

            SelectGood.Visibility = Visibility.Hidden;
            Plus.Visibility       = Visibility.Hidden;
            Minus.Visibility      = Visibility.Hidden;
            Finish.Visibility     = Visibility.Hidden;

            // Clocks timer:
            var dispatcherTimer = new DispatcherTimer();

            dispatcherTimer.Tick    += Clocks;
            dispatcherTimer.Interval = new TimeSpan(0, 0, 1);
            dispatcherTimer.Start();
        }
Exemplo n.º 11
0
 private void PasswordBox_KeyDown(object sender, Windows.UI.Xaml.Input.KeyRoutedEventArgs e)
 {
     if (e.Key == VirtualKey.Enter)
     {
         //for unknown reason calls twice (on Enter)
         if (!string.IsNullOrWhiteSpace(PasswordBox.Password))
         {
             if (string.IsNullOrWhiteSpace(LoginBox.Text))
             {
                 LoginBox.Focus(FocusState.Keyboard);
             }
             else if (CaptchaForm.Visibility == Visibility.Visible && string.IsNullOrWhiteSpace(CaptchaBox.Text))
             {
                 CaptchaBox.Focus(FocusState.Keyboard);
             }
             else
             {
                 ViewModel.LoginCommand.Execute(null);
             }
         }
     }
 }
Exemplo n.º 12
0
        //Event BtnLogin
        private void LoginBtn_Click(object sender, EventArgs e)
        {
            if (!CheckName(LoginBox.Text))
            {
                MessageBox.Show("Имя должно соответствовать следующим требованиям: Не должно быть меньше 6 или больше 24, Не должно содержать спец. символы.");
                LoginBox.Focus();

                return;
            }
            else
            {
                string LoginString = LoginBox.Text;

                if (CheckBox.Checked)
                {
                    Properties.Settings.Default["Login"] = LoginString;
                }

                Properties.Settings.Default.Save();

                CashName();
                LoginSuccessful();
            }
        }
Exemplo n.º 13
0
 /// <summary>
 ///     Инициализация страницы регистрации
 /// </summary>
 public RegisterPage()
 {
     InitializeComponent();
     LoginBox.Focus(FocusState.Programmatic);
 }
 public LoginPage()
 {
     InitializeComponent();
     LoginBox.Focus();
 }
Exemplo n.º 15
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (LoginBox.Text == "")
            {
                MessageBox.Show("Пожалуйста, введите логин", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                LoginBox.Focus();
                return;
            }

            if (PasswordBox.Text == "")
            {
                MessageBox.Show("Пожалуйста, введите пароль", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                PasswordBox.Focus();
                return;
            }
            try // обработчик исключений, в связке с catch
            {
                if (a < 3)
                {
                    SqlConnection  con         = new SqlConnection(@"Data Source = sqlstud; Initial Catalog = 16is27; User ID = 16is27; Password = 16is27");                                                   //строка подключения
                    SqlDataAdapter dataAdapter = new SqlDataAdapter("SELECT Count(*) FROM [Account] WHERE Login ='******' and Password = '******'and Type='" + 1 + "'", con); //выбираем количесвто строк из таблицы и присваем имя dataAdapter
                    DataTable      dt          = new DataTable();                                                                                                                                              // создание таблице с именем dt
                    dataAdapter.Fill(dt);                                                                                                                                                                      // заполнение таблицы dt из запроса
                    if (dt.Rows[0][0].ToString() == "1")                                                                                                                                                       // условие: если в таблице есть строка, то выполняем
                    {
                        MessageBox.Show("Вы успешно зашли в систему " + LoginBox.Text);
                        this.Hide();
                        Form f0 = new Form2();
                        f0.Show();
                    }
                    else


                    {
                        SqlDataAdapter dataAdapter1 = new SqlDataAdapter("SELECT COUNT(*) FROM [Account] WHERE Login = '******' and Password = '******'and Type ='" + 2 + "'", con);
                        DataTable      dt1          = new DataTable();
                        dataAdapter1.Fill(dt1);
                        if (dt1.Rows[0][0].ToString() == "1")
                        {
                            MessageBox.Show("Добро пожаловать " + LoginBox.Text);
                            this.Hide();
                            Form f1 = new Form3();
                            f1.Show();
                        }

                        else
                        {
                            SqlDataAdapter dataAdapter2 = new SqlDataAdapter("SELECT COUNT(*) FROM [Account] WHERE Login = '******' and Password = '******'and Type = '" + 3 + "'", con);
                            DataTable      dt2          = new DataTable();
                            dataAdapter2.Fill(dt2);
                            if (dt2.Rows[0][0].ToString() == "1")
                            {
                                MessageBox.Show("Добро пожаловать " + LoginBox.Text);
                                this.Hide();
                                Form f2 = new Form4();
                                f2.Show();
                            }
                            else
                            {
                                a = a + 1;
                                MessageBox.Show("Не удалось войти в систему... Попробуйте позже", "Вход запрещен", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                LoginBox.Text    = "";
                                PasswordBox.Text = "";
                            }
                        }
                    }
                }
                else if (a == 3)
                {
                    int b = timer1.Interval / 1000;
                    timer1.Start();
                    MessageBox.Show("Вы превысили лимит ввода данных, система заблокирована на " + b + " секунд.", "Блокировка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    LoginBox.Enabled    = false;
                    PasswordBox.Enabled = false;
                    button1.Enabled     = false;
                    LoginBox.Text       = "";
                    PasswordBox.Text    = "";
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 16
0
        private void ConnectButton_Click(object sender, EventArgs e)
        {
            switch (LoginContext)
            {
            case IsLogedIn.No:
                if (LoginBox.Text == "" || LoginBox.Text == "Entrez un identifiant")
                {
                    LoginBox.Text = "Entrez un identifiant";
                    LoginBox.Focus();
                }
                else
                {
                    RestRequest Request = new RestRequest($"ranking/search/{LoginBox.Text}/false/true/false");
                    Request.OnBeforeDeserialization = resp => { resp.ContentType = "application/json"; };
                    ConnectButton.Text = "...";
                    var SearchResponse = Client.Execute <SearchResults>(Request).Data;
                    if (SearchResponse.success)
                    {
                        if (SearchResponse.results.Count == 0)
                        {
                            MessageBox.Show("Aucun compte ne correspond à cet identifiant");
                        }
                        else
                        {
                            LoginBox.Text     = SearchResponse.results[0].name;
                            Size              = new Size(400, 350);
                            LoginBox.Enabled  = false;
                            LoginBox.Font     = new Font(LoginBox.Font, FontStyle.Bold);
                            LoginBox.Size     = new Size(LoginBox.PreferredSize.Width - 5, LoginBox.PreferredSize.Height);
                            LoginBox.Location = new Point((Size.Width - LoginBox.Size.Width) / 2, 225);
                            LoginContext      = IsLogedIn.LoginOk;

                            label1.Text     = "Mot de passe :";
                            label1.Location = new Point(12, 278);
                            PasswordBox.Show();

                            File.WriteAllBytes(Path.Combine(Directory.GetCurrentDirectory(), LoginBox.Text + "_image.jpg"), new RestClient((SearchResponse.results[0].image.StartsWith("http") ? "" : "http://www.leekwars.com/") + SearchResponse.results[0].image).DownloadData(new RestRequest()));
                            ImageBox.ImageLocation = Path.Combine(Directory.GetCurrentDirectory(), LoginBox.Text + "_image.jpg");
                            ImageBox.Show();
                            ConnectButton.Location = new Point(200, 315);
                            ChangeButton.Show();
                            TokenCheckbox.Show();
                            PasswordBox.Focus();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Une erreur est survenue");
                    }
                    ConnectButton.Text = "Connexion";
                }
                break;

            case IsLogedIn.LoginOk:
                if (PasswordBox.Text == "" || PasswordBox.Text == "Entrez un mot de passe")
                {
                    PasswordBox.Text = "Entrez un mot de passe";
                    PasswordBox.Focus();
                }
                else
                {
                    RestRequest Request = new RestRequest($"farmer/login-token/{LoginBox.Text}/{PasswordBox.Text}");
                    Request.OnBeforeDeserialization = resp => { resp.ContentType = "application/json"; };
                    ConnectButton.Text = "...";
                    var LoginResponse = Client.Execute <Login>(Request).Data;
                    if (LoginResponse.success)
                    {
                        if (TokenCheckbox.Checked)
                        {
                            MessageBox.Show(LoginResponse.token, "Token");
                        }

                        LoginContext = IsLogedIn.PassWordOk;
                        var GUI = new GUI(LoginResponse);
                        GUI.Show();
                        Hide();
                    }
                    else
                    {
                        MessageBox.Show("Mauvais mot de passe");
                        PasswordBox.Focus();
                    }
                }
                ConnectButton.Text = "Connexion";
                break;
            }
        }
Exemplo n.º 17
0
 private void OnLoaded(object sender, RoutedEventArgs e)
 {
     LoginBox.Focus();
 }
Exemplo n.º 18
0
        private void Login_Click(object sender, RoutedEventArgs e)
        {
            Manager manager = Manager.Instance();

            manager.ManagerOperation();
            string managerEmail    = manager.GetManagerEmail();
            string managerPassword = manager.GetManagerPassword();

            if (LoginBox.Text == managerEmail && PassBox.Password == managerPassword)
            {
                context = new Context(new ConcreteStrategyE());
                context.ContextInterface();
                this.Close();
            }
            else
            {
                try
                {
                    var email  = DB.Clients.Where(u => u.Email == LoginBox.Text).FirstOrDefault();
                    var email2 = DB.Sellers.Where(u => u.Email == LoginBox.Text).FirstOrDefault();
                    var email3 = DB.Storekeepers.Where(u => u.Email == LoginBox.Text).FirstOrDefault();

                    if ((LoginBox.Text == "") || (PassBox.Password == ""))
                    {
                        if (LoginBox.Text == "")
                        {
                            MessageBox.Show("Email is Required!", "Caution", MessageBoxButton.OK);
                            LoginBox.Focus();
                        }
                        else if (PassBox.Password == "")
                        {
                            MessageBox.Show("Password is Required!", "Caution", MessageBoxButton.OK);
                            PassBox.Focus();
                        }
                    }
                    else
                    {
                        if (email != null)
                        {
                            var pass = email.Password;
                            pass = PassBox.Password;
                            if (PassBox.Password == pass)
                            {
                                MessageBox.Show("Login Successfully!", "Login Success", MessageBoxButton.OK);
                                client  = DB.Clients.Where(u => u.Email == LoginBox.Text).FirstOrDefault();
                                context = new Context(new ConcreteStrategyE(client));
                                context.ContextInterface();
                                this.Close();
                            }
                            else
                            {
                                MessageBox.Show("Email or Password are wrong!");
                            }
                        }
                        else if (email2 != null)
                        {
                            var pass = email2.Password;
                            pass = PassBox.Password;
                            if (PassBox.Password == pass)
                            {
                                MessageBox.Show("Login Successfully!", "Login Success", MessageBoxButton.OK);
                                seller  = DB.Sellers.Where(u => u.Email == LoginBox.Text).FirstOrDefault();
                                context = new Context(new ConcreteStrategyE(seller));
                                context.ContextInterface();
                                this.Close();
                            }
                            else
                            {
                                MessageBox.Show("Email and Password or wrong!");
                            }
                        }
                        else if (email3 != null)
                        {
                            var pass = email3.Password;
                            pass = PassBox.Password;
                            if (PassBox.Password == pass)
                            {
                                MessageBox.Show("Login Successfully!", "Login Success", MessageBoxButton.OK);
                                storekeeper = DB.Storekeepers.Where(u => u.Email == LoginBox.Text).FirstOrDefault();
                                context     = new Context(new ConcreteStrategyE(storekeeper));
                                context.ContextInterface();
                                this.Close();
                            }
                            else
                            {
                                MessageBox.Show("Email and Password or wrong!");
                            }
                        }
                        else
                        {
                            MessageBox.Show("Email and Password is invalid");
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Exemplo n.º 19
0
        void Rejestracja()
        {
            MySqlConnection polaczenie = new MySqlConnection("server=localhost; user=root; database=food; port=3306; pooling=false");
            MySqlCommand    komenda    = polaczenie.CreateCommand();
            MySqlCommand    komenda1   = polaczenie.CreateCommand();

            try
            {
                if (polaczenie.State == ConnectionState.Closed)
                {
                    polaczenie.Open();

                    string haslo = PasswordBox.Text;

                    using (MD5 hash = MD5.Create())
                    {
                        haslo = GetMd5Hash(hash, haslo);
                    }

                    komenda1.CommandText = string.Format("SELECT count(id) FROM data where Login='******'");
                    int wartosc = Convert.ToInt32(komenda1.ExecuteScalar());
                    if (wartosc == 1)
                    {
                        MessageBox.Show(String.Format("Login: {0}, already exists.", LoginBox.Text), "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        komenda.CommandText = string.Format("INSERT INTO data(Login,Password,Resort,Street,NumerHouse) VALUES('{0}','{1}','{2}','{3}','{4}')", LoginBox.Text, haslo, ResortBox.Text, StreetBox.Text, HostNumberBox.Text);
                        if (komenda.ExecuteNonQuery() == 1)
                        {
                            MessageBox.Show("You have logged successfuly. Now you can Login!", "Informacja", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            MessageBox.Show("Login Error.", "Informacja", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                    HostNumberBox.Clear(); StreetBox.Clear(); ResortBox.Clear(); LoginBox.Clear(); PasswordBox.Clear(); LoginBox.Focus();
                }
            }
            catch (Exception ex)
            {
                string byk = string.Format("Problem register with user: \n{0}.", ex.Message);
                MessageBox.Show(byk, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                if (polaczenie.State == ConnectionState.Open)
                {
                    polaczenie.Close();
                }
            }
        }