コード例 #1
0
        public JsonResult EditClass(string id, string Title, string TraningId, string PlanId, string SignUpStartTime, string SignUpEndTime
            , string OpenClassFrom, string OpenClassTo, string ClassForm, string LimitPeopleCnt, string Address
            , string Content, string Subject, string StudyLevel, string TeachGrade, string TeachRank, string OrganRange
            , string Status)
        {
            try
            {
                var bll = new Class_DetailBLL();
                var model = bll.GetModel(id.ToInt());
                model.Title = Title;
                model.TraningId = TraningId.ToInt();
                model.PlanId = PlanId.ToInt();
                model.SignUpStartTime = SignUpStartTime.ToDateTime();
                model.SignUpEndTime = SignUpEndTime.ToDateTime();
                model.OpenClassFrom = OpenClassFrom.ToDateTime();
                model.OpenClassTo = OpenClassTo.ToDateTime();
                model.ClassForm = ClassForm.ToInt();
                model.People = 0;
                model.LimitPeopleCnt = LimitPeopleCnt.ToInt();
                model.Address = Address;
                model.Content = Content;
                model.Subject = Subject.Contains("all") ? true : false;
                model.StudyLevel = StudyLevel.Contains("all") ? true : false; ;
                model.TeachGrade = TeachGrade.Contains("all") ? true : false; ;
                model.TeachRank = TeachRank.Contains("all") ? true : false;
                model.OrganRange = OrganRange.Contains("all") ? "0" : OrganRange; ;
                model.ManagerId = SiteCache.Instance.ManagerId;
                model.Status = Status.ToInt();
                model.CreateDate = DateTime.Now;

                bll.Update(model);

                Member_ClassRegisterBLL member_ClassRegisterBLL = new Member_ClassRegisterBLL();
                List<Member_ClassRegister> member_ClassRegisterList = member_ClassRegisterBLL.GetList("ClassId='" + id + "'", "");
                if (member_ClassRegisterList != null && member_ClassRegisterList.Count > 0)
                {
                    foreach (Member_ClassRegister m in member_ClassRegisterList)
                    {
                        m.Delflag = true;
                        member_ClassRegisterBLL.Update(m);
                    }
                }

                if (!model.StudyLevel)//不是全部则建立关联数据
                {

                    var arr = StudyLevel.Split(',');
                    var section = new Class_StudySectionBLL();

                    var oldSection = section.GetList(" Delflag=0 and ClassId=" + model.Id, "");
                    foreach (var old in oldSection)
                    {
                        var oldId = old.StudySection.ToString();
                        var exists = arr.Where(s => s == oldId);
                        if (exists == null || exists.Count() == 0)//旧的在新的里面不存,则删除
                        {
                            old.Delflag = true;
                            section.Update(old);
                        }
                    }
                    foreach (var item in arr)//新的在旧的里面不存在,则新加
                    {
                        var newid = item.ToInt();
                        var exists = oldSection.Where(s => s.StudySection == newid && s.Delflag == false);
                        if (exists == null || exists.Count() == 0)//
                        {
                            var classSection = new Dianda.AP.Model.Class_StudySection();
                            classSection.ClassId = model.Id;
                            classSection.CreateDate = DateTime.Now;
                            classSection.Delflag = false;
                            classSection.StudySection = item.ToInt();
                            section.Add(classSection);
                        }

                    }
                }
                if (!model.Subject)//不是全部则建立关联数据
                {
                    var arr = Subject.Split(',');
                    var section = new Class_TeachSubjectBLL();
                    var oldSection = section.GetList(" Delflag=0 and ClassId=" + model.Id, "");
                    foreach (var old in oldSection)
                    {
                        var oldId = old.TeachSubject.ToString();
                        var exists = arr.Where(s => s == oldId);
                        if (exists == null || exists.Count() == 0)//旧的在新的里面不存,则删除
                        {
                            old.Delflag = true;
                            section.Update(old);
                        }
                    }
                    foreach (var item in arr)
                    {
                        var newid = item.ToInt();
                        var exists = oldSection.Where(s => s.TeachSubject == newid && s.Delflag == false);
                        if (exists == null || exists.Count() == 0)//
                        {
                            var teachSubject = new Dianda.AP.Model.Class_TeachSubject();
                            teachSubject.ClassId = model.Id;
                            teachSubject.CreateDate = DateTime.Now;
                            teachSubject.Delflag = false;
                            teachSubject.TeachSubject = item.ToInt();
                            section.Add(teachSubject);
                        }
                    }
                }
                if (!model.TeachGrade)//不是全部则建立关联数据
                {
                    var arr = TeachGrade.Split(',');
                    var section = new Class_TeachGradeBLL();
                    var oldSection = section.GetList(" Delflag=0 and ClassId=" + model.Id, "");
                    foreach (var old in oldSection)
                    {
                        var oldId = old.TeachGrade.ToString();
                        var exists = arr.Where(s => s == oldId);
                        if (exists == null || exists.Count() == 0)//旧的在新的里面不存,则删除
                        {
                            old.Delflag = true;
                            section.Update(old);
                        }
                    }
                    foreach (var item in arr)
                    {
                        var newid = item.ToInt();
                        var exists = oldSection.Where(s => s.TeachGrade == newid && s.Delflag == false);
                        if (exists == null || exists.Count() == 0)//
                        {
                            var classSection = new Dianda.AP.Model.Class_TeachGrade();
                            classSection.ClassId = model.Id;
                            classSection.CreateDate = DateTime.Now;
                            classSection.Delflag = false;
                            classSection.TeachGrade = item.ToInt();
                            section.Add(classSection);
                        }
                    }
                }

                if (!model.TeachRank)//不是全部则建立关联数据
                {
                    var arr = TeachRank.Split(',');
                    var section = new Class_TeachRankBLL();
                    var oldSection = section.GetList(" Delflag=0 and ClassId=" + model.Id, "");
                    foreach (var old in oldSection)
                    {
                        var oldId = old.TeachRank.ToString();
                        var exists = arr.Where(s => s == oldId);
                        if (exists == null || exists.Count() == 0)//旧的在新的里面不存,则删除
                        {
                            old.Delflag = true;
                            section.Update(old);
                        }
                    }
                    foreach (var item in arr)
                    {
                        var newid = item.ToInt();
                        var exists = oldSection.Where(s => s.TeachRank == newid && s.Delflag == false);
                        if (exists == null || exists.Count() == 0)//
                        {
                            var classSection = new Dianda.AP.Model.Class_TeachRank();
                            classSection.ClassId = model.Id;
                            classSection.CreateDate = DateTime.Now;
                            classSection.Delflag = false;
                            classSection.TeachRank = item.ToInt();
                            section.Add(classSection);
                        }
                    }
                }

                if (Status == "2")//为提交状态时,新建审核记录
                {
                    var apply = new Dianda.AP.Model.Class_ApplyApplication();
                    apply.ClassId = id.ToInt();
                    apply.AccountId = SiteCache.Instance.LoginInfo.UserId;
                    apply.Remark = "提交审核";
                    apply.CreateDate = DateTime.Now;
                    var applyBll = new Class_ApplyApplicationBLL();
                    applyBll.Add(apply);
                }
                return Json(new { Code = 0, Msg = "提交成功" }, JsonRequestBehavior.AllowGet);
            }
            catch (Exception ex)
            {
                return Json(new { Code = -1, Msg = ex.Message }, JsonRequestBehavior.AllowGet);
            }
        }
