public ResponseSupplierUpdate SupplierUpdate([FromBody] RequestSupplierUpdate request) { try { SupplierBLL bll = new SupplierBLL(); return(bll.SupplierUpdate(request)); } catch (Exception ex) { throw new HttpResponseException( Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message)); } }
public ResponseSupplierUpdate SupplierUpdate(RequestSupplierUpdate request) { ResponseSupplierUpdate response = new ResponseSupplierUpdate(); using (cnn = GetConnection()) { var ts = cnn.BeginTransaction(); try { var user = this.UserInfoGetButAccount(request.Token, ts); var d = cnn.Query(@"select * from tks_fas_Supplier where supplierId=@SupplierId and orgId=@OrgId", new { SupplierId = request.Data.SupplierId, OrgId = user.Node.CreditCode }, ts); if (d.Count() > 0) { throw new NormalException("兼职会计已经存在"); } string sql = @"update tks_fas_Supplier set supplierId=@SupplierId, supplierName=@SupplierName where id=@Id"; var r = cnn.Execute(sql, request.Data, ts); if (r == 1) { ts.Commit(); response.IsSuccess = true; response.Message = "更新成功"; return(response); } else { throw new AppException(user.User.UserName, "SupplierUpdate", "数据更新异常", r + "行数据被更新"); } } catch (Exception ex) { ts.Rollback(); return(this.DealException(response, ex) as ResponseSupplierUpdate); } } }