Exemplo n.º 1
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);
        }
Exemplo n.º 2
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;
         }
     }
 }
 /// <summary>
 /// 添加部门信息 2014-09-07 14:58:50 By 唐有炜
 /// </summary>
 /// <param name="sysDepartment"></param>
 /// <returns></returns>
 public bool AddDepartment(TSysDepartment sysDepartment)
 {
     return SysDepartmentDao.InsertEntity(sysDepartment);
 }
Exemplo n.º 4
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);
        }
 /// <summary>
 /// 修改部门信息 2014-09-07 14:58:50 By 唐有炜
 /// </summary>
 /// <param name="sysDepartment"></param>
 /// <returns></returns>
 public bool UpdateDepartment(TSysDepartment sysDepartment)
 {
     return SysDepartmentDao.UpadateEntity(sysDepartment);
 }