把欲消耗的數量,當成參數丟給SQL去計算就行了吧....
SQL應該是這樣吧...
<pre class="c" name="code">
SELECT a.[code],a.[hokan],a.[zaik],b.[siyou]*@useage AS [consum], a.[zaik]-b.[siyou]*@useage AS [shortage]
FROM [zaik] a JOIN [prts] b ON a.[code]=b.[kcode];
然後,用你的asp.net,把參數@usage帶進去就可以了...
沒猜錯的話...siyou應該是個倍數參數...所以我這樣寫。