예제 #1
0
        /// <summary>
        /// 插入月度数据库
        /// </summary>
        /// <param name="model"></param>
        public void InsertTr_MonthPlan(Tr_MonthPlan model)
        {
            using (IDbConnection conn = OpenConnection())
            {
                const string sql   = @"INSERT INTO dbo.Tr_MonthPlan
	                            (
	                            Year,
	                            Month,
	                            LastUpdateTime,
	                            UserId,
	                            PublishFlag,
	                            IsDelete
	                            )
                            VALUES 
	                            (
	                            @year,
	                            @month,
	                            getdate(),
	                            @userid,
	                            0,
	                            0
	                            );SELECT @@IDENTITY as ID "    ;
                var          param = new
                {
                    year   = model.Year,
                    month  = model.Month,
                    userid = model.UserId
                };
                dynamic list = conn.Query <dynamic>(sql, param).FirstOrDefault();
                model.Id = decimal.ToInt32(list.ID);
            }
        }
예제 #2
0
        /// <summary>
        /// 添加月度计划,月计划和课程的关联
        /// </summary>
        /// <returns></returns>
        public JsonResult AddMonthPlanAndCourse()
        {
            try
            {
                var     monPlan  = Request.Form["monPlan"];
                dynamic plandata = Newtonsoft.Json.JsonConvert.DeserializeObject(monPlan);

                var plan = new Tr_MonthPlan()
                {
                    Id     = plandata.id,
                    Year   = plandata.year,
                    Month  = plandata.month,
                    UserId = CurrentUser.UserId
                };

                var monthPlanID = plan.Id;
                var dic         = new Dictionary <int, int>();

                //添加新课程之后的ID
                var newAddCourseID = "";
                var publish        = 0;

                if (!Imonth.IsExistMonplan(plan.Year, plan.Month, monthPlanID))
                {
                    if (monthPlanID == 0)
                    {
                        Imonth.InsertTr_MonthPlan(plan);
                        monthPlanID = plan.Id;
                    }
                    else
                    {
                        var Smonth = Imonth.Get(monthPlanID);
                        publish = Smonth == null ? 0 : Smonth.PublishFlag;
                        string courses = plandata.deleteCourse;
                        //如果是修改,需要添加新的课程的话,先把课程全部删了,我厉害吧
                        if (!string.IsNullOrEmpty(courses))
                        {
                            DeleteMonPlanCourse(monthPlanID, courses);
                        }
                    }

                    #region 添加课程 课程与计划的关联
                    if (plandata.newCourse.Count > 0)
                    {
                        for (int i = 0; i < plandata.newCourse.Count; i++)
                        {
                            Co_Course course = new Co_Course()
                            {
                                Code          = plandata.newCourse[i].Code,
                                CourseName    = plandata.newCourse[i].CourseName,
                                PreCourseTime = plandata.newCourse[i].PreCourseTime,
                                OpenLevel     = plandata.newCourse[i].OpenLevel,
                                IsMust        = plandata.newCourse[i].IsMust,
                                Way           = plandata.newCourse[i].Way,
                                Teacher       = plandata.newCourse[i].teacher,
                                SurveyPaperId = plandata.newCourse[i].id,
                                Year          = plandata.year,
                                Month         = plandata.month,
                                Publishflag   = publish,
                                Day           = 0,
                                CourseFrom    = 1,
                                CourseLength  = plandata.newCourse[i].CourseLength,
                                IsCPA         = plandata.newCourse[i].IsCPA,
                                RoomId        = plandata.newCourse[i].roomID,
                                IsSystem      = plandata.newCourse[i].IsSystem,
                                IsYearPlan    = 0
                            };
                            course.CourseName = course.CourseName.HtmlDecode();
                            Imonth.InsertCo_Course(course);

                            if (course.Id > 0 && monthPlanID > 0)
                            {
                                var model = new Tr_MonthPlanCourse()
                                {
                                    MonthId  = monthPlanID,
                                    CourseId = course.Id,
                                    IsSystem = plandata.newCourse[i].IsSystem
                                };
                                Imonth.InsertTr_MonthPlanCourse(model);
                            }
                        }
                    }
                    #endregion

                    return(Json(new
                    {
                        result = 1,
                        monthPlanID = monthPlanID,
                        content = "添加成功"
                    }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new
                    {
                        result = 0,
                        content = plan.Year + "年" + plan.Month + ":此月度计划已经存在,请选择其他的时间"
                    }, JsonRequestBehavior.AllowGet));
                }
            }
            catch
            {
                return(Json(new
                {
                    result = 0,
                    content = "添加失败"
                }, JsonRequestBehavior.AllowGet));
            }
        }
예제 #3
0
 /// <summary>
 /// 插入月度数据库
 /// </summary>
 /// <param name="model"></param>
 public void InsertTr_MonthPlan(Tr_MonthPlan model)
 {
     monthDB.InsertTr_MonthPlan(model);
 }