Beispiel #1
0
    /// <summary>
    /// เรียกดูข้อมูลจากตาราง COURSEGROUP
    /// </summary>
    /// <param name="sql">SQL Command</param>
    /// <returns>ข้อมูลจากตาราง COURSEGROUP</returns>
    public List <CourseGroup> getCourseGroupManual(string sql)
    {
        List <CourseGroup> CourseGroupData = new List <CourseGroup>();

        ConnectDB     db        = new ConnectDB();
        SqlDataSource oracleObj = db.ConnectionOracle_tqf2();

        oracleObj.SelectCommand = sql;

        DataView allData = (DataView)oracleObj.Select(DataSourceSelectArguments.Empty);

        foreach (DataRowView rowData in allData)
        {
            CourseGroup CourseGroupRow = new CourseGroup();

            CourseGroupRow.CourseGroupCode   = rowData["COURSEGROUPCODE"].ToString();
            CourseGroupRow.CourseGroupThName = rowData["COURSEGROUPTHNAME"].ToString();
            CourseGroupRow.CourseGroupEnName = rowData["COURSEGROUPENNAME"].ToString();
            CourseGroupRow.CourseGroupFlag   = rowData["COURSEGROUPFLAG"].ToString();

            CourseGroupData.Add(CourseGroupRow);
        }

        return(CourseGroupData);
    }
Beispiel #2
0
    /// <summary>
    /// เพิ่มข้อมูลลงตาราง COURSEGROUP
    /// </summary>
    /// <param name="dataInsert">CourseGroup Object</param>
    /// <returns>Success</returns>
    public string insertCourseGroup(CourseGroup dataInsert)
    {
        string response = "";

        ConnectDB     db        = new ConnectDB();
        SqlDataSource oracleObj = db.ConnectionOracle_tqf2();

        string sql = "Insert into COURSEGROUP (COURSEGROUPCODE, COURSEGROUPTHNAME, COURSEGROUPENNAME, COURSEGROUPFLAG) values ('" + dataInsert.CourseGroupCode + "','" + dataInsert.CourseGroupThName + "','" + dataInsert.CourseGroupEnName + "','" + dataInsert.CourseGroupFlag + "')";

        oracleObj.InsertCommand = sql;

        try
        {
            if (oracleObj.Insert() == 1)
            {
                response = "Success";
            }
        }
        catch (Exception e)
        {
            string exception = e.Message;
            HttpContext.Current.Session["response"] = "insertCourseGroup: " + exception;
            HttpContext.Current.Response.Redirect("../err_response.aspx");
        }

        return(response);
    }
