public async void ShowCourses()
        {
            List <Course> courses = await App.DB.ShowCourses(termValue);

            foreach (Course course in courses)
            {
                CourseList.Add(course);
            }
            if (CourseList.Count > 0)
            {
                CourseLabel = true;
            }
            ButtonEnabled = CourseList.Count >= 6 ? false : true;
        }
示例#2
0
        private void DoFilter(object o)
        {
            string instructor = o.ToString();
            var    course     = CourseAll;

            if (instructor != "All")
            {
                course = CourseAll.Where(c => c.CourseInstructors.Exists(e => e == instructor)).ToList();
            }
            CourseList.Clear();
            foreach (var item in course)
            {
                CourseList.Add(item);
            }
        }
        private async void GetCourses()
        {
            List <Course> courses = await App.Database.GetCoursesAsync(_term);

            foreach (Course course in courses)
            {
                CourseList.Add(course);
            }
            if (CourseList.Count > 0)
            {
                ShowCourseLabel = true;
            }
            AddButtonEnabled = CourseList.Count >= 6 ? false : true;
            RaiseAllProperties();
        }
        internal static CourseList DataTableToTitleList(DataTable Dt)
        {
            CourseList courses = new CourseList();

            try
            {
                foreach (DataRow item in Dt.Rows)
                {
                    courses.Add(DataRowToTitle(item));
                }
            }
            catch
            {
            }
            return(courses);
        }
示例#5
0
        private void DoFilter(object o)
        {
            string             teacher = o.ToString();
            List <CourseModel> temp    = courseAll;

            if (teacher != "全部")
            {
                temp = courseAll.Where(c => c.Teachers.Exists(e => e == teacher)).ToList();
            }
            CourseList.Clear();

            foreach (var item in temp)
            {
                CourseList.Add(item);
            }
        }
        public bool MakeCourses(Courses courses)
        {
            if (courses.Status == "Compulsory")
            {
                SettingStatus = "Big";
                Sizee         = "C";
            }
            else if (courses.Status == "Required")
            {
                SettingStatus = "Medium";
                Sizee         = "R";
            }
            else
            {
                if (courses.Status == "Elective")
                {
                    SettingStatus = "Small";
                    Sizee         = "E";
                }
            }
            int count = CourseList.Count <Courses>(chk => chk.Name == courses.Name);

            if (count > 0)
            {
                return(false);
            }
            else
            {
                CourseList.Add(new Courses
                {
                    Name   = courses.Name,
                    Status = SettingStatus,
                    Size   = Sizee
                });
                CourseList.CollectionChanged += CourseList_CollectionChanged;
            }
            //int search = CourseList.IndexOf(courses.Name);
            // CourseList.Contains(courses.Name);
            //CourseList.Where(chk=> chk.CourseList.Contains(courses.Name))

            return(true);
        }
        async Task ExecuteLoadCourses()
        {
            if (IsBusy)
            {
                return;
            }
            IsBusy = true;
            try
            {
                CourseList.Clear();
                var courses = await App.DB.ShowCourses(Term);

                foreach (var course in courses)
                {
                    CourseList.Add(course);
                }
            }
            catch (Exception exception) { }
            finally { IsBusy = false; }
        }
示例#8
0
        //Responsible of submitting the course with all its details to the database
        private void ButtonSubmit_Click(object sender, EventArgs e)
        {
            //Check if there is an empty field
            bool isValid = true;

            foreach (Control ctr in Controls)
            {
                if (ctr is TextBox)
                {
                    if (ctr.Text == "" || ctr.Text is null)
                    {
                        isValid = false;
                    }
                }
            }

            //Check if there is an empty field that wasn't put
            if (isValid)
            {
                Course course = new Course();
                course.CourseID = textBoxID.Text.ToString();
                course.Title    = textBoxTitle.Text;
                course.Credits  = textBoxCredits.Text;
                courseList.Add(course);
                if (course.getValid())
                {
                    //Show confirmation message
                    MessageBox.Show("Course Added Successfully!");
                    Clear();
                }
                else
                {
                    MessageBox.Show(course.geterrorMessage());
                }
            }
            else
            {
                MessageBox.Show("A field is empty");
            }
        }
示例#9
0
        private void InitCourseList()
        {
            for (int i = 0; i < 10; i++)
            {
                CourseList.Add(new CourseModel {
                    IsShowSkeleton = true
                });
            }
            Task.Run(new Action(async() =>
            {
                courseAll = LocalDataAccess.GetInstance().GetCourses();
                await Task.Delay(4000);

                Application.Current.Dispatcher.Invoke(new Action(() =>
                {
                    CourseList.Clear();
                    foreach (var item in courseAll)
                    {
                        CourseList.Add(item);
                    }
                }));
            }));
        }
示例#10
0
        bool IModel.addCourse(string courseID, string name, string deptid, double priceEU, double priceNonEU, string desc, int points, int capacity, int curCapacity, int isNight)
        {
            ICourse duplicateCourse = this.CourseList.FirstOrDefault(cour => cour.CourseID == courseID.Trim());

            if (duplicateCourse != null)
            {
                return(false);
            }
            else
            {
                try
                {
                    ICourse acourse = UserFactory.GetCourse(courseID, name, deptid, priceEU, priceNonEU, desc, points, capacity, curCapacity, isNight);
                    CourseList.Add(acourse);
                    DataLayer.addNewCourseToDB(acourse);
                    return(true);
                }
                catch (System.Exception excep)
                {
                    return(false);
                }
            }
        }
