rio simanjuntak blogger Lets Go to Forum   
20 Aug 2006 02:19:44 pm
3 tier program
Listing 1 - VB5

Function GetList() As ADODB.Recordset
Dim rs As New ADODB.Recordset
Dim cn As New ADODB.Connection
Dim objContext As ObjectContext

Set objContext = GetObjectContext()

On Error GoTo GetListError

' Open the connection
cn.Open mszDSN' Get the list of vendors
rs.CursorLocation = adUseClientBatch
rs.Open mszSQLGETVENDORS, cn, adOpenUnspecified, _
adLockUnspecified, adCmdUnspecified
' Setup the recordset to return
Set GetList = rs
' Disconnect the recordset
Set rs.ActiveConnection = Nothing
' Close the connection
cn.Close
objContext.SetComplete
Exit Function

GetListError:
' Raise a generic error and pass the description on
objContext.SetAbort
Err.Raise vbObjectError + 100, mszCLASSNAME, _
Err.Description
End Function


Listing 2 - VB5

Sub LoadVendorList()
Dim rs As ADOR.Recordset
Dim clsVend As New CVendor

' Clear the listbox
lstVendors.Clear

' Get all the vendors and
Set rs = clsVend.GetList

' Loop through and add vendors
Do While Not rs.EOF
' Add the vendor name
lstVendors.AddItem rs("Name")
' Store the VendorID
lstVendors.ItemData(lstVendors.NewIndex) = _
rs("VendorID")
' Get the next vendor
rs.MoveNext
Loop
End Sub


Listing 3 - VB5

Private Sub CFindInterface_FindByID(lID As Long)
Dim iCount As Integer

' Refresh the list
LoadProductList

' Loop through and look for specified vendor
For iCount = 0 To lstProducts.ListCount - 1
' Did we find it?
If lstProducts.ItemData(iCount) = lID Then
' Select that one
lstProducts.ListIndex = iCount
' Bail out
Exit For
End If
Next
End Sub


Listing 4 - VB5

Private Sub lstRelatedProduct_DblClick()
Dim clsFind As New CFindInterface

' Get a find interface
Set clsFind = Parent.Frame.GetPanel( _
"Products").Control.object
' Find the vendor
clsFind.FindByID lstRelatedProduct.ItemData( _
lstRelatedProduct.ListIndex)
' Show the control
Parent.Frame.SetActivePanel "Products"
End Sub

Listing 5 vb5

If bNew Then
iVendorID = clsVend.Add(txtName, txtAddress1, _
txtAddress2, txtCountry, txtCity, _
txtState, txtZip, txtPostalCode, mskPhone, _
txtFax, txtEmail, txtURL, mskTollFree, _
txtContactName, mskContactPhone, txtContactEmail)
bNew = False
Else
iVendorID = lstVendors.ItemData( _
lstVendors.ListIndex)
clsVend.Update iVendorID, txtName, _
txtAddress1, txtAddress2, txtCountry, _
txtCity, txtState, txtZip, txtPostalCode, _
mskPhone, txtFax, txtEmail, txtURL, _
mskTollFree, txtContactName, _
mskContactPhone, txtContactEmail
End If


Listing 6 - VB5

Private Sub CToolbarInterface_DeleteItem()
Dim clsProd As New CProduct

' Check if there is already a new record pending
If bNew Then
' Ask if they want to save
If MsgBox( _
"Do you want to save the new vendor?", _
vbYesNo) = vbYes Then
' Attempt a save
If Not SaveItem Then
' If it fails, bail so user can correct mistake
Exit Sub
End If
End If
bNew = False
End If

' Delete the item
clsProd.Delete lstProducts.ItemData( _
lstProducts.ListIndex)

' clear the controls
ClearControls
' Reload the list of products
LoadProductList
End Sub

Private Sub CToolbarInterface_NewItem()
' Check if there is already a new record pending
If bNew Then
' Ask if they want to save
If MsgBox("Do you want to save the new vendor?", _
vbYesNo) = vbYes Then
' Attempt a save
If Not SaveItem Then
' If it fails, bail so user can correct mistake
Exit Sub
End If
End If
End If
' Clear the controls
ClearControls
' Deselect the current vendor
lstProducts.ListIndex = -1
' Set the new flag
bNew = True
End Sub

Private Sub CToolbarInterface_RefreshItem()
Dim lProductID As Long
Dim iCount As Integer

' If a product is selected store it's productid
If lstProducts.ListIndex >= 0 Then
' Store the ID
lProductID = lstProducts.ItemData( _
lstProducts.ListIndex)
Else
' Else store indicator that no product
' was selected
lProductID = -1
End If

' Reload the product list
LoadProductList lProductID
End Sub

Private Sub CToolbarInterface_SaveItem()
' Call the save routine
SaveItem
End Sub

