public ResponseCustomDataDelete CustomDataDelete(RequestCustomDataDelete request) { ResponseCustomDataDelete response = new ResponseCustomDataDelete(); using (cnn = GetConnection()) { var ts = cnn.BeginTransaction(); try { var detail = cnn.Query <TKS_FAS_CaculateHelperDetail>(@"select * from TKS_FAS_CaculateHelperDetail where id=@Id", request.Data, ts).FirstOrDefault(); if (detail != null) { var doc = cnn.Query(@"select * from TKS_FAS_DocDetail where CalItem1=@CalItem1 and CalValue1=@CalValue1", new { CalItem1 = detail.ParentId, CalValue1 = detail.Code }, ts); if (doc.Count() > 0) { throw new NormalException("辅助核算项已使用,不可删除"); } } cnn.Execute("delete from TKS_FAS_CaculateHelperDetail where id=@Id", request.Data, ts); ts.Commit(); response.IsSuccess = true; response.Message = "删除成功"; return(response); } catch (Exception ex) { ts.Rollback(); return(this.DealException(response, ex) as ResponseCustomDataDelete); } } }
public ResponseCustomDataDelete CustomDataDelete([FromBody] RequestCustomDataDelete request) { try { CustomDataBLL bll = new CustomDataBLL(); return(bll.CustomDataDelete(request)); } catch (Exception ex) { throw new HttpResponseException( Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message)); } }