コード例 #2
0
        public JsonResult CreateClass(string Title, string TraningId, string PlanId, string SignUpStartTime, string SignUpEndTime
            , string OpenClassFrom, string OpenClassTo, string ClassForm, string People, string LimitPeopleCnt, string Address
            , string Content, string Subject, string StudyLevel, string TeachGrade, string TeachRank, string OrganRange
            , string OrganId, string Status, string PartitionId)
        {
            try
            {
                var model = new Dianda.AP.Model.Class_Detail();
                model.Title = Title;
                model.TraningId = TraningId.ToInt();
                model.PlanId = PlanId.ToInt();
                model.SignUpStartTime = SignUpStartTime.ToDateTime();
                model.SignUpEndTime = SignUpEndTime.ToDateTime();
                model.OpenClassFrom = OpenClassFrom.ToDateTime();
                model.OpenClassTo = OpenClassTo.ToDateTime();
                model.ClassForm = ClassForm.ToInt();
                model.People = People.ToInt();
                model.LimitPeopleCnt = LimitPeopleCnt.ToInt();
                model.Address = Address;
                model.Content = Content;
                model.Subject = Subject.Contains("all") ? true : false;
                model.StudyLevel = StudyLevel.Contains("all") ? true : false; ;
                model.TeachGrade = TeachGrade.Contains("all") ? true : false; ;
                model.TeachRank = TeachRank.Contains("all") ? true : false;
                model.OrganRange = OrganRange.Contains("all") ? "0" : OrganRange; ;
                model.ManagerId = SiteCache.Instance.ManagerId;
                model.Status = Status.ToInt();
                model.CreateDate = DateTime.Now;
                model.OrganId = OrganId.ToInt();
                model.PartitionId = PartitionId.ToInt();
                model.Display = true;
                var bll = new Dianda.AP.BLL.Class_DetailBLL();
                var cid = bll.Add(model);

                if (!model.Subject)//不是全部则建立关联数据
                {
                    var arr = Subject.Split(',');
                    var subject = new Class_TeachSubjectBLL();

                    foreach (var item in arr)
                    {
                        var classSubject = new Dianda.AP.Model.Class_TeachSubject();
                        classSubject.ClassId = cid;
                        classSubject.CreateDate = DateTime.Now;
                        classSubject.Delflag = false;
                        classSubject.TeachSubject = item.ToInt();
                        subject.Add(classSubject);
                    }
                }
                if (!model.StudyLevel)//不是全部则建立关联数据
                {
                    var arr = StudyLevel.Split(',');

                    foreach (var item in arr)
                    {
                        var section = new Class_StudySectionBLL();
                        var teachSection = new Dianda.AP.Model.Class_StudySection();
                        teachSection.ClassId = cid;
                        teachSection.CreateDate = DateTime.Now;
                        teachSection.Delflag = false;
                        teachSection.StudySection = item.ToInt();
                        section.Add(teachSection);
                    }
                }
                if (!model.TeachGrade)//不是全部则建立关联数据
                {
                    var arr = TeachGrade.Split(',');
                    var section = new Class_TeachGradeBLL();
                    foreach (var item in arr)
                    {
                        var classSection = new Dianda.AP.Model.Class_TeachGrade();
                        classSection.ClassId = cid;
                        classSection.CreateDate = DateTime.Now;
                        classSection.Delflag = false;
                        classSection.TeachGrade = item.ToInt();
                        section.Add(classSection);
                    }
                }
                if (!model.TeachRank)//不是全部则建立关联数据
                {
                    var arr = TeachRank.Split(',');
                    var section = new  Class_TeachRankBLL();
                    foreach (var item in arr)
                    {
                        var classSection = new Dianda.AP.Model.Class_TeachRank();
                        classSection.ClassId = cid;
                        classSection.CreateDate = DateTime.Now;
                        classSection.Delflag = false;
                        classSection.TeachRank = item.ToInt();
                        section.Add(classSection);
                    }
                }
                if (Status == "2")//为提交状态时,新建审核记录
                {
                    var apply = new Dianda.AP.Model.Class_ApplyApplication();
                    apply.ClassId = cid;
                    apply.AccountId = SiteCache.Instance.LoginInfo.UserId;
                    apply.Remark = "提交审核";
                    apply.CreateDate = DateTime.Now;
                    var applyBll = new Class_ApplyApplicationBLL();
                    applyBll.Add(apply);
                }
                return Json(new { Code = 0, Msg = "提交成功" }, JsonRequestBehavior.AllowGet);
            }
            catch (Exception ex)
            {
                return Json(new { Code = -1, Msg = ex.Message }, JsonRequestBehavior.AllowGet);
            }
        }