Esempio n. 1
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (ValidateInputs())
            {
                BusinessRules objBusinessRules = new BusinessRules();
                using (DataTable dt = objBusinessRules.AuthenticateUser(txtUserName.Text.Trim(), txtPassword.Text.Trim()))
                {
                    if (!string.IsNullOrEmpty(dt.Rows[0]["User_Name"].ToString()))
                    {
                        panelLogin.Visible = false;
                        menuStrip.Enabled  = toolStrip.Enabled = true;

                        User.Instance.User_Name  = txtUserName.Text.Trim();
                        User.Instance.First_Name = Convert.ToString(dt.Rows[0]["First_Name"]);
                        User.Instance.Last_Name  = Convert.ToString(dt.Rows[0]["Last_Name"]);
                        User.Instance.Password   = Convert.ToString(dt.Rows[0]["Password"]);
                        User.Instance.IsAdmin    = Convert.ToBoolean(dt.Rows[0]["IsAdmin"]);

                        userManagementToolStripMenuItem.Visible = deleteAllDataToolStripMenuItem.Visible = User.Instance.IsAdmin;
                        //userManagementToolStripMenuItem.Visible = User.Instance.IsAdmin;

                        this.Text = "Lakshya - Yatra ==== (Logged in User : "******" " + User.Instance.Last_Name + ")";
                    }
                    else
                    {
                        MessageBox.Show("Invalid User Name/Password combination", "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }