Beispiel #1
0
        public Courses(int TimeId)
        {
            DateTime d_today = DateTime.Now;
            d_today = d_today.AddDays(-3);
            string myDate = d_today.ToString("MM/dd/yyyy");
            SqlDataReader reader;
            DBConnection connection = new DBConnection();
            string sql_command;
            int message_id;
            int LecturerID;

            // Load the course details.
            sql_command = "SELECT * FROM Courses A, CourseTimes B WHERE B.id = " + TimeId + " AND A.id = B.courseId;";
            reader = connection.queryExecute(sql_command);
            reader.Read();
            ID = Convert.ToInt32(reader[0].ToString());
            Name = (string)reader[1];
            Class_Room = (string)reader[12];
            LecturerID = Convert.ToInt32(reader[2]);
            DateTime first_hour = DateTime.Parse("08:00");
            DateTime course_hour = DateTime.Parse((string)reader[10]);
            Start_time = course_hour.Subtract(first_hour).Hours;// (string)reader[10];
            duration = Convert.ToInt32(reader[11]);
            Day = Convert.ToInt32(reader[9]);
            if (Convert.ToInt32(reader[4]) == -1)
                is_lecture = false;
            else
                is_lecture = true;
            reader.Close();

            sql_command = "SELECT fName, lName, degree, email FROM Users WHERE id = " + LecturerID + ";";
            reader = connection.queryExecute(sql_command);
            reader.Read();
            Lecturer = (string)reader["degree"] + " " + (string)reader["lName"] + " " + (string)reader["fName"];
            email = (string)reader["email"];
            reader.Close();

            // Load the message of this course.
            sql_command = "SELECT id FROM Messages WHERE " + ID + "= courseID and publishDate >= '" + myDate + "' ORDER BY id DESC;";
            reader = connection.queryExecute(sql_command);
            if (reader.Read())
            {
                message_id = Convert.ToInt32(reader["id"]);
                _message = new Message(message_id);
            }
            else
                _message = null;
            reader.Close();

            // Load the exercise of this course.
            d_today = DateTime.Now;
            int day_today = (int)d_today.DayOfWeek + 1;
            day_today = Day - day_today;
            d_today = d_today.AddDays(day_today);
            myDate = d_today.ToString("MM/dd/yyyy");
            _exercise = new Exercise(myDate, ID);
        }
Beispiel #2
0
        public Message(int id)
        {
            SqlDataReader reader;
            DBConnection connection = new DBConnection();

            ID = id;
            string sql_command = "SELECT *  FROM Messages WHERE "+ID+" = id";
            reader = connection.queryExecute(sql_command);
            reader.Read();
            subject = (string)reader["subject"];
            Content = (string)reader["_content"];
            Date = Convert.ToDateTime(reader["publishDate"]);
            reader.Close();
        }
Beispiel #3
0
        public Schedule(long id,  int rows)
        {
            int i,j;
            Courses temp;
            Student_ID = id;
            Student_Name = "אבי מורלי";
            SqlDataReader reader;
            DBConnection connection = new DBConnection();
            string today = DateTime.Today.ToString("MM/dd/yyyy");
            string sql_command;
            this.int_table = new int[rows][];
            this.c_table = new Courses[rows][];
            for (i = 0; i < rows; i++)
            {
                int_table[i] = new int[6];
                c_table[i] = new Courses[6];
            }

            for (i = 0; i < rows; i++)
                for (j = 0; j < 6; j++)
                    int_table[i][j] = 0;

            sql_command = "SELECT B.*, C.* FROM Studies A, CourseTimes B, Courses C WHERE A.CourseTimesID = B.id"
                + " AND C.id = B.courseID AND " + Student_ID + " = A.studentID AND '" + today + "' >= C.startDate AND '"
                + today + "' <= C.endDate";
            reader = connection.queryExecute(sql_command);

            DateTime temp_min = DateTime.Parse("23:00");
            DateTime temp_max = DateTime.Parse("00:00");

            while (reader.Read())
            {
                DateTime course_hour = DateTime.Parse((string)reader[3]);
                temp = new Courses((int)reader[0]);
                if (temp_min.Subtract(course_hour).Hours > 0)
                    temp_min = course_hour;
                if (temp_max.Subtract(course_hour.AddHours(temp.duration)).Hours < 0)
                    temp_max = course_hour.AddHours(temp.duration);

                c_table[temp.Start_time][temp.Day - 1] = temp;
                int_table[temp.Start_time][temp.Day - 1] = temp.duration;
                for (i=1;i<temp.duration;i++)
                     int_table[temp.Start_time + i][temp.Day - 1] = -1;
            }
            start_time = temp_min.Subtract(DateTime.Parse("08:00")).Hours;
            end_time = temp_max.Subtract(DateTime.Parse("08:00")).Hours -1;
            reader.Close();
        }
Beispiel #4
0
 public Exercise(string due_date, int c_id)
 {
     SqlDataReader reader;
     DBConnection connection = new DBConnection();
     string sql_command = "SELECT * FROM Exercises WHERE '" + due_date + "' = dueDate AND courseID = " + c_id + ";";
     reader = connection.queryExecute(sql_command);
     if (reader.Read())
     {
         deadline = Convert.ToDateTime(reader["dueDate"]);
         ID = (int)reader["id"];
         Content = (string)reader["_content"];
         subject = (string)reader["subject"];
         Date = Convert.ToDateTime(reader["publishDate"]);
         reader.Close();
     }
     else
     {
         this.ID = -1;
     }
 }