private void ResetFormControl()
        {
            NewPasswordTextBox.Clear();
            OldPasswordTextBox.Clear();
            ConfirmPasswordTextBox.Clear();

            OldPasswordTextBox.Focus();
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 修改密码
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ChangePasswordQQButton_Click(object sender, EventArgs e)
 {
     if (FormBasicFeatrues.GetInstence().GetMd5Hash(MD5.Create(), OldPasswordTextBox.Text).Equals(MainWindow.PASSWORD_HASH))
     {
         if (NewPasswordTextBox.Text.Equals(NewPasswordTextBox2.Text))
         {
             try
             {
                 if (DatabaseConnections.Connector.OnlineUpdateData(
                         "users",
                         new string[] { "password" },
                         new string[] { FormBasicFeatrues.GetInstence().GetMd5Hash(MD5.Create(), NewPasswordTextBox.Text) },
                         MainWindow.ID) > 0)
                 {
                     OldPasswordTextBox.Clear();
                     NewPasswordTextBox.Clear();
                     NewPasswordTextBox2.Clear();
                     MessageBox.Show("修改密码成功!下次登录时候您将需要使用新密码!", "成功");
                     //MainWindow.PASSWORD_HASH = FormBasicFeatrues.GetInstence().GetMd5Hash(MD5.Create(), NewPasswordTextBox.Text);
                     ChangePasswordCheckBox.Checked = false;
                     isChangedPassword = true;
                 }
             }
             catch (Exception ee)
             {
                 MessageBox.Show(ee.Message, "密码修改错误");
                 //throw;
             }
         }
         else
         {
             MessageBox.Show("两次密码不同!", "错误");
             NewPasswordTextBox.Clear();
             NewPasswordTextBox2.Clear();
         }
     }
     else
     {
         MessageBox.Show("旧密码输入错误!", "错误");
         OldPasswordTextBox.Clear();
         NewPasswordTextBox.Clear();
         NewPasswordTextBox2.Clear();
     }
 }
        private void SaveButton_Click(object sender, EventArgs e)
        {
            if (!UsernameTextBox.Text.Trim().Equals(string.Empty) && !OldPasswordTextBox.Text.Trim().Equals(string.Empty) && !NewPasswordTextBox.Text.Trim().Equals(string.Empty) && !RepeatPasswordTextBox.Text.Trim().Equals(string.Empty))
            {
                userData = XmlDataManager.XmlUserDataReader("userdata.xml");
                string unchangeUsername = userData.Username; // old Username
                string UserAttribut     = userData.UserAttribut;

                userData1 = XmlDataManager.XmlUserDataReader("XMLSystemAdmin.xml");
                string UserAttribut1 = userData1.UserAttribut;

                if (!(UserAttribut.Equals("SuperAdmin")))
                {
                    // return the UserId from the database
                    int UserId = databaseManager.ReturnUserID(unchangeUsername, OldPasswordTextBox.Text);

                    string newUsername    = UsernameTextBox.Text;       // new Username
                    string oldPassword    = OldPasswordTextBox.Text;    // old Password
                    string newPassword    = NewPasswordTextBox.Text;    // new Password
                    string repeatPassword = RepeatPasswordTextBox.Text; // new Password

                    //Edit the UserData as simple user.
                    databaseManager.EditAccountUser(UserId, newUsername, oldPassword, newPassword, repeatPassword);
                    UsernameTextBox.Clear();
                    OldPasswordTextBox.Clear();
                    NewPasswordTextBox.Clear();
                    RepeatPasswordTextBox.Clear();

                    AdminUI adminUI = new AdminUI(Online_User);
                    this.Close();
                    adminUI.Show();
                }
                else
                {
                    string AdminPassword = userData1.Password;
                    if ((OldPasswordTextBox.Text).Equals(AdminPassword))
                    {
                        if (File.Exists("XMLSystemAdmin.xml"))
                        {
                            userData.Username     = UsernameTextBox.Text.Trim();
                            userData.Password     = NewPasswordTextBox.Text.Trim();
                            userData.UserAttribut = UserAttribut;
                            XmlDataManager.XmlDataWriter(userData, "XMLSystemAdmin.xml");
                            MessageBox.Show("SuperAdmin Data changed successful");

                            AdminUI adminUI = new AdminUI(Online_User);
                            this.Close();
                            adminUI.Show();
                        }
                        else
                        {
                            MessageBox.Show("XMLSystemAdmin.xml File not found!");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Wrong Password. Please give a correct password!");
                    }
                }
            }
            else
            {
                MessageBox.Show("Fill all Fields");
            }
        }
Ejemplo n.º 4
0
        private void ForgotPassword4NextButton_Click(object sender, RoutedEventArgs e)
        {
            LoginPage LP = new LoginPage();

            OldPasswordTextBox.Password = LP.GetSha512FromString(OldPasswordTextBox.Password);
            NewPasswordTextBox.Password = LP.GetSha512FromString(NewPasswordTextBox.Password);

            string selected_ForgotPasswordEmail = (App.Current as App).ForgotPasswordEmail;

            try
            {
                ConnectionStringSettings conSettings = ConfigurationManager.ConnectionStrings["connString"];
                string connectionString = conSettings.ConnectionString;

                con = new SqlConnection(connectionString);
                con.Open();
                cmd    = new SqlCommand("select * from [dbo].[test] where Password = '******' and Email = '" + selected_ForgotPasswordEmail + "'", con);
                reader = cmd.ExecuteReader();

                int count = 0;
                while (reader.Read())
                {
                    count += 1;
                }
                if (count == 1)
                {
                    try
                    {
                        ConnectionStringSettings conSettings1 = ConfigurationManager.ConnectionStrings["connString"];
                        string connectionString1 = conSettings1.ConnectionString;

                        con = new SqlConnection(connectionString1);
                        con.Open();
                        cmd = new SqlCommand("UPDATE [dbo].[test] SET Password = '******' WHERE Email = '" + selected_ForgotPasswordEmail + "'", con);
                        cmd.ExecuteNonQuery();
                    }
                    catch (Exception ex)
                    {
                        System.Windows.MessageBox.Show(ex.Message);
                    }
                    finally
                    {
                        con.Close();
                    }

                    MessageBox.Show("You have changed your password.");
                    OldPasswordTextBox.Clear();
                    NewPasswordTextBox.Clear();
                    this.NavigationService.Navigate(new Uri(@"LoginPage.xaml", UriKind.RelativeOrAbsolute));
                }
                else
                {
                    MessageBox.Show("Incorrect old password.");
                }
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show(ex.Message);
            }
            finally
            {
                con.Close();
            }

            OldPasswordTextBox.Clear();
            NewPasswordTextBox.Clear();
        }