コード例 #1
0
        private void btnBack_Click(object sender, EventArgs e)
        {
            StudentHomePage shp = new StudentHomePage(userid, status);

            shp.Show();
            this.Hide();
        }
コード例 #2
0
        private void btnLogIn_Click(object sender, EventArgs e)
        {
            DBConnect dbc = new DBConnect();

            string username = txtLogInUserName.Text;
            string password = txtLogInPassword.Text;
            string dpass    = "";
            string userid   = null;
            string status   = null;

            if (rbtnLogInOwner.Checked)
            {
                try
                {
                    string  query = "select password, userid, status from OwnerDetails where username = '******'";
                    DataSet ds    = dbc.GetInfo(query);

                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        dpass  = ds.Tables[0].Rows[i]["password"].ToString();
                        userid = ds.Tables[0].Rows[i]["userid"].ToString();
                        status = ds.Tables[0].Rows[i]["status"].ToString();
                    }

                    if (dpass == password)
                    {
                        Owner.OwnerHomePage ohp = new Owner.OwnerHomePage(userid, status);
                        ohp.Show();
                        this.Hide();
                    }
                    else
                    {
                        MessageBox.Show(this, "Username or Password Incorrect. Try again");
                        txtLogInPassword.Text = "";
                    }
                }
                catch (Exception er)
                {
                    Console.WriteLine("Error : " + er);
                }
            }
            else if (rbtnLogInStudent.Checked)
            {
                try
                {
                    string  query = "select password, userid, status from StudentDetails where username = '******'";
                    DataSet ds    = dbc.GetInfo(query);

                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        dpass  = ds.Tables[0].Rows[i]["password"].ToString();
                        userid = ds.Tables[0].Rows[i]["userid"].ToString();
                        status = ds.Tables[0].Rows[i]["status"].ToString();
                    }

                    if (dpass == password)
                    {
                        Student.StudentHomePage shp = new Student.StudentHomePage(userid, status);
                        shp.Show();
                        this.Hide();
                    }
                    else
                    {
                        MessageBox.Show(this, "Username or Password Incorrect. Try again");
                        txtLogInPassword.Text = "";
                    }
                }
                catch (Exception er)
                {
                    Console.WriteLine("Error : " + er);
                }
            }
            else
            {
                MessageBox.Show("Select Owner/Student");
            }
        }