Beispiel #3
0
        public async Task <bool> CurrentUserIsInSameReviewGroup(CourseGroup courseGroup)
        {
            AppUser user = await userManager.GetUserAsync(HttpContext.User);

            string reviewGroupForAssignment = courseGroup.ReviewGroup;
            string reviewGroupForUser       = "";

            List <CourseGroup> courseGroups = courseGroupRepo.GetAll();

            foreach (CourseGroup cg in courseGroups)
            {
                if (cg.FK_AppUser == user && cg.ID == courseGroup.ID)
                {
                    reviewGroupForUser = cg.ReviewGroup;
                }
            }
            if (reviewGroupForUser == reviewGroupForAssignment)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public JsonResult viewCourseScheduleByDepartmentId(int departmentId)
        {
            var Result = classRoomScheduleDAL.AllocateClassRoomGetAll().Select(n => new
            {
                CourseId = n.CourseId,
                RomNo    = n.RoomNo,
                Day      = n.Day,
                ToTime   = n.ToTime,
                FromTime = n.FromTime,
                Schedule = n.RoomNo + ",  " + n.Day + ",  " + new DateTime(n.FromTime.Ticks).ToString("%h:mm tt") + " - " + new DateTime(n.ToTime.Ticks).ToString("%h:mm tt") + ";<br />",
            });
            var newResult = (from a in Result.ToList()
                             group a by a.CourseId into CourseGroup
                             select new
            {
                CourseId = CourseGroup.FirstOrDefault().CourseId,
                Schedule = String.Join("\n", (CourseGroup.Select(x => x.Schedule)).ToArray())
            });
            var ResultFinal = from s in courseTeacherDAL.CourseGetAll()
                              join c in newResult
                              on s.CourseId equals c.CourseId into sGroup
                              from c in sGroup.DefaultIfEmpty()
                              //where s.DepartmentId == departmentId
                              select new
            {
                DepartmentId = s.DepartmentId,
                CourseCode   = s.CourseCode,
                CourseName   = s.CourseName,
                Schedule     = c == null ? "Not Scheduled Yet" : c.Schedule,
            };
            var dataList = ResultFinal.Where(c => c.DepartmentId == departmentId).ToList();
            var jsonData = dataList.Select(c => new { c.CourseCode, c.CourseName, c.Schedule });

            return(Json(jsonData, JsonRequestBehavior.AllowGet));
        }
Beispiel #5
0
        public void readWeeklyReportItemsFromDataBase(int stuid)
        {
            ObservableCollection <WeeklyReportItem> weeklyReportItems = DatabaseHelper.getWeeklyReportItems(weekNoForDB, selectedClassId, stuid);
            CourseGroup cg = null;

            foreach (WeeklyReportItem item in weeklyReportItems)
            {
                cg = findCourseGroupById(item.courseid);
                if (cg != null)
                {
                    item.category   = cg.category;
                    item.coursename = cg.courseName;
                }
                if (item.category.Equals("多元智能"))
                {
                    weeklyReportDuoYuanItems.Add(item);
                }
                else if (item.category.Equals("生活"))
                {
                    weeklyReportLiveItems.Add(item);
                }
                else if (item.category.Equals("风险事故"))
                {
                    weeklyReportRiskItems.Add(item);
                }
                else if (item.category.Equals("一周综合评价"))
                {
                    weeklyReportEvaluationItems.Add(item);
                }
                else if (item.category.Equals("家园合作建议"))
                {
                    weeklyReportFamilyAndSchollEduItems.Add(item);
                }
            }
        }
Beispiel #6
0
    /// <summary>
    /// แก้ไขข้อมูลจากตาราง COURSEGROUP
    /// </summary>
    /// <param name="updateData">CourseGroup Object</param>
    /// <returns>Success</returns>
    public string updateCourseGroup(CourseGroup updateData)
    {
        string        response  = "";
        ConnectDB     db        = new ConnectDB();
        SqlDataSource oracleObj = db.ConnectionOracle_tqf2();

        string sql = "Update COURSEGROUP Set COURSEGROUPTHNAME = '" + updateData.CourseGroupThName + "', COURSEGROUPENNAME = '" + updateData.CourseGroupEnName + "', COURSEGROUPFLAG = '" + updateData.CourseGroupFlag + "' Where COURSEGROUPCODE = '" + updateData.CourseGroupCode + "'";

        oracleObj.UpdateCommand = sql;

        try
        {
            if (oracleObj.Update() == 1)
            {
                response = "Success";
            }
        }
        catch (Exception e)
        {
            string exception = e.Message;
            HttpContext.Current.Session["response"] = "updateAboutLecturer: " + exception;
            HttpContext.Current.Response.Redirect("../err_response.aspx");
        }

        return(response);
    }
Beispiel #7
0
        public async Task <JsonResult> GetStudentGroup(string studentID, int courseID)
        {
            JsonResponse <CourseGroup> response = new JsonResponse <CourseGroup>();
            AppUser currentUser = await usrMgr.GetUserAsync(HttpContext.User);

            CourseGroup courseGroup = null;

            courseGroupRepository.GetAll().ForEach(cG =>
            {
                if (cG.FK_Course.ID == courseID && cG.FK_AppUser.Id == studentID)
                {
                    courseGroup = cG;
                }
            });
            SetRoles();
            if (courseGroup != null)
            {
                if (this.isAdmin || this.isInstructor && courseGroup.FK_Course.FK_INSTRUCTOR.Id == currentUser.Id)
                {
                    response.Data.Add(courseGroup);
                }
                else
                {
                    response.Error.Add(new Error("Forbidden", "You are not allowed here."));
                }
            }
            else
            {
                response.Error.Add(new Error("NotFound", "The course group was not found."));
            }
            return(Json(response));
        }
 public void OnGet(int?id)
 {
     CourseGroups = new CourseGroup()
     {
         ParentID = id
     };
 }
        /// <summary>
        /// Generate a dropdown list of courses to pick from based on the list of available courses and course groups within the database.
        /// Additionally segments the courses into the course groups defined in the database to make courses easier to find.
        /// </summary>
        /// <param name="courses">List of courses to include in the drop down</param>
        /// <param name="groups">List of groups to segment the courses into</param>
        /// <param name="selectedCourseId">Pre-select a course if it has been selected previously</param>
        /// <returns>A dropdown list of available courses to apply for.</returns>
        public static IEnumerable <SelectListItem> ToSelectList(this List <Course> courses, List <CourseGroup> groups, int?selectedCourseId)
        {
            // Order the courses into groups in the select list, following the same groups as the overall course groups.
            List <SelectListGroup> selectGroups = new List <SelectListGroup>();

            if (groups != null && groups.Any())
            {
                groups.ForEach(g => selectGroups.Add(new SelectListGroup {
                    Name = g.Name
                }));
            }

            // Convert each course into an item in the select list
            foreach (Course course in courses)
            {
                // Find the group that this course belongs to, if any.
                CourseGroup     courseGroup = groups.FirstOrDefault(g => g.Id == course.Type);
                SelectListGroup selectGroup = selectGroups.FirstOrDefault(g => courseGroup != null && g.Name == courseGroup.Name);

                yield return(new SelectListItem {
                    Value = course.Id.ToString(),
                    Text = course.Title,
                    Selected = selectedCourseId.HasValue ? selectedCourseId.Value == course.Id : false,
                    Group = selectGroup
                });
            }
        }
        public static CourseGroup CreateCourseGroup(string group)
        {
            CourseGroup courseGroup = new CourseGroup();

            courseGroup.Group = group;
            return(courseGroup);
        }
Beispiel #11
0
        public void UpdateCoursesNumOfStudents()
        {
            List <int> numOfStudents = new List <int>();

            using (Kita1205GradesEntities gradesEntities = new Kita1205GradesEntities())
            {
                var allCoursesGrouped = (from g in gradesEntities.Grades
                                         group g by g.Course_ID).ToList();

                foreach (var CourseGroup in allCoursesGrouped)
                {
                    numOfStudents.Add(CourseGroup.Count());
                }

                List <Courses> courses = (from c in gradesEntities.Courses
                                          select c).ToList();

                for (int i = 0; i < numOfStudents.Count; i++)
                {
                    courses[i].Num_Of_Students = numOfStudents[i];
                    gradesEntities.SaveChanges();
                }

                gradesEntities.SaveChanges();
            }
        }
Beispiel #12
0
        public async Task <JsonResult> ChangeStudentGroup(int courseGroupID, string reviewGroupID)
        {
            JsonResponse <CourseGroup> response = new JsonResponse <CourseGroup>();
            AppUser currentUser = await usrMgr.GetUserAsync(HttpContext.User);

            CourseGroup courseGroup = courseGroupRepository.FindByID(courseGroupID);

            SetRoles();
            if (courseGroup != null)
            {
                if (this.isAdmin || this.isInstructor && courseGroup.FK_Course.FK_INSTRUCTOR.Id == currentUser.Id)
                {
                    courseGroup.ReviewGroup = reviewGroupID;
                    if (courseGroupRepository.Edit(courseGroup))
                    {
                        response.Data.Add(courseGroup);
                    }
                    else
                    {
                        response.Error.Add(new Error("NotSuccessful", "The data was not successfully writen."));
                    }
                }
                else
                {
                    response.Error.Add(new Error("Forbidden", "You are not allowed here."));
                }
            }
            else
            {
                response.Error.Add(new Error("NotFound", "The Course Group was not found."));
            }
            return(Json(response));
        }
 /// <summary>
 /// Validate the object.
 /// </summary>
 /// <exception cref="Microsoft.Rest.ValidationException">
 /// Thrown if validation fails
 /// </exception>
 public virtual void Validate()
 {
     if (CourseGroup != null)
     {
         CourseGroup.Validate();
     }
 }
Beispiel #14
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["login_data"] == null)
        {
            Response.Redirect("../index.aspx");
        }
        else
        {
            //ตรวจสอบสิทธิ์
            login_data = (UserLoginData)Session["login_data"];
            if (autro_obj.CheckGroupUser(login_data, group_var.officer_department) || autro_obj.CheckGroupUser(login_data, group_var.officer_faculty))
            {
                // ======== Process ===========
                code = Request.QueryString["token"];

                CourseGroup courseGroupData = new CourseGroup().getCourseGroup(code);

                if (!Page.IsPostBack)
                {
                    txtGROUP_THAINAME.Text = courseGroupData.CourseGroupThName;
                    txtGROUP_ENGNAME.Text  = courseGroupData.CourseGroupEnName;
                }
                //=============================
            }
            else
            {
                HttpContext.Current.Session["response"] = "ตรวจสอบไม่พบสิทธิ์การเข้าใช้งาน";
                HttpContext.Current.Response.Redirect("err_response.aspx");
            }
        }
    }
