give me code for selecting itemcode and correspondin vendor
details wll displays in the gridview?



give me code for selecting itemcode and correspondin vendor details wll displays in the gridview?..

Answer / sree11

Imports System.Data
Imports System.Data.SqlClient
Imports System.Windows.Forms
Public Class ItemVendorReport
Dim da As New SqlDataAdapter
Dim itemcode As String
Private Function getitemid(ByVal itemcode As String)
Dim itemid As Integer
da = New SqlDataAdapter("select item_id from
item_master where item_refid='" & itemcode & "'", Con)
Dim ds As New DataSet
da.Fill(ds)
If ds.Tables(0).Rows.Count > 0 Then
itemid = ds.Tables(0).Rows(0).Item(0).ToString()
End If
Return itemid
End Function
'Show the vendor details from vendor_details tables by
enter the itemid in txt_ItemId.
Private Sub btn_show_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
btn_show.Click
clear_toolstrip()
If txt_ItemId.Text <> ""
Then 'verify the ItemId textbox value empty
or not
itemcode = txt_ItemId.Text.Trim
Dim itemid1 As String
itemid1 = getitemid(itemcode)
da = New SqlDataAdapter("select v.vendor_refid
as VendorCode,v.company_name as
CompanyName,v.firstcontactperson as
FirstContactPerson,v.mobno as MobileNo,v.address as
Address,v.city as City,v.state as State,v.country as
Country,v.pincode as PinCode,v.phone1 as PhoneNo1,v.phone2
as PhoneNo2,v.fax as Fax,v.email as EmailId,v.website As
WebSite from vendor_details v,vendor_item i where
i.vendor_id=v.vendor_id and i.item_id=" & itemid1 & " order
by v.vendor_id", Con)
Dim ds As New DataSet
da.Fill(ds, "vendorDetails")
dgv_View.DataSource = ds.Tables("vendorDetails")

dgv_View.AlternatingRowsDefaultCellStyle.BackColor =
Color.Bisque
For Each column As DataGridViewColumn In
dgv_View.Columns
column.SortMode =
DataGridViewColumnSortMode.NotSortable 'making
disable sorting of all columns
Next

For rowcount = 1 To dgv_View.Columns.Count - 1
dgv_View.Columns(rowcount).ReadOnly = True
Next
dgv_View.Columns(0).ReadOnly = False
dgv_View.Columns(0).Width = 50

dgv_View.Columns(0).ReadOnly = False
If ds.Tables("vendorDetails").Rows.Count = 0
Then 'verify macthing vendor details exists in the
database or not.
Stl_text.Text = "Invalid ItemId"
Stl_Image.Image = My.Resources.Red
Stl_text.ForeColor = Color.Red

End If
End If
End Sub
'Purpose :To Clear Toolstrip Messages and Images
Private Sub clear_toolstrip()
Stl_Image.Image = Nothing
Stl_text.Text = ""
End Sub
'Purpose : Selects All the records in datagridview
Private Sub lnk_Selectall_LinkClicked(ByVal sender As
System.Object, ByVal e As
System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles
lnk_Selectall.LinkClicked
clear_toolstrip()
Dim Counter As Integer
For Counter = 0 To dgv_View.RowCount - 1
dgv_View.Item(0, Counter).Value = True
Next
End Sub
'Purpose : DeSelects All the records in datagridview
Private Sub lnk_Deselectall_LinkClicked(ByVal sender As
System.Object, ByVal e As
System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles
lnk_Deselectall.LinkClicked
clear_toolstrip()
Dim Counter As Integer
For Counter = 0 To dgv_View.RowCount - 1
dgv_View.Item(0, Counter).Value = False
Next
End Sub
'Purpose : Calls when the export link clicked
Private Sub lnk_Export_LinkClicked(ByVal sender As
System.Object, ByVal e As
System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles
lnk_Export.LinkClicked
clear_toolstrip()
Dim fn As String
Dim counter, rowcount As Integer
For counter = 0 To dgv_View.Rows.Count - 1
If dgv_View.Rows(counter).Cells(0).Value = True
Then
rowcount += 1
End If
Next
If rowcount > 0 Then
dlg_save.Filter = "Excel files (*.xls)|*.xls"
dlg_save.ShowDialog()
fn = dlg_save.FileName
If fn = "" Then
Exit Sub
End If
exporttoexcel_fromdgv(Me, dgv_View, fn, "Vendor
Details Report")
Else
Stl_text.Text = "Select atleast one record"
Stl_text.ForeColor = Color.Red
Stl_Image.Image = My.Resources.Red
End If
End Sub
'Purpose : Print the Datagridview records
Private Sub lnk_Print_LinkClicked(ByVal sender As
System.Object, ByVal e As
System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles
lnk_Print.LinkClicked
clear_toolstrip() 'for clearing the status
strip
PrintDGV.Print_DataGridView(dgv_View)
End Sub
'Purpose : for clear the toolstrip values
Private Sub lnk_Selectall_Leave(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
lnk_Selectall.Leave
clear_toolstrip() 'for clearing the status
strip
End Sub
'Purpose : for clear the toolstrip values
Private Sub lnk_Deselectall_Leave(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
lnk_Deselectall.Leave
clear_toolstrip() 'for clearing the status
strip
End Sub
'Purpose : for clear the toolstrip values
Private Sub lnk_Export_Leave(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
lnk_Export.Leave
clear_toolstrip() 'for clearing the status
strip
End Sub
'Purpose : for clear the toolstrip values
Private Sub lnk_Print_Leave(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
lnk_Print.Leave
clear_toolstrip() 'for clearing the status
strip
End Sub
'purpose: for showing ErrorMessage
Private Sub txt_ItemId_Validating(ByVal sender As
System.Object, ByVal e As
System.ComponentModel.CancelEventArgs) Handles
txt_ItemId.Validating
If txt_ItemId.Text = "" Then
Errp.SetError(txt_ItemId, "Enter item Id")
Else
Errp.SetError(txt_ItemId, "")
End If
End Sub
'for allowing numbers only in the ItemId textbox
Private Sub txt_ItemId_KeyPress(ByVal sender As
System.Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles
txt_ItemId.KeyPress
e.KeyChar = AllowNumber(e.KeyChar.ToString)
End Sub
'for clearing the status strip
Private Sub txt_ItemId_Leave(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
txt_ItemId.Leave
clear_toolstrip() 'for clearing the
status strip
End Sub
End Class

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More VB.NET Interview Questions

Give the sample code for ItemStockGroupwise Report?

1 Answers   CTS,


thak you Mr Govind for replying to my question. My next question is that how to retrieve image stored in an SQL server table and assign it to any image control or picture control using VB.net

0 Answers  


What are different types of jit ?

0 Answers  


What is the difference between vb 6 and vb.net?

0 Answers  


how to create crystal reports in asp.net & vb.net with syntax

2 Answers  






hello friends, I have created a animated button in VB.NET. As its dll file coding can be viewed and also copied to some other location. So my question is how can I protect the Dll file of the animated button so that noone can access it. Any idea about this???????? Thanks Rekha

3 Answers  


Explain the difference between int and int32?

0 Answers  


What is the DIfference between Friend and Protected Friend?

6 Answers   CTS, Sykes Enterprises, TCS,


Can you please explain the difference between namespace and assembly?

0 Answers  


Explain about the performance of visual basic?

0 Answers  


How do you call a stored procedure in Visual Basic?

0 Answers   CGI,


Explain manifest?

0 Answers  


Categories