give me code for selecting itemcode and correspondin vendor
details wll displays in the gridview?
Answer Posted / 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 View All Answers
Explain managed code?
Explain about the performance of visual basic?
What is the main use of a namespace?
Tell us how many languages are supported by .net?
How to store images in sql server database through vb.net?
Is vb.net dead?
Explain trace in vb.net?
What is a static variable?
Write a VB.Net console program to check whether a number is perfect or not.
What is the purpose of objects present in asp.net?
What do you mean by serialization and deserialization?
Explain about Visual basic.NET culture?
i am attending to US consulate i kept my projects on vb.net ,please help me what questions will be ask on vb.net in us consulate
Define clr?
What is public assembly?