vb access 
如何实现在输入订单的时候,实现产品库存的自动更新?
产品信息表中有“库存”字段,订单中有“订货数量”字段。
大家帮帮忙,谢谢了。

解决方案 »

  1.   

    'Add Ticket Release Table Record and Update Master Label Table,Update PS_TICKET_DTL Table
    Public Function UpdatePSTicketTables(ByVal strArinvtID As String, ByVal strPsTicketDtlID As String, ByVal strModuleSN As String)
        Dim strTicketRelID As String
        'add record to pick ticket release table
        Dim InstSql As String
        Dim InstCommand As New ADODB.command
        
        strTicketRelID = GetPsTicketRelID()    
        
        'update master label table for this Serial/Inventory item.
        InstSql = "update iqms.master_label " + _
                    "set orderno='" + Trim(lblSalesOrderNumber.Caption) + "'," + _
                    "pono='" + Trim(lblCustomerPONumber.Caption) + "'," + _
                    "ps_ticket_rel_id=" + strTicketRelID + "," + _
                    "ps_ticket_dtl_id=" + Trim(lblPSDtlTicketID.Caption) + _
                    "where serial='" + Trim(strModuleSN) + "' and arinvt_id=" + Trim(strArinvtID)    InstCommand.ActiveConnection = Conn
        InstCommand.CommandType = adCmdText
        InstCommand.CommandText = InstSql
        InstCommand.Execute
        
    End Function
      

  2.   

    补充,订单分几种订单,可能是 Forecast Sales Order,就扣库存数量,逻辑不对,或者不能是库存数量。订单一般分为三张主要的 Table(Order、Order_Detail、Order_Release),那么 Detail Table 中有包括库存料号的 ID ,也就是通过 Inventory ID 来对其“库存”进行更新,请参考如上的代码。
      

  3.   

    SQL语句使用Update来实现;逻辑更新,"库存数量" 先加上原值,再减去新值。