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 get sum of two numbers in vb.net?

14 Answers   Factorial, Paul Infotech, Satyam,


what is vb,net

1 Answers   ME,


Explain private assembly?

0 Answers  


code for export,import,save,update,delete ?

1 Answers  


How does you get record no from 5 to 15 from a dataset of 100 records?

3 Answers   ABC,


Explain about jagged arrarys ?

0 Answers  


How would you implement inheritance using vb.net?

0 Answers  


Regarding Types of compatability in VB and their usage ?

1 Answers   Satyam,


Tell us how many languages are supported by .net?

0 Answers  


Observations between vb.net and vc#.net?

0 Answers  


my project run very wel in my sytem yhen i am deploying my project on client machine ,after deployment i run my project then it show " can no find server name " what i do .

0 Answers  


What are the features present in vb 2005?

0 Answers  


Categories