my whole vb.net sample project code url

May 19, 2009

http://www.mediafire.com/?sharekey=a1f25174745d66d700d27174b47c6657e04e75f6e8ebb871


My module used in vb.net

May 19, 2009

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


vb.net code for searching

May 19, 2009

i have used a textbox in the key up event this is wat i did :

i have also used add modules where i stored my codes for functions that i would use through out this project

Dim SQLString As String
Dim dtdbEmp As New DataTable
Dim DataAdapter1 As New OleDb.OleDbDataAdapter

Dim ConnectString As OleDb.OleDbConnection = New OleDb.OleDbConnection
DbConnect(ConnectString)
Try
Dim params_to_search As String = txtParam.Text

If rbtnempID.Checked = True Then
SQLString = “SELECT * FROM tblEmployee_Users WHERE ID=”
SQLString = SQLString & Trim(txtParam.Text)

Else
SQLString = “SELECT * FROM tblEmployee_Users WHERE Lastname LIKE “
SQLString = SQLString & “‘” & txtParam.Text & “%’”
End If

If params_to_search.Length > 0 Then
DataAdapter1 = New OleDb.OleDbDataAdapter(SQLString, ConnectString)
DataAdapter1.Fill(dtdbEmp)
DataGridView1.DataSource = dtdbEmp

End If
Catch ex As Exception
MsgBox(ex.Message)
End Try

DbDisconnect(ConnectString)


Some Vb.net Codes for My Login

May 19, 2009

If login_attempts = 2 Then
MsgBox(“You have exceeded the Number of Attempts allowed”, MsgBoxStyle.Critical, “Invalid Login Attempts”)
End
End If

Dim qryString, acc_ative, admin_type As String

Dim connection As OleDb.OleDbConnection = New OleDb.OleDbConnection

qryString = “SELECT * FROM tblEmployee_Users WHERE Emp_Username=”
qryString = qryString & “‘” & txtUsername.Text & “‘”
qryString = qryString & ” AND Emp_password=” & “‘” & txtPassword.Text & “‘”

DbConnect(connection) ‘connecting to database

Dim Command1 As OleDb.OleDbCommand = New OleDb.OleDbCommand(qryString)
Command1.CommandType = CommandType.Text
Command1.Connection = connection

Dim Reader1 As OleDb.OleDbDataReader = Command1.ExecuteReader()

Dim user_type As String

If Reader1.HasRows Then

While (Reader1.Read())
admin_type = Reader1(“Emp_Is_Admin”).ToString
acc_ative = Reader1(“Emp_Acct_Active”).ToString

user_type = admin_type

If admin_type.Equals(“True”) Then
usertype_admin = True

Else
usertype_admin = False

End If
If acc_ative.Equals(“True”) Then
loged_on = txtUsername.Text
txtUsername.Text = “”
txtPassword.Text = “”
frmMenu.Show()
Me.Hide()
End If
End While

Else
txtUsername.BackColor = Color.Red
txtPassword.BackColor = Color.Red
txtUsername.Focus()
login_attempts = login_attempts + 1
End If

DbDisconnect(connection)


Follow

Get every new post delivered to your Inbox.