Ejemplo n.º 1
0
        /// <summary>
        /// 成本中心类型模板的验证
        /// </summary>
        /// <param name="entity">成本中心类型模板对象</param>
        public static string ValidateCCTTInputDto(CCTTInputDto entity)
        {
            //基础验证
            StringBuilder sb = BasicValidate <CCTTInputDto>(entity);

            //额外验证
            if (!string.IsNullOrEmpty(entity.CC_TT_AEACheckers))
            {
                string[] CheckUsers = entity.CC_TT_AEACheckers.Split(',');
                foreach (string s in CheckUsers)
                {
                    if (!userRepository.IsExists(s))
                    {
                        sb.Append("行政审批人" + s + "不在用户表中!");
                    }
                }
            }
            if (!string.IsNullOrEmpty(entity.CC_TT_FinancialCheckers))
            {
                string[] CheckUsers2 = entity.CC_TT_FinancialCheckers.Split(',');
                foreach (string s in CheckUsers2)
                {
                    if (!userRepository.IsExists(s))
                    {
                        sb.Append("财政审批人" + s + "不在用户表中!");
                    }
                }
            }
            return(sb.ToString());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 更新成本中心类型的模板
        /// </summary>
        /// <param name="entity">成本中心类型的模板对象</param>
        public ReturnInfo UpdateCC_Type_Template(CCTTInputDto entity)
        {
            ReturnInfo    RInfo        = new ReturnInfo();
            StringBuilder sb           = new StringBuilder();
            string        ValidateInfo = Helper.ValidateCCTTInputDto(entity);

            if (string.IsNullOrEmpty(ValidateInfo))
            {
                CC_Type_Template cctt = _cc_Type_TemplateRepository.GetByID(entity.CC_TT_TemplateID).FirstOrDefault();
                if (cctt != null)
                {
                    try
                    {
                        cctt.CC_TT_UpdateDate = DateTime.Now;
                        if (entity.CC_TT_AEACheckers != null)
                        {
                            cctt.CC_TT_AEACheckers = entity.CC_TT_AEACheckers;
                        }
                        if (entity.CC_TT_FinancialCheckers != null)
                        {
                            cctt.CC_TT_FinancialCheckers = entity.CC_TT_FinancialCheckers;
                        }
                        if (entity.CC_TT_TypeID != null)
                        {
                            cctt.CC_TT_TypeID = entity.CC_TT_TypeID;
                        }
                        if (entity.CC_TT_UpdateUser != null)
                        {
                            cctt.CC_TT_UpdateUser = entity.CC_TT_UpdateUser;
                        }
                        _unitOfWork.RegisterDirty(cctt);
                        bool result = _unitOfWork.Commit();
                        RInfo.IsSuccess = result;
                        RInfo.ErrorInfo = sb.ToString();
                        return(RInfo);
                    }
                    catch (Exception ex)
                    {
                        _unitOfWork.RegisterClean(cctt);
                        _unitOfWork.Rollback();
                        sb.Append(ex.Message);
                        RInfo.IsSuccess = false;
                        RInfo.ErrorInfo = sb.ToString();
                        return(RInfo);
                    }
                }
                else
                {
                    RInfo.IsSuccess = false;
                    RInfo.ErrorInfo = "找不到该成本中心类型的模板!";
                    return(RInfo);
                }
            }
            else
            {
                RInfo.IsSuccess = false;
                RInfo.ErrorInfo = sb.ToString();
                return(RInfo);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 添加成本中心类型的模板
        /// </summary>
        /// <param name="entity">成本中心类型的模板对象</param>
        public ReturnInfo AddCC_Type_Template(CCTTInputDto entity)
        {
            ReturnInfo    RInfo = new ReturnInfo();
            StringBuilder sb    = new StringBuilder();
            string        MaxID = _cc_Type_TemplateRepository.GetMaxID();
            string        NowID = Helper.GenerateIDEx("CT", MaxID);

            entity.CC_TT_TemplateID = NowID;
            string ValidateInfo = Helper.ValidateCCTTInputDto(entity);

            sb.Append(ValidateInfo);
            if (string.IsNullOrEmpty(ValidateInfo))
            {
                try
                {
                    CC_Type_Template cctt = Mapper.Map <CCTTInputDto, CC_Type_Template>(entity);
                    cctt.CC_TT_UpdateDate = DateTime.Now;
                    string MaxID2 = _cc_Type_TemplateRepository.GetMaxID();
                    string NowID2 = Helper.GenerateIDEx("CT", MaxID2);
                    cctt.CC_TT_TemplateID = NowID2;
                    _unitOfWork.RegisterNew(cctt);
                    bool result = _unitOfWork.Commit();
                    RInfo.IsSuccess = result;
                    RInfo.ErrorInfo = sb.ToString();
                    return(RInfo);
                }
                catch (Exception ex)
                {
                    _unitOfWork.Rollback();
                    sb.Append(ex.Message);
                    RInfo.IsSuccess = false;
                    RInfo.ErrorInfo = sb.ToString();
                    return(RInfo);
                }
            }
            else
            {
                RInfo.IsSuccess = false;
                RInfo.ErrorInfo = sb.ToString();
                return(RInfo);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(type) == true)
                {
                    throw new Exception("请输入类型!");
                }
                if (listAEAChecks.Count <= 0)
                {
                    throw new Exception("请输入行政审批人!");
                }
                if (listFCheckers.Count <= 0)
                {
                    throw new Exception("请输入财务审批人!");
                }

                CCTTInputDto ccTemplate = new CCTTInputDto();
                ccTemplate.CC_TT_TypeID = type;
                //行政审批人
                string AEAChecks = "";
                foreach (string checkuser in listAEAChecks)
                {
                    if (string.IsNullOrWhiteSpace(AEAChecks) == true)
                    {
                        AEAChecks = checkuser;
                    }
                    else
                    {
                        AEAChecks += "," + checkuser;
                    }
                }
                ccTemplate.CC_TT_AEACheckers = AEAChecks;
                //财务审批人
                string FCheckers = "";
                foreach (string checkuser in listFCheckers)
                {
                    if (string.IsNullOrWhiteSpace(FCheckers) == true)
                    {
                        FCheckers = checkuser;
                    }
                    else
                    {
                        FCheckers += "," + checkuser;
                    }
                }
                ccTemplate.CC_TT_FinancialCheckers = FCheckers;
                ccTemplate.CC_TT_UpdateUser        = Client.Session["U_ID"].ToString();
                ReturnInfo result;
                if (string.IsNullOrEmpty(CTempID) == false)
                {
                    ccTemplate.CC_TT_TemplateID = CTempID;
                    //更新成本中心模板信息
                    result = AutofacConfig.costCenterService.UpdateCC_Type_Template(ccTemplate);
                }
                else
                {
                    //创建成本中心模板
                    result = AutofacConfig.costCenterService.AddCC_Type_Template(ccTemplate);
                }
                //如果返回true,则创建或更新成本中心成功,否则失败并抛出错误
                if (result.IsSuccess == true)
                {
                    ShowResult = ShowResult.Yes;
                    //if (string.IsNullOrEmpty(CTempID) == true)
                    //{
                    Close();
                    //}
                    Toast("成本中心类型模板提交成功!", ToastLength.SHORT);
                }
                else
                {
                    throw new Exception(result.ErrorInfo);
                }
            }
            catch (Exception ex)
            {
                Toast(ex.Message, ToastLength.SHORT);
            }
        }