Module MyLibraryCodes
‘This modules contains the code that is used and repeats through this project
Public path As String = “C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\New Age Entertainment MIS”
Public loged_on As String
Public login_attempts As Integer ‘variable used to chek login attempt
Public usertype_admin As Boolean ‘is used like a session variable to know throughout if user is an admin
Public Sub load_default_combo(ByRef cmbox As ComboBox)
With cmbox
.SelectedItem = 0
.SelectedValue = 0
.SelectedIndex = 0
.Items.IndexOf(0)
End With
End Sub
Public Function msg_panel(ByRef txt As TextBox, ByVal msg_title As String, ByVal msg As String)
If txt.Text.Trim = String.Empty Then
MessageBox.Show(msg_title, msg, MessageBoxButtons.OK, MessageBoxIcon.Error)
txt.Focus()
changecolor(txt, Color.Red)
txt.SelectAll()
Return False
End If
Return True
End Function
Public Sub clearComponent(ByRef frm As Form)
‘this component clears the component text on a form
For Each txt As Control In frm.Controls
If TypeOf txt Is TextBox Then
txt.Text = “”
End If
If TypeOf txt Is ComboBox Then
txt.Text = “”
End If
If TypeOf txt Is MaskedTextBox Then
txt.Text = “”
End If
Next
End Sub
Public Sub changecolor(ByRef txt As TextBox, ByVal clor As Color)
‘This procedure allows the color of a textbox to be changed
txt.BackColor = clor
End Sub
Public Sub enable_components(ByRef frm As Form, ByVal cvalue As Boolean)
‘This Procedure enables and disables components Accordingly
For Each txt As Control In frm.Controls
If TypeOf txt Is TextBox Then
txt.Enabled = cvalue
End If
If TypeOf txt Is ComboBox Then
txt.Enabled = cvalue
End If
If TypeOf txt Is DateTimePicker Then
txt.Enabled = cvalue
End If
If TypeOf txt Is MaskedTextBox Then
txt.Enabled = cvalue
End If
If TypeOf txt Is CheckBox Then
txt.Enabled = cvalue
End If
Next
End Sub
Public Sub DbConnect(ByRef conn As OleDb.OleDbConnection)
‘This procedure creates a Connection to database
‘Dim path As String = System.AppDomain.CurrentDomain.BaseDirectory()
Dim connString As String = _
“Provider=Microsoft.Jet.OLEDB.4.0;” & _
“Data Source=” & path & “\Video_Club_MIS.mdb;” & “Jet OLEDB:Database Password=” & “administrator”
conn = New OleDb.OleDbConnection(connString)
Try
conn.Open()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Public Sub DbDisconnect(ByRef conn As OleDb.OleDbConnection)
‘This procedure close a connection to database
conn.Close()
End Sub
Public Sub ChekMdiChild(ByRef frm As Form)
‘This procedure checks whether an mdi child already exist , n if so, closes it
For Each f As Form In frm.MdiChildren
f.Close()
Next
End Sub
End Module