Пример #1
0
        private void ChangePasswordToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var IsOpen = false;

            foreach (Form f in Application.OpenForms)
            {
                if (f.Text == "Change Password")
                {
                    IsOpen = true;
                    f.Focus();
                    break;
                }
            }

            if (IsOpen == false)
            {
                var changePassword = new FrmChangePassword();
                changePassword.MdiParent = this;
                changePassword.Show();
            }
        }
Пример #2
0
        ///<summary>
        ///This method is tagged to the login button click event; user credential validation is done.
        ///</summary>
        /// <returns></returns>
        ///
        private void BtnLogin_Click(object sender, EventArgs e)
        {
            var users = GetUsers();

            string password = EncryptionLibrary.EncryptText(txtPassword.Text.Trim(), txtUsername.Text.Trim());

            var user = users.Find(u => u.UserName == txtUsername.Text.Trim() && u.UserPassword == password);

            if (user != null)
            {
                GlobalAccess.GbEmpId               = user.EmpId;
                GlobalAccess.GbCurrentUser         = user.UserName;
                GlobalAccess.GbCurrentUserPassword = txtPassword.Text.Trim();
                GlobalAccess.GbIsUserAdmin         = user.IsAdmin;

                if (user.IsDisabled)
                {
                    lblSystemMessage.ForeColor = Color.Red;
                    lblSystemMessage.Text      = @"Your account is disabled";
                }
                else if (user.MustChangePassword)
                {
                    var frmChangePassword = new FrmChangePassword();
                    frmChangePassword.Show(this);
                    txtPassword.Text = string.Empty;
                }
                else
                {
                    var frmMain = new FrmMain();
                    frmMain.Show();
                    Hide();
                }
            }
            else
            {
                lblSystemMessage.ForeColor = Color.Red;
                lblSystemMessage.Text      = @"Wrong Username and Password Entered";
            }
        }