Exemple #1
0
        //page navigation start

        private void adminPanelToolStripMenuItem_Click_1(object sender, EventArgs e)
        {
            adPanel ad = new adPanel();

            ad.Show();
            this.Hide();
        }
Exemple #2
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            string id = txtId.Text;

            if (string.IsNullOrEmpty(id))
            {
                MessageBox.Show("ID required");
                txtId.Focus();
                return;
            }

            string password = txtPass.Text;

            if (string.IsNullOrEmpty(password))
            {
                MessageBox.Show("Password required");
                txtPass.Focus();
                return;
            }

            if (password.Length < 8)
            {
                MessageBox.Show("minimum 8 character required");
                txtPass.Focus();
                return;
            }


            string query = "select * from Users where id = '" + txtId.Text + "' and pass='******'";

            DataTable dt = DataAccess.GetData(query);

            if (dt == null)
            {
                return;
            }

            if (dt.Rows.Count != 1)
            {
                MessageBox.Show("Invalid Username Or Password");
                return;
            }

            string uType = dt.Rows[0]["uType"].ToString();

            if (uType == "admin")
            {
                adPanel ad = new adPanel(txtId.Text);
                User.userId = txtId.Text;

                query = "select * from Users where id=" + txtId.Text + "";

                dt = DataAccess.GetData(query);

                User.userName = dt.Rows[0]["name"].ToString();

                ad.Show();
                this.Hide();
            }

            else if (uType == "teacher")
            {
                t_DashBoard tDash = new t_DashBoard(txtId.Text);
                User.userId = txtId.Text;

                query = "select Users.id,[name],pass,dob,[address],teacherNum,teacherEmail,salary.salary,allowance "
                        + "from salary,Users where Users.id=" + txtId.Text + " and salary.s_id= Users.id";

                dt = DataAccess.GetData(query);

                User.userName    = dt.Rows[0]["name"].ToString();
                User.u_pass      = dt.Rows[0]["pass"].ToString();
                User.u_dob       = dt.Rows[0]["dob"].ToString();
                User.u_address   = dt.Rows[0]["address"].ToString();
                User.t_Num       = dt.Rows[0]["teacherNum"].ToString();
                User.t_Email     = dt.Rows[0]["teacherEmail"].ToString();
                User.t_salary    = dt.Rows[0]["salary"].ToString();
                User.t_allowance = dt.Rows[0]["allowance"].ToString();


                tDash.Show();
                this.Hide();
            }
            else if (uType == "student")
            {
            }

            else
            {
                MessageBox.Show("Invalid Users!!");
                return;
            }
        }