コード例 #1
0
        public object Put(FaPiaoModel model)
        {
            var fapiao = _fapiaoService.GetFaPiao(model.Id);
            if (fapiao == null)
            {
                return Failed("找不到发票");
            }
            if (string.IsNullOrEmpty(model.Code))
            {
                return Failed("发票编号不能为空");
            }
            if (model.Code.Trim().Length != 8)
            {
                return Failed("发票编号只能是8位");
            }
            try
            {
                fapiao.Code = model.Code.Trim();
                _fapiaoService.Update();
                return Success();
            }
            catch (Exception ex)
            {

                return Failed(ex.Message);
            }
        }
コード例 #2
0
        public object Post(FaPiaoModel model)
        {
            var finance = _financeService.GetFinance(model.FinanceId);
            if (finance == null)
            {
                return Failed("找不到收款");
            }
            if (string.IsNullOrEmpty(model.Code))
            {
                return Failed("发票编号不能为空");
            }
            if (model.Code.Trim().Length != 8)
            {
                return Failed("发票编号只能是8位");
            }
            if (_fapiaoService.GetFaPiaos().Any(p => p.Code == model.Code.Trim()))
            {
                return Failed("发票编号重复");
            }
            try
            {
                _fapiaoService.Insert(new FaPiao
                {
                    Id = Guid.NewGuid(),
                    Code = model.Code.Trim(),
                    FinanceId = model.FinanceId
                });
                return Success();
            }
            catch (Exception ex)
            {
                return Failed(ex.Message);
            }

        }