/// <summary>
        /// 编辑财务应收应付
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public int Edit(FinanceBillEntity entity)
        {
            if (entity.CateNum.IsNotEmpty())
            {
                List <FinanceCateEntity> listCate = new FinanceCateProvider(this.CompanyID).GetList();
                if (!listCate.IsNullOrEmpty())
                {
                    FinanceCateEntity cate = listCate.FirstOrDefault(a => a.SnNum == entity.CateNum);
                    entity.CateName = cate != null ? cate.CateName : string.Empty;
                }
            }
            entity.Include(a => new { a.CateNum, a.CateName, a.BillType, a.FromNum, a.FromName, a.ToNum, a.ToName, a.Amount, a.PrePayCount, a.PrePayRate, a.RealPayCount, a.LastTime, a.Title, a.ContractSn, a.ContractNum, a.Remark });
            entity.Where(a => a.SnNum == entity.SnNum).And(a => a.CompanyID == this.CompanyID);
            int line = this.FinanceBill.Update(entity);

            return(line);
        }
        /// <summary>
        /// 新增应收应付
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public int Add(FinanceBillEntity entity)
        {
            entity.SnNum      = ConvertHelper.NewGuid();
            entity.BillNum    = entity.BillNum.IsEmpty() ? DateTime.Now.ToString("yyyyMMdd") + new TNumProvider(this.CompanyID).GetSwiftNumByDay(typeof(FinanceBillEntity), 4) : entity.BillNum;
            entity.CreateTime = DateTime.Now;
            entity.IsDelete   = (int)EIsDelete.NotDelete;
            entity.Status     = (int)EFinanceStatus.Wait;
            entity.CompanyID  = this.CompanyID;
            if (entity.CateNum.IsNotEmpty())
            {
                List <FinanceCateEntity> listCate = new FinanceCateProvider(this.CompanyID).GetList();
                if (!listCate.IsNullOrEmpty())
                {
                    FinanceCateEntity cate = listCate.FirstOrDefault(a => a.SnNum == entity.CateNum);
                    entity.CateName = cate != null ? cate.CateName : string.Empty;
                }
            }
            entity.IncludeAll();
            int line = this.FinanceBill.Add(entity);

            return(line);
        }