Exemple #1
0
        public ActionResult Edit(FormCollection fc, int id)
        {
            //首次访问

            if (fc.Count == 0)
            {
                var vdepartment = SysDepartmentService.GetDepartment(d => d.Id == id);
                ViewBag.Department = vdepartment;
                return(View("DepartmentEdit"));
            }
            //修改提交
            ResponseMessage rmsg = new ResponseMessage();

            try
            {
                var compNum  = Session[teaCRMKeys.SESSION_USER_COMPANY_INFO_NUM].ToString();
                var depNum   = 0;
                var depOrder = 0;
                if (!String.IsNullOrEmpty(fc["DepNum"]))
                {
                    depNum = int.Parse(fc["DepNum"]);
                }
                if (!String.IsNullOrEmpty(fc["depOrder"]))
                {
                    depNum = int.Parse(fc["depOrder"]);
                }
                TSysDepartment department = new TSysDepartment
                {
                    Id         = id,
                    DepName    = fc["DepName"],
                    ParentId   = int.Parse(fc["HiddenParentId"].ToString()),
                    CompNum    = compNum,
                    DepNum     = depNum,
                    DepOrder   = depOrder,
                    CreateDate = DateTime.Now,
                    DepGoal    = fc["DepGoal"],
                    DepRespon  = fc["DepRespon"],
                    DepSkills  = fc["DepSkills"],
                    DepCourse  = fc["DepCourse"],
                    DepNote    = fc["DepNote"]
                };
                bool status = SysDepartmentService.UpdateDepartment(department);
                if (status)
                {
                    rmsg.Status = true;
                }
                else
                {
                    rmsg.Status = false;
                }
                LogHelper.Debug("部门" + department.DepName + "修改成功!");
            }
            catch (Exception ex)
            {
                LogHelper.Error("部门修改失败!", ex);
                rmsg.Status = false;
            }
            return(Json(rmsg));
        }
Exemple #2
0
        // /Apps/Settings/Department/Add/
        public ActionResult Add(FormCollection fc, int?id)
        {
            if (fc.Count == 0)
            {
                VSysDepartment vdepartment = new VSysDepartment();
                if (String.IsNullOrEmpty(id.ToString()))
                {
                    id = 0;
                }
                vdepartment.ParentId   = (int)id;
                vdepartment.ParentName = Request.QueryString["name"];
                ViewBag.Department     = vdepartment;
                return(View("DepartmentEdit"));
            }
            ResponseMessage rmsg     = new ResponseMessage();
            var             compNum  = Session[teaCRMKeys.SESSION_USER_COMPANY_INFO_NUM].ToString();
            var             depNum   = 0;
            var             depOrder = 0;

            if (!String.IsNullOrEmpty(fc["DepNum"]))
            {
                depNum = int.Parse(fc["DepNum"]);
            }
            if (!String.IsNullOrEmpty(fc["depOrder"]))
            {
                depNum = int.Parse(fc["depOrder"]);
            }

            TSysDepartment sysDepartment = new TSysDepartment()
            {
                DepName    = fc["DepName"],
                ParentId   = int.Parse(fc["HiddenParentId"].ToString()),
                CompNum    = compNum,
                DepNum     = depNum,
                DepOrder   = depOrder,
                CreateDate = DateTime.Now,
                DepGoal    = fc["DepGoal"],
                DepRespon  = fc["DepRespon"],
                DepSkills  = fc["DepSkills"],
                DepCourse  = fc["DepCourse"],
                DepNote    = fc["DepNote"]
            };
            bool status = SysDepartmentService.AddDepartment(sysDepartment);

            if (status)
            {
                rmsg.Status = true;
                rmsg.Msg    = "部门添加成功!";
            }
            else
            {
                rmsg.Status = false;
                rmsg.Msg    = "部门添加失败!";
            }
            return(Json(rmsg));
        }
Exemple #3
0
 /// <summary>
 /// 修改实体
 /// </summary>
 /// <param name="entity">实体对象</param>
 public bool UpadateEntity(TSysDepartment entity)
 {
     using (teaCRMDBContext db = new teaCRMDBContext())
     {
         int rows = db.TSysDepartments.Update(entity);
         if (rows > 0)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
Exemple #4
0
 /// <summary>
 /// 添加实体
 /// </summary>
 /// <param name="entity">实体对象</param>
 public bool InsertEntity(TSysDepartment entity)
 {
     using (UCDbContext db = new UCDbContext())
     {
         int rows = db.TSysDepartments.Insert(entity);
         if (rows > 0)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
Exemple #5
0
 /// <summary>
 /// 删除实体
 /// </summary>
 /// <param name="predicate">Lamda表达式</param>
 public bool DeleteEntity(Expression <Func <TSysDepartment, bool> > predicate)
 {
     using (teaCRMDBContext db = new teaCRMDBContext())
     {
         TSysDepartment entity = db.TSysDepartments.Where(predicate).First();
         int            rows   = db.TSysDepartments.Delete(entity);
         if (rows > 0)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
        /// <summary>
        /// 修改信息  2014-11-05 20:23:33 By 唐有炜
        /// </summary>
        /// <param name="id">id</param>
        /// <param name="TSysDepartment">TSysDepartment</param>
        /// <returns>添加状态</returns>
        public bool EditSysDepartment(TSysDepartment SysDepartment)
        {
            var status = false;

            try
            {
                status = TSysDepartmentDao.UpdateEntity(SysDepartment);
            }
            catch (Exception ex)
            {
                LogHelper.Error("获取SysDepartment失败。", ex);
                status = false;
            }

            return(status);
        }
Exemple #7
0
 /// <summary>
 /// 添加部门信息 2014-09-07 14:58:50 By 唐有炜
 /// </summary>
 /// <param name="sysDepartment"></param>
 /// <returns></returns>
 public bool AddDepartment(TSysDepartment sysDepartment)
 {
     return(SysDepartmentDao.InsertEntity(sysDepartment));
 }
Exemple #8
0
 /// <summary>
 /// 修改部门信息 2014-09-07 14:58:50 By 唐有炜
 /// </summary>
 /// <param name="sysDepartment"></param>
 /// <returns></returns>
 public bool UpdateDepartment(TSysDepartment sysDepartment)
 {
     return(SysDepartmentDao.UpadateEntity(sysDepartment));
 }