Private Sub lstDownloads_DblClick()
Dim clsFind As New CFindInterface

' Get a find interface
Set clsFind = Parent.Frame.GetPanel( _
"Downloads").Control.object
' Find the vendor
clsFind.FindByID lstDownloads.ItemData( _
lstDownloads.ListIndex)
' Show the control
Parent.Frame.SetActivePanel "Downloads"
End Sub


Listing 7 - VB5

Private Sub btnDelete_Click(Index As Integer)
Dim tbtemp As CToolbarInterface
Set tbtemp = Frame.GetActivePanel.Control.object
tbtemp.DeleteItem
Set tbtemp = Nothing
End Sub

Private Sub btnNew_Click()
Dim tbtemp As CToolbarInterface
Set tbtemp = Frame.GetActivePanel.Control.object
tbtemp.NewItem
Set tbtemp = Nothing
End Sub

Private Sub btnRefresh_Click(Index As Integer)
Dim tbtemp As CToolbarInterface
Set tbtemp = Frame.GetActivePanel.Control.object
tbtemp.RefreshItem
Set tbtemp = Nothing
End Sub

Private Sub btnSave_Click()
Dim tbtemp As CToolbarInterface
Set tbtemp = Frame.GetActivePanel.Control.object
tbtemp.SaveItem
Set tbtemp = Nothing
End Sub
Category : visual basic | Posted By : admin | Comments [3] | Trackbacks [0]
Trackbacks
The URI to TrackBack this entry is :
http://rio.awardspace.com/trackback.php/15
Comments
`WOW GOLD
By : wow power leveling @ Time : 27 Apr 2009 02:14:30 am : Email : Home

we offer wow power leveling and wow gold wow gold
wow gold
By : wow gold @ Time : 17 Jun 2009 03:24:02 am : Email : Home
GHW wow gold Bush wow gold and wow gold his buy wow gold Bush uy wow gold Nazi buy wow gold swine cheap wow gold have cheap wow gold been cheap wow gold throwing world of warcraft gold a form world of warcraft gold of anthrax world of warcraft gold on wow power leveling me. That nike shoes produces jordan shoes immediate sport shoes chills casual shoes fever buy nike shoes in an cheap nike shoes attempt to wholesale nike shoes convince buy jordan shoes me that cheap jordan shoes I am wholesale jordan shoes seriously sick. This wholesale watches is why wholesale watch the replica watches disease watches replica experts replica watches are watch replica professing fake watches to have fake watch found cheap watches a new rolex replica type replica rolex of flu replica rolex watches, for replica rolex watch the fake rolex instantly breitling replica debilitating wholesale watches effects wholesale watch of replica watches inhalation watches replica anthrax replica watch have watch replica been fake watches replaced fake watch by cheap watches chills rolex replica with replica rolex this replica rolex watches type replica rolex watch of anthrax fake rolex. In breitling replica addition wholesale watches to throwing wholesale watch it at replica watches me at watches replica home replica watch and watch replica the fake watches libraries; fake watch they cheap watches were rolex replica also replica rolex broadcasting replica rolex watches it, most replica rolex watch likely fake rolex from breitling replica their wholesale watches Eagle wholesale watch stealth replica watches helicoptors watches replica. I replica watch have watch replica looked fake watches up fake watch what cheap watches is available rolex replica on anthrax replica rolex on the replica rolex watches computer, replica rolex watch and I fake rolex am sure breitling replica that my Antrax.An car insurance Ancient auto insurance Scourge home insurance is still health insurance the life insurance best business insurance account auto insurance quotes by cheap auto insurance far cheap car insurance of car insurance quotes anthrax ugg boots, even buy ugg boots though cheap ugg boots they wholesale ugg boots give.
NCVVCB
By : DFGFDRETE @ Time : 31 Jul 2009 06:55:46 am :
MY wow power leveling
buy wow gold
my wow power leveling
BUY wow gold
CHEAP wow power leveling
my wow gold

Add Your Comment

Subject

Comments

Name

Email Address (Optional)

Home Page (Optional)

Security Code

Please enter the security code as displayed :



Oct 2009 November 2009 Dec 2009
S M T W T F S
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30      
Categories
About Me[5]
Links[3]
PI-DEL[1]
Succes[3]
visual basic[4]
windows[3]
Recent
Link Baru
blog.medanit.net
Medanit
run and wait pid by shell
Hapus brontok manual
3 tier program
making dll, MTS
vb client server
Aplikasi membuka dan menutup cdrom
Aku Pada Mu
Archives
January 2009[1]
April 2008[5]
September 2006[2]
August 2006[6]
March 2006[4]
February 2006[1]
Syndication
Template theme : simanjuntak
Copyright © simanjuntak blogger 2005