В моей программе инвентаризации было 3 таблицы в моей базе данных.
1. Вход
Колонка (идентификатор, материал, количество)
2. Выход
Колонка (идентификатор, материал, количество)
3. MaterialList (Таблица) Где я могу ввести названия материалов
Колонка (идентификатор, материал)
В моей оставшейся форме Запасов я хочу показать Оставшиеся Запасы всего Списка материалов, включая материал, который не имеет запасов.
Например:
Из MaterialList Из количества ввода и вывода
Список материалов Остальные запасы
Item1 150
item2
item3
item4 200
Я пробовал это, но надежды нет.
conn.Open()
conn = New MySqlConnection
conn.ConnectionString = "server=localhost;userid=root;password=SOUTHEAST;database=reportingsystem"
Dim searchquery As String = "select reportingsystem.rawmaterialswarehouseandrawmaterials.Rawmaterials, reportingsystem.rawmaterialswarehouseandrawmaterials.safetystocks, (Sum(reportingsystem.rawmaterialsinput.Quantity) - sum(reportingsystem.rawmaterialsoutput.Quantity)) as 'Remaining Stocks' from reportingsystem.rawmaterialsinput, reportingsystem.rawmaterialsoutput, reportingsystem.rawmaterialswarehouseandrawmaterials where reportingsystem.rawmaterialsinput.RawMaterial = reportingsystem.rawmaterialswarehouseandrawmaterials.Rawmaterials" ' JOIN reportingsystem.rawmaterialsinput.RawMaterial ON reportingsystem.rawmaterialswarehouseandrawmaterials.Rawmaterials = reportingsystem.rawmaterialsinput.RawMaterial ORDER BY reportingsystem.rawmaterialswarehouseandrawmaterials.Rawmaterials"
'Select rawmaterialsinput.DeliveryDate as 'Delivery Date', rawmaterialswarehouseandrawmaterials.Rawmaterials, (sum(rawmaterialsinput.Quantity) - sum(rawmaterialsoutput.Quantity)) as 'Quantity' , rawmaterialswarehouseandrawmaterials.safetystocks from reportingsystem.rawmaterialsinput, reportingsystem.rawmaterialsoutput, reportingsystem.rawmaterialswarehouseandrawmaterials where rawmaterialsinput.RawMaterial = rawmaterialsoutput.RawMaterial
'"Select rawmaterialswarehouseandrawmaterials.Rawmaterials as 'Raw Materials', rawmaterialswarehouseandrawmaterials.safetystocks as 'Safety Stock', (sum(rawmaterialsinput.Quantity) - sum(rawmaterialsoutput.Quantity)) as 'Remaining Stocks' where rawmaterialsinput.RawMaterial = rawmaterialswarehouseandrawmaterials.Rawmaterials FROM reportingsystem.rawmaterialswarehouseandrawmaterials, reportingsystem.rawmaterialsinput, reportingsystem.rawmaterialsoutput"
'Select rawmaterialswarehouseandmaterials.Rawmaterials, (sum(rawmaterialsinput.Quantity) - sum(rawmaterialsoutput.Quantity)) as 'Remaining Stocks', rawmaterialswarehouseandrawmaterials.safetystocks FROM reportingsystem.rawmaterialswarehouseandrawmaterials, reportingsystem.rawmaterialsinput, reportingsystem.rawmaterialsoutput JOIN input ON rawmaterialsinput.RawMaterial = rawmaterialswarehouseandrawmaterials.Rawmaterials
Dim commander As New MySqlCommand(searchquery, conn)
Dim adapter As New MySqlDataAdapter(commander)
monitoringdata.Clear()
adapter.Fill(monitoringdata)
MonitoringDGV.DataSource = monitoringdata
For Each row As DataGridViewRow In MonitoringDGV.Rows
Dim quantity As Integer = Val(row.Cells(1).Value)
Dim safetystocks As Integer = Val(row.Cells(2).Value)
If safetystocks < quantity Then
row.DefaultCellStyle.BackColor = Color.Red
ElseIf safetystocks < (quantity * 1.2) Then
row.DefaultCellStyle.BackColor = Color.Green
ElseIf safetystocks > (quantity * 1.2) Then
row.DefaultCellStyle.BackColor = Color.Green
End If
Next
conn.Close()
Что мне действительно нужно, так это показать все Название материала в столбце 1 и показать оставшиеся запасы в столбце 2.
Пример:
Остаток материала
Item1 1
Item2 4
Item3
Item4
Item5 18
Item6 30
Ст.7