Exemplo n.º 1
0
        private void loginButton_Click(object sender, EventArgs e)
        {
            //connect to SQL database
            SqlConnection  con = new SqlConnection("Data Source=LAPTOP-0RU2PM09;Initial Catalog=Stock;Integrated Security=True");
            SqlDataAdapter sda = new SqlDataAdapter(@"SELECT *
                                                   FROM [dbo].[Login] where UserName = '******' and Password = '******' ", con);
            DataTable      dt  = new DataTable();

            sda.Fill(dt);
            //if the username and password is wrong, the dt has a value of null

            //TO-DO: ckecklogin detail
            if (dt.Rows.Count == 1)
            {
                this.Hide();
                StockMain main = new StockMain();
                main.Show();
            }
            else
            {
                UserNameTextBox.Clear();
                passwordTextBox.Clear();
                MessageBox.Show("Incorrect username and password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 2
0
        private void AddPlayerButton_Click(object sender, EventArgs e)
        {
            string currentUserName = UserNameTextBox.Text;

            if (currentUserName == "")
            {
                MessageBox.Show("Please enter a Name");
                return;
            }
            if (!PlayerList.DoesPlayerExist(currentUserName))
            {
                listBox1.Items.Add(PlayerList.NumberOfPlayers + ")  " + currentUserName);
                Player newPlayer = new Player(currentUserName);
                PlayerList.AddPlayerInVector(newPlayer);

                UserNameTextBox.Clear();
                if (PlayerList.IsGameFull())
                {
                    AddPlayerButton.Hide();
                    UserNameTextBox.Hide();
                }

                if (PlayerList.AreEnoughPlayers())
                {
                    StartButton.Show();
                }
            }
            else
            {
                MessageBox.Show("This username is already used");
            }
        }
Exemplo n.º 3
0
 private void AddNewUserButton_Click(object sender, RoutedEventArgs e)
 {
     UserNameTextBox.Clear();
     WybraneRole.Clear();
     PozostaleRole.Clear();
     foreach (Operacja o in Operacje)
     {
         if (!WybraneOperacje.Contains(o))
         {
             PozostaleOperacje.Add(o);
         }
     }
     WybraneRole.Clear();
     PozostaleRole.Clear();
     foreach (Rola r in Role)
     {
         {
             PozostaleRole.Add(r);
         }
     }
     SaveUserButton.Content          = "Dodaj uzytkownika";
     PasswordLabel.Visibility        = System.Windows.Visibility.Visible;
     UserPasswordBox.Visibility      = System.Windows.Visibility.Visible;
     EdycjaRolColumn2Grid.Visibility = System.Windows.Visibility.Visible;
 }
Exemplo n.º 4
0
        private void clearButton_Click(object sender, EventArgs e)
        {
            UserNameTextBox.Focus();

            UserNameTextBox.Clear();
            passwordTextBox.Clear();
        }
Exemplo n.º 5
0
 private bool InvalidAction()
 {
     UserNameTextBox.Clear();
     PasswordTextBox.Clear();
     UserNameTextBox.Focus();
     return(false);
 }
Exemplo n.º 6
0
 public void Limpiar()
 {
     UserIdNumericUpDown.Value = 0;
     NameUserTextBox.Clear();
     UserNameTextBox.Clear();
     PasswordMaskedTextBox.Clear();
     ConfirmPasswordMaskedTextBox.Clear();
     ErrorProvider.Clear();
 }
Exemplo n.º 7
0
 public void LoginToAPP()
 {
     UserNameTextBox.Clear();
     UserNameTextBox.SendKeys(ReadEnv.ReadData("base", "username"));
     PasswordText.Clear();
     PasswordText.SendKeys(ReadEnv.ReadData("base", "password"));
     LoginButton.Click();
     Assert.True(LaunchButton.Displayed);
 }
Exemplo n.º 8
0
 private void textBox1_Click(object sender, EventArgs e)
 {
     UserNameTextBox.Clear();
     UserNameTextBox.ForeColor = Color.Black;
     if (UserNameTextBox.Text == "")
     {
         PassWordTextBox.ForeColor = Color.Gray;
         PassWordTextBox.Text      = "Enter User Name Here";
     }
 }
Exemplo n.º 9
0
 private void UserNameTextBox_Enter(object sender, EventArgs e)
 {
     UserNameTextBox.Clear();
     UserNameTextBox.ForeColor = Color.Black;
     if (UserNameTextBox.Text == "")
     {
         PassWordTextBox.UseSystemPasswordChar = false;
         PassWordTextBox.ForeColor             = Color.Gray;
         PassWordTextBox.Text = "Enter Pass Word Here";
     }
 }
 private void UserNameTextBox_Enter(object sender, EventArgs e)// ברגע שנכנסים לתיבה אז נמחק כל התוכן בו והכתב הופך לשחור
 {
     UserNameTextBox.Clear();
     UserNameTextBox.ForeColor = Color.Black;
     if (UserNameTextBox.Text == "")
     {
         PassWordTextBox.UseSystemPasswordChar = false;
         PassWordTextBox.ForeColor             = Color.Gray;
         PassWordTextBox.Text = "Enter Pass Word Here";
     }
 }
 private void UserNameTextBoxClicked(object sender, EventArgs e)//מנקה את התיבה ברגע הלחיצה ומשנה את הכתב מאפור לשחור
 {
     UserNameTextBox.Clear();
     UserNameTextBox.ForeColor = Color.Black;
     if (UserNameTextBox.Text == "")
     {
         PassWordTextBox.UseSystemPasswordChar = false;
         PassWordTextBox.ForeColor             = Color.Gray;
         PassWordTextBox.Text = "Enter Pass Word Here";
     }
 }
Exemplo n.º 12
0
 private void NewUserButton_Click(object sender, RoutedEventArgs e)
 {
     UserNameTextBox.Clear();
     UserLastNameTextBox.Clear();
     UserLoginTextBox.Clear();
     UserPassword.Clear();
     UserZoneCombo.SelectedItem             = null;
     IsAdminCheckBox.IsChecked              = false;
     ActiveCheckBox.IsChecked               = false;
     _mainWindowViewController.SelectedUser = null;
 }
 private void Reset()
 {
     UserNameTextBox.Clear();
     PasswordTextBox.Clear();
     NameTextBox.Clear();
     SecondNameTextBox.Clear();
     SurnameTextBox.Clear();
     BirthDayDatePicker.ClearValue(DatePicker.SelectedDateProperty);
     SexComboBox.ClearValue(ComboBox.SelectedItemProperty);
     PositionComboBox.ClearValue(ComboBox.SelectedItemProperty);
 }
Exemplo n.º 14
0
 private void AddUser()
 {
     if (_quizManager.AddUser(UserNameTextBox.Text))
     {
         ConfirmedTextBlock.Text       = "Added";
         ConfirmedTextBlock.Visibility = Visibility.Visible;
         UserNameTextBox.Clear();
     }
     else
     {
         ConfirmedTextBlock.Text       = "Empty box or name exist";
         ConfirmedTextBlock.Visibility = Visibility.Visible;
     }
 }
Exemplo n.º 15
0
        // Clear UI infput fields
        private void ClearUI()
        {
            IDTextBox.Clear();
            UserNameTextBox.Clear();
            PasswordTextBox.Clear();
            FirstNameTextBox.Clear();
            LastNameTextBox.Clear();
            EmailTextBox.Clear();
            var date = new DateTime();

            date = DateTime.Today;
            StartDateDatePickerTextBox.Text = date.ToShortDateString();
            UserTypeComboBox.Text           = "Staff";
            ProtectedUserCheckBox.IsChecked = false;
            UserInactiveCheckBox.IsChecked  = false;
        }
Exemplo n.º 16
0
        public RegisterView(RegisterViewModel viewModel)
        {
            InitializeComponent();
            ViewModel = viewModel;

            this.WhenActivated(disposableRegistration =>
            {
                this.WhenAnyValue(v => v.UserNameTextBox.Text)
                .BindTo(ViewModel, vm => vm.UserName)
                .DisposeWith(disposableRegistration);

                Observable.FromEventPattern(PasswordTextBox, nameof(PasswordTextBox.PasswordChanged))
                .Select(ep => PasswordTextBox.Password)
                .BindTo(ViewModel, vm => vm.Password)
                .DisposeWith(disposableRegistration);

                Observable.FromEventPattern(PasswordRepeatTextBox, nameof(PasswordRepeatTextBox.PasswordChanged))
                .Select(ep => PasswordRepeatTextBox.Password)
                .BindTo(ViewModel, vm => vm.PasswordRepeat)
                .DisposeWith(disposableRegistration);

                this.WhenAnyValue(v => v.NameTextBox.Text)
                .BindTo(ViewModel, vm => vm.Name)
                .DisposeWith(disposableRegistration);

                this.WhenAnyValue(v => v.NationalIdentificationNumberTextBox.Text)
                .BindTo(ViewModel, vm => vm.NationalIdentificationNumber)
                .DisposeWith(disposableRegistration);

                this.BindCommand(ViewModel,
                                 vm => vm.RegisterCommand,
                                 v => v.RegisterButton)
                .DisposeWith(disposableRegistration);

                ViewModel.Registered.RegisterHandler(interactioni =>
                {
                    interactioni.SetOutput(Unit.Default);
                    UserNameTextBox.Clear();
                    PasswordTextBox.Clear();
                    PasswordRepeatTextBox.Clear();
                    NameTextBox.Clear();
                    NationalIdentificationNumberTextBox.Clear();
                    ParentView.Navigate(ParentView.AccountInfoSideMenu.Name);
                }).DisposeWith(disposableRegistration);
            });
        }
Exemplo n.º 17
0
 private void SignInButton_Click(object sender, EventArgs e)
 {
     if (!isValid())
     {
         MessageBox.Show("Please Fill User Name OR Password", "Error",
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         try
         {
             bool IsUserNameCurrect, IsPasswordCurrect;
             GetIsUserLoginCurrect(out IsUserNameCurrect, out IsPasswordCurrect);
             if (IsUserNameCurrect && IsPasswordCurrect)
             {
                 Expanses Exp = new Expanses();
                 Exp.Show();
                 this.Hide();
             }
             else
             {
                 if (!IsUserNameCurrect)
                 {
                     MessageBox.Show("User Name is Not Currect.", "Error",
                                     MessageBoxButtons.OK, MessageBoxIcon.Error);
                     UserNameTextBox.Clear();
                     PasswordTextBox.Clear();
                     UserNameTextBox.Focus();
                 }
                 else
                 {
                     MessageBox.Show("Password is Not Currect.", "Error",
                                     MessageBoxButtons.OK, MessageBoxIcon.Error);
                     PasswordTextBox.Clear();
                     PasswordTextBox.Focus();
                 }
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show("Error" + ex.Message, "Error",
                             MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Exemplo n.º 18
0
        private void ResetFormControl()
        {
            UserNameTextBox.Clear();
            PasswordTextBox.Clear();
            RolesComboBox.SelectedIndex = 0;
            IsActiveCheckBox.Checked    = true;
            DescriptionTextBox.Clear();

            UserNameTextBox.Focus();

            if (this.IsUpdate)
            {
                this.IsUpdate        = false;
                SaveButton.Text      = "Save User Information";
                DeleteButton.Enabled = false;
                this.UserName        = null;
            }
        }
        private bool IsFormValid()
        {
            if (UserNameTextBox.Text.Trim() == String.Empty)
            {
                MessageBox.Show("User name is required.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                UserNameTextBox.Clear();
                UserNameTextBox.Focus();
                return(false);
            }

            if (PasswordTextBox.Text.Trim() == String.Empty)
            {
                MessageBox.Show("Password is required.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                PasswordTextBox.Clear();
                PasswordTextBox.Focus();
                return(false);
            }
            return(true);
        }
Exemplo n.º 20
0
        private bool isFormValid()
        {
            if (UserNameTextBox.Text.Trim() == string.Empty)
            {
                SMSMessageBox.ShowErrorMessage("User name is not correct");
                UserNameTextBox.Clear();
                UserNameTextBox.Focus();
                return(false);
            }

            if (PasswordTextBox.Text.Trim() == string.Empty)
            {
                SMSMessageBox.ShowErrorMessage("Password is not correct");
                PasswordTextBox.Clear();
                PasswordTextBox.Focus();
                return(false);
            }

            return(true);
        }
Exemplo n.º 21
0
        //This just does exactly the same thing as the Login Button, but ...uses the "Enter" key
        private void PasswordTextBox_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)Keys.Enter)
            {
                //This part will get the User Name and Password data from the MYSQL database
                MySqlConnection conn = new MySqlConnection(DBset());
                conn.Open();
                MySqlCommand cmd = conn.CreateCommand();
                cmd.CommandText = "SELECT username, password FROM user_accounts_table WHERE username = @username";
                cmd.Parameters.AddWithValue("@username", UserNameTextBox.Text);
                MySqlDataReader reader = cmd.ExecuteReader();

                //This part checks if what the user has inputted MATCHES what is inputted in the HIS MySQL database
                if (reader.HasRows == true)
                {
                    while (reader.Read())
                    {
                        if (UserNameTextBox.Text == reader[0].ToString() && PasswordTextBox.Text == reader[1].ToString())
                        {
                            MessageBox.Show("Login Successful");
                            ControlPanel cp = new ControlPanel();
                            cp.Show();
                            this.Hide();
                        }
                        else
                        {
                            //User has inputted wrong credentials. He has to start over. Text Boxes are cleared.
                            MessageBox.Show("Login Failed. Please input correct username and/or password");
                            UserNameTextBox.Clear();
                            PasswordTextBox.Clear();
                        }
                    }
                }
                else
                {
                    MessageBox.Show("No Such User Found");
                    UserNameTextBox.Clear();
                    PasswordTextBox.Clear();
                }
            }
        }
Exemplo n.º 22
0
        private void LoginButton_Click(object sender, EventArgs e)
        {
            String userName = UserNameTextBox.Text;
            String password = PasswordTextBox.Text;

            // Successful Authentication
            if (userDatabase.Login(userName, password))
            {
                userDatabase.SetAuthentication(userName, true);
                user            = userDatabase.GetByUserName(userName);
                IsAuthenticated = true;
                this.Close();
            }
            // Failure to Authenticate
            else
            {
                MessageBox.Show("Incorrect Username or Password.", "Attention");
                UserNameTextBox.Clear();
                PasswordTextBox.Clear();
            }
        }
Exemplo n.º 23
0
        /// <summary>
        /// Udalost kliknuti na tlacitko Prihlasit: overeni udaju a prihlaseni zakaznika nebo admina
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void LoginUserButton_Click(object sender, EventArgs e)
        {
            // prihlaseni administratora
            if (adminLogin)
            {
                if (PasswordTextBox.Text == Administrator.Password)
                {
                    Session.LoginAdmin();
                    Close();
                }
                else
                {
                    PasswordTLPanel.BackColor = Color.MistyRose;
                    Message.InvalidPasswordWarning();
                    PasswordTextBox.Clear();
                }
            }
            // prihlaseni zakaznika
            else
            {
                string userEmail    = UserNameTextBox.Text;
                string userPassword = PasswordTextBox.Text;

                Customer customer = Database.GetVerifiedCustomer(userEmail, userPassword);

                if (customer != null)
                {
                    Session.LoginCustomer(customer);
                    Close();
                }
                else
                {
                    UserNameTextBox.Clear();
                    PasswordTextBox.Clear();
                    UserNameTLPanel.BackColor = Color.MistyRose;
                    PasswordTLPanel.BackColor = Color.MistyRose;
                    Message.InvalidCredentialsWarning();
                }
            }
        }
Exemplo n.º 24
0
        private async void LoginButton_Click(object sender, RoutedEventArgs e)
        {
            string username = UserNameTextBox.Text;
            string password = PasswordTextBox.Password;

            //username = "******";
            //password = "******";

            try
            {
                userList = EmployeeService.GetLoggedEmployeeByUserNamePassword(username, password);

                if (userList.Count() == 1)
                {
                    Session.LoggedEmployee = userList.SingleOrDefault();
                    Session.Account_Type   = userList.SingleOrDefault().ACCOUNT_TYPE;
                    Session.EmployeeID     = userList.SingleOrDefault().EMP_ID;

                    MainWindow.Instance.Show();
                    ShouldClose = true;
                    this.Close();
                }
                else
                {
                    await this.ShowMessageAsync("Login Error", "Please check your username and password", MessageDialogStyle.Affirmative);

                    UserNameTextBox.Clear();
                    PasswordTextBox.Clear();
                }
            }
            catch (Exception ex)
            {
                capturedException = ex;
            }
            if (capturedException != null)
            {
                await this.ShowMessageAsync("Login Error", capturedException.Message.ToString(), MessageDialogStyle.Affirmative);
            }
        }
Exemplo n.º 25
0
 private void Loginbtn_Click(object sender, EventArgs e)
 {
     if (UserNameTextBox.Text == "" || PasswordTextBox.Text == "")
     {
         MessageBox.Show("Username or password can not be empty");
     }
     else
     {
         UserService userService = new UserService();
         bool        result      = userService.LoginValidation(UserNameTextBox.Text, PasswordTextBox.Text);
         if (result)
         {
             Dashboard dashBoard = new Dashboard();
             dashBoard.Show();
             this.Hide();
         }
         else
         {
             MessageBox.Show("Invalid Username or password");
             UserNameTextBox.Clear();
             PasswordTextBox.Clear();
         }
     }
 }
Exemplo n.º 26
0
 private void LoginButton_Click(object sender, EventArgs e)
 {
     if (isValid())
     {
         bool IsUserNameCurrect, IsPasswordCurrect;
         GetIsUserLoginCurrect(out IsUserNameCurrect, out IsPasswordCurrect);
         if (IsUserNameCurrect && IsPasswordCurrect)
         {
             DashBoardForm dbf = new DashBoardForm();
             dbf.Show();
             this.Hide();
         }
         else
         {
             if (!IsUserNameCurrect)
             {
                 MessageBox.Show("UserName is Not Currect.", "Error",
                                 MessageBoxButtons.OK, MessageBoxIcon.Error);
                 UserNameTextBox.Clear();
                 PasswordTextBox.Clear();
                 UserNameTextBox.Focus();
             }
             else
             {
                 MessageBox.Show("Password is Not Currect.", "Error",
                                 MessageBoxButtons.OK, MessageBoxIcon.Error);
                 PasswordTextBox.Clear();
                 PasswordTextBox.Focus();
             }
         }
     }
     else
     {
         MessageBox.Show("Please Enter User Name And Password", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemplo n.º 27
0
 /// <summary>
 /// Clear all the textbox content
 /// </summary>
 public void ClearInformation()
 {
     UserNameTextBox.Clear();
     PasswordTextBox.Clear();
     IdentifyingCodeTextBox.Clear();
 }
Exemplo n.º 28
0
        void Login()
        {
            LoginWindow.Log.login = UserNameTextBox.Text;
            MainWindow fr1 = new MainWindow();
            UserWindow fr2 = new UserWindow();

            try
            {
                string        connetionString = null;
                SqlConnection cnn;
                connetionString = "Data Source=SLAVIK;Initial Catalog=hotel;Integrated Security=True;";
                cnn             = new SqlConnection(connetionString);
                if (UserNameTextBox.Text != string.Empty && PasswordPasswordBox.Password != string.Empty)
                {
                    if (Remember.IsChecked == true)
                    {
                        Remember        remember = new Remember();
                        List <Remember> rem      = App.db.Remember.Select(x => x).ToList();
                        App.db.Remember.RemoveRange(rem);
                        App.db.SaveChanges();
                        remember.Login    = UserNameTextBox.Text;
                        remember.Password = PasswordPasswordBox.Password;
                        LoginWindow.db.Remember.Add(remember);
                        LoginWindow.db.SaveChanges();
                    }
                    PasswordPasswordBox.Password = GetHashString(PasswordPasswordBox.Password);
                    string     cmd     = "SELECT COUNT(*) FROM Registration WHERE Login = @VALUE1 AND Password = @VALUE4";
                    SqlCommand Command = new SqlCommand(cmd, cnn);
                    Command.Parameters.AddWithValue("@VALUE1", UserNameTextBox.Text);
                    Command.Parameters.AddWithValue("@VALUE4", PasswordPasswordBox.Password);

                    Command.Connection.Open();
                    Command.ExecuteNonQuery();

                    int size = System.Convert.ToInt32(Command.ExecuteScalar());
                    if (size > 0)
                    {
                        if (UserNameTextBox.Text == "Slavik")
                        {
                            this.Hide();
                            fr1.ShowDialog();
                        }
                        else
                        {
                            this.Hide();
                            fr2.ShowDialog();
                        }
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Логин или пароль введены неверно!", "Error", MessageBoxButton.OK, MessageBoxImage.Warning);
                        UserNameTextBox.Clear();
                        PasswordPasswordBox.Clear();
                        UserNameTextBox.Background     = Brushes.LightCoral;
                        PasswordPasswordBox.Background = Brushes.LightCoral;
                    }
                    Command.Connection.Close();
                }
                else
                {
                    MessageBox.Show("Введите логин и пароль!", "Error", MessageBoxButton.OK, MessageBoxImage.Warning);
                    UserNameTextBox.Background     = Brushes.LightCoral;
                    PasswordPasswordBox.Background = Brushes.LightCoral;
                }
            }
            catch (SqlException sqlexcept)
            { MessageBox.Show(sqlexcept.Message); }
            catch (Exception except)
            { MessageBox.Show(except.Message); }
        }
Exemplo n.º 29
0
 public void ClearTextBoxes()
 {
     UserNameTextBox.Clear();
     PasswordTextBox.Clear();
     UserNameTextBox.Focus();
 }
Exemplo n.º 30
0
 private void CancelButton_Click(object sender, RoutedEventArgs e)
 {
     UserNameTextBox.Clear();
     PasswordTextBox.Clear();
 }