Exemplo n.º 1
0
        /// <summary>
        /// Handles the Click event of the btnLogin control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtUserId.Text.Trim()) |
                (_user == null) |
                string.IsNullOrEmpty(txtPassword.Text.Trim())) return;

            string usr = txtUserId.Text.Trim();

            string pwd =
                UserCryptoService.Encrypt(usr, txtPassword.Text.Trim());

            using (var db = new UserBase())
            {
                if (!db.AuthenticateUser(usr, pwd))
                {
                    MessageBox.Show(@"Access Denied!", @"Warning!",
                                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }

            DialogResult = DialogResult.OK;
            Close();
        }