Exemplo n.º 1
0
 /// <summary>
 /// 修改
 /// </summary>
 /// <returns></returns>
 public ActionResult ProjectEdit(int?id, int?parentID)
 {
     if (id != null)
     {
         WRProjectDBDataContext dbContext = new WRProjectDBDataContext();
         var project = dbContext.项目信息.SingleOrDefault((e => e.ID == id.Value));
         if (project == null)
         {
             throw new Exception("未找到id=" + id + "的项目信息");
         }
         return(View(project));
     }
     else if (parentID != null)
     {
         WRProjectDBDataContext dbContext = new WRProjectDBDataContext();
         var  parentProject = dbContext.项目信息.Where(e => e.ID == parentID.Value).SingleOrDefault();
         项目信息 project       = new 项目信息()
         {
             启用标识 = true
         };
         project.级项目信息 = parentProject;
         return(View(project));
     }
     throw new Exception("id和parentid不能同时为空");
 }
Exemplo n.º 2
0
        public ActionResult ProjectEdit(项目信息 project)
        {
            if (string.IsNullOrEmpty(project.称))
            {
                throw new ArgumentNullException("project.name");
            }

            WRProjectDBDataContext dbContext = new WRProjectDBDataContext();

            if (project.ID == 0)
            {
                //新增
                project.创建时间 = DateTime.Now;
                dbContext.项目信息.InsertOnSubmit(project);
            }
            else
            {
                //编辑
                var res = dbContext.项目信息.SingleOrDefault(e => e.ID == project.ID);
                res.称    = project.称;
                res.启用标识 = project.启用标识;
            }
            dbContext.SubmitChanges();
            return(Redirect("/wr/projectedit?id=" + project.ID));
        }
Exemplo n.º 3
0
        public ActionResult Project()
        {
            WRProjectDBDataContext dbContext = new WRProjectDBDataContext();
            var res  = dbContext.项目信息.Select(e => e).ToList();
            var tree = TreeNode.GetTree(res);

            this.ViewBag.tree = Newtonsoft.Json.JsonConvert.SerializeObject(tree);
            return(View());
        }