Beispiel #15
0
        public async Task <IActionResult> Edit(int id, [Bind("CourseId,GroupId")] CourseGroup courseGroup)
        {
            if (id != courseGroup.CourseId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(courseGroup);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CourseGroupExists(courseGroup.CourseId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CourseId"] = new SelectList(_context.Courses, "CourseId", "CourseId", courseGroup.CourseId);
            ViewData["GroupId"]  = new SelectList(_context.Groups, "GroupId", "GroupId", courseGroup.GroupId);
            return(View(courseGroup));
        }
Beispiel #16
0
        public ActionResult DeleteConfirmed(long id)
        {
            CourseGroup courseGroup = db.CourseGroups.Find(id);

            db.CourseGroups.Remove(courseGroup);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #17
0
 public CourseGroupDTO MapCourseGroup(CourseGroup courseGroup)
 {
     return(new CourseGroupDTO {
         CourseId = courseGroup.CourseId,
         GroupId = courseGroup.GroupId,
         Name = courseGroup.Group.Name,
     });
 }
        public ActionResult CreateCourseGroup()
        {
            CourseGroup courseGroup = new CourseGroup();

            ViewBag.groupList       = DropDownListHelper.getAppraiseGroupList(false);
            ViewBag.courseClassList = DropDownListHelper.getCourseClassList(false);
            return(View(courseGroup));
        }
Beispiel #19
0
 private CourseGroupDTO MapGroupRef(CourseGroup group)
 {
     return(new CourseGroupDTO {
         GroupId = group.GroupId,
         CourseId = group.CourseId,
         Name = group.Group.Name
     });
 }
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            CourseGroup courseGroup = await _ctx.CourseGroups.FindAsync(id);

            _ctx.CourseGroups.Remove(courseGroup);
            await _ctx.SaveChangesAsync();

            return(RedirectToAction("Default"));
        }
Beispiel #21
0
    protected void btnOK_Click(object sender, EventArgs e)
    {
        string courseGroupDelete = new CourseGroup().deleteCourseGroup(code);

        if (courseGroupDelete == "Success")
        {
            Response.Redirect("listGROUP.aspx");
        }
    }
        public async Task <ActionResult> Edit(CourseGroup courseGroup)
        {
            if (ModelState.IsValid)
            {
                _ctx.Entry(courseGroup).State = EntityState.Modified;
                await _ctx.SaveChangesAsync();

                return(RedirectToAction("Default"));
            }
            return(View(courseGroup));
        }
        public async Task <ActionResult> Create(CourseGroup courseGroup)
        {
            if (ModelState.IsValid)
            {
                _ctx.CourseGroups.Add(courseGroup);
                await _ctx.SaveChangesAsync();

                return(RedirectToAction("Default"));
            }

            return(View(courseGroup));
        }
        public void TestAddCourseGroupToNullDegree()
        {
            var newGroup = new CourseGroup()
            {
                CourseGroupId   = "ABCD123",
                Name            = "Testing Course Group",
                CreditsRequired = 3,
                CoursesRequired = 1
            };

            _service.AddCourseGroupToDegree("GroupNull", newGroup);
        }
Beispiel #25
0
 public ActionResult Edit([Bind(Include = "Id,CourseId,GroupId,TeacherId,TeacherId1,TeacherId2,Capacity,StudentCount,ClassId,SectionGroup,DayTimeSlot,Sex")] CourseGroup courseGroup)
 {
     if (ModelState.IsValid)
     {
         db.Entry(courseGroup).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ClassId   = new SelectList(db.ClassOrYears, "Code", "Name", courseGroup.ClassId);
     ViewBag.CourseId  = new SelectList(db.CourseContents, "CourseId", "CourseName", courseGroup.CourseId);
     ViewBag.TeacherId = new SelectList(db.EmployeeAccounts, "AccountId", "EmployeeCatagoryId", courseGroup.TeacherId);
     return(View(courseGroup));
 }
Beispiel #26
0
        public async Task <IActionResult> Create([Bind("CourseId,GroupId")] CourseGroup courseGroup)
        {
            if (ModelState.IsValid)
            {
                _context.Add(courseGroup);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CourseId"] = new SelectList(_context.Courses, "CourseId", "CourseId", courseGroup.CourseId);
            ViewData["GroupId"]  = new SelectList(_context.Groups, "GroupId", "GroupId", courseGroup.GroupId);
            return(View(courseGroup));
        }
        public IActionResult UploadCourseGroup(FileUploadVm vm)
        {
            if (!Authenticate())
            {
                return(RedirectToAction("Index", "Home"));
            }
            var user = GetCurrentlyLoggedInUser();

            if (!user.IsAdmin)
            {
                return(RedirectToAction("Index", "Planner"));
            }

            if (!ModelState.IsValid)
            {
                return(View(vm));
            }

            using (var context = new DegreePlannerContext())
                using (var stream = vm.File.OpenReadStream())
                    using (var reader = new StreamReader(stream)) {
                        string line;
                        while ((line = reader.ReadLine()) != null)
                        {
                            var data = line.Split(',');

                            var name        = data[0];
                            var courseGroup = new CourseGroup()
                            {
                                Name = name,
                                CourseCourseGroupLinks = new List <CourseCourseGroupLink>()
                            };
                            for (var i = 1; i < data.Length; i++)
                            {
                                var link       = new CourseCourseGroupLink();
                                var department = data[i].Substring(0, 4);
                                var number     = data[i].Substring(4);
                                var course     = CreateOrFetchCourse(context, department, number, out var gen);

                                link.Course = course;

                                courseGroup.CourseCourseGroupLinks.Add(link);
                            }

                            context.CourseGroups.Add(courseGroup);
                            context.SaveChanges();
                        }
                    }

            return(RedirectToAction("Index", "Planner"));
        }
        public void TestAddCourseGroupToDegree()
        {
            var newGroup = new CourseGroup()
            {
                CourseGroupId   = "ABCD123",
                Name            = "Testing Course Group",
                CreditsRequired = 3,
                CoursesRequired = 1
            };

            _service.AddCourseGroupToDegree("CSAI", newGroup);
            Assert.IsTrue(_reqContext.Degrees.Find("CSAI").CourseGroups.Contains(newGroup));
            SeedRequirementsData.reset = true;
        }
        // GET: Admin/CourseGroupManagement/Delete/5
        public async Task <ActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CourseGroup courseGroup = await _ctx.CourseGroups.FindAsync(id);

            if (courseGroup == null)
            {
                return(HttpNotFound());
            }
            return(View(courseGroup));
        }
Beispiel #30
0
        // GET: CourseGroup/Details/5
        public ActionResult Details(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CourseGroup courseGroup = db.CourseGroups.Find(id);

            if (courseGroup == null)
            {
                return(HttpNotFound());
            }
            return(View(courseGroup));
        }