Ejemplo n.º 1
0
        private void ButtonLogin_Click(object sender, EventArgs e)
        {
            try
            {
                if (textBoxUserId.Text == "")
                {
                    MessageBox.Show("Please Enter User ID");
                }
                else if (textBoxPassword.Text == "")
                {
                    MessageBox.Show("Enter Password");
                }
                else
                {
                    string     sql = "select type from AllUser where userId = '" + this.textBoxUserId.Text + "' and password = '******';";
                    DataAccess da  = new DataAccess();
                    DataSet    ds  = da.ExecuteQuery(sql);

                    if (ds.Tables[0].Rows.Count == 1)
                    {
                        MessageBox.Show("Login approve for " + this.textBoxUserId.Text);
                        if (ds.Tables[0].Rows[0][0].ToString() == "student")
                        {
                            formStudent s = new formStudent(this.textBoxUserId.Text);
                            this.Hide();
                            s.Show();
                        }
                        else if (ds.Tables[0].Rows[0][0].ToString() == "teacher")
                        {
                            formTeachers t = new formTeachers(this.textBoxUserId.Text);
                            this.Hide();
                            t.Show();
                        }
                        else if (ds.Tables[0].Rows[0][0].ToString() == "admin")
                        {
                            formAdmin a = new formAdmin(this.textBoxUserId.Text);
                            this.Hide();
                            a.Show();
                        }
                        else
                        {
                            MessageBox.Show("not done");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Login invlalid");
                    }
                }
            }
            catch (Exception ea)
            {
                MessageBox.Show(ea.Message);
            }
        }
Ejemplo n.º 2
0
        private void adminToolStripMenuItem_Click(object sender, EventArgs e)
        {
            formAdmin f = new formAdmin();

            f.ShowDialog();
        }