I have to tables
1.[Mobilization]-Primary key is [Fen_Inovoice_No] it is the forgien key is of [invovoice details]
2.[invovoice details] the primary keys are [Fen_Inovoice_No],[Item]
when I tried to view the data , the all data are not loading to listview
why is that?
Dim intResponse As Integer
intResponse = MsgBox("Please insert the invoice no", MsgBoxStyle.OkOnly)
If intResponse = vbOK Then
Try
myConnection = New SqlConnection(connectionstring)
myConnection.Open()
myCommand2 = New SqlCommand(" SELECT Fen_Telephone_No,[Fen_VAT_No] ,[Date],[Fen_Fax_No] ,[Source_of_order] ,[Totalamount],[NBT_Value] ,[NBT_Amount] ,[VAT_Value] ,[VAT_Amount] ,[Grand_total] ,[Contract_Name],[Client_Name] ,[Moblization_Value],[Moblization_Percentage] FROM [Mobilization] where [Fen_Inovoice_No]='" & TextBox1.Text & "'", myConnection)
Dim dr As SqlDataReader = myCommand2.ExecuteReader
While dr.Read()
'Fen_Telephone_No
Debug.WriteLine(dr(0))
TextBox3.Text = dr(0).ToString
'[Fen_VAT_No]
Debug.WriteLine(dr(1))
TextBox2.Text = dr(1).ToString
'[Date]
Debug.WriteLine(dr(2))
DateTimePicker1.Value = dr(2).ToString
'[Fen_Fax_No]
Debug.WriteLine(dr(3))
TextBox4.Text = dr(3)
'[Source_of_order]
Debug.WriteLine(dr(4))
TextBox12.Text = Val(dr(4))
'[Totalamount]
Debug.WriteLine(dr(5))
TextBox11.Text = Val(dr(5))
'[NBT_Value]
Debug.WriteLine(dr(6))
TextBox10.Text = Val(dr(6))
'[NBT_Amount]
Debug.WriteLine(dr(7))
TextBox5.Text = Val(dr(7))
'[VAT_Value]
Debug.WriteLine(dr(8))
TextBox6.Text = Val(dr(8))
'[VAT_Amount]
Debug.WriteLine(dr(9))
TextBox7.Text = Val(dr(9))
'[Grand_total]
Debug.WriteLine(dr(10))
TextBox8.Text = Val(dr(10))
'[Contract_Name]
Debug.WriteLine(dr(11))
ComboBox1.Text = dr(11)
'[Client_Name]
Debug.WriteLine(dr(12))
ComboBox2.Text = dr(12)
'[Moblization_Value]
Debug.WriteLine(dr(13))
TextBox17.Text = Val(dr(13))
'[Moblization_Percentage]
Debug.WriteLine(dr(14))
TextBox9.Text = Val(dr(14))
End While
dr.Close()
myConnection.Close()
Catch err As Exception
MsgBox(err.Message, MsgBoxStyle.Exclamation)
End Try
'list
End If
Call AppendItem1()
Private Sub AppendItem1()
myConnection = New SqlConnection(connectionstring)
myConnection.Open()
sqlcmd = New SqlCommand("SELECT Item,Quantity,Descrption ,Amount FROM [invovoice details] where Fen_Inovoice_No='" & TextBox1.Text & "' ", myConnection)
sqlcmd.ExecuteNonQuery()
' Dim dr As SqlDataReader = myCommand1.ExecuteReader
Dim dr As SqlDataReader = sqlcmd.ExecuteReader
dr.Read()
' pr = dr1("Category").ToString
''''''''''''''''''''''''
' For i = 0 To TempData.Rows.Count-1
Dim newItem1 As New ListViewItem(dr.Item("Item").ToString)
newItem1.SubItems.Add(dr("Descrption").ToString)
newItem1.SubItems.Add(dr("Quantity"))
newItem1.SubItems.Add(dr("Amount"))
ListView1.Items.Add(newItem1)
' newItem.SubItems.Add()
CalTotal()
dr.Close()
'''''''''''''''''''''''''''''
myConnection.Close()
End Sub
Private Sub CalTotal()
Dim TotalSum As Double = 0
Dim TempNode As ListViewItem
Dim TempDbl As Double
For Each TempNode In ListView1.Items
If Double.TryParse(TempNode.SubItems.Item(3).Text, TempDbl) Then
End If
TotalSum += TempDbl
Next
TextBox11.Text = TotalSum
End Sub