- Код: Выделить всё
Form1.ToolStripProgressBar1.Maximum = i
For MyRow As Integer = 0 To i - 1
Form1.ToolStripProgressBar1.Value = MyRow
Form1.ToolStripStatusLabel1.Text = "Выполнение запроса - " & MyRow & " из " & i
objDataTableA.Clear()
sSQL = "Select Top 1 Stock, MadeDate from ProductMovements where Index='" & Me.DataGridView1(0, MyRow).Value & "' And" & _
" Date<=" & MyDate & " order by Date DESC;"
Dim objConnectionA As New OleDb.OleDbConnection(TypeDB)
Dim objCommandA As New OleDb.OleDbCommand(sSQL, objConnectionA)
Dim objDataAdapterA As New OleDb.OleDbDataAdapter(objCommandA)
objDataAdapterA.Fill(objDataTableA, "Stocks")
Dim dr As DataRow
Dim NullRow As Boolean = True
For Each dr In objDataTableA.Tables(0).Rows
NullRow = False
Me.DataGridView1(5, MyRow).Value = dr("Stock").ToString
DBstock = dr("Stock").ToString
Exit For
Next
If NullStocks = "2" Then
If NullRow = True And MyRow <> 0 Then
Me.DataGridView1.Rows(MyRow).Visible = False
GoTo 1
End If
End If
'Заполняем приход за месяц
Dim CM As String = Month(Me.DateTimePicker1.Value)
Dim CY As String = Year(Me.DateTimePicker1.Value)
Dim FD As String = "#" & CM & "/01/" & CY & "#"
Dim SD As String = "#" & CM & "/30/" & CY & "#"
sSQL = "Select sum(Value) as SP from ProductMovements where Index='" & Me.DataGridView1(0, MyRow).Value & "' And" & _
" (Date BETWEEN " & SD & " AND " & FD & ") AND Type='1';"
Dim objConnectionB As New OleDb.OleDbConnection(TypeDB)
Dim objCommandB As New OleDb.OleDbCommand(sSQL, objConnectionB)
Dim objDataAdapterB As New OleDb.OleDbDataAdapter(objCommandB)
objDataAdapterB.Fill(objDataTableA, "Prihod")
Dim drB As DataRow
For Each drB In objDataTableA.Tables(1).Rows
Me.DataGridView1(3, MyRow).Value = drB("SP").ToString
Exit For
Next
'Заполняем расход за месяц
sSQL = "Select sum(Value) as SU from ProductMovements where Index='" & Me.DataGridView1(0, MyRow).Value & "' And" & _
" (Date BETWEEN " & SD & " AND " & FD & ") AND Type='2';"
Dim objConnectionC As New OleDb.OleDbConnection(TypeDB)
Dim objCommandC As New OleDb.OleDbCommand(sSQL, objConnectionC)
Dim objDataAdapterC As New OleDb.OleDbDataAdapter(objCommandC)
objDataAdapterC.Fill(objDataTableA, "Uhod")
Dim drC As DataRow
For Each drC In objDataTableA.Tables(2).Rows
Me.DataGridView1(4, MyRow).Value = drC("SU").ToString
Exit For
Next
'Пересчитываем в палеты
sSQL = "Select InPallet from ProductData where Index='" & Me.DataGridView1(0, MyRow).Value & "';"
Dim objConnectionE As New OleDb.OleDbConnection(TypeDB)
Dim objCommandE As New OleDb.OleDbCommand(sSQL, objConnectionE)
Dim objDataAdapterE As New OleDb.OleDbDataAdapter(objCommandE)
objDataAdapterE.Fill(objDataTableA, "Pallets")
Dim drE As DataRow
For Each drE In objDataTableA.Tables(3).Rows
Try
Dim DBpallet As Double = CDbl(drE("InPallet").ToString)
Me.DataGridView1(6, MyRow).Value = Format(DBstock / DBpallet, "# ##0.00")
DBstock = 0
Catch ex As Exception
End Try
Exit For
Next
1:
Next
Своими силами лучше написать не могу - подкиньте идейку!