Hey Man,
Here is the code:
Code:
*****FORM LOAD**************
Private Sub RepairOrderSystemForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'pull all the data from the database, the customer search should
'be taking care of this. Whenever we double click on a job
'the page load load should be given a job ID and then Grab
'Get the values for the actuator, valve, Instrument and accessories
'And populate the List boxes and the combo boxes.
PopulateBoxes("Valve", JobValveCombo)
PopulateBoxes("Actuator", JobActuatorCombo)
PopulateBoxes("Accessory", JobAccessoryCheckList)
PopulateBoxes("Instrument", JobInstrumentCheckList)
StatusIndex = 0
Dim i As Integer
For i = 1 To (Me.TabControl1.TabPages.Count() - 1)
Me.TabControl1.TabPages(i).Enabled = False
Next i
If Not JobId.Text = "" Then
'Call the function that will do the checks for items in the database
SelectChosen(JobId.Text)
End If
End Sub Code:
********Populate Boxes Function**************
Public Sub PopulateBoxes(ByVal type As String, ByVal obj As Object)
Try
Dim proc As New RepairItemProcessor
Dim aList As ArrayList
'The only reason for this TempList, is to have a
'"Select An Item" Choice
Dim TempList As New ArrayList
Dim anitem As New RepairItem
anitem.RepairItemName = "Select an Item"
TempList.Add(anitem)
aList = proc.getRepairItemList(type)
If Not aList Is Nothing AndAlso aList.Count > 0 Then
If type = "Instrument" Or type = "Accessory" Then
obj.DisplayMember = "RepairItemName"
obj.ValueMember = "Mechanism"
obj.DataSource = aList
Else
TempList.AddRange(aList)
obj.DisplayMember = "RepairItemName"
obj.ValueMember = "Mechanism"
obj.DataSource = TempList
End If
End If
Catch ex As Exception
Throw New Exception("AccessDBError", ex)
End Try
End Sub
Code:
*********Select Chosen Function*****************
Code:
Public Sub SelectChosen(ByVal JobId As String)Dim proc As New Job_xref_RepaitItemProcessor
Dim proc2 As New RepairItemProcessor
Dim ChosenOnes As ArrayList
Dim AllTheOnes As ArrayList
'Go to the database and grab the list of the repair items
'selected. Display the selected items on the Main Form
ChosenOnes = proc.getRepairItemList(JobId)
'Dim ChosenCount As Int16 = ChosenOnes.Count
choose(ChosenOnes, JobActuatorCombo)
choose(ChosenOnes, JobValveCombo)
choose(ChosenOnes, JobInstrumentCheckList, True)
choose(ChosenOnes, JobAccessoryCheckList, True)
JobInstrumentCheckList.SetItemCheckState(0, CheckState.Checked)
JobInstrumentCheckList.SetItemCheckState(1, CheckState.Checked)
JobInstrumentCheckList.SetItemCheckState(2, CheckState.Checked)
JobInstrumentCheckList.SetItemCheckState(3, CheckState.Checked)
End Sub
Code:
*****Choose Function*******************
Public Sub choose(ByVal obj As Object, ByVal obj2 As Object, Optional ByVal IsInstrument As Boolean = False)
Dim ChosenCount As Int16 = obj.Count
'update(chosenones,Jobactuatorcombo)
Dim AllCount As Int16 = obj2.Items.Count
For I As Integer = 0 To (ChosenCount - 1)
For J As Integer = 0 To (AllCount - 1)
If IsInstrument Then
'dealing with the checklist boxes
If obj(I).RepairItemName = obj2.Items.Item(J).RepairItemName Then
' obj2.SetItemChecked(J, True)
End If
Else
'Dealing with the combo boxes
If obj(I).RepairItemName = obj2.Items.Item(J).RepairItemName Then
obj2.SelectedItem = obj2.Items.Item(J)
End If
End If
Next
Next
Bookmarks