Example #1
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            string userName = txtUserName.Text;
            string password = txtPassword.Text;
            int    role;


            if (txtUserName.Text.Trim() == "" || txtPassword.Text.Trim() == "")
            {
                MessageBox.Show("Please enter username and password!");
            }
            mySet = new DataSet();
            myCon = new SqlConnection(@"Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=DBRemax;Integrated Security=True");
            myCon.Open();
            myCmd     = new SqlCommand("SELECT * FROM Users WHERE UserName = '******' AND Password = '******'", myCon);
            myAdapter = new SqlDataAdapter(myCmd);
            myAdapter.Fill(mySet, "Users");
            tabUsers = mySet.Tables["Users"];
            if (tabUsers.Rows.Count > 0)
            {
                MessageBox.Show("Welcome back " + userName + " !");

                this.Hide();
                frmManagement   fm   = new frmManagement();
                frmManageClient fmCl = new frmManageClient();
                foreach (DataRow myRow in tabUsers.Rows)
                {
                    fm.lblRoleId.Text = myRow["RoleId"].ToString();
                    fm.lblId.Text     = myRow["EmployeeId"].ToString();
                }
                role = Convert.ToInt32(tabUsers.Rows[0]["RoleId"]);

                switch (role)
                {
                case 0:
                    fm.Show();
                    fm.btnManageEmployees.Hide();
                    fm.lblRoleId.Text = role.ToString();
                    break;

                case 1:

                    fm.Show();
                    fm.lblRoleId.Text = role.ToString();
                    break;
                }
            }
            else
            {
                lblError.Text    = "Incorrect UserName or Password!";
                lblError.Visible = true;
            }
        }
Example #2
0
        private void btnManageClients_Click(object sender, EventArgs e)
        {
            frmManageClient fmCl = new frmManageClient();

            fmCl.lblUser.Text   = this.lblId.Text;
            fmCl.lblRoleId.Text = this.lblRoleId.Text;
            fmCl.Show();
            //this.Hide();
            //frmManageClient fmcl = new frmManageClient();
            //fmcl.MdiParent = this;
            //fmcl.Show();
        }