コード例 #1
0
        private void SetPassword(Object Sender, EventArgs e)
        {
            string username = GetSelectedDetailRow().UserId;

            // only request the password once, since this is the sysadmin changing it.
            // see http://bazaar.launchpad.net/~openpetracore/openpetraorg/trunkhosted/view/head:/csharp/ICT/Petra/Client/MSysMan/Gui/SysManMain.cs
            // for the change password dialog for the normal user
            PetraInputBox input = new PetraInputBox(
                Catalog.GetString("Change the password"),
                String.Format(Catalog.GetString("Please enter the new password for user {0}:"), username),
                "", true);

            if (input.ShowDialog() == DialogResult.OK)
            {
                string password = input.GetAnswer();
                TVerificationResult VerificationResult;

                if (TSharedSysManValidation.CheckPasswordQuality(password, out VerificationResult))
                {
                    if (TRemote.MSysMan.Maintenance.WebConnectors.SetUserPassword(username, password, true, true))
                    {
                        MessageBox.Show(String.Format(Catalog.GetString("Password was successfully set for user {0}"), username));

                        // this has already been saved on during the server call to change the password
                        GetSelectedDetailRow().Retired = false;
                    }
                    else
                    {
                        MessageBox.Show(String.Format(Catalog.GetString("There was a problem setting the password for user {0}"), username));
                    }
                }
                else
                {
                    MessageBox.Show(String.Format(Catalog.GetString(
                                "There was a problem setting the password for user {0}."), username) +
                        Environment.NewLine + VerificationResult.ResultText);
                }
            }
        }
コード例 #2
0
        private void OnBtnRcptNumber(Object sender, EventArgs e)
        {
            Boolean IntFormatIsOk = false;
            Int32 ReceiptNum;
            Int32 NewReceiptNum = 0;

            do
            {
                ReceiptNum = TRemote.MFinance.Gift.WebConnectors.GetLastReceiptNumber(FLedgerNumber);
                String ReceiptNumString = (ReceiptNum + 1).ToString();
                PetraInputBox input = new PetraInputBox(
                    Catalog.GetString("Receipt Numbers"),
                    Catalog.GetString("The next Gift Receipt will have this number:"),
                    ReceiptNumString, false);
                input.ShowDialog();

                if (input.DialogResult == System.Windows.Forms.DialogResult.Cancel)
                {
                    return;
                }

                ReceiptNumString = input.GetAnswer();
                try
                {
                    NewReceiptNum = Convert.ToInt32(ReceiptNumString) - 1;
                    IntFormatIsOk = true;
                }
                catch (FormatException)
                {
                    MessageBox.Show(
                        Catalog.GetString("Please enter an integer."),
                        Catalog.GetString("Format Problem")
                        );
                }
            } while (!IntFormatIsOk);

            if (NewReceiptNum < ReceiptNum)
            {
                MessageBox.Show(
                    Catalog.GetString("WARNING - new Receipt Number is less than previous number.\r\nDuplicate Receipt Numbers might be printed."),
                    Catalog.GetString("Receipt Numbers"),
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning
                    );
            }

            TRemote.MFinance.Gift.WebConnectors.SetLastReceiptNumber(FLedgerNumber, NewReceiptNum);
        }
