示例#1
0
        /// <summary>
        /// 删除计划
        /// </summary>
        /// <param name="plan"></param>
        /// <returns></returns>
        public int Delete(CIVersionPlan plan)
        {
            const string sql = "DELETE FROM CIVersionPlan WHERE ID=@ID ";

            using (var conn = new DapperHelper().OpenConnection())
            {
                return(conn.Execute(sql, new { ID = plan.ID }));
            }
        }
示例#2
0
        /// <summary>
        /// 新增一个计划
        /// </summary>
        /// <param name="plan"></param>
        /// <returns></returns>
        public int Insert(CIVersionPlan plan)
        {
            var sql = @"INSERT INTO CIVersionPlan (ID,BeginTime,EndTime,PlanCode,Status,Note,AddTime,UpdateTime,UserName,OpenDate)
                                          VALUES (@ID,@BeginTime,@EndTime,@PlanCode,@Status,@Note,@AddTime,@UpdateTime,@UserName,@OpenDate)";

            using (var conn = new DapperHelper().OpenConnection())
            {
                return(conn.Execute(sql, plan));
            }
        }
示例#3
0
        /// <summary>
        /// 更新计划
        /// </summary>
        /// <param name="plan"></param>
        /// <returns></returns>
        public int Update(CIVersionPlan plan)
        {
            const string sql = @"UPDATE CIVersionPlan SET
				                                        BeginTime = @BeginTime,	
				                                        EndTime = @EndTime,	
				                                        PlanCode = @PlanCode,	
				                                        Status = @Status,	
				                                        Note = @Note,	
				                                        UpdateTime = @UpdateTime,	
				                                        UserName = @UserName,
				                                        OpenDate = @OpenDate
				                       WHERE ID=@ID"                            ;

            using (var conn = new DapperHelper().OpenConnection())
            {
                return(conn.Execute(sql, plan));
            }
        }
示例#4
0
 public PlanModel()
 {
     plan = new CIVersionPlan();
 }
示例#5
0
 public CheckItemModel()
 {
     CheckItem      = new CICheckItem();
     plan           = new CIVersionPlan();
     PlanSelectItem = new List <SelectListItem>();
 }
示例#6
0
 /// <summary>
 /// 更新计划
 /// </summary>
 /// <param name="plan"></param>
 /// <returns></returns>
 public int UpdateVersionPlan(CIVersionPlan plan)
 {
     return(_planRepository.Update(plan));
 }
示例#7
0
 /// <summary>
 /// 新增计划
 /// </summary>
 /// <param name="plan"></param>
 /// <returns></returns>
 public int InsertVersionPlan(CIVersionPlan plan)
 {
     return(_planRepository.Insert(plan));
 }
示例#8
0
        public ActionResult Edit(CIVersionPlan plan)
        {
            var model = new PlanModel();

            model.plan = plan;
            bool success = true;

            #region 格式验证
            if (string.IsNullOrEmpty(plan.BeginTime) || string.IsNullOrEmpty(plan.EndTime))
            {
                ErrorNotification("请选择时间范围");
                return(View(model));
            }
            if (string.IsNullOrEmpty(plan.OpenDate))
            {
                ErrorNotification("请选择开放时间");
                return(View(model));
            }
            if (string.IsNullOrEmpty(plan.Note))
            {
                ErrorNotification("请填写计划说明");
                return(View(model));
            }
            #endregion

            //新增计划
            if (string.IsNullOrEmpty(plan.ID))
            {
                plan.AddTime    = DateTime.Now;
                plan.UpdateTime = DateTime.Now;
                plan.UserName   = CurrentUser.UserName;
                var begintime = Convert.ToDateTime(plan.BeginTime);
                var endtime   = Convert.ToDateTime(plan.EndTime);
                plan.PlanCode = "CCMS" + begintime.ToString("yyyyMMdd").Substring(2, 6) + "_" + endtime.ToString("yyyyMMdd").Substring(2, 6);
                int num = 0;
                if (success)
                {
                    plan.ID = Guid.NewGuid().ToString();
                    num     = _planService.InsertVersionPlan(plan);
                }
                if (num > 0)
                {
                    SuccessNotification("添加成功");
                }
                else
                {
                    ErrorNotification("添加失败");
                    return(View(model));
                }
            }
            else//修改计划
            {
                var oldmodel = _planService.GetPlan(plan.ID);;
                plan.AddTime    = oldmodel.AddTime;
                plan.UpdateTime = DateTime.Now;
                plan.UserName   = oldmodel.UserName;
                int num = 0;
                if (success)
                {
                    num = _planService.UpdateVersionPlan(plan);
                }
                if (num > 0)
                {
                    SuccessNotification("修改成功");
                }
                else
                {
                    ErrorNotification("修改失败");
                    return(View(model));
                }
            }
            if (success)
            {
                return(Redirect(Url.Action("list", "plan")));
            }
            else
            {
                return(View(model));
            }
        }