当前位置: 代码迷 >> VB Dotnet >> 怎么批量计算并更新数据表中的扣税金额
  详细解决方案

怎么批量计算并更新数据表中的扣税金额

热度:160   发布时间:2016-04-25 02:20:40.0
如何批量计算并更新数据表中的扣税金额?
数据表中有:姓名、金额、扣税额、实付金额四个字段。姓名、金额已经有数据,如何计算并更新数据表中扣税额字段的记录
比如:
              姓名                   金额                      扣税额                    实付金额
             张三                  1000                                                                          
             李四                   5000     
             王五                       ****                                                           
如果“金额”小于或等于4000,扣税额=(1000-800)*20%=40
如果“金额”大于4000,扣税额=5000*(1-20%)*20%=800
如何将全部记录自动批量计算并更新呢?
------解决方案--------------------
Dim mlejs As String = "update yzs set  扣税额 = (金额-800)*0.2 where 销售收入 < 4001  and  金额-800>0 "
Dim mlejscommand As OleDbCommand = New OleDbCommand(mlejs, mlconn)
 mlejscommand.ExecuteNonQuery()
------解决方案--------------------
update 数据表 set 扣税额 = case when 金额<=4000 then (金额-800)*0.20 else  金额 *(1-0.20)*0.20 end
  
*****************************************************************************
签名档: http://feiyun0112.cnblogs.com/
  相关解决方案