Beispiel #1
0
        private void EditSchedule_StudentCoordinator_FormClosed(object sender, FormClosedEventArgs e)
        {
            this.Close();
            MenuStudentCoordinator f = (MenuStudentCoordinator)this.Owner;

            f.Show();
        }
        private void Move_To_Secteraty_Student_Form_Click_1(object sender, EventArgs e)
        {
            this.Hide();
            MenuStudentCoordinator Studet_secretery_form = new MenuStudentCoordinator(scn);

            Studet_secretery_form.ShowDialog(this);
        }
        private void SearchStudentScheduleStudentCoordinator_FormClosed(object sender, FormClosedEventArgs e)
        {
            this.Close();
            MenuStudentCoordinator sc = (MenuStudentCoordinator)this.Owner;

            sc.Show();
        }
        /*this func send massege if user name empy*/
        private void Login_Click(object sender, EventArgs e)
        {
            SqlConnection c = new SqlConnection(scn);

            if (string.IsNullOrEmpty(Usertxt.Text))                                                                          //if string empty
            {
                MessageBox.Show("Please enter your user name", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning);     //shoe warning
                Usertxt.Focus();                                                                                             //focus on username box
                return;                                                                                                      //end
            }//end click
            if (string.IsNullOrEmpty(txtPassword.Text))                                                                      //if string empty
            {
                MessageBox.Show("Please enter your user password", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); //shoe warning
                Usertxt.Focus();                                                                                             //focus on username box
                return;                                                                                                      //end
            }
            String         q  = "select Users.userid,Users.permission,Users.first_name,Users.last_name,Users.Email from Users where username like '" + Usertxt.Text.ToString() + "' and Users.password like '" + txtPassword.Text + "'";
            SqlDataAdapter da = new SqlDataAdapter(q, c);
            DataTable      dt = new DataTable();

            if (c.State != ConnectionState.Open)
            {
                c.Open();
            }
            da.Fill(dt);
            if (dt.Rows.Count == 0)
            {
                MessageBox.Show("incorect username and password", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning);//shoe warning
            }
            else if (dt.Rows.Count >= 2)
            {
                MessageBox.Show("more then one account", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning);//shoe warning
            }
            else
            {
                if (dt.Rows[0].Field <int>("permission") == 5)
                {
                    c.Close();                                                                                                    //c is bussy so close
                    c.Open();                                                                                                     //open to new connection.
                    da = new SqlDataAdapter("select Year from Student where username like '" + Usertxt.Text.ToString() + "'", c); //get year
                    DataTable dr = new DataTable();                                                                               //
                    da.Fill(dr);
                    OStudent s = new OStudent(dt.Rows[0].Field <int>("userid").ToString(), dt.Rows[0].Field <String>("first_name").ToString(), dt.Rows[0].Field <String>("last_name").ToString(), dt.Rows[0].Field <String>("Email").ToString(), dr.Rows[0].Field <String>("Year")[0]);
                    c.Close();
                    MainStudent f = new MainStudent(s, scn);
                    this.Hide();
                    f.ShowDialog(this);
                }
                if (dt.Rows[0].Field <int>("permission") == 1)
                {
                    c.Close();//c is bussy so close
                    MenuStudentCoordinator f = new MenuStudentCoordinator(scn);
                    this.Hide();
                    f.ShowDialog(this);
                }
                if (dt.Rows[0].Field <int>("permission") == 3)
                {
                    c.Close();//c is bussy so close

                    OLecture l = new OLecture(dt.Rows[0].Field <int>("userid").ToString(), dt.Rows[0].Field <String>("first_name").ToString(), dt.Rows[0].Field <String>("last_name").ToString(), dt.Rows[0].Field <String>("Email").ToString());
                    c.Close();
                    MenuLecturer f = new MenuLecturer(l, c);
                    this.Hide();
                    f.ShowDialog(this);
                }
                if (dt.Rows[0].Field <int>("permission") == 2)
                {
                    c.Close();//c is bussy so close

                    OTutor t = new OTutor(dt.Rows[0].Field <int>("userid").ToString(), dt.Rows[0].Field <String>("first_name").ToString(), dt.Rows[0].Field <String>("last_name").ToString(), dt.Rows[0].Field <String>("Email").ToString());
                    c.Close();
                    MenuTutor f = new MenuTutor(c, t);
                    this.Hide();
                    f.ShowDialog(this);
                }
            }
        }