public ResponseDocNOGet GetNextDocNO(RequestDocNOGet request) { using (cnn = GetConnection()) { ResponseDocNOGet res = new ResponseDocNOGet(); DateTime docDate = DateTime.Parse(request.DocDate); PeriodBLL periodBLL = new PeriodBLL(cnn); var user = this.UserInfoGet(request.Token, null); AccountSetBLL accountSetBLL = new AccountSetBLL(cnn); var activePeriod = accountSetBLL.GetActivePeriod(user.AccountId, null); if ((activePeriod.Year == docDate.Year && activePeriod.Month > docDate.Month) || activePeriod.Year > docDate.Year) { res.IsSuccess = false; res.Message = "该期别,不可新增凭证"; return(res); } var period = cnn.QueryFirstOrDefault <TKS_FAS_MonthPeriodInfo>("select * from TKS_FAS_MonthPeriodInfo where Year=@Year and AccountId=@AccountId and Month=@Month", new { Year = docDate.Year, Month = docDate.Month, AccountId = user.AccountId }, null); string no = string.Empty; if (period == null) { no = "1"; } else { string sql = @"select (case when max(pzzno) is null then 0 else max(pzzno) end) from TKS_FAS_Doc where accountid=@AccountId and periodId=@PeriodId"; var max = cnn.ExecuteScalar(sql, new { AccountId = user.AccountId, PeriodId = period.Id }, null); no = (int.Parse(max.ToString()) + 1).ToString(); } res.NO = no; res.IsSuccess = true; return(res); } }
public ResponseDocNOGet GetNextDocNO([FromBody] RequestDocNOGet request) { try { DocBLL bll = new DocBLL(); return(bll.GetNextDocNO(request)); } catch (Exception ex) { throw new HttpResponseException( Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message)); } }