private void btnOk_Click(object sender, EventArgs e)
 {
     if ((txtUserName.Text.Trim() != "") && (txtPassword.Text.Trim() != ""))
     {
         if (UserBO.AuthenticateUser(txtUserName.Text, txtPassword.Text))//checking the password and user anme
         {
             this.DialogResult = DialogResult.OK;
         }
         else
         {
             MessageBox.Show("Please Enter the correct password");
         }
     }
 }
Ejemplo n.º 2
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            UserBO objUserBO = new UserBO();

            if (txtUserName.Text.Trim() != "" && txtPassword.Text.Trim() != "")
            {
                //Checking the Admin and username
                string adminUserName = System.Configuration.ConfigurationManager.AppSettings["AdminUserName"];
                string adminPassword = System.Configuration.ConfigurationManager.AppSettings["AdminPassword"];

                if (txtUserName.Text.ToLower() == adminUserName.ToLower() && txtPassword.Text.Trim() == adminPassword)
                {
                    Helper.Role       = "Admin";
                    Helper.UserId     = -1;
                    this.DialogResult = DialogResult.OK;
                }
                else
                {
                    int pkuserid = objUserBO.AuthenticateUser(txtUserName.Text.Trim(), txtPassword.Text.Trim());
                    if (pkuserid != 0)
                    {
                        Helper.Role       = "user";
                        Helper.UserId     = pkuserid;
                        this.DialogResult = DialogResult.OK;
                    }
                    else
                    {
                        MessageBox.Show("Please provide the valid credentials");
                    }
                }
            }
            else
            {
                MessageBox.Show("Please provide username and password");
            }
        }