我试图创建一个简单的库存库存,但我很难根据mysql的输入和输出来获取剩余库存。
我真正需要的是减去input.quantity-output.quantity的总量,其中input.material等于output.material,如果total.quantity低于安全库存,则datagridview将突出显示该行。
conn = New MySqlConnection
conn.ConnectionString = "server=localhost;userid=root;password=1234;database=inventory"
Dim searchquery As String = "Select input.DeliveryDate as 'Delivery Date',input.Material, (sum(input.Quantity) - sum(output.Quantity)) as 'Remaining Stocks' where rawmaterialsinput.Material = output.Material, safetystandard.safetystocks from inventory.input, inventory.output, inventory.safetystandard"
Dim commander As New MySqlCommand(searchquery, conn)
Dim adapter As New MySqlDataAdapter(commander)
inventorydata.Clear()
adapter.Fill(inventorydata)
inventoryDGV.DataSource = inventorydata
到目前为止,这是我正在尝试的代码,但没有希望。请帮助
我需要在datagridview中有4列,其中包含交货日期,原材料,剩余库存,安全库存。
答案 0 :(得分:0)
conn.Open()
conn = New MySqlConnection
conn.ConnectionString = "server=localhost;userid=root;password=SOUTHEAST;database=reportingsystem"
Dim searchquery As String = "Select reportingsystem.rawmaterialswarehouseandrawmaterials.Rawmaterials as 'Raw Material', reportingsystem.rawmaterialswarehouseandrawmaterials.safetystocks as 'Safety Stocks', (select sum(reportingsystem.rawmaterialsinput.Quantity) - sum(reportingsystem.rawmaterialsoutput.Quantity) from reportingsystem.rawmaterialsinput, reportingsystem.rawmaterialsoutput where reportingsystem.rawmaterialsinput.RawMaterial = reportingsystem.rawmaterialswarehouseandrawmaterials.Rawmaterials ) as 'Remaining Stocks' from reportingsystem.rawmaterialswarehouseandrawmaterials" ' JOIN reportingsystem.rawmaterialsinput.RawMaterial ON reportingsystem.rawmaterialswarehouseandrawmaterials.Rawmaterials = reportingsystem.rawmaterialsinput.RawMaterial ORDER BY reportingsystem.rawmaterialswarehouseandrawmaterials.Rawmaterials"
Dim commander As New MySqlCommand(searchquery, conn)
Dim adapter As New MySqlDataAdapter(commander)
monitoringdata.Clear()
adapter.Fill(monitoringdata)
MonitoringDGV.DataSource = monitoringdata
conn.close()
在此代码中,仅选择了3列。希望对您有帮助