示例#1
0
        /// <summary>
        /// 新增/编辑
        /// </summary>
        /// <param name="companyId">父编号</param>
        /// <param name="departmentId">部门主键编号</param>
        /// <returns></returns>
        public ActionResult Edit(string companyId, string departmentId)
        {
            var entity = new CrmDepartmentEntity();

            if (!string.IsNullOrEmpty(departmentId))
            {
                entity = new CrmDepartmentBll().Get(departmentId);
            }
            else if (!string.IsNullOrEmpty(companyId))
            {
                entity.CompanyId = companyId;
            }
            return(View(entity));
        }
示例#2
0
        public string SubmitDepartmentForm(CrmDepartmentEntity entity)
        {
            string rtMsrg;
            int    rtState;

            try
            {
                var  isAdd = string.IsNullOrEmpty(entity.Id);
                bool flag;
                if (isAdd)
                {
                    entity.Id        = Guid.NewGuid().ToString();
                    entity.RowStatus = (int)RowStatus.Normal;
                    entity.CreateBy  = CurrentUser.CrmUser.LoginName;
                    entity.CreatorId = CurrentUser.CrmUser.Id;
                    entity.CreateOn  = DateTime.Now;
                    entity.UpdateBy  = CurrentUser.CrmUser.LoginName;
                    entity.UpdateId  = CurrentUser.CrmUser.Id;
                    entity.UpdateOn  = DateTime.Now;
                    flag             = new CrmDepartmentBll().Add(entity) != null;
                }
                else
                {
                    entity.UpdateBy = CurrentUser.CrmUser.LoginName;
                    entity.UpdateId = CurrentUser.CrmUser.Id;
                    entity.UpdateOn = DateTime.Now;
                    flag            = new CrmDepartmentBll().Update(entity) > 0;
                }
                rtMsrg  = flag ? "保存成功" : "保存失败";
                rtState = flag ? (int)OperationState.Success : (int)OperationState.Failure;
            }
            catch (Exception ex)
            {
                rtState = (int)OperationState.Error;
                rtMsrg  = ex.Message;
            }
            var rtEntity = new StatusModel <DBNull>
            {
                rtData  = null,
                rtMsrg  = rtMsrg,
                rtState = rtState
            };

            return(CommonMethod.ToJson(rtEntity));
        }