Example #1
0
        private void btnChange_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtOldPassword.Text.Trim()))
            {
                CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("PleaseInputOldPassword"),
                                                                 Common.clsLanguages.GetResource("Information"),
                                                                 Common.Config.CUSTOM_MESSAGEBOX_ICON.Information,
                                                                 Common.Config.CUSTOM_MESSAGEBOX_BUTTON.OK);
                txtOldPassword.Focus();
                return;
            }

            if (string.IsNullOrEmpty(txtNewPassword.Text.Trim()))
            {
                CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("PleaseInputNewPassword"),
                                                                 Common.clsLanguages.GetResource("Information"),
                                                                 Common.Config.CUSTOM_MESSAGEBOX_ICON.Information,
                                                                 Common.Config.CUSTOM_MESSAGEBOX_BUTTON.OK);
                txtNewPassword.Focus();
                return;
            }

            if (string.IsNullOrEmpty(txtConfirmPassword.Text.Trim()))
            {
                CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("PleaseRequireNewPassword"),
                                                                 Common.clsLanguages.GetResource("Information"),
                                                                 Common.Config.CUSTOM_MESSAGEBOX_ICON.Information,
                                                                 Common.Config.CUSTOM_MESSAGEBOX_BUTTON.OK);
                txtConfirmPassword.Focus();
                return;
            }
            if (!Program.ConvertStringToMD5(txtOldPassword.Text.Trim()).Equals(Program.Password))
            {
                CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("PasswordIncorrect"),
                                                                 Common.clsLanguages.GetResource("Information"),
                                                                 Common.Config.CUSTOM_MESSAGEBOX_ICON.Information,
                                                                 Common.Config.CUSTOM_MESSAGEBOX_BUTTON.OK);
                txtConfirmPassword.Focus();
                return;
            }
            if (!txtNewPassword.Text.Trim().Equals(txtConfirmPassword.Text.Trim()))
            {
                CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("RePasswordNotMacth"),
                                                                 Common.clsLanguages.GetResource("Information"),
                                                                 Common.Config.CUSTOM_MESSAGEBOX_ICON.Information,
                                                                 Common.Config.CUSTOM_MESSAGEBOX_BUTTON.OK);
                txtConfirmPassword.Focus();
                return;
            }

            try
            {
                UsersBLL userBLL = new UsersBLL();
                Users    user    = new Users();
                user.UserId = Program.Username;
                user.Pwd    = Program.ConvertStringToMD5(txtNewPassword.Text.Trim());
                userBLL.ChangePassword(user);
                CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("ChangePasswordSuccess"),
                                                                 Common.clsLanguages.GetResource("Information"),
                                                                 Common.Config.CUSTOM_MESSAGEBOX_ICON.Information,
                                                                 Common.Config.CUSTOM_MESSAGEBOX_BUTTON.OK);
                frmLogin frm = (frmLogin)Application.OpenForms["frmLogin"];
                frm.SetUIChanges();
                frm.Show();
                Application.OpenForms["MainForm"].Close();
                this.Close();
            }
            catch (Exception)
            {
                CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("ChangePasswordError"),
                                                                 Common.clsLanguages.GetResource("Error"),
                                                                 Common.Config.CUSTOM_MESSAGEBOX_ICON.Error,
                                                                 Common.Config.CUSTOM_MESSAGEBOX_BUTTON.OK);
                return;
            }
        }