Example #1
0
        public JsonResult Update(List <string> liSubjectContentCode, string coursecode, string subjectcode, List <string> liContentTypeCode)
        {
            COURSESTUDIED_BUS bus = new COURSESTUDIED_BUS();
            int ret = 0, ret1 = 0, ret2 = 0;
            COURSESTUDIED_OBJ obj_temp = null;

            if (liSubjectContentCode == null || liSubjectContentCode.Count <= 0)
            {
                ret = -1;
            }
            else
            {
                for (int i = 0; i < liSubjectContentCode.Count; i++)
                {
                    var subjectcontentcode = liSubjectContentCode[i];
                    obj_temp = bus.GetByKey(new fieldpara("SUBJECTCONTENTCODE", subjectcontentcode, 0),
                                            new fieldpara("COURSECODE", coursecode, 0));
                    if (obj_temp == null)
                    {
                        obj_temp = new COURSESTUDIED_OBJ();
                        //hết kiểm tra tồn tại bản ghi
                        obj_temp.EDITTIME           = DateTime.Now;  //Thời điểm sủa bản ghi
                        obj_temp.EDITUSER           = ses.loginCode; //Người sửa bản ghi
                        obj_temp.SUBJECTCODE        = subjectcode;
                        obj_temp.UNIVERSITYCODE     = ses.gUNIVERSITYCODE;
                        obj_temp.LOCK               = 0;
                        obj_temp.COURSECODE         = coursecode;
                        obj_temp.SUBJECTCONTENTCODE = subjectcontentcode;
                        //    obj_temp.LANG = ses.getLang();
                        //Kiểm tra tình trạng sửa hay là thêm mới
                        obj_temp.CODE     = bus.genNextCode(obj_temp);
                        obj_temp.LOCKDATE = DateTime.Now;
                        ret = bus.insert(obj_temp);
                        // nếu là bài kiểm tra thì sinh phòng thi và đề thi
                        // check xem có phải là bài kiểm tra hay ko
                        CONTENTTYPE_OBJ contentType = null;//new CONTENTTYPE_OBJ();
                        if (!string.IsNullOrEmpty(liContentTypeCode[i]))
                        {
                            CONTENTTYPE_BUS busContentType = new CONTENTTYPE_BUS();
                            contentType = busContentType.GetByID(new CONTENTTYPE_OBJ.BusinessObjectID(liContentTypeCode[i]));
                            busContentType.CloseConnection();
                        }
                        var contentTypeCode = "";
                        if (contentType != null)
                        {
                            contentTypeCode = contentType.CODEVIEW;
                        }
//Nội dung học lý thuyết: LT - Nội dung hiển thị nếu có(NOTE != null, '') thì hiển thị (Ms Cúc)
//Nội dung là bài tập: BT - Nội dung hiển thị là bài tập (mr Uyên)
//Nội dung là kiểm tra cuối giai đoạn: KT - Kiểm tra kết thúc giai đoạn (Mr Uyên)
//Nội dung là thi kết thúc môn: TH - Thi kết thúc môn (Mr Cúc)

                        if (contentTypeCode == "KT" || contentTypeCode == "BT" || contentTypeCode == "TH")
                        {
                            //Mỗi code sẽ tự động thêm vào trong subjectcontenttest một bản ghi
                            //sinh ra examhallstudent
                            //sinh ra examhall - giả
                            //sinh ra examform
                            //sinh ra examform detail
                            //
                            ExamFormController con = new ExamFormController();
                            //Tiến hành sinh đề cho cấu trúc này, và sinh viên cho phần đó

                            // lấy đợt thi và mã cấu trúc đề thi thông qua subjectcontenttest
                            List <string> result         = new SubjectContentTestController().GetBySubjectContent(subjectcontentcode);
                            var           examTimeCode   = result[0];
                            var           testStructCode = result[1];
                            ret = con.ProcessExamFormAuto(examTimeCode, coursecode, 1);
                            //// tạo phòng thi
                            //ret1 = new ExamHallStudentController().CreateExamHallStudent(examTimeCode);// , examhallstudent, examhall
                            //ArrayList resArrayList = new ExamFormController().CreateExamForm(examTimeCode, testStructCode);//cập nhật vào examform, examformdetail
                            //ret2 = (int)resArrayList[0];
                        }
                    }
                    else
                    {
                        obj_temp.LOCK = 1;
                        ret           = bus.update(obj_temp);
                    }
                }
            }
            bus.CloseConnection();
            //some thing like that
            return(Json(new { ret = ret, ret1 = ret1, ret2 = ret2 }, JsonRequestBehavior.AllowGet));
        }