小区物业管理系统-数据库交互
UserDao 用户登录数据库交互
Imports System .Data .SqlClient
Imports System .Data .OleDb
Module UserDao
Dim conn As String = sqlconn( )
Dim conn2 As String = sqlconn2( )
Public Function userSelectUsername( user As User)
Dim f As Integer
Try
Dim objconn As New SqlConnection( conn2)
Dim strsql1 As String = "select count(*) from " & user.tableGet( ) & " where username='" & user.usernameGet( ) & "'"
objconn.Open ( )
Dim objcmd As New SqlCommand( strsql1, objconn)
f = objcmd.ExecuteScalar
objconn.Close ( )
objcmd.Dispose( )
Catch ex As Exception
MsgBox( "userServletUsername" + ex.Message)
End Try
If ( f > 0 ) Then
Return 1
Else
Return 0
End If
End Function
Public Function userSelectPassworld( user As User)
Dim f As Integer
Try
Dim objconn As New OleDbConnection( conn)
Dim objAdap As OleDbDataAdapter
Dim objDataSet As New DataSet
Dim strsql As String = "select password from " & user.tableGet( ) & " where username='" & user.usernameGet( ) & "'"
objAdap = New OleDbDataAdapter( strsql, conn)
objDataSet.Reset( )
objAdap.Fill( objDataSet, "User" )
f = objDataSet.Tables( "User" ) .Rows( 0 ) .Item( 0 )
Catch ex As Exception
MsgBox( "userServletPassworld" + ex.Message)
End Try
If ( Int ( user.passwordGet( ) ) = f) Then
Return 1
Else
Return 0
End If
End Function
Public Function userSelect( username As String , table As String )
Dim user As New User( )
Try
Dim objconn As New OleDbConnection( conn)
Dim objAdap As OleDbDataAdapter
Dim objDataSet As New DataSet
Dim strsql As String = "select username,password from " & table & " where username='" & username & "'"
objAdap = New OleDbDataAdapter( strsql, objconn)
objDataSet.Reset( )
objAdap.Fill( objDataSet, "User" )
user.usernameSet( Trim( objDataSet.Tables( "User" ) .Rows( 0 ) .Item( 0 ) ) )
user.passwordSet( Trim( objDataSet.Tables( "User" ) .Rows( 0 ) .Item( 1 ) ) )
Catch ex As Exception
MsgBox( "userSelect:" + ex.Message)
End Try
Return user
End Function
Public Function userUpdata( user As User)
Try
Dim strsql As String = "update " & user.tableGet( ) & " set password ='" & user.passwordGet( ) & "' where username ='" & user.usernameGet( ) & "'"
Dim objconn As New SqlConnection( conn2)
Dim objcmd As New SqlCommand( strsql, objconn)
objconn.Open ( )
objcmd.ExecuteNonQuery( )
MsgBox( "修改成功!")
objconn.Close ( )
Catch ex As Exception
MsgBox( "userUpdata:" + ex.Message)
End Try
Return user
End Function
Public Function userInsert( user As User)
Try
Dim strsql As String = "insert " & user.tableGet( ) & " values ('" & user.usernameGet( ) & "',123);"
Dim objconn As New SqlConnection( conn2)
Dim objcmd As New SqlCommand( strsql, objconn)
objconn.Open ( )
objcmd.ExecuteNonQuery( )
objconn.Close ( )
Catch ex As Exception
MsgBox( "userInsert:" + ex.Message)
End Try
Return user
End Function
Public Sub UserDelete( pno As String )
Try
Dim strsql As String = "delete from User_Proprietor where username='" & pno & "'"
Dim objconn As New SqlConnection( conn2)
Dim objcmd As New SqlCommand( strsql, objconn)
objconn.Open ( )
objcmd.ExecuteNonQuery( )
objconn.Close ( )
Catch ex As Exception
MsgBox( "UserDelete:" + ex.Message)
End Try
End Sub
Public Sub UserDeletePropetyManager( pno As String )
Try
Dim strsql As String = "delete from User_PropetyManager where username='" & pno & "'"
Dim objconn As New SqlConnection( conn2)
Dim objcmd As New SqlCommand( strsql, objconn)
objconn.Open ( )
objcmd.ExecuteNonQuery( )
objconn.Close ( )
Catch ex As Exception
MsgBox( "UserDelete:" + ex.Message)
End Try
End Sub
End Module
ProprietorDao 业主数据库交互
Imports System .Data .OleDb
Imports System .Data .SqlClient
Module ProprietorDao
Dim conn As String = sqlconn( )
Dim conn2 As String = sqlconn2( )
Public Function ProprietorSelect( pno As String )
Dim proprietor As New Proprietor
Try
Dim objconn As New OleDbConnection( conn)
Dim objAdap As OleDbDataAdapter
Dim objDataSet As New DataSet
Dim strsql As String = "select * from Proprietor where Pno ='" & pno & "'"
objAdap = New OleDbDataAdapter( strsql, objconn)
objDataSet.Reset( )
objAdap.Fill( objDataSet, "Pro" )
proprietor.pnoSet( objDataSet.Tables( "Pro" ) .Rows( 0 ) .Item( 0 ) )
proprietor.pnameSet( objDataSet.Tables( "Pro" ) .Rows( 0 ) .Item( 1 ) )
proprietor.p_bnoSet( objDataSet.Tables( "Pro" ) .Rows( 0 ) .Item( 2 ) )
proprietor.p_gnoSet( objDataSet.Tables( "Pro" ) .Rows( 0 ) .Item( 3 ) )
proprietor.psexSet( objDataSet.Tables( "Pro" ) .Rows( 0 ) .Item( 4 ) )
proprietor.pageSet( objDataSet.Tables( "Pro" ) .Rows( 0 ) .Item( 5 ) )
proprietor.pnativeSet( objDataSet.Tables( "Pro" ) .Rows( 0 ) .Item( 6 ) )
Return proprietor
Catch ex As Exception
MsgBox( "ProprietorSelect" + ex.Message)
End Try
Return 0
End Function
Public Sub proprietorUpdata( proprietor As Proprietor)
Try
Dim strsql As String = "update Proprietor set Pname='" & proprietor.pnameGet & "',Psex='" & proprietor.psexGet & "',Page='" & proprietor.pageGet & "',Pnative='" & proprietor.pnativeGet & "',P_Bno='" & proprietor.p_bnoGet & "',P_Gno='" & proprietor.p_gnoGet & "' where Pno='" & proprietor.pnoGet & "'"
Dim objconn As New SqlConnection( conn2)
Dim objcmd As New SqlCommand( strsql, objconn)
objconn.Open ( )
objcmd.ExecuteNonQuery( )
MsgBox( "修改成功!")
objconn.Close ( )
Catch ex As Exception
MsgBox( "proprietorUpdata:" + ex.Message)
End Try
End Sub
Public Function proprietorSelectCount( pno As String )
Dim f As Integer
Try
Dim objconn As New SqlConnection( conn2)
Dim strsql1 As String = "select count(*) from Proprietor where Pno='" & pno & "' or Pname ='" & pno & "'"
objconn.Open ( )
Dim objcmd As New SqlCommand( strsql1, objconn)
f = objcmd.ExecuteScalar
objconn.Close ( )
objcmd.Dispose( )
Catch ex As Exception
MsgBox( "proprietorSelectCount" + ex.Message)
End Try
Return f
End Function
Public Function proprietorCount( )
Dim f As Integer
Try
Dim objconn As New SqlConnection( conn2)
Dim strsql1 As String = "select count(*) from Proprietor"
objconn.Open ( )
Dim objcmd As New SqlCommand( strsql1, objconn)
f = objcmd.ExecuteScalar
objconn.Close ( )
objcmd.Dispose( )
Catch ex As Exception
MsgBox( "proprietorCount" + ex.Message)
End Try
Return f
End Function
Public Function ProprietorSelectForPnoName( pnoandName As String )
Dim proprietor As New Proprietor
Try
Dim objconn As New OleDbConnection( conn)
Dim objAdap As OleDbDataAdapter
Dim objDataSet As New DataSet
Dim strsql As String = "select * from Proprietor where Pno ='" & pnoandName & "' or Pname ='" & pnoandName & "'"
objAdap = New OleDbDataAdapter( strsql, objconn)
objDataSet.Reset( )
objAdap.Fill( objDataSet, "Pro" )
proprietor.pnoSet( objDataSet.Tables( "Pro" ) .Rows( 0 ) .Item( 0 ) )
proprietor.pnameSet( objDataSet.Tables( "Pro" ) .Rows( 0 ) .Item( 1 ) )
proprietor.p_bnoSet( objDataSet.Tables( "Pro" ) .Rows( 0 ) .Item( 2 ) )
proprietor.p_gnoSet( objDataSet.Tables( "Pro" ) .Rows( 0 ) .Item( 3 ) )
proprietor.psexSet( objDataSet.Tables( "Pro" ) .Rows( 0 ) .Item( 4 ) )
proprietor.pageSet( objDataSet.Tables( "Pro" ) .Rows( 0 ) .Item( 5 ) )
proprietor.pnativeSet( objDataSet.Tables( "Pro" ) .Rows( 0 ) .Item( 6 ) )
Return proprietor
Catch ex As Exception
MsgBox( "ProprietorSelectForPnoName" + ex.Message)
End Try
Return 0
End Function
Public Sub proprietorInsert( proprietor As Proprietor)
Try
Dim strsql As String = "insert into Proprietor values ('" & proprietor.pnoGet & "','" & proprietor.pnameGet & "','" & proprietor.p_bnoGet & "','" & proprietor.p_gnoGet & "','" & proprietor.psexGet & "'," & proprietor.pageGet & ",'" & proprietor.pnativeGet & "')"
Dim objconn As New SqlConnection( conn2)
Dim objcmd As New SqlCommand( strsql, objconn)
objconn.Open ( )
objcmd.ExecuteNonQuery( )
objconn.Close ( )
Catch ex As Exception
MsgBox( "proprietorInsert:" + ex.Message)
End Try
End Sub
Public Sub proprietorDelete( pno As String )
Try
Dim strsql As String = "delete from Proprietor where Pno='" & pno & "'"
Dim objconn As New SqlConnection( conn2)
Dim objcmd As New SqlCommand( strsql, objconn)
objconn.Open ( )
objcmd.ExecuteNonQuery( )
objconn.Close ( )
Catch ex As Exception
MsgBox( "proprietorDelete:" + ex.Message)
End Try
End Sub
Public Function ProprietorSelectLike( pnoandName As String )
Dim pro( 100 ) As Proprietor
Try
Dim objconn As New OleDbConnection( conn)
Dim objAdap As OleDbDataAdapter
Dim objDataSet As New DataSet
Dim strsql As String = "select * from Proprietor where Pno like '" & pnoandName & "%' or Pname like '" & pnoandName & "%'"
objAdap = New OleDbDataAdapter( strsql, objconn)
objDataSet.Reset( )
objAdap.Fill( objDataSet, "Pro" )
For i = 0 To Int ( objDataSet.Tables( "Pro" ) .Rows.Count) - 1
Dim proprietor As New Proprietor
proprietor.pnoSet( objDataSet.Tables( "Pro" ) .Rows( i) .Item( 0 ) )
proprietor.pnameSet( objDataSet.Tables( "Pro" ) .Rows( i) .Item( 1 ) )
proprietor.p_bnoSet( objDataSet.Tables( "Pro" ) .Rows( i) .Item( 2 ) )
proprietor.p_gnoSet( objDataSet.Tables( "Pro" ) .Rows( i) .Item( 3 ) )
proprietor.psexSet( objDataSet.Tables( "Pro" ) .Rows( i) .Item( 4 ) )
proprietor.pageSet( objDataSet.Tables( "Pro" ) .Rows( i) .Item( 5 ) )
proprietor.pnativeSet( objDataSet.Tables( "Pro" ) .Rows( i) .Item( 6 ) )
pro( i + 1 ) = proprietor
Next
Catch ex As Exception
MsgBox( "ProprietorSelectForPnoName" + ex.Message)
End Try
Return pro
End Function
Public Function proprietorCountLike( pnoandName As String )
Dim f As Integer
Try
Dim objconn As New SqlConnection( conn2)
Dim strsql1 As String = "select count(*) from Proprietor where Pno like '" & pnoandName & "%' or Pname like '" & pnoandName & "%'"
objconn.Open ( )
Dim objcmd As New SqlCommand( strsql1, objconn)
f = objcmd.ExecuteScalar
objconn.Close ( )
objcmd.Dispose( )
Catch ex As Exception
MsgBox( "proprietorCount" + ex.Message)
End Try
Return f
End Function
End Module
ProprietorDao 管理人员数据库交互
Imports System .Data .OleDb
Imports System .Data .SqlClient
Module PropertyManagementDao
Dim conn As String = sqlconn( )
Dim conn2 As String = sqlconn2( )
Public Function PropertyManagementSelectLike( wnoandName As String )
Dim pro( 100 ) As PropetyManager
Try
Dim objconn As New OleDbConnection( conn)
Dim objAdap As OleDbDataAdapter
Dim objDataSet As New DataSet
Dim strsql As String = "select * from PropetyManager where PMno like '" & wnoandName & "%' or PMname like '" & wnoandName & "%'"
objAdap = New OleDbDataAdapter( strsql, objconn)
objDataSet.Reset( )
objAdap.Fill( objDataSet, "Pro" )
For i = 0 To Int ( objDataSet.Tables( "Pro" ) .Rows.Count) - 1
Dim proprietor As New PropetyManager
proprietor.pmnoSet( objDataSet.Tables( "Pro" ) .Rows( i) .Item( 0 ) )
proprietor.pmnameSet( objDataSet.Tables( "Pro" ) .Rows( i) .Item( 1 ) )
proprietor.pmsexSet( objDataSet.Tables( "Pro" ) .Rows( i) .Item( 2 ) )
proprietor.pmageSet( objDataSet.Tables( "Pro" ) .Rows( i) .Item( 3 ) )
proprietor.pmeduSet( objDataSet.Tables( "Pro" ) .Rows( i) .Item( 4 ) )
proprietor.pmnativeSet( objDataSet.Tables( "Pro" ) .Rows( i) .Item( 5 ) )
proprietor.pmdeptSet( objDataSet.Tables( "Pro" ) .Rows( i) .Item( 6 ) )
proprietor.pm_leaderSet( objDataSet.Tables( "Pro" ) .Rows( i) .Item( 7 ) )
pro( i + 1 ) = proprietor
Next
Catch ex As Exception
MsgBox( "PropertyManagementSelectLike" + ex.Message)
End Try
Return pro
End Function
Public Function PropertyManagementCountLike( wnoandName As String )
Dim f As Integer
Try
Dim objconn As New SqlConnection( conn2)
Dim strsql1 As String = "select count(*) from PropetyManager where PMno like '" & wnoandName & "%' or PMname like '" & wnoandName & "%'"
objconn.Open ( )
Dim objcmd As New SqlCommand( strsql1, objconn)
f = objcmd.ExecuteScalar
objconn.Close ( )
objcmd.Dispose( )
Catch ex As Exception
MsgBox( "PropertyManagementCountLike" + ex.Message)
End Try
Return f
End Function
Public Function PropertyManagementSelect( wnoandName As String )
Dim proprietor As New PropetyManager
Try
Dim objconn As New OleDbConnection( conn)
Dim objAdap As OleDbDataAdapter
Dim objDataSet As New DataSet
Dim strsql As String = "select * from PropetyManager where PMno= '" & wnoandName & "'"
objAdap = New OleDbDataAdapter( strsql, objconn)
objDataSet.Reset( )
objAdap.Fill( objDataSet, "Pro" )
proprietor.pmnoSet( objDataSet.Tables( "Pro" ) .Rows( 0 ) .Item( 0 ) )
proprietor.pmnameSet( objDataSet.Tables( "Pro" ) .Rows( 0 ) .Item( 1 ) )
proprietor.pmsexSet( objDataSet.Tables( "Pro" ) .Rows( 0 ) .Item( 2 ) )
proprietor.pmageSet( objDataSet.Tables( "Pro" ) .Rows( 0 ) .Item( 3 ) )
proprietor.pmeduSet( objDataSet.Tables( "Pro" ) .Rows( 0 ) .Item( 4 ) )
proprietor.pmnativeSet( objDataSet.Tables( "Pro" ) .Rows( 0 ) .Item( 5 ) )
proprietor.pmdeptSet( objDataSet.Tables( "Pro" ) .Rows( 0 ) .Item( 6 ) )
proprietor.pm_leaderSet( objDataSet.Tables( "Pro" ) .Rows( 0 ) .Item( 7 ) )
Catch ex As Exception
MsgBox( "PropertyManagementSelectLike" + ex.Message)
End Try
Return proprietor
End Function
Public Sub PropertyManagementDelete( pno As String )
Try
Dim strsql As String = "delete from PropetyManager where PMno='" & pno & "'"
Dim objconn As New SqlConnection( conn2)
Dim objcmd As New SqlCommand( strsql, objconn)
objconn.Open ( )
objcmd.ExecuteNonQuery( )
objconn.Close ( )
Catch ex As Exception
MsgBox( "PropertyManagementDelete:" + ex.Message)
End Try
End Sub
Public Sub PropertyManagementUpdata( pm As PropetyManager)
Try
Dim strsql As String = "update PropetyManager set PMname ='" & pm.pmnameGet & "',PMage =" & pm.pmageGet & ",PMsex ='" & pm.pmsexGet & "',PMdept='" & pm.pmdeptGet & "',PMedu ='" & pm.pmeduGet & "',PMnative ='" & pm.pmnativeGet & "',PM_Leader ='" & pm.pm_leaderGet & "' where PMno ='" & pm.pmnoGet & "'"
Dim objconn As New SqlConnection( conn2)
Dim objcmd As New SqlCommand( strsql, objconn)
objconn.Open ( )
objcmd.ExecuteNonQuery( )
objconn.Close ( )
Catch ex As Exception
MsgBox( "PropertyManagementUpdata:" + ex.Message)
End Try
End Sub
Public Function PropertyManagementSelectForDept( )
Dim pro( 100 ) As PropetyManager
Try
Dim objconn As New OleDbConnection( conn)
Dim objAdap As OleDbDataAdapter
Dim objDataSet As New DataSet
Dim strsql As String = "select * from PropetyManager where PMdept=
objAdap = New OleDbDataAdapter( strsql, objconn)
objDataSet.Reset( )
objAdap.Fill( objDataSet, "Pro" )
For i = 0 To Int ( objDataSet.Tables( "Pro" ) .Rows.Count) - 1
Dim proprietor As New PropetyManager
proprietor.pmnoSet( objDataSet.Tables( "Pro" ) .Rows( i) .Item( 0 ) )
proprietor.pmnameSet( objDataSet.Tables( "Pro" ) .Rows( i) .Item( 1 ) )
proprietor.pmsexSet( objDataSet.Tables( "Pro" ) .Rows( i) .Item( 2 ) )
proprietor.pmageSet( objDataSet.Tables( "Pro" ) .Rows( i) .Item( 3 ) )
proprietor.pmeduSet( objDataSet.Tables( "Pro" ) .Rows( i) .Item( 4 ) )
proprietor.pmnativeSet( objDataSet.Tables( "Pro" ) .Rows( i) .Item( 5 ) )
proprietor.pmdeptSet( objDataSet.Tables( "Pro" ) .Rows( i) .Item( 6 ) )
proprietor.pm_leaderSet( objDataSet.Tables( "Pro" ) .Rows( i) .Item( 7 ) )
pro( i + 1 ) = proprietor
Next
Catch ex As Exception
MsgBox( "PropertyManagementSelectLike" + ex.Message)
End Try
Return pro
End Function
Public Function PropertyManagementCountJL( )
Dim f As Integer
Try
Dim objconn As New SqlConnection( conn2)
Dim strsql1 As String = "select count( * ) from PropetyManager where PMdept=
objconn.Open ( )
Dim objcmd As New SqlCommand( strsql1, objconn)
f = objcmd.ExecuteScalar
objconn.Close ( )
objcmd.Dispose( )
Catch ex As Exception
MsgBox( "PropertyManagementCountJL" + ex.Message)
End Try
Return f
End Function
Public Function PropertyManagementSelectWno( wnoandName As String )
Try
Dim objconn As New OleDbConnection( conn)
Dim objAdap As OleDbDataAdapter
Dim objDataSet As New DataSet
Dim strsql As String = "select PMno from PropetyManager where PMname='" & wnoandName & "'"
objAdap = New OleDbDataAdapter( strsql, objconn)
objDataSet.Reset( )
objAdap.Fill( objDataSet, "Pro" )
Return objDataSet.Tables( "Pro" ) .Rows( 0 ) .Item( 0 )
Catch ex As Exception
MsgBox( "PropertyManagementSelectLike" + ex.Message)
End Try
Return 0
End Function
Public Function PropertyManagementSelectforAll( )
Dim pro( 100 ) As PropetyManager
Try
Dim objconn As New OleDbConnection( conn)
Dim objAdap As OleDbDataAdapter
Dim objDataSet As New DataSet
Dim strsql As String = "select * from PropetyManager"
objAdap = New OleDbDataAdapter( strsql, objconn)
objDataSet.Reset( )
objAdap.Fill( objDataSet, "Pro" )
For i = 0 To Int ( objDataSet.Tables( "Pro" ) .Rows.Count) - 1
Dim proprietor As New PropetyManager
proprietor.pmnoSet( objDataSet.Tables( "Pro" ) .Rows( i) .Item( 0 ) )
proprietor.pmnameSet( objDataSet.Tables( "Pro" ) .Rows( i) .Item( 1 ) )
proprietor.pmsexSet( objDataSet.Tables( "Pro" ) .Rows( i) .Item( 2 ) )
proprietor.pmageSet( objDataSet.Tables( "Pro" ) .Rows( i) .Item( 3 ) )
proprietor.pmeduSet( objDataSet.Tables( "Pro" ) .Rows( i) .Item( 4 ) )
proprietor.pmnativeSet( objDataSet.Tables( "Pro" ) .Rows( i) .Item( 5 ) )
proprietor.pmdeptSet( objDataSet.Tables( "Pro" ) .Rows( i) .Item( 6 ) )
proprietor.pm_leaderSet( objDataSet.Tables( "Pro" ) .Rows( i) .Item( 7 ) )
pro( i + 1 ) = proprietor
Next
Catch ex As Exception
MsgBox( "PropertyManagementSelectforAll" + ex.Message)
End Try
Return pro
End Function
Public Function PropertyManagementSelectforAllCount( )
Dim f As Integer
Try
Dim objconn As New SqlConnection( conn2)
Dim strsql1 As String = "select count(*) from PropetyManager"
objconn.Open ( )
Dim objcmd As New SqlCommand( strsql1, objconn)
f = objcmd.ExecuteScalar
objconn.Close ( )
objcmd.Dispose( )
Catch ex As Exception
MsgBox( "PropertyManagementSelectforAllCount" + ex.Message)
End Try
Return f
End Function
Public Sub PropertyManagementInsert( pm As PropetyManager)
Try
Dim strsql As String = "insert into PropetyManager values ('" & pm.pmnoGet & "','" & pm.pmnameGet & "','" & pm.pmsexGet & "'," & pm.pmageGet & ",'" & pm.pmeduGet & "','" & pm.pmnativeGet & "','" & pm.pmdeptGet & "','" & pm.pm_leaderGet & "')"
Dim objconn As New SqlConnection( conn2)
Dim objcmd As New SqlCommand( strsql, objconn)
objconn.Open ( )
objcmd.ExecuteNonQuery( )
objconn.Close ( )
Catch ex As Exception
MsgBox( "PropertyManagementInsert:" + ex.Message)
End Try
End Sub
End Module
GarageDao 车库数据库交互
Imports System .Data .OleDb
Imports System .Data .SqlClient
Module GarageDao
Dim conn As String = sqlconn( )
Dim conn2 As String = sqlconn2( )
Public Function GarageSelect( )
Dim ga( 1000 ) As Garage
Try
Dim objconn As New OleDbConnection( conn)
Dim objAdap As OleDbDataAdapter
Dim objDataSet As New DataSet
Dim strsql As String = "select * from Garage"
objAdap = New OleDbDataAdapter( strsql, objconn)
objDataSet.Reset( )
objAdap.Fill( objDataSet, "Gar" )
For i = 0 To objDataSet.Tables( "Gar" ) .Rows.Count - 1
Dim garage As New Garage
garage.gnoSet( objDataSet.Tables( "Gar" ) .Rows( i) .Item( 1 ) )
garage.gaddressSet( objDataSet.Tables( "Gar" ) .Rows( i) .Item( 1 ) )
Next
Catch ex As Exception
MsgBox( "GarageSelect" + ex.Message)
End Try
Return ga
End Function
Public Function GarageSelectByGno( gno As String )
Dim garage As New Garage
Try
Dim objconn As New OleDbConnection( conn)
Dim objAdap As OleDbDataAdapter
Dim objDataSet As New DataSet
Dim strsql As String = "select * from Garage where Gno ='" & gno & "'"
objAdap = New OleDbDataAdapter( strsql, objconn)
objDataSet.Reset( )
objAdap.Fill( objDataSet, "Gar" )
garage.gnoSet( gno)
garage.gaddressSet( objDataSet.Tables( "Gar" ) .Rows( 0 ) .Item( 1 ) )
Return garage
Catch ex As Exception
MsgBox( "GarageSelectByGno" + ex.Message)
End Try
Return 0
End Function
Public Function GarageSelectGaddress( )
Dim s( 100 ) As String
Try
Dim objconn As New OleDbConnection( conn)
Dim objAdap As OleDbDataAdapter
Dim objDataSet As New DataSet
Dim strsql As String = "select Gaddress from View_Garage_NO"
objAdap = New OleDbDataAdapter( strsql, objconn)
objDataSet.Reset( )
objAdap.Fill( objDataSet, "Gar" )
s( 0 ) = Int ( objDataSet.Tables( "Gar" ) .Rows.Count)
For i = 0 To Int ( objDataSet.Tables( "Gar" ) .Rows.Count) - 1
s( i + 1 ) = objDataSet.Tables( "Gar" ) .Rows( i) .Item( 0 )
Next
Catch ex As Exception
MsgBox( "GarageSelectGaddress" + ex.Message)
End Try
Return s
End Function
Public Function GarageSelectGno( address As String )
Try
Dim objconn As New OleDbConnection( conn)
Dim objAdap As OleDbDataAdapter
Dim objDataSet As New DataSet
Dim strsql As String = "select Gno from Garage where Gaddress='" & address & "'"
objAdap = New OleDbDataAdapter( strsql, objconn)
objDataSet.Reset( )
objAdap.Fill( objDataSet, "Gar" )
Return objDataSet.Tables( "Gar" ) .Rows( 0 ) .Item( 0 )
Catch ex As Exception
MsgBox( "GarageSelectGaddress" + ex.Message)
End Try
Return 0
End Function
Public Function GarageSelectLike( bno As String )
Dim b( 1000 ) As Garage
Try
Dim objconn As New OleDbConnection( conn)
Dim objAdap As OleDbDataAdapter
Dim objDataSet As New DataSet
Dim strsql As String = "select * from View_Garage_NO where Gno like'" & bno & "%' or Gaddress like '" & bno & "%'"
objAdap = New OleDbDataAdapter( strsql, objconn)
objDataSet.Reset( )
objAdap.Fill( objDataSet, "Bui" )
For i = 0 To objDataSet.Tables( "Bui" ) .Rows.Count - 1
Dim building As New Garage
building.gnoSet( objDataSet.Tables( "Bui" ) .Rows( i) .Item( 0 ) )
building.gaddressSet( objDataSet.Tables( "Bui" ) .Rows( i) .Item( 1 ) )
b( i + 1 ) = building
Next
Catch ex As Exception
MsgBox( "GarageSelectLike" + ex.Message)
End Try
Return b
End Function
Public Function GarageSelectLikeCount( bno As String )
Dim f As Integer
Try
Dim objconn As New SqlConnection( conn2)
Dim strsql1 As String = "select count(*) from View_Garage_NO where Gno like'" & bno & "%' or Gaddress like '" & bno & "%'"
objconn.Open ( )
Dim objcmd As New SqlCommand( strsql1, objconn)
f = objcmd.ExecuteScalar
objconn.Close ( )
objcmd.Dispose( )
Catch ex As Exception
MsgBox( "GarageSelectLikeCount" + ex.Message)
End Try
Return f
End Function
Public Function GarageSelectCount( )
Dim f As Integer
Try
Dim objconn As New SqlConnection( conn2)
Dim strsql1 As String = "select count(*) from Garage"
objconn.Open ( )
Dim objcmd As New SqlCommand( strsql1, objconn)
f = objcmd.ExecuteScalar
objconn.Close ( )
objcmd.Dispose( )
Catch ex As Exception
MsgBox( "GarageSelectCount" + ex.Message)
End Try
Return f
End Function
Public Sub GarageDelete( pno As String )
Try
Dim strsql As String = "delete from Garage where Gno ='" & pno & "'"
Dim objconn As New SqlConnection( conn2)
Dim objcmd As New SqlCommand( strsql, objconn)
objconn.Open ( )
objcmd.ExecuteNonQuery( )
objconn.Close ( )
Catch ex As Exception
MsgBox( "GarageDelete:" + ex.Message)
End Try
End Sub
Public Sub GarageInsert( pno As Garage)
Try
Dim strsql As String = "insert into Garage values ('" & pno.gnoGet & "','" & pno.gaddressGet & "')"
Dim objconn As New SqlConnection( conn2)
Dim objcmd As New SqlCommand( strsql, objconn)
objconn.Open ( )
objcmd.ExecuteNonQuery( )
objconn.Close ( )
Catch ex As Exception
MsgBox( "GarageInsert:" + ex.Message)
End Try
End Sub
End Module
CostDao 缴费数据库交互
Imports System .Data .OleDb
Imports System .Data .SqlClient
Module CostDao
Dim conn As String = sqlconn( )
Dim conn2 As String = sqlconn2( )
Public Function costSelect( pno As String )
Dim cost As New Cost( )
Try
Dim objconn As New OleDbConnection( conn)
Dim objAdap As OleDbDataAdapter
Dim objDataSet As New DataSet
Dim strsql As String = "select Cwater,Celectricity,Cgas,Cproperty,C_Bno from Cost where C_Pno ='" & pno & "'"
objAdap = New OleDbDataAdapter( strsql, objconn)
objDataSet.Reset( )
objAdap.Fill( objDataSet, "Cost" )
cost.c_pnoSet( pno)
cost.cwaterSet( objDataSet.Tables( "Cost" ) .Rows( 0 ) .Item( 0 ) )
cost.celectricitySet( objDataSet.Tables( "Cost" ) .Rows( 0 ) .Item( 1 ) )
cost.cgasSet( objDataSet.Tables( "Cost" ) .Rows( 0 ) .Item( 2 ) )
cost.cpropertySet( objDataSet.Tables( "Cost" ) .Rows( 0 ) .Item( 3 ) )
cost.c_bnoSet( objDataSet.Tables( "Cost" ) .Rows( 0 ) .Item( 4 ) )
Catch ex As Exception
MsgBox( "costSelect:" + ex.Message)
End Try
Return cost
End Function
Public Sub costUpdata( str As String , pno As String , number As Double )
Try
Dim strsql As String = "update Cost set " & str & " = " & number & " where C_Pno ='" & pno & "'"
Dim objconn As New SqlConnection( conn2)
Dim objcmd As New SqlCommand( strsql, objconn)
objconn.Open ( )
objcmd.ExecuteNonQuery( )
objconn.Close ( )
Catch ex As Exception
MsgBox( "costUpdata:" + ex.Message)
End Try
End Sub
Public Sub costInsert( pno As String , bno As String )
Try
Dim strsql As String = "insert into Cost values ('" & pno & "','" & bno & "',0,0,0,0)"
Dim objconn As New SqlConnection( conn2)
Dim objcmd As New SqlCommand( strsql, objconn)
objconn.Open ( )
objcmd.ExecuteNonQuery( )
objconn.Close ( )
Catch ex As Exception
MsgBox( "costInsert:" + ex.Message)
End Try
End Sub
Public Sub costDelete( pno As String )
Try
Dim strsql As String = "delete from Cost where C_Pno ='" & pno & "'"
Dim objconn As New SqlConnection( conn2)
Dim objcmd As New SqlCommand( strsql, objconn)
objconn.Open ( )
objcmd.ExecuteNonQuery( )
objconn.Close ( )
Catch ex As Exception
MsgBox( "costDelete:" + ex.Message)
End Try
End Sub
Public Sub costSelectAll( )
Try
Dim objconn As New OleDbConnection( conn)
Dim objAdap As OleDbDataAdapter
Dim objDataSet As New DataSet
Dim i As Integer
Dim strsql As String = "select Cwater,Celectricity,Cgas,Cproperty,C_Bno,C_Pno from Cost"
objAdap = New OleDbDataAdapter( strsql, objconn)
objDataSet.Reset( )
objAdap.Fill( objDataSet, "Cost" )
For i = 0 To Int ( objDataSet.Tables( "Cost" ) .Rows.Count) - 1
costUpdata( "Cwater" , objDataSet.Tables( "Cost" ) .Rows( i) .Item( 5 ) , CDbl ( Str ( objDataSet.Tables( "Cost" ) .Rows( i) .Item( 0 ) ) ) - 20 )
costUpdata( "Celectricity" , objDataSet.Tables( "Cost" ) .Rows( i) .Item( 5 ) , CDbl ( Str ( objDataSet.Tables( "Cost" ) .Rows( i) .Item( 1 ) ) ) - 30 )
costUpdata( "Cgas" , objDataSet.Tables( "Cost" ) .Rows( i) .Item( 5 ) , CDbl ( Str ( objDataSet.Tables( "Cost" ) .Rows( i) .Item( 2 ) ) ) - 40 )
costUpdata( "Cproperty" , objDataSet.Tables( "Cost" ) .Rows( i) .Item( 5 ) , CDbl ( Str ( objDataSet.Tables( "Cost" ) .Rows( i) .Item( 3 ) ) ) - 50 )
Next
Catch ex As Exception
MsgBox( "costSelectAll:" + ex.Message)
End Try
End Sub
Public Function costSelectCount( pno As String )
Dim f As Integer
Try
Dim objconn As New SqlConnection( conn2)
Dim strsql1 As String = "select count(*) from Cost where C_Pno='" & pno & "'"
objconn.Open ( )
Dim objcmd As New SqlCommand( strsql1, objconn)
f = objcmd.ExecuteScalar
objconn.Close ( )
objcmd.Dispose( )
Catch ex As Exception
MsgBox( "costSelectCount" + ex.Message)
End Try
If ( f > 0 ) Then
Return 1
Else
Return 0
End If
End Function
End Module
BuildingDao 楼房数据库交互
Imports System .Data .OleDb
Imports System .Data .SqlClient
Module BuildingDao
Dim conn As String = sqlconn( )
Dim conn2 As String = sqlconn2( )
Public Function BuildingSelectByBno( bno As String )
Dim building As New Building
Try
Dim objconn As New OleDbConnection( conn)
Dim objAdap As OleDbDataAdapter
Dim objDataSet As New DataSet
Dim strsql As String = "select * from Building where Bno ='" & bno & "'"
objAdap = New OleDbDataAdapter( strsql, objconn)
objDataSet.Reset( )
objAdap.Fill( objDataSet, "Bui" )
building.bnoSet( bno)
building.bareaSet( objDataSet.Tables( "Bui" ) .Rows( 0 ) .Item( 1 ) )
building.blounoSet( objDataSet.Tables( "Bui" ) .Rows( 0 ) .Item( 2 ) )
building.bapartmentSet( objDataSet.Tables( "Bui" ) .Rows( 0 ) .Item( 3 ) )
building.broomnoSet( objDataSet.Tables( "Bui" ) .Rows( 0 ) .Item( 4 ) )
Return building
Catch ex As Exception
MsgBox( "BuildingSelectByBno" + ex.Message)
End Try
Return 0
End Function
Public Function BuildingSelectForBarea( )
Dim s( 100 ) As String
Try
Dim objconn As New OleDbConnection( conn)
Dim objAdap As OleDbDataAdapter
Dim objDataSet As New DataSet
Dim strsql As String = "select distinct Barea from View_Building_NO"
objAdap = New OleDbDataAdapter( strsql, objconn)
objDataSet.Reset( )
objAdap.Fill( objDataSet, "Bui" )
s( 0 ) = objDataSet.Tables( "Bui" ) .Rows.Count
For i = 0 To Int ( objDataSet.Tables( "Bui" ) .Rows.Count) - 1
s( i + 1 ) = objDataSet.Tables( "Bui" ) .Rows( i) .Item( 0 )
Next
Catch ex As Exception
MsgBox( "BuildingSelectForBarea" + ex.Message)
End Try
Return s
End Function
Public Function BuildingSelectForBlouno( barea As String )
Dim s( 100 ) As String
Try
Dim objconn As New OleDbConnection( conn)
Dim objAdap As OleDbDataAdapter
Dim objDataSet As New DataSet
Dim strsql As String = "select distinct Blouno from View_Building_NO where Barea='" & barea & "'"
objAdap = New OleDbDataAdapter( strsql, objconn)
objDataSet.Reset( )
objAdap.Fill( objDataSet, "Bui" )
s( 0 ) = objDataSet.Tables( "Bui" ) .Rows.Count
For i = 0 To Int ( objDataSet.Tables( "Bui" ) .Rows.Count) - 1
s( i + 1 ) = objDataSet.Tables( "Bui" ) .Rows( i) .Item( 0 )
Next
Catch ex As Exception
MsgBox( "BuildingSelectForBarea" + ex.Message)
End Try
Return s
End Function
Public Function BuildingSelectForBapartment( barea As String , blouno As String )
Dim s( 100 ) As String
Try
Dim objconn As New OleDbConnection( conn)
Dim objAdap As OleDbDataAdapter
Dim objDataSet As New DataSet
Dim strsql As String = "select distinct Bapartment from View_Building_NO where Barea='" & barea & "' and Blouno='" & blouno & "'"
objAdap = New OleDbDataAdapter( strsql, objconn)
objDataSet.Reset( )
objAdap.Fill( objDataSet, "Bui" )
s( 0 ) = objDataSet.Tables( "Bui" ) .Rows.Count
For i = 0 To Int ( objDataSet.Tables( "Bui" ) .Rows.Count) - 1
s( i + 1 ) = objDataSet.Tables( "Bui" ) .Rows( i) .Item( 0 )
Next
Catch ex As Exception
MsgBox( "BuildingSelectForBarea" + ex.Message)
End Try
Return s
End Function
Public Function BuildingSelectForBRoomNo( barea As String , blouno As String , bapartment As String )
Dim s( 100 ) As String
Try
Dim objconn As New OleDbConnection( conn)
Dim objAdap As OleDbDataAdapter
Dim objDataSet As New DataSet
Dim strsql As String = "select distinct BRoomNo from View_Building_NO where Barea='" & barea & "' and Blouno='" & blouno & "' and Bapartment='" & bapartment & "'"
objAdap = New OleDbDataAdapter( strsql, objconn)
objDataSet.Reset( )
objAdap.Fill( objDataSet, "Bui" )
s( 0 ) = objDataSet.Tables( "Bui" ) .Rows.Count
For i = 0 To Int ( objDataSet.Tables( "Bui" ) .Rows.Count) - 1
s( i + 1 ) = objDataSet.Tables( "Bui" ) .Rows( i) .Item( 0 )
Next
Catch ex As Exception
MsgBox( "BuildingSelectForBarea" + ex.Message)
End Try
Return s
End Function
Public Function BuildingSelectForBno( barea As String , blouno As String , bapartment As String , bRoomNo As String )
Dim s( 100 ) As String
Try
Dim objconn As New OleDbConnection( conn)
Dim objAdap As OleDbDataAdapter
Dim objDataSet As New DataSet
Dim strsql As String = "select Bno from Building where Barea='" & barea & "' and Blouno='" & blouno & "' and Bapartment='" & bapartment & "' and BRoomNo='" & bRoomNo & "'"
objAdap = New OleDbDataAdapter( strsql, objconn)
objDataSet.Reset( )
objAdap.Fill( objDataSet, "Bui" )
Return objDataSet.Tables( "Bui" ) .Rows( 0 ) .Item( 0 )
Catch ex As Exception
MsgBox( "BuildingSelectForBno" + ex.Message)
End Try
Return 0
End Function
Public Function BuildingSelectLike( bno As String )
Dim b( 1000 ) As Building
Try
Dim objconn As New OleDbConnection( conn)
Dim objAdap As OleDbDataAdapter
Dim objDataSet As New DataSet
Dim strsql As String = "select * from View_Building_NO where Bno like'" & bno & "%'"
objAdap = New OleDbDataAdapter( strsql, objconn)
objDataSet.Reset( )
objAdap.Fill( objDataSet, "Bui" )
For i = 0 To objDataSet.Tables( "Bui" ) .Rows.Count - 1
Dim building As New Building
building.bnoSet( objDataSet.Tables( "Bui" ) .Rows( i) .Item( 0 ) )
building.bareaSet( objDataSet.Tables( "Bui" ) .Rows( i) .Item( 1 ) )
building.blounoSet( objDataSet.Tables( "Bui" ) .Rows( i) .Item( 2 ) )
building.bapartmentSet( objDataSet.Tables( "Bui" ) .Rows( i) .Item( 3 ) )
building.broomnoSet( objDataSet.Tables( "Bui" ) .Rows( i) .Item( 4 ) )
b( i + 1 ) = building
Next
Catch ex As Exception
MsgBox( "BuildingSelectLike" + ex.Message)
End Try
Return b
End Function
Public Function BuildingSelectCount( bno As String )
Dim f As Integer
Try
Dim objconn As New SqlConnection( conn2)
Dim strsql1 As String = "select count(*) from View_Building_NO where Bno like'" & bno & "%'"
objconn.Open ( )
Dim objcmd As New SqlCommand( strsql1, objconn)
f = objcmd.ExecuteScalar
objconn.Close ( )
objcmd.Dispose( )
Catch ex As Exception
MsgBox( "BuildingSelectCount" + ex.Message)
End Try
Return f
End Function
Public Sub BuiDelete( pno As String )
Try
Dim strsql As String = "delete from Building where Bno ='" & pno & "'"
Dim objconn As New SqlConnection( conn2)
Dim objcmd As New SqlCommand( strsql, objconn)
objconn.Open ( )
objcmd.ExecuteNonQuery( )
objconn.Close ( )
Catch ex As Exception
MsgBox( "BuiDelete:" + ex.Message)
End Try
End Sub
End Module