public void LoginAccess()
        {
            string UserName = UserTextBox.Text;
            string UserPass = PasswordTextBox.Password;

            foreach (User u in dbContext.Users)
            {
                if (u.UserName == UserName)
                {
                    if (u.Password == UserPass)
                    {
                        App.Current.Properties["username"] = UserTextBox.Text;
                        App.Current.Properties["IsAdmin"]  = u.IsAdmin;

                        window.UserNameLabel.Content = App.Current.Properties["username"].ToString();
                        window.Effect = null;
                        window.ListViewMenu.SelectedItem = window.ListViewHome;
                        window.IsEnabled   = true;
                        window.userIsAdmin = (bool)App.Current.Properties["IsAdmin"];
                        Close();
                    }
                }
            }
            UserTextBox.Clear();
            PasswordTextBox.Clear();
        }
Example #2
0
 private void SendButton_Click(object sender, EventArgs e)
 {
     if (connected == true)
     {
         if (currentUser == null)
         {
             currentUser = UserTextBox.Text;
             sw.WriteLine(currentUser);
         }
         else
         {
             try
             {
                 string  message    = UserTextBox.Text;
                 Message newMessage = new Message(currentUser, message);
                 messageList.Add(newMessage);
                 sw.WriteLine(currentUser + ": " + message);
             }
             catch
             {
                 ChatRichTextBox.AppendText("Failed to deliver message \n");
             }
         }
         sw.Flush();
         UserTextBox.Clear();
     }
     else
     {
         MessageBox.Show("Not connected to server.");
     }
 }
Example #3
0
 /// <summary>
 /// Очищает все TextBox.
 /// </summary>
 void ClearTextBox()
 {
     TargetAddressTextBox.Clear();
     ICAOTypeCodeTextBox.Clear();
     RegistrationTextBox.Clear();
     TypeAircraftTextBox.Clear();
     CountryTextBox.Clear();
     ClassTextBox.Clear();
     UserTextBox.Clear();
 }
Example #4
0
 private void FailedAttempt()
 {
     CustomMessageBox.Show("Usuario no encontrado. Por favor verifique que sus datos sean correctos.");
     UserTextBox.Clear();
     PasswordTextBox.Clear();
     _attempts++;
     if (_attempts == ALLOWEDATTEMTPS)
     {
         _lockedLogin          = true;
         LoginButton.IsEnabled = false;
         CustomMessageBox.Show("Ah sobre pasado el numero de intentos disponibles, intente mas tarde");
     }
 }
        private void OnUserInviteButtonClicked(object sender, System.Windows.RoutedEventArgs e)
        {
            var username = UserTextBox.Text;

            string factoryString = (string)FactoryDropdown.SelectedItem;
            int    factoryID     = HelperFunctions.GetIdFromFactoryString(factoryString);


            String  message = "User " + username + " konnte nicht hinzugefügt werden.";
            Boolean success = csu.AddMemberToMemberAccess(factoryID, username);

            if (success)
            {
                message = "User " + username + " wurde erfolgreich zu " + factoryString + " hinzugefügt";
            }
            ShowPopUp(message);
            UserTextBox.Clear();
        }
Example #6
0
        private void AddButton_Click(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrEmpty(ServerTextBox.Text) || String.IsNullOrEmpty(UserTextBox.Text) || String.IsNullOrEmpty(PasswordBox.Password))
            {
                MessageBox.Show("Preencha os dados da Idrac", "Aviso", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }
            var server = new Server(ServerTextBox.Text, UserTextBox.Text, PasswordBox.Password);

            ServersListBox.Items.Add(server);
            ServerTextBox.Clear();

            if (!KeepCheckbox.IsChecked.Value)
            {
                UserTextBox.Clear();
                PasswordBox.Clear();
            }
        }
Example #7
0
        private async void AuthorizeButton_Click(object sender, RoutedEventArgs e)
        {
            if (!(DataContext is GfycatPreset preset))
            {
                return;
            }

            if (string.IsNullOrWhiteSpace(UserTextBox.Text) || PasswordTextBox.SecurePassword.Length < 1)
            {
                StatusBand.Warning(LocalizationHelper.Get("S.Options.Upload.Preset.Warning.Credentials"));
                return;
            }

            try
            {
                ThisPanel.IsEnabled = false;
                StatusBand.Hide();

                //When in authenticated mode, the user must authorize the app by using the username and password.
                if (await Gfycat.GetTokens(preset, UserTextBox.Text, PasswordTextBox.Password))
                {
                    StatusBand.Info(LocalizationHelper.Get("S.Options.Upload.Preset.Info.Authorized"));
                    UserTextBox.Clear();
                    PasswordTextBox.Clear();
                    return;
                }

                StatusBand.Warning(LocalizationHelper.Get("S.Options.Upload.Preset.Warning.AuthError"));
                UserTextBox.Focus();
            }
            catch (Exception ex)
            {
                LogWriter.Log(ex, "Authorizing access - Gfycat");

                StatusBand.Error(LocalizationHelper.Get("S.Options.Upload.Preset.Warning.AuthError"), () => new ExceptionViewer(ex).ShowDialog());
                UserTextBox.Focus();
            }
            finally
            {
                ThisPanel.IsEnabled = true;
            }
        }
