示例#1
0
        private void Login_Click(object sender, EventArgs e)
        {
            try
            {
                DBConnect conn = new DBConnect();

                String          query    = "SELECT * FROM `prioritytable` WHERE `ID` = '" + metroTextBox1.Text + "' AND `Password` = '" + metroTextBox2.Text + "'";
                MySqlDataReader dr       = conn.Select(query);
                int             priority = -1;

                while (dr.Read())
                {
                    UserName = Convert.ToString(dr["ID"]);
                    Password = Convert.ToString(dr["Password"]);
                    priority = Convert.ToInt32(dr["Priority"]);
                }

                if (UserName == metroTextBox1.Text && Password == metroTextBox2.Text)
                {
                    switch (priority)
                    {
                    case 0:
                        TeacherHigh aTeacher = new TeacherHigh(UserName);
                        this.Hide();
                        aTeacher.Show();
                        break;

                    case 1:
                        TeacherNorm bTeacher = new TeacherNorm(UserName);
                        this.Hide();
                        bTeacher.Show();
                        break;

                    case 2:
                        Student aStudent = new Student(UserName);
                        this.Hide();
                        aStudent.Show();
                        break;

                    case 3:
                        Parent aParent = new Parent(UserName);
                        this.Hide();
                        aParent.Show();
                        break;
                    }
                    //MessageBox.Show("Correct");
                }
                else
                {
                    MessageBox.Show("Incorrect");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(Convert.ToString(ex));
            }
        }
 public TeacherHighAddSelection(TeacherHigh a)
 {
     aTab = a;
     InitializeComponent();
 }
 public TeacherHighChangePassword(TeacherHigh a, String u)
 {
     aTab   = a;
     userID = u;
     InitializeComponent();
 }
        private void Login_Click(object sender, EventArgs e)
        {
            try
            {
                string           oradb = "Data Source=XE; User Id=RIAD;Password=1133;";
                OracleConnection conn  = new OracleConnection(oradb);
                conn.Open();
                OracleCommand cmd = new OracleCommand();
                cmd.Connection = conn;

                cmd.CommandText = "SELECT * FROM prioritytable WHERE ID = '" + metroTextBox1.Text + "' AND Password = '******'";
                cmd.CommandType = CommandType.Text;
                OracleDataReader dr = cmd.ExecuteReader();
                int priority        = -1;

                while (dr.Read())
                {
                    UserName = Convert.ToString(dr.GetString(0));
                    Password = Convert.ToString(dr.GetString(1));
                    priority = Convert.ToInt32(dr.GetValue(2));
                }

                if (UserName == metroTextBox1.Text && Password == metroTextBox2.Text)
                {
                    switch (priority)
                    {
                    case 0:
                        TeacherHigh aTeacher = new TeacherHigh(UserName);
                        this.Hide();
                        aTeacher.Show();
                        break;

                    case 1:
                        TeacherNorm bTeacher = new TeacherNorm(UserName);
                        this.Hide();
                        bTeacher.Show();
                        break;

                    case 2:
                        Student aStudent = new Student(UserName);
                        this.Hide();
                        aStudent.Show();
                        break;

                    case 3:
                        Parent aParent = new Parent(UserName);
                        this.Hide();
                        aParent.Show();
                        break;
                    }
                    //MessageBox.Show("Correct");
                }
                else
                {
                    MessageBox.Show("Incorrect");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(Convert.ToString(ex));
            }
        }