コード例 #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            this.Hide();
            TAForm tform = new TAForm();

            tform.ShowDialog();
            this.Close();
        }
コード例 #2
0
        private void signInBtn_Click(object sender, EventArgs e)
        {
            // requirement 2

            OracleCommand cmd1 = new OracleCommand();

            cmd1.Connection  = conn;
            cmd1.CommandText = "select username, password from user_info where username = :usrnm and password = :pswrd";
            cmd1.CommandType = CommandType.Text;
            cmd1.Parameters.Add("usrnm", textBox2.Text);
            cmd1.Parameters.Add("pswrd", textBox3.Text);
            OracleDataReader dr1 = cmd1.ExecuteReader();
            int flag             = 0;

            if (dr1.Read())
            {
                flag = 1;
            }
            else
            {
                MessageBox.Show("username or password is incorrect!");
            }
            dr1.Close();
            if (flag == 1)
            {
                if (comboBox1.SelectedIndex == 0)
                {
                    OracleCommand cmd = new OracleCommand();
                    cmd.Connection  = conn;
                    cmd.CommandText = "select stud_id, stud_name from student where username = :usrnm";
                    cmd.CommandType = CommandType.Text;
                    cmd.Parameters.Add("usrnm", textBox2.Text);
                    OracleDataReader dr = cmd.ExecuteReader();
                    while (dr.Read())
                    {
                        id   = dr[0].ToString();
                        name = dr[1].ToString();
                    }
                    dr.Close();

                    this.Hide();
                    StudentForm studForm = new StudentForm();
                    studForm.ShowDialog();
                    this.Close();
                }
                else if (comboBox1.SelectedIndex == 1)
                {
                    OracleCommand cmd = new OracleCommand();
                    cmd.Connection  = conn;
                    cmd.CommandText = "select lec_id, lec_name from lecturer where username = :usrnm";
                    cmd.CommandType = CommandType.Text;
                    cmd.Parameters.Add("usrnm", textBox2.Text);
                    OracleDataReader dr = cmd.ExecuteReader();
                    while (dr.Read())
                    {
                        id   = dr[0].ToString();
                        name = dr[1].ToString();
                    }
                    dr.Close();

                    this.Hide();
                    LecturerForm lecForm = new LecturerForm();
                    lecForm.ShowDialog();
                    this.Close();
                }
                else if (comboBox1.SelectedIndex == 2)
                {
                    OracleCommand cmd = new OracleCommand();
                    cmd.Connection  = conn;
                    cmd.CommandText = "select ta_id, ta_name from TA where username = :usrnm";
                    cmd.CommandType = CommandType.Text;
                    cmd.Parameters.Add("usrnm", textBox2.Text);
                    OracleDataReader dr = cmd.ExecuteReader();
                    while (dr.Read())
                    {
                        id   = dr[0].ToString();
                        name = dr[1].ToString();
                    }
                    dr.Close();

                    this.Hide();
                    TAForm taForm = new TAForm();
                    taForm.ShowDialog();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Please choose a role!");
                }
            }
        }