public CoursesForTheSemester(OStudent student, String connectionString)
 {
     s  = student;
     dt = new DataTable();
     this.connectionString = connectionString;
     InitializeComponent();
 }
        public StudentSchedule(String co, OStudent s)
        {
            this.connectionString = co;
            this.student          = s;
            this.dtSchedule       = new MyDataTableSchedule();

            InitializeComponent();
        }
Example #3
0
        public void login_run(String un, String pass, Form login_form)
        {
            DBC           newcon   = new DBC();
            List <String> userinfo = newcon.get_row_by_username(un);

            if (userinfo.Count > 0)
            {
                if (userinfo[1].Replace(" ", "") == pass)
                {
                    //MessageBox.Show("succesfully loged in ");
                    if (Convert.ToInt32(userinfo[2]) == (int)permission.admin)
                    {
                        nperson = new Admin(userinfo);
                        (nperson as Admin).run(login_form);
                    }
                    else if (Convert.ToInt32(userinfo[2]) == (int)permission.sec)
                    {
                        nperson = new Secretary(userinfo);
                        (nperson as Secretary).run(login_form);
                    }
                    else if (Convert.ToInt32(userinfo[2]) == (int)permission.prac)
                    {
                        nperson = new Teacher(userinfo);
                        (nperson as Teacher).run(login_form);
                    }
                    else if (Convert.ToInt32(userinfo[2]) == (int)permission.lect)
                    {
                        nperson = new Teacher(userinfo);
                        (nperson as Teacher).run(login_form);
                    }
                    else if (Convert.ToInt32(userinfo[2]) == (int)permission.md)
                    {
                        nperson = new deptmanager(userinfo);
                        (nperson as deptmanager).run(login_form);
                    }
                    else if (Convert.ToInt32(userinfo[2]) == (int)permission.student)
                    {
                        char    year;
                        OPerson p;
                        year = newcon.getStudyYear(userinfo[0]);
                        p    = new OStudent(userinfo[0], userinfo[3], userinfo[4], userinfo[5], year);
                        MainStudent ms = new MainStudent(p as OStudent, constring);
                        login_form.Hide();
                        ms.ShowDialog(login_form);
                    }
                }
                else
                {
                    MessageBox.Show("wrong password");
                }
            }
            else
            {
                MessageBox.Show("wrong username or password");
            }
        }
Example #4
0
        public DataTable StudentFindHisCourses(OStudent s, SqlConnection c)
        {
            c.Open();
            SqlDataAdapter da = new SqlDataAdapter("SELECT Id,Name FROM Courses WHERE Id IN(SELECT CourseID FROM Constraints WHERE Constraints.Id IN(SELECT LessonID FROM Lesson WHERE StudentID LIKE '" + s.ID + "'))", c);
            //SqlDataAdapter da = new SqlDataAdapter("SELECT Id,Name FROM Courses WHERE Id IN(SELECT CourseID FROM Constraints WHERE Id IN(SELECT LessonID FROM Lesson WHERE Lesson.StudentID LIKE'" + s.ID + "'))", c);
            DataTable dt = new DataTable();

            da.Fill(dt);
            c.Close();
            return(dt);
        }
Example #5
0
        public EmailsOfLecturers(OStudent student, String connectionString)
        {
            InitializeComponent();

            dt.Columns.Add("lecturer name", typeof(string));
            dt.Columns.Add("email", typeof(string));


            List <OPerson> lecturers = Queries.selectLecturersOfStudent(student, connectionString);

            foreach (OPerson lec in lecturers)
            {
                dt.Rows.Add(new object[] { lec.FName.Trim() + " " + lec.LName.Trim(), lec.Email.Trim() });
            }


            dataGridView1.DataSource = dt;
        }
Example #6
0
        public static List <OCourse> selectCoursesOfStudent(OStudent student, String connectionString)
        {
            List <OCourse> electiveCourses = new List <OCourse>();

            using (SqlConnection conn = new SqlConnection())
            {
                conn.ConnectionString = connectionString;
                conn.Open();
                SqlCommand command = new SqlCommand("SELECT * FROM Courses WHERE Id IN(SELECT CourseID FROM Constraints WHERE Confirmed=1 Id IN(SELECT LessonID FROM Lesson WHERE StudentID=" + student.ID + "))", conn);
                using (SqlDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        electiveCourses.Add(new OCourse(reader[0].ToString(), reader[1].ToString(), reader[2].ToString(), reader[3].ToString(), reader[4].ToString(), reader[5].ToString(), reader[6].ToString(), reader[7].ToString()));
                    }
                }
                conn.Close();
            }
            return(electiveCourses);
        }
Example #7
0
        // Select lecturers that teaches the student
        public static List <OPerson> selectLecturersOfStudent(OStudent student, String connectionString)
        {
            List <OPerson> lecturers = new List <OPerson>();

            using (SqlConnection conn = new SqlConnection())
            {
                conn.ConnectionString = connectionString;
                conn.Open();
                SqlCommand command = new SqlCommand("SELECT userid,first_name,last_name,Email FROM Users WHERE userid IN(SELECT LecturerID FROM Constraints WHERE Confirmed=1 AND Id IN(SELECT LessonID FROM Lesson WHERE StudentID=" + student.ID + "))", conn);
                using (SqlDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        lecturers.Add(new OPerson(reader[0].ToString(), reader[1].ToString(), reader[2].ToString(), reader[3].ToString()));
                    }
                }
                conn.Close();
            }
            return(lecturers);
        }
Example #8
0
 public StudentEditSchedule(String co, OStudent s)
 {
     this.connectionString = co;
     this.student          = s;
     InitializeComponent();
 }
Example #9
0
 public MainStudent(OStudent student, String connectionString)
 {
     this.student          = student;
     this.connectionString = connectionString;
     InitializeComponent();
 }
        /*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);
                }
            }
        }