Exemplo n.º 1
0
        //Возвращает распарсенный список организаций
        public List<SubjectDetail> GetDetailSubjects(string filePatch)
        {
            var detailedSubjectList = new List<SubjectDetail>();

            var table = GetTable(filePatch);
            foreach (DataRow row in table.Rows)
            {
                var data = row.ItemArray[0].ToString();
                var splitterIndex = data.IndexOf('_');
                var lenght = data.Length;
                var subjectNumber = data.Substring(0, splitterIndex);
                var classNumber = "";
                var classDetail = "";
                if (splitterIndex != lenght-1)
                {
                    var classString = data.Substring(splitterIndex + 1, lenght - splitterIndex);
                    var codeLenght = classString.Length;
                    classNumber = classString.Remove(codeLenght - 2, 1);
                    classDetail = classString.Remove(0, codeLenght - 1);
                }

                var newDetailedSubject = new SubjectDetail
                                             {
                                                 SubjectNumber = subjectNumber,
                                                 ClassNumber = classNumber,
                                                 ClassDetail = classDetail
                                             };
                if (!detailedSubjectList.Contains(newDetailedSubject))
                {
                    detailedSubjectList.Add(newDetailedSubject);
                }
            }
            return detailedSubjectList;
        }
Exemplo n.º 2
0
 public ActionResult CreateNew([Bind(Include = "ID,ID_Subject,SubjectName,Contents,Description,ID_Teacher,DateBegin,isActive,IDSubjectType")]  Subject subject)
 {
     if (subject.ID_Teacher != 0 && subject.SubjectName != null)
     {
         if (!IsSubjectNameinSubject(subject.SubjectName) && !IsSubjectNameinTSubject(subject.SubjectName))
         {
             String ID_Student = GetCurrentStudent().MSSV;
             subject.DateBegin     = month + "/" + day + "/" + year;
             subject.ID_Subject    = "DTTC";
             subject.isActive      = true;
             subject.IDSubjectType = 1;
             if (ModelState.IsValid)
             {
                 db.Subjects.Add(subject);
                 db.SaveChanges();
                 subject.ID_Subject += string.Format("{0:0000}", subject.ID);
                 db.SaveChanges();
             }
         }
         SubjectDetail Detail = new SubjectDetail();
         Detail.ID_Subject      = db.Subjects.FirstOrDefault(s => s.ID_Subject == subject.ID_Subject).ID;
         Detail.ID_Student      = db.Students.FirstOrDefault(student => student.ID_Account == CurrentUser.ID).ID;
         Detail.PrecentComplete = 0;
         Student CurrentStudent = GetCurrentStudent();
         CurrentStudent.ID_Subject = subject.ID;
         if (ModelState.IsValid)
         {
             db.SubjectDetails.Add(Detail);
             db.SaveChanges();
         }
         return(RedirectToAction("Index"));
     }
     return(RedirectToAction("CreateNew"));
 }
Exemplo n.º 3
0
        public IActionResult UpdateInactiveSubject([FromBody] SubjectDetail request)
        {
            var inActiveSubject = repoQ.GetInActiveSubject(request.id);

            repoQ.UpdateSubjectCodeAndNameAndContentLanguage(request.id, request.SubjectCode, request.SubjectName, request.ContentLanguage);

            return(Ok(new { Message = $"Updated!", SubjectId = request.id }));
        }
