Question Database inter-dependency code

Rishad Hasan

Member
Joined
Feb 1, 2013
Messages
8
Programming Experience
Beginner
Hello Everyone,

I am a new bie in vb.net. So, I started getting very small problems in my code. I am seeking for solution please. I have two issues, first one is in above dotted line code.
I have a combobox for nominal size. This nominal size determines the rows for every table. Like, If nominal size 1", In item 14 table it will pick the record with 1" row.
But for only Item 15 it need to be changed. In the green code, if I pick 1" nominal size it'll pick the record from Item 15 with 1". But I am trying to insert a logic here:

I dont want to let the nominal size have control over item 15. I want to chage the row conditions like that: If user picks nominal size 0.75" up to 1.5"(any one within this range), then row should be always i=0 for item_15 table. If 2", then i=1, if 2.5" up to 3" then i=2 like that. I already wrote conditions for the column in item-15, but I am wondering how can I change the row code as per I mentioned above.

My second issue: Look at the red code please,that will give the output of our program stored as csv file in C drive of my pc.

In the database table, Item_15 is always op=50, but I created two checkboxes to operate the 'op'. When I'll check those two boxes. my output automatically need to be changed to 40.

For example, the normal output is partnumber (330026), quantity (1), op(50)

so as csv: 330026,1,50

I am wondering is there anyway that when I'll checked those boxes either or, it'll change the op to 40.


Thanks.



ComboBoxNominalSize.Items.Add("0.75" + Chr(34))
ComboBoxNominalSize.Items.Add("1" + Chr(34))
ComboBoxNominalSize.Items.Add("1.25" + Chr(34))
ComboBoxNominalSize.Items.Add("1.5" + Chr(34))
ComboBoxNominalSize.Items.Add("2" + Chr(34))
ComboBoxNominalSize.Items.Add("2.5" + Chr(34))
ComboBoxNominalSize.Items.Add("3" + Chr(34))
ComboBoxNominalSize.Items.Add("4" + Chr(34))
ComboBoxNominalSize.Items.Add("6" + Chr(34))
ComboBoxNominalSize.Items.Add("8" + Chr(34))
ComboBoxNominalSize.SelectedIndex = 1




Private Sub findPartNumberforItem15()




Dim Table_ As String




Table_ = "Item_15"






Dim query As String = "SELECT * FROM " & Table_


Dim MDBConnString_ As String = dataBaseLocation
Dim ds As New DataSet
Dim cnn As OleDb.OleDbConnection = New OleDb.OleDbConnection(MDBConnString_)


cnn.Open()
Dim cmd As New OleDb.OleDbCommand(query, cnn)
Dim da As New OleDb.OleDbDataAdapter(cmd)
da.Fill(ds, Table_)
cnn.Close()


Dim t1 As DataTable = ds.Tables(Table_)


'Dim row As DataRow
Dim i As Integer


For i = 0 To 3




If t1.Rows(i).Item("Size") = ComboBoxNominalSize.Text Then 'this is the right row




If ComboBoxInletPressure.SelectedIndex = 1 Then ' 0-5 psig
'this is where you pick which column
If Not IsDBNull(t1.Rows(i).Item("5PSI")) Then
partNumber = t1.Rows(i).Item("5PSI")
Else
partNumber = 0
End If
Else '0-25 psig
'this is where you pick which column
If Not IsDBNull(t1.Rows(i).Item("25PSI")) Then
partNumber = t1.Rows(i).Item("25PSI")
Else
partNumber = 0
End If


End If


'MsgBox("part number is: " + Str(partNumber))


Exit For
End If


Next i






End Sub


..................................................................................

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click


out = My.Computer.FileSystem.OpenTextFileWriter(file, False)


Dim op As Integer




Dim Table_ As String


Dim MaxRowNumber As Integer


Dim MDBConnString_ As String = dataBaseLocation


If ComboBoxModValveVendor.Text = "ASCO" Or ComboBoxModValveVendor.Text = "Honeywell" Then
Table_ = "DiagramDetails_ASCO_HW"
MaxRowNumber = 20
Else
Table_ = "DiagramDetails_Siemens"
MaxRowNumber = 15
End If




Dim query As String = "SELECT * FROM " & Table_
Dim ds As New DataSet
Dim cnn As OleDb.OleDbConnection = New OleDb.OleDbConnection(MDBConnString_)


cnn.Open()
Dim cmd As New OleDb.OleDbCommand(query, cnn)
Dim da As New OleDb.OleDbDataAdapter(cmd)
da.Fill(ds, Table_)
cnn.Close()


Dim t1 As DataTable = ds.Tables(Table_)


'Dim row As DataRow
Dim i As Integer


For i = 0 To 19 'MaxRowNumber


If t1.Rows(i).Item("DiagramNumber") = TextBox2.Text Then
If Not IsDBNull(t1.Rows(i).Item("15")) Then
findPartNumberforItem15()
op = t1.Rows(i).Item("15")
WR(partNumber, 1, op)


End If

Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged

End Sub




Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged


End Sub
 
Back
Top