Ejemplo n.º 1
0
        public bool EditOrgSchedule(XkSystem.Models.DbContext db, Course.Entity.tbOrg Org, string orgSchedule)
        {
            //删除之前的数据
            var delList = (from p in db.Table <Course.Entity.tbOrgSchedule>()
                           where p.tbOrg.Id == Org.Id
                           select p).ToList();

            foreach (var a in delList)
            {
                a.IsDeleted = true;
            }
            var arr = orgSchedule.Split(new char[] { ',', ',' });

            foreach (var v in arr)
            {
                var tb = new Course.Entity.tbOrgSchedule();
                if (v.Contains("["))
                {
                    var arr1 = v.Split(new char[] { '[', ']' });
                    var temp = arr1[0];
                    tb = new Course.Entity.tbOrgSchedule()
                    {
                        tbOrg        = Org,
                        tbWeek       = db.Table <Basis.Entity.tbWeek>().Where(d => temp.Contains(d.WeekName)).FirstOrDefault(),
                        tbPeriod     = db.Table <Basis.Entity.tbPeriod>().Where(d => temp.Contains(d.PeriodName)).FirstOrDefault(),
                        ScheduleType = arr1[1].Contains("单") ? Code.EnumHelper.CourseScheduleType.Odd : Code.EnumHelper.CourseScheduleType.Dual
                    };
                }
                else
                {
                    tb = new Course.Entity.tbOrgSchedule()
                    {
                        tbOrg        = Org,
                        tbWeek       = db.Table <Basis.Entity.tbWeek>().Where(d => v.Contains(d.WeekName)).FirstOrDefault(),
                        tbPeriod     = db.Table <Basis.Entity.tbPeriod>().Where(d => v.Contains(d.PeriodName)).FirstOrDefault(),
                        ScheduleType = Code.EnumHelper.CourseScheduleType.All
                    };
                }

                db.Set <Course.Entity.tbOrgSchedule>().Add(tb);
            }

            return(true);
        }
Ejemplo n.º 2
0
        public bool EditOrgSchedule(XkSystem.Models.DbContext db, Course.Entity.tbOrg Org, string[] ids)
        {
            //删除之前的数据
            var delList = (from p in db.Table <Course.Entity.tbOrgSchedule>()
                           where p.tbOrg.Id == Org.Id
                           select p).ToList();

            foreach (var a in delList)
            {
                a.IsDeleted = true;
            }

            if (ids.Length > 0)
            {
                foreach (var v in ids)
                {
                    var type = v.Split('_');
                    if (type[2] != "-1")
                    {
                        var tb = new Course.Entity.tbOrgSchedule()
                        {
                            tbOrg    = Org,
                            tbWeek   = db.Set <Basis.Entity.tbWeek>().Find(Convert.ToInt32(v.Split('_')[0])),
                            tbPeriod = db.Set <Basis.Entity.tbPeriod>().Find(Convert.ToInt32(v.Split('_')[1])),
                            //ScheduleType = type[2] == "1" ? Code.EnumHelper.CourseScheduleType.Odd : Code.EnumHelper.CourseScheduleType.Dual
                        };
                        switch (type[2])
                        {
                        case "1": tb.ScheduleType = Code.EnumHelper.CourseScheduleType.Odd; break;

                        case "2": tb.ScheduleType = Code.EnumHelper.CourseScheduleType.Dual; break;

                        default: tb.ScheduleType = Code.EnumHelper.CourseScheduleType.All; break;
                        }

                        db.Set <Course.Entity.tbOrgSchedule>().Add(tb);
                    }
                }
            }

            return(true);
        }