That's a bit teasy - the juicy bit you left out!
For those following along at home, you'll need to add some custom code in your handler for the GetCandidatesUltraButton.Click event that Nina shows being wired up in the SetupBeforeHandlers.
The handler we have looks like this -
but you don't want to replicate this - :
- Code: Select all
Private Sub GetCandidatesUltraButton_Click(sender As Object, e As EventArgs)
Dim oldCursor As Cursor = Cursor
Try
Cursor = Cursors.WaitCursor
Dim orderBy As Integer
If OrderByUltraOptionSet.CheckedIndex = 0 Then
orderBy = 0
Else
orderBy = 1
End If
ManualBOBatch.BatchLines.AddRange(orderBy)
CheckEditStatus()
Finally
Cursor = oldCursor
End Try
End Sub
ManualBOBatch in the above is a property of the form - this is the business logic object backing the form. In order to be able to customise the parameters to the stored procedure, you need to
not call the ManualBOBatch.BatchLines.AddRange() method above, but instead write your own code which does what that does - here's the AddRange method we have in our ManualBOBatch.BatchLineCollection business logic class - it should be enough for you to customise the parameters as required. Just keep in mind this code is within the AddRange method of the ManualBOBatch.BatchLines - so calls like
Add(newBatchLine) seen below would actually need to be
ManualBOBatch.BatchLines.Add(newBatchLine)- Code: Select all
Public Sub AddRange(ByVal OrderBy As Integer)
Dim SQLReader As SqlDataReader = Nothing
Dim SQLParam As SqlParameter
Dim e As New System.ComponentModel.CancelEventArgs
OnRangeAdding(e)
If e.Cancel = False Then
Try
With Manager.Database
Dim SQL As String = _ManualBOBatch.SystemSettings.ReadBackOrderDetailsListStoredProcedureName
Using SQLCmd As SqlCommand = New SqlCommand(SQL, .SQLConnection, .SQLTransaction)
SQLCmd.CommandType = Data.CommandType.StoredProcedure
SQLParam = New SqlParameter("@IN_LogicalID", System.Data.SqlDbType.Char)
SQLParam.Value = _ManualBOBatch.Warehouse.IN_LogicalID
SQLCmd.Parameters.Add(SQLParam)
SQLParam = New SqlParameter("@From_InvoiceNo", System.Data.SqlDbType.VarChar)
SQLParam.Value = ManualBOBatch.Ranges.SalesOrder.From.InvoiceNo
SQLCmd.Parameters.Add(SQLParam)
SQLParam = New SqlParameter("@To_InvoiceNo", System.Data.SqlDbType.VarChar)
SQLParam.Value = ManualBOBatch.Ranges.SalesOrder.To.InvoiceNo
SQLCmd.Parameters.Add(SQLParam)
SQLParam = New SqlParameter("@From_ExpectedDeliveryDate", System.Data.SqlDbType.DateTime)
SQLParam.Value = ManualBOBatch.Ranges.ExpectedDeliveryDate.From
SQLCmd.Parameters.Add(SQLParam)
SQLParam = New SqlParameter("@To_ExpectedDeliveryDate", System.Data.SqlDbType.DateTime)
SQLParam.Value = CDate(ManualBOBatch.Ranges.ExpectedDeliveryDate.To.ToShortDateString & " 23:59:59")
SQLCmd.Parameters.Add(SQLParam)
SQLParam = New SqlParameter("@From_DebtorAccountNo", System.Data.SqlDbType.VarChar)
SQLParam.Value = ManualBOBatch.Ranges.Debtor.From.AccountNo
SQLCmd.Parameters.Add(SQLParam)
SQLParam = New SqlParameter("@To_DebtorAccountNo", System.Data.SqlDbType.VarChar)
SQLParam.Value = ManualBOBatch.Ranges.Debtor.To.AccountNo
SQLCmd.Parameters.Add(SQLParam)
SQLParam = New SqlParameter("@From_PartNo", System.Data.SqlDbType.VarChar)
SQLParam.Value = ManualBOBatch.Ranges.Inventory.From.PartNo
SQLCmd.Parameters.Add(SQLParam)
SQLParam = New SqlParameter("@To_PartNo", System.Data.SqlDbType.VarChar)
SQLParam.Value = ManualBOBatch.Ranges.Inventory.To.PartNo
SQLCmd.Parameters.Add(SQLParam)
SQLParam = New SqlParameter("@From_BillType", System.Data.SqlDbType.SmallInt)
SQLParam.Value = ManualBOBatch.Ranges.BillType.From
SQLCmd.Parameters.Add(SQLParam)
SQLParam = New SqlParameter("@To_BillType", System.Data.SqlDbType.SmallInt)
SQLParam.Value = ManualBOBatch.Ranges.BillType.To
SQLCmd.Parameters.Add(SQLParam)
SQLParam = New SqlParameter("@From_WholesaleInvoice", System.Data.SqlDbType.SmallInt)
SQLParam.Value = ManualBOBatch.Ranges.InvoiceType.From
SQLCmd.Parameters.Add(SQLParam)
SQLParam = New SqlParameter("@To_WholesaleInvoice", System.Data.SqlDbType.SmallInt)
SQLParam.Value = ManualBOBatch.Ranges.InvoiceType.To
SQLCmd.Parameters.Add(SQLParam)
SQLParam = New SqlParameter("@From_OrderType", System.Data.SqlDbType.SmallInt)
SQLParam.Value = ManualBOBatch.Ranges.OrderType.From
SQLCmd.Parameters.Add(SQLParam)
SQLParam = New SqlParameter("@To_OrderType", System.Data.SqlDbType.SmallInt)
SQLParam.Value = ManualBOBatch.Ranges.OrderType.To
SQLCmd.Parameters.Add(SQLParam)
SQLParam = New SqlParameter("@OrderBy", System.Data.SqlDbType.SmallInt)
SQLParam.Value = OrderBy
SQLCmd.Parameters.Add(SQLParam)
SQLReader = .ExecuteReader(SQLCmd)
RemoveAll()
_ManualBOBatch.InventoryItems.RemoveAll()
Dim OrdersOnBackID As String = ""
Dim InventoryID As String = ""
Dim InvoiceID As String = ""
Dim newInventoryItem As InventoryItem = Nothing
Dim newSalesOrder As SalesOrder = Nothing
Dim newBatchLine As BatchLine = Nothing
Do While SQLReader.Read = True
OrdersOnBackID = .Sanitise(SQLReader, "OrdersOnBackID").ToString.Trim()
If OrdersOnBackID.Trim.Length > 0 And BackOrderExists(OrdersOnBackID) = False Then
InventoryID = .Sanitise(SQLReader, "InventoryID").ToString.Trim()
If _ManualBOBatch.InventoryItems.Contains(InventoryID) = False Then
newInventoryItem = Manager.CollectionItemFactory.CreateCollectionItem(Of InventoryItem)
newInventoryItem.Inventory.ReadRecord(InventoryID)
newInventoryItem.QuantityAvailable = .Sanitise(SQLReader, "QuantityAvailable")
newInventoryItem.RecID = InventoryID
_ManualBOBatch.InventoryItems.Add(newInventoryItem)
End If
InvoiceID = .Sanitise(SQLReader, "InvoiceID").ToString.Trim()
If _ManualBOBatch.SalesOrders.Contains(InvoiceID) = False Then
newSalesOrder = Manager.CollectionItemFactory.CreateCollectionItem(Of SalesOrder)
newSalesOrder.SalesOrder.ReadRecord(InvoiceID)
newSalesOrder.InvoiceHistoryID = .Sanitise(SQLReader, "InvoiceHistoryID").ToString.Trim()
newSalesOrder.InvoiceHistoryNo = .Sanitise(SQLReader, "HistoryNo")
newSalesOrder.RecID = InvoiceID
_ManualBOBatch.SalesOrders.Add(newSalesOrder)
End If
newBatchLine = Manager.CollectionItemFactory.CreateCollectionItem(Of BatchLine)
newBatchLine.IN_OnBackOrder_OrdersOnBackID = OrdersOnBackID
newBatchLine.InventoryItemKey = InventoryID
newBatchLine.BackOrderQuantity = .Sanitise(SQLReader, "BackOrderQuantity")
newBatchLine.BackOrderValue = .Sanitise(SQLReader, "BackOrderValue")
newBatchLine.SalesOrderItemKey = InvoiceID
newBatchLine.BackOrderPriority = .Sanitise(SQLReader, "Priority")
newBatchLine.BackOrderPriorityWeight = .Sanitise(SQLReader, "PriorityWeight")
newBatchLine.InvoiceLineID = .Sanitise(SQLReader, "InvoiceLineID").ToString.Trim()
newBatchLine.KitType = .Sanitise(SQLReader, "KitType")
Add(newBatchLine)
_ManualBOBatch.InventoryItems.RecalculateAvailable(_ManualBOBatch.InventoryItems(newBatchLine.InventoryItemKey).Inventory.InventoryID)
End If
Loop
SQLReader.Close()
End Using
End With
OnRangeAdded()
Finally
If Not SQLReader Is Nothing Then
SQLReader.Close()
End If
End Try
End If
End Sub