示例#11
0
 /// <summary>
 /// Gets a list of Courses
 /// </summary>
 /// <returns>List of Courses</returns>
 public static CourseList GetItem()
 {
     CourseList myCourseList = null;
     using (SqlConnection myConnection = new SqlConnection(AppSettings.ConnectionString))
     {
         SqlCommand myCommand = new SqlCommand("spSelectCourseList", myConnection);
         myCommand.CommandType = CommandType.StoredProcedure;
         myConnection.Open();
         using (SqlDataReader myDataReader = myCommand.ExecuteReader())
         {
             if (myDataReader.HasRows)
             {
                 myCourseList = new CourseList();
                 while (myDataReader.Read())
                 {
                     myCourseList.Add(FillRecord(myDataReader));
                 }
             }
             myDataReader.Close();
         }
         myConnection.Close();
     }
     return myCourseList;
 }
示例#12
0
        /// <summary>
        /// Gets list of courses taken by a student.
        /// </summary>
        /// <param name="id">A unique student id.</param>
        /// <param name="isStudent">Boolean flag for student. True if user is a student else false.</param>
        /// <returns>A list of courses.</returns>
        public static CourseList GetItem(string id, bool isStudent)
        {
            CourseList myCourseList = null;
            using (SqlConnection myConnection = new SqlConnection(AppSettings.ConnectionString))
            {
                //SqlCommand cmd = new SqlCommand("Select * from Course where CourseID = 'cid01'",myConnection);
                string callProcedure = isStudent ?
                    "spGetEnrolledCourseListByStudent" : "spGetEnrolledCourseListByInstructor";
                SqlCommand myCommand = new SqlCommand(callProcedure, myConnection);
                myCommand.CommandType = CommandType.StoredProcedure;
                myCommand.Parameters.AddWithValue("@id", id);

                myConnection.Open();
                using (SqlDataReader myDataReader = myCommand.ExecuteReader())
                {
                    if (myDataReader.HasRows)
                    {
                        myCourseList = new CourseList();
                        while (myDataReader.Read())
                        {
                            myCourseList.Add(FillRecord(myDataReader));
                        }
                    }
                    myDataReader.Close();
                }
                myConnection.Close();
            }
            return myCourseList;
        }
示例#13
0
 public void AddCourse(CourseList <C> course)
 {
     CourseList.Add(course);
 }
示例#14
0
        private void ExecuteSearch(object parameter)
        {
            String QueryBaseAddition  = "";
            String dynamic_query_part = "";

            foreach (var v in text_criteria)
            {
                if (v.isChecked)
                {
                    if (dynamic_query_part == "")
                    {
                        dynamic_query_part = dynamic_query_part + v.representation + " LIKE '%" + v.input + "%'";
                    }
                    else
                    {
                        dynamic_query_part = dynamic_query_part + " AND " + v.representation + " LIKE '%" + v.input + "%'";
                    }
                }
            }

            foreach (var v in list_criteria)
            {
                if (v.isChecked)
                {
                    bool used = false;
                    if (v.representation == "Läsperiod" && v.Selected != "")
                    {
                        QueryBaseAddition += "JOIN Läsperioder USING (Kurskod) ";
                        used = true;
                    }
                    if (v.representation == "Specialisering" && v.Selected != "")
                    {
                        QueryBaseAddition += "JOIN Specialiseringar USING (Kurskod) ";
                        used = true;
                    }
                    if (dynamic_query_part == "" && used)
                    {
                        dynamic_query_part = dynamic_query_part + v.representation + " LIKE '%" + v.Selected + "%'";
                    }
                    else if (used || v.representation == "Poängtyp")
                    {
                        dynamic_query_part = dynamic_query_part + " AND " + v.representation + " LIKE '%" + v.Selected + "%'";
                    }
                }
            }

            foreach (var v in Interval_criteria)
            {
                if (v.isChecked)
                {
                    String lower = v.LowerBounds.ToString().Replace(',', '.');
                    String upper = v.UpperBounds.ToString().Replace(',', '.');

                    if (dynamic_query_part == "")
                    {
                        dynamic_query_part = dynamic_query_part + v.representation + " >= " + lower + " AND " + v.representation + " <= " + upper;
                    }
                    else
                    {
                        dynamic_query_part = dynamic_query_part + " AND " + v.representation + " >= " + lower + " AND " + v.representation + " <= " + upper;
                    }
                }
            }
            CourseList.Clear();
            String query = "SELECT DISTINCT Kurskod, Antal_poäng, Poängtyp, Kursnamn, Beskrivning,  Representant_email FROM spec_course_info " + QueryBaseAddition + " WHERE " + dynamic_query_part + ";";

            if (dynamic_query_part != "")
            {
                foreach (var v in PerformDatabaseCourseAccess(query))
                {
                    CourseList.Add(v);
                }
            }
        }