Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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

How to store images in sql server database through vb.net?

0 Answers  


What is visual basic.net culture?

0 Answers  


What is the feature which is common to all .net languages?

0 Answers  


Explain cts?

0 Answers  


In vb.net how to connect crystal report?

1 Answers  


What are the shadow variables?

0 Answers  


I want to sample Hotel management project in vb.net because still now i am doing that project for small hotel....so please send me my email id is jmuthu_pearls@yahoo.com...

4 Answers   Sapphire Comfort Hotel, TATA,


What’s the difference between private and shared assembly?

0 Answers  


What do you mean by serialization and deserialization and it's use.

0 Answers  


Tell us how many languages are supported by .net?

0 Answers  


How to store decimal data in .net?

0 Answers  


if user enters 1 or 2 or any other number in digit format in next textbox it should show the answer in word reading like if enters 12 answer should be twelve

4 Answers  


Categories