예제 #1
0
        /// <summary>
        /// 添加部门
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public string AddDepartment(HttpContext context)
        {
            var departmentBll = new DepartmentBLL();
            var depId         = context.Request.Params["id"];
            var parentId      = context.Request.Params["parid"];
            var depname       = context.Request.Params["depName"];
            var department    = new Department {
                Id = depId, Name = depname, ParentDept = parentId
            };

            try
            {
                var bdata = departmentBll.Exist(department);
                switch (bdata)
                {
                case "1":
                    return("exist");

                case "0":
                    departmentBll.AddDepartment(department);
                    break;
                }
            }
            catch (Exception e)
            {
                Log.Error(e);
                return("false");
            }
            //操作日志
            if (null == context.Session[Constant.LoginUser])
            {
                return("2");
            }
            var oprlog = new OprLog
            {
                Operator   = ((Employer)(context.Session[Constant.LoginUser])).Name,
                OperResult = "成功",
                OprSrc     = "添加部门",
                LogDate    = DateTime.Now
            };

            _oprLogBll.Add(oprlog);
            return("true");
        }