コード例 #3
0
ファイル: SysManMain.cs プロジェクト: js1987/openpetragit
        /// <summary>
        /// change the password of the current user
        /// </summary>
        public static void SetUserPassword(Form AParentForm)
        {
            string username = Ict.Petra.Shared.UserInfo.GUserInfo.UserID;

            // TODO: use old password as well, to make sure the password is changed by its owner
            PetraInputBox input = new PetraInputBox(
                Catalog.GetString("Change your password"),
                Catalog.GetString("Please enter the old password:"******"", true);

            if (input.ShowDialog() == DialogResult.OK)
            {
                TLoginForm.CreateNewPassword(username, input.GetAnswer(), false);
            }
        }
コード例 #4
0
ファイル: LoginDialog.cs プロジェクト: js1987/openpetragit
        /// <summary>
        /// create a new password for the current user
        /// </summary>
        public static bool CreateNewPassword(string AUserName, string AOldPassword, bool APasswordNeedsChanged)
        {
            // repeat if an invalid password is entered
            while (true)
            {
                PetraInputBox input = new PetraInputBox(
                    Catalog.GetString("Change your password"),
                    Catalog.GetString("Please enter the new password:"******"", true);

                if (input.ShowDialog() == DialogResult.OK)
                {
                    string password = input.GetAnswer();

                    TVerificationResultCollection VerificationResultCollection;
                    TVerificationResult VerificationResult;

                    if (password == AOldPassword)
                    {
                        MessageBox.Show(String.Format(Catalog.GetString(
                                    "Password not changed as the old password was entered. Please enter a new password."), AUserName));
                    }
                    else if (TSharedSysManValidation.CheckPasswordQuality(password, out VerificationResult))
                    {
                        // if first password is valid then ask user to enter it again
                        input = new PetraInputBox(
                            Catalog.GetString("Change your password"),
                            Catalog.GetString("Please enter the new password once more:"),
                            "", true);

                        if (input.ShowDialog() == DialogResult.OK)
                        {
                            // if both passwords are the same then save
                            if (password == input.GetAnswer())
                            {
                                if (TRemote.MSysMan.Maintenance.WebConnectors.SetUserPassword(AUserName, password, AOldPassword,
                                        APasswordNeedsChanged,
                                        out VerificationResultCollection))
                                {
                                    MessageBox.Show(String.Format(Catalog.GetString("Password was successfully set for user {0}"), AUserName));
                                    return true;
                                }
                                else
                                {
                                    MessageBox.Show(String.Format(Catalog.GetString(
                                                "There was a problem setting the password for user {0}."), AUserName) +
                                        Environment.NewLine + VerificationResultCollection.BuildVerificationResultString());
                                    break;
                                }
                            }
                            else
                            {
                                MessageBox.Show("Passwords do not match! Please try again...");
                            }
                        }
                        else
                        {
                            break;
                        }
                    }
                    else
                    {
                        MessageBox.Show(String.Format(Catalog.GetString(
                                    "There was a problem setting the password for user {0}."), AUserName) +
                            Environment.NewLine + VerificationResult.ResultText);
                    }
                }
                else
                {
                    break;
                }
            }

            return false;
        }
コード例 #5
0
        /// <summary>
        /// create a new password for the current user
        /// </summary>
        public static bool CreateNewPassword(string AUserName, string AOldPassword, bool APasswordNeedsChanged)
        {
            // repeat if an invalid password is entered
            while (true)
            {
                PetraInputBox input = new PetraInputBox(
                    Catalog.GetString("Change your password"),
                    Catalog.GetString("Please enter the new password:"******"", true);

                if (input.ShowDialog() == DialogResult.OK)
                {
                    string password = input.GetAnswer();

                    TVerificationResultCollection VerificationResultCollection;
                    TVerificationResult           VerificationResult;

                    if (password == AOldPassword)
                    {
                        MessageBox.Show(String.Format(Catalog.GetString(
                                                          "Password not changed as the old password was entered. Please enter a new password."), AUserName));
                    }
                    else if (TSharedSysManValidation.CheckPasswordQuality(password, out VerificationResult))
                    {
                        // if first password is valid then ask user to enter it again
                        input = new PetraInputBox(
                            Catalog.GetString("Change your password"),
                            Catalog.GetString("Please enter the new password once more:"),
                            "", true);

                        if (input.ShowDialog() == DialogResult.OK)
                        {
                            // if both passwords are the same then save
                            if (password == input.GetAnswer())
                            {
                                if (TRemote.MSysMan.Maintenance.WebConnectors.SetUserPassword(AUserName, password, AOldPassword,
                                                                                              APasswordNeedsChanged,
                                                                                              out VerificationResultCollection))
                                {
                                    MessageBox.Show(String.Format(Catalog.GetString("Password was successfully set for user {0}"), AUserName));
                                    return(true);
                                }
                                else
                                {
                                    MessageBox.Show(String.Format(Catalog.GetString(
                                                                      "There was a problem setting the password for user {0}."), AUserName) +
                                                    Environment.NewLine + VerificationResultCollection.BuildVerificationResultString());
                                    break;
                                }
                            }
                            else
                            {
                                MessageBox.Show("Passwords do not match! Please try again...");
                            }
                        }
                        else
                        {
                            break;
                        }
                    }
                    else
                    {
                        MessageBox.Show(String.Format(Catalog.GetString(
                                                          "There was a problem setting the password for user {0}."), AUserName) +
                                        Environment.NewLine + VerificationResult.ResultText);
                    }
                }
                else
                {
                    break;
                }
            }

            return(false);
        }