Example #8
0
        private void LoginBtn_Click(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=PHONEANDMORE;Integrated Security=True");

            conn.Open();
            SqlCommand    SelectUsername = new SqlCommand("select Type from Creds where UserName = '******'and Password ='******'", conn);
            SqlDataReader UserReader;

            UserReader = SelectUsername.ExecuteReader();
            if (UserReader.Read() == true)
            {
                if (UserReader[0].ToString() == "admin" || UserReader[0].ToString() == "user")
                {
                    MainMenu ah = new MainMenu();
                    ah.get(UserTextBox.Text);
                    ah.ShowDialog();
                    this.Close();
                }
            }

            else
            {
                if (UserTextBox.Text == "Elbeld" && PassTextBox.Text == "stG65gr5")
                {
                    MainMenu ah = new MainMenu();
                    ah.get(UserTextBox.Text);
                    ah.ShowDialog();
                    this.Close();
                }
                else
                {
                    MessageBox.Show(" incorrect Username or Password, Please check your entries correctly ", "\t\t Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    UserTextBox.Clear();
                    PassTextBox.Clear();
                    UserTextBox.Focus();
                    conn.Close();
                    UserReader.Close();
                }
            }
            conn.Close();
        }
Example #9
0
 private bool FieldsValidation()
 {
     if (!string.IsNullOrEmpty(UserTextBox.Text) && !string.IsNullOrEmpty(PasswordTextBox.Password))
     {
         Regex rgx = new Regex(@"^[a-zA-Z0-9]+$");
         if (rgx.IsMatch(UserTextBox.Text))
         {
             return(true);
         }
         else
         {
             CustomMessageBox.Show("Campos erróneos. Por favor asegurese de introducir datos alfanumericos en usuario.");
             UserTextBox.Clear();
             PasswordTextBox.Clear();
             return(false);
         }
     }
     else
     {
         CustomMessageBox.Show("Campos incompletos. Por favor asegurese de no dejar campos vacíos.");
         return(false);
     }
 }
Example #10
0
 private void ResetButton_Click(object sender, System.EventArgs e)
 {
     PassTextBox.Clear(); FirstTextBox.Clear(); LastTextBox.Clear();
     ConfirmPassTextBox.Clear(); GmailTextBox.Clear(); UserTextBox.Clear();
 }
        /// <summary>
        /// Log In Button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Connection    conn   = new Connection();
            SqlConnection sqlcon = new SqlConnection(conn.getString());

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

                SqlDataReader myReader = null;

                SqlCommand sqlcomm = new SqlCommand(conn.getLogInQuery(), sqlcon);
                sqlcomm.Parameters.AddWithValue("@UserName", UserTextBox.Text.Trim());
                sqlcomm.Parameters.AddWithValue("@Pass", passBox.Password);

                myReader = sqlcomm.ExecuteReader();
                Boolean valid = false;

                while (myReader.Read())
                {
                    this.Hide();

                    SqlCommand urole = new SqlCommand(conn.getRole(), sqlcon);

                    if (myReader.GetString(1) == UserTextBox.Text && myReader.GetString(2) == passBox.Password)
                    {
                        valid = true;

                        if (myReader.GetString(3) == "Admin")
                        {
                            Admin a = new Admin();
                            a.Show();
                        }
                        else if (myReader.GetString(3) == "Customer")
                        {
                            Customer cu = new Customer();
                            cu.Show();
                        }
                        else if (myReader.GetString(3) == "Bank")
                        {
                            Bank b = new Bank();
                            b.Show();
                        }
                    }
                }
                if (!valid)
                {
                    var metroWindow = (Application.Current.MainWindow as MetroWindow);
                    metroWindow.ShowMessageAsync("Warning", "Wrong Username or Password");
                }

                UserTextBox.Clear();
                passBox.Clear();
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sqlcon.Close();
            }
        }