Exemple #1
0
 public EditCoursePage(Course EditCourse)
 {
     InitializeComponent();
     CurrentCourseDays = new CourseDays();
     if (EditCourse == null)
     {
         Action        = "Add";
         CurrentCourse = new Course();
     }
     else
     {
         Action        = "Edit";
         CurrentCourse = EditCourse;
         OriginalId    = EditCourse.Id;
         if (CurrentCourse.Days.Length > 0)
         {
             if (CurrentCourse.Days.Contains(","))
             {
                 foreach (string DayId in CurrentCourse.Days.Split(','))
                 {
                     CurrentCourseDays.SetSelectedValue(int.Parse(DayId), true);
                 }
             }
             else
             {
                 CurrentCourseDays.SetSelectedValue(int.Parse(CurrentCourse.Days), true);
             }
         }
     }
     SetUIText();
 }
Exemple #2
0
 public EditCoursePage()
 {
     InitializeComponent();
     Action            = "Add";
     CurrentCourseDays = new CourseDays();
     SetUIText();
 }
Exemple #3
0
        private static List <CourseDays> parse_courseDays(SqlDataReader rdr)
        {
            List <CourseDays> courseDaysList = new List <CourseDays>();

            while (rdr.Read())
            {
                CourseDays courseDays = new CourseDays();
                courseDays.id        = Convert.ToInt64(rdr["id"]);
                courseDays.course_id = Convert.ToInt64(rdr["course_id"]);
                courseDays.day       = (days_of_week_enum)Convert.ToInt64(rdr["day"]);
                try
                {
                    courseDays.from_time = Convert.ToDateTime(rdr["from_time"]);
                }
                catch (Exception)
                {
                    courseDays.from_time = DateTime.Now;
                }

                try
                {
                    courseDays.to_time = Convert.ToDateTime(rdr["to_time"]);
                }
                catch (Exception)
                {
                    courseDays.to_time = DateTime.Now;
                }

                courseDaysList.Add(courseDays);
            }

            return(courseDaysList);
        }
Exemple #4
0
        private static long addCourseDay(CourseDays courseDays)
        {
            long id = 0;

            using (SqlConnection con = new SqlConnection(Database.connection_string))
            {
                con.Open();
                SqlCommand com = new SqlCommand("Course", con);
                com.CommandType = CommandType.StoredProcedure;
                com.Parameters.AddWithValue("@course_id", courseDays.course_id);
                com.Parameters.AddWithValue("@day", courseDays.day);
                com.Parameters.AddWithValue("@from_time", courseDays.from_time);
                com.Parameters.AddWithValue("@to_time", courseDays.to_time);


                com.Parameters.AddWithValue("@Action", "InsertCourseDay");

                SQL_Utility.Stored_Procedure(ref com);

                SqlDataReader rdr = com.ExecuteReader();
                if (rdr.Read())
                {
                    id = Convert.ToInt64(rdr[0]);
                }
            }
            return(id);
        }
Exemple #5
0
        public static long addCourse(Course_Insert_Helper helper)
        {
            Course course = new Course
            {
                instructor_id  = 0,
                branch_id      = helper.branch_id,
                course_type_id = helper.CourseType,

                name           = helper.name,
                name_ar        = helper.name_ar,
                description    = helper.description,
                description_ar = helper.description_ar,

                start_date = Convert.ToDateTime(helper.start_date),
                end_date   = Convert.ToDateTime(helper.end_date),
                capacity   = helper.capacity,

                capacity_is_visible = is_visible_enum.visible,

                old_price = helper.old_price,
                new_price = helper.new_price,

                expiration_register_date = Convert.ToDateTime(helper.expiration_register_date),
                course_duration_in_hours = helper.course_duration_in_hours,
                no_of_days_per_week      = helper.no_of_days_per_week,
                no_of_hours_per_day      = helper.no_of_hours_per_day,

                center_or_instructor = center_or_instructor_enum.center,
                is_visible           = is_visible_enum.visible
            };
            long course_id = addCourse(course);
            int  i         = 0;

            foreach (int item in helper.Days)
            {
                CourseDays day = new CourseDays();
                day.course_id = course_id;
                day.day       = (days_of_week_enum)item;
                day.to_time   = Convert.ToDateTime(helper.Tos[i]);
                day.from_time = Convert.ToDateTime(helper.froms[i]);
                addCourseDay(day);
                i++;
            }


            return(course_id);
        }
Exemple #6
0
        public override string ToString()
        {
            string[] items = new string[Times.Count];

            for (int i = 0; i < Times.Count; i++)
            {
                items[i] = Times[i].ToString();
            }

            return(string.Format("Title: {0}, Code: {1}, Instructor: {2}," +
                                 " Buildings: {3}, Classes: {4}, Days: {5}, Times: {6}",
                                 CourseTitle, CourseCode, CourseInstructor,
                                 string.Join(",", Buildings.ToArray()),
                                 string.Join(",", Classes.ToArray()),
                                 string.Join(",", CourseDays.ToArray()),
                                 string.Join(",", items)
                                 ));
        }
 public DaysPage(ref CourseDays coursedays)
 {
     InitializeComponent();
     CurrentCourseDays = coursedays;
     SetUIText();
 }