Exemplo n.º 4
0
        public ActionResult CreateExist([Bind(Include = "ID,ID_Subject,SubjectName,Contents,Description,ID_Teacher,DateBegin,isActive,IDSubjectType")]  Subject subject)
        {
            if (subject.ID_Subject != null)
            {
                Subject       findsubject    = db.Subjects.FirstOrDefault(s => s.ID_Subject == subject.ID_Subject);
                SubjectDetail Detail         = new SubjectDetail();
                Student       CurrentStudent = db.Students.FirstOrDefault(s => s.ID_Account == CurrentUser.ID);
                T_Subject     TSubject       = db.T_Subject.FirstOrDefault(s => s.ID_Subject == subject.ID_Subject);

                if (SubjectAvaiable(findsubject)) /* Tạo mới subject nếu nó đã bị xóa */
                {
                    subject.SubjectName   = TSubject.T_SubjectName;
                    subject.DateBegin     = month + "/" + day + "/" + year;
                    subject.ID_Teacher    = int.Parse(TSubject.ID_Teacher.ToString());
                    subject.IDSubjectType = 1;
                    subject.isActive      = true;

                    TSubject.isActive = false;
                    if (ModelState.IsValid)
                    {
                        db.Subjects.Add(subject);
                        db.SaveChanges();
                        CurrentStudent.ID_Subject = subject.ID;
                        db.SaveChanges();
                    }

                    Detail.ID_Student      = CurrentStudent.ID;
                    Detail.ID_Subject      = subject.ID;
                    Detail.PrecentComplete = 0;
                    if (ModelState.IsValid)
                    {
                        db.SubjectDetails.Add(Detail);
                        db.SaveChanges();
                    }
                }
                else if (findsubject.isSubmit != true) /* Nếu đề tài đã được người khác đăng ký nhưng chưa submit thì có thể đăng ký chung nhóm */
                {
                    Detail.ID_Subject      = findsubject.ID;
                    Detail.ID_Student      = CurrentStudent.ID;
                    Detail.PrecentComplete = 0;

                    CurrentStudent.ID_Subject = subject.ID;
                    if (ModelState.IsValid)
                    {
                        db.SubjectDetails.Add(Detail);
                        db.SaveChanges();
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(RedirectToAction("CreateExist"));
        }
        public ActionResult CreateTimetable(Project.Models.Timetable timetable)
        {
            try
            {
                using (DBmodel tution = new DBmodel())
                {
                    ViewBag.IsError = false;
                    try
                    {
                        if (ModelState.IsValid)
                        {
                            SubjectDetail subject = new SubjectDetail();

                            var subje = tution.SubjectTBs.Where(m => m.SubjectName == timetable.Subject).Select(u => new { sub = u.SubjectCode }).Single();

                            tution.Timetables.Add(timetable);
                            tution.SaveChanges();

                            subject.Hall      = timetable.Hall;
                            subject.StartTime = timetable.StartTime;
                            subject.EndTime   = timetable.EndTime;
                            subject.Day       = timetable.Day;
                            subject.SubjectID = subje.sub;

                            tution.SubjectDetails.Add(subject);
                            tution.SaveChanges();

                            return(RedirectToAction("TimetableList"));
                        }
                    }
                    catch
                    {
                    }
                }
            }

            catch
            {
                DBmodel db = new DBmodel();

                List <TeacherList> list     = db.TeacherLists.ToList();
                List <GradeList>   grades   = db.GradeLists.ToList();
                List <subject>     subjects = db.subjects.ToList();

                ViewBag.teacherlist = new SelectList(list, "teacher_name", "teacher_name");
                ViewBag.Grades      = new SelectList(grades, "Grade", "Grade");
                ViewBag.Subjects    = new SelectList(subjects, "subject1", "subject1");

                return(View());
            }
            return(RedirectToAction("TimetableList"));
        }
 public CFIDetailDialog(object selectedItem)
 {
     this.InitializeComponent();
     detail = selectedItem as SubjectDetail;
     binding(richEBCRN, detail.CRN);
     binding(richEBSubjectCode, detail.SubjectCode);
     binding(richEBCompetencyName, detail.CompetencyName);
     binding(richEBStartDate, detail.StartDate);
     binding(richEBEndDate, detail.EndDate);
     binding(richEBDayOfWeek, detail.DayOfWeek);
     binding(richEBTime, detail.Time);
     binding(richEBRoom, detail.Room);
     binding(richEBLecturer, detail.Lecturer);
     binding(richEBCampus, detail.Campus);
 }
Exemplo n.º 7
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            SubjectDetail = await _context.subjectDetails
                            .Include(s => s.Subject).FirstOrDefaultAsync(m => m.SubjectDetailId == id);

            if (SubjectDetail == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Exemplo n.º 8
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            SubjectDetail = await _context.subjectDetails.FindAsync(id);

            if (SubjectDetail != null)
            {
                _context.subjectDetails.Remove(SubjectDetail);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
Exemplo n.º 9
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            SubjectDetail = await _context.subjectDetails
                            .Include(s => s.Subject).FirstOrDefaultAsync(m => m.SubjectDetailId == id);

            if (SubjectDetail == null)
            {
                return(NotFound());
            }


            ViewData["SubjectId"] = new SelectList(_context.subjects, "SubjectId", "Title");
            return(Page());
        }
Exemplo n.º 10
0
 public ActionResult Delete(int?id)
 {
     if (id != null)
     {
         Subject CurrentSubject = db.Subjects.Find(id);
         if (CanDelete(CurrentSubject))
         {
             Student student = GetCurrentStudent();
             student.ID_Subject = null;
             SubjectDetail Detail = db.SubjectDetails.FirstOrDefault(detail => detail.ID_Student == student.ID && detail.ID_Subject == CurrentSubject.ID);
             db.SubjectDetails.Remove(Detail);
             if (!IsCurSubjectInStuList(CurrentSubject.ID))
             {
                 CurrentSubject.isDelete = true;
             }
             db.SaveChanges();
             return(RedirectToAction("Index", "Home"));
         }
         return(RedirectToAction("Index"));
     }
     return(RedirectToAction("Index"));
 }
        public ActionResult Delete(int id, SubjectTB subject)
        {
            try
            {
                using (DBmodel DBmodel = new DBmodel())
                {
                    subject         model_subject = DBmodel.subjects.Find(id);
                    teacher_grade   model_grade   = DBmodel.teacher_grade.Find(id);
                    teacher_subject model_teacher = DBmodel.teacher_subject.Find(id);

                    SubjectDetail subDetail = new SubjectDetail();
                    subject = DBmodel.SubjectTBs.Where(x => x.SubjectCode == id).FirstOrDefault();
                    if (DBmodel.SubjectDetails.Any(x => x.SubjectID == id))
                    {
                        subDetail = DBmodel.SubjectDetails.Where(x => x.SubjectID == id).FirstOrDefault();
                        DBmodel.SubjectDetails.Remove(subDetail);
                    }
                    DBmodel.SubjectTBs.Remove(subject);
                    DBmodel.SaveChanges();

                    string grade  = model_grade.grade;
                    int    grade2 = model_grade.grade_id;
                    int    grade3 = model_grade.subjectCode;
                    int    grade4 = model_grade.teacher_id;

                    DBmodel.teacher_grade.Remove(model_grade);
                    // DBmodel.subjects.Remove(model_subject);
                    // DBmodel.teacher_subject.Remove(model_teacher);
                    DBmodel.SaveChanges();
                }
                return(RedirectToAction("SubjectList"));
            }
            catch
            {
                return(View());
            }
        }
Exemplo n.º 12
0
        public IActionResult CreateInactiveSubject([FromBody] SubjectDetail examSuite)
        {
            //var subjectId = $"{examSuite.SubjectCode}{examSuite.ContentLanguage}";
            var subjectId = Guid.NewGuid().ToString();

            var newSubject = new ViewModels.ExamBankModelsBack.InActiveSubject.InactiveSubject
            {
                _id                  = subjectId,
                SubjectCode          = examSuite.SubjectCode,
                SubjectName          = examSuite.SubjectName,
                CreateDateTime       = DateTime.Now,
                IsEReadiness         = false, //Hack
                ContentLanguage      = examSuite.ContentLanguage,
                SiteId               = HomeController._centerdata.SiteId,
                QuestionCount        = 0,
                ExamSuiteCount       = 0,
                ExamSuiteAcceptCount = 0,
                ExamSuiteRejectCount = 0,
            };

            repoQ.InsertInActiveSubject(newSubject);

            return(Ok(new { Message = $"Created!", SubjectId = subjectId }));
        }