Beruflich Dokumente
Kultur Dokumente
acsconnadministrator As New OleDbConnection acsdradministrator As OleDbDataReader acsdaadministrator As New OleDbDataAdapter strsqladministrator As String acsconnstudentschedule As New OleDbConnection acsdrstudentschedule As OleDbDataReader acsdastudentschedule As New OleDbDataAdapter strsqlstudentschedule As String
acsconnstudentmonitoring As New OleDbConnection acsdrstudentmonitoring As OleDbDataReader acsdastudentmonitoring As New OleDbDataAdapter strsqlstudentmonitoring As String acsconnregistrar As New OleDbConnection acsdrregistrar As OleDbDataReader acsdaregistrar As New OleDbDataAdapter strsqlregistrar As String
Sub connectadministrator() acsconnadministrator.ConnectionString = "Provider=microsoft.ace.oledb.12.0; data source=|datadirectory|administrator.accdb; persist security info=false;" acsconnadministrator.Open() If acsconnadministrator.State = ConnectionState.Open Then End If End Sub Sub connectstudentschedule() acsconnstudentschedule.ConnectionString = "Provider=microsoft.ace.oledb.12.0; data source=|datadirectory|studentschedule.accdb; persist security info=false;" acsconnstudentschedule.Open() If acsconnstudentschedule.State = ConnectionState.Open Then End If End Sub Sub connectstudentmonitoring() acsconnstudentmonitoring.ConnectionString = "Provider=microsoft.ace.oledb.12.0; data source=|datadirectory|studentmonitoring.accdb; persist security info=false;" acsconnstudentmonitoring.Open()
Sub connectregistrar() acsconnregistrar.ConnectionString = "Provider=microsoft.ace.oledb.12.0; data source=|datadirectory|registrar.accdb; persist security info=false;" acsconnregistrar.Open() If acsconnregistrar.State = ConnectionState.Open Then End If End Sub
End Module
End Sub
Sub filllistview1() strsqlstudentmonitoring = "select * from studentmonitoring" Dim acscmd As New OleDb.OleDbCommand acscmd.CommandText = strsqlstudentmonitoring acscmd.Connection = acsconnstudentmonitoring acsdastudentmonitoring.SelectCommand = acscmd acsdrstudentmonitoring = acscmd.ExecuteReader ListView1.Items.Clear() While (acsdrstudentmonitoring.Read()) With ListView1.Items.Add(acsdrstudentmonitoring("studentnum")) .subitems.add(acsdrstudentmonitoring("ipaddress")) .subitems.add(acsdrstudentmonitoring("pcname")) .subitems.add(acsdrstudentmonitoring("date")) .subitems.add(acsdrstudentmonitoring("time"))
Sub searchrecord(ByVal searchword As String) strsqlstudentmonitoring = "select * from studentmonitoring where studentnum like '" & txtstudnum.Text & "%'" Dim acscmd As New OleDb.OleDbCommand acscmd.CommandText = strsqlstudentmonitoring acscmd.Connection = acsconnstudentmonitoring
acsdaadministrator.SelectCommand = acscmd acsdrstudentmonitoring = acscmd.ExecuteReader ListView1.Items.Clear() While (acsdrstudentmonitoring.Read()) With ListView1.Items.Add(acsdrstudentmonitoring("studentnum")) .subitems.add(acsdrstudentmonitoring("ipaddress")) .subitems.add(acsdrstudentmonitoring("pcname")) .subitems.add(acsdrstudentmonitoring("date")) .subitems.add(acsdrstudentmonitoring("time"))
End With End While acscmd.Dispose() acsdrstudentmonitoring.Close() End Sub Private Sub txtstudnum_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtstudnum.TextChanged searchrecord(txtstudnum.Text)
End Sub Private Sub ListView1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListView1.MouseClick
With ListView1.SelectedItems(0) txtstudentnum.Text = .SubItems(0).Text txtipaddress.Text = .SubItems(1).Text txtpcname.Text = .SubItems(2).Text txtdate.Text = .SubItems(3).Text txttime.Text = .SubItems(4).Text
Form1.txtClientIP.Text = .SubItems(1).Text
Add Student
Public Class addstudent Private Sub addstudent_KeyPress(sender As Object, e As KeyPressEventArgs) Handles Me.KeyPress If Me.TextBox1.Focused = False Then TextBox1.Focus() TextBox1.Text = e.KeyChar.ToString TextBox1.SelectionStart = TextBox1.Text.Length e.Handled = True End If End Sub Private Sub addstudent_Load(sender As Object, e As EventArgs) Handles MyBase.Load ListView1.View = View.Details ListView1.GridLines = True ListView1.FullRowSelect = True ListView1.HideSelection = True ListView1.MultiSelect = False ListView1.Columns.Add("Student Number", 70, HorizontalAlignment.Left) ListView1.Columns.Add("Name", 0, HorizontalAlignment.Left) ListView1.Columns.Add("MI", 100, HorizontalAlignment.Left) ListView1.Columns.Add("Last name", 30, HorizontalAlignment.Left) ListView1.Columns.Add("Course", 150, HorizontalAlignment.Left) ListView1.Columns.Add("Year level", 120, HorizontalAlignment.Left)
Sub filllistview1() strsqlregistrar = "select * from registrar" Dim acscmd As New OleDb.OleDbCommand acscmd.CommandText = strsqlregistrar acscmd.Connection = acsconnregistrar acsdaregistrar.SelectCommand = acscmd acsdrregistrar = acscmd.ExecuteReader ListView1.Items.Clear() While (acsdrregistrar.Read()) With ListView1.Items.Add(acsdrregistrar("studentnumber")) .subitems.add(acsdrregistrar("name")) .subitems.add(acsdrregistrar("mi")) .subitems.add(acsdrregistrar("lastname")) .subitems.add(acsdrregistrar("course")) .subitems.add(acsdrregistrar("yearlevel"))
acscmd.Dispose() acsdrregistrar.Close() End Sub Private Sub cmdsave_Click(sender As Object, e As EventArgs) Handles cmdsave.Click Try
strsqlstudentschedule = "insert into studentschedule ([studentnumber], [name], [mi], [lastname], [course], [yearlevel]) values ('" _ & txtstudentnum.Text & "','" _ & txtname.Text & "','" _ & txtmi.Text & "','" _ & txtlastname.Text & "','" _ & txtcourse.Text & "','" _ & txtyearlevel.Text & "')"
Dim acscmd As New OleDb.OleDbCommand acscmd.CommandText = strsqlstudentschedule acscmd.Connection = acsconnstudentschedule acscmd.ExecuteNonQuery() acscmd.Dispose() MsgBox("Saved!", MsgBoxStyle.Information) End If Catch ex As Exception MsgBox("Account Already registered") End Try End Sub
Sub searchrecord(ByVal searchword As String) strsqlregistrar = "select * from registrar where studentnumber like '" & TextBox1.Text & "%'" Dim acscmd As New OleDb.OleDbCommand acscmd.CommandText = strsqlregistrar acscmd.Connection = acsconnregistrar acsdaregistrar.SelectCommand = acscmd acsdrregistrar = acscmd.ExecuteReader ListView1.Items.Clear() While (acsdrregistrar.Read()) With ListView1.Items.Add(acsdrregistrar("studentnumber")) .subitems.add(acsdrregistrar("name")) .subitems.add(acsdrregistrar("mi")) .subitems.add(acsdrregistrar("lastname")) .subitems.add(acsdrregistrar("course")) .subitems.add(acsdrregistrar("yearlevel"))
End With End While acscmd.Dispose() acsdrregistrar.Close() End Sub Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged Try
searchrecord(TextBox1.Text) If TextBox1.TextLength = 7 Then If ListView1.Items IsNot Nothing Then If ListView1.Items.Count > 0 Then ListView1.Items(0).Selected = True ListView1.Select() With ListView1.SelectedItems(0) txtstudentnum.Text = .SubItems(0).Text txtname.Text = .SubItems(1).Text txtmi.Text = .SubItems(2).Text txtlastname.Text = .SubItems(3).Text txtcourse.Text = .SubItems(4).Text txtyearlevel.Text = .SubItems(5).Text
End With
End If End If
strsqlstudentschedule = "insert into studentschedule ([studentnumber], [name], [mi], [lastname], [course], [yearlevel]) values ('" _ & txtstudentnum.Text & "','" _ & txtname.Text & "','" _ & txtmi.Text & "','" _ & txtlastname.Text & "','" _ & txtcourse.Text & "','" _ & txtyearlevel.Text & "')"
Dim acscmd As New OleDb.OleDbCommand acscmd.CommandText = strsqlstudentschedule acscmd.Connection = acsconnstudentschedule acscmd.ExecuteNonQuery() acscmd.Dispose() MsgBox("Saved!", MsgBoxStyle.Information) End If
Sub filllistview1() strsqladministrator = "select * from administrator" Dim acscmd As New OleDb.OleDbCommand acscmd.CommandText = strsqladministrator acscmd.Connection = acsconnadministrator acsdaadministrator.SelectCommand = acscmd acsdradministrator = acscmd.ExecuteReader ListView1.Items.Clear() While (acsdradministrator.Read()) With ListView1.Items.Add(acsdradministrator("username")) .subitems.add(acsdradministrator("password"))
End With End While acscmd.Dispose() acsdradministrator.Close() End Sub Sub searchrecord(ByVal searchword As String) strsqladministrator = "select * from administrator where username like '" & txtusername.Text & "%'" Dim acscmd As New OleDb.OleDbCommand acscmd.CommandText = strsqladministrator acscmd.Connection = acsconnadministrator acsdaadministrator.SelectCommand = acscmd acsdradministrator = acscmd.ExecuteReader ListView1.Items.Clear() While (acsdradministrator.Read()) With ListView1.Items.Add(acsdradministrator("username")) .subitems.add(acsdradministrator("password"))
If ListView1.Items IsNot Nothing Then If ListView1.Items.Count > 0 Then ListView1.Items(0).Selected = True ListView1.Select() With ListView1.SelectedItems(0) TextBox2.Text = .SubItems(0).Text TextBox3.Text = .SubItems(1).Text
End With If txtusername.Text <> TextBox2.Text Then MsgBox("Invalid Username", MsgBoxStyle.Exclamation) Exit Sub ElseIf txtpassword.Text <> TextBox3.Text Then MsgBox("Invalid Password", MsgBoxStyle.Exclamation) Exit Sub ElseIf txtpassword2.Text <> TextBox1.Text Then MsgBox("New password and Confirm password does not match!", MsgBoxStyle.Exclamation) Exit Sub ElseIf txtpassword2.TextLength < 7 Then MsgBox("Password must contain atleast 8 characters long", MsgBoxStyle.Exclamation) Exit Sub ElseIf txtusername.Text = "" Then MsgBox("Please fill in username", MsgBoxStyle.Exclamation) Exit Sub ElseIf txtusername2.Text = "" Then MsgBox("Please fill in New Username!", MsgBoxStyle.Exclamation) Exit Sub ElseIf txtpassword.Text = "" Then MsgBox("Please fill in Password", MsgBoxStyle.Exclamation) Exit Sub ElseIf txtpassword2.Text = "" Then MsgBox("Please fill in New Password!", MsgBoxStyle.Exclamation) Exit Sub
Else
strsqladministrator = "delete * from administrator where username='" & txtusername.Text & "'" Dim acscmd As New OleDb.OleDbCommand acscmd.CommandText = strsqladministrator acscmd.Connection = acsconnadministrator acscmd.ExecuteNonQuery() acscmd.Dispose()
strsqladministrator = "insert into administrator ([username], [password]) values ('" _ & txtusername2.Text & "','" _ & txtpassword2.Text & "')"
Dim acscmd2 As New OleDb.OleDbCommand acscmd.CommandText = strsqladministrator acscmd.Connection = acsconnadministrator acscmd.ExecuteNonQuery() acscmd.Dispose() MsgBox("Saved!", MsgBoxStyle.Information) TextBox2.Clear() TextBox3.Clear()
Me.filllistview1()
End If
End If End If
End Sub End Class Client Form Imports System.Net Imports System.IO Imports System.Net.Mail Public Class client Private Sub client_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim x As Integer
strsqlstudentmonitoring = "insert into studentmonitoring ([studentnum], [ipaddress], [pcname], [date], [time]) values ('" _ & txtstudentnum.Text & "','" _ & txtip.Text & "','" _ & txtpcname.Text & "','" _ & txtdate.Text & "','" _ & txttime.Text & "')"
Dim acscmd As New OleDb.OleDbCommand acscmd.CommandText = strsqlstudentmonitoring acscmd.Connection = acsconnstudentmonitoring acscmd.ExecuteNonQuery() acscmd.Dispose()
End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) End Sub Private Function b() As String Return Dns.GetHostName End Function
Private Sub cmdloglout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdloglout.Click If MsgBox("Do you want exit?", vbYesNo, MsgBoxStyle.Information) = vbYes Then login.txtusername.Clear() login.txtpassword.Clear() screenlock.Show() login.Show() Me.Hide() End If End Sub End Class
Client Remote
Imports System.net Imports System.Net.Sockets Imports System.Threading Imports System.IO Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents txtClientIP As System.Windows.Forms.TextBox Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents btnOK As System.Windows.Forms.Button Friend WithEvents rbShutdown As System.Windows.Forms.RadioButton Friend WithEvents rbReboot As System.Windows.Forms.RadioButton Friend WithEvents rbLogOff As System.Windows.Forms.RadioButton Friend WithEvents rbNothing As System.Windows.Forms.RadioButton Friend WithEvents btnExit As System.Windows.Forms.Button Friend WithEvents Label4 As System.Windows.Forms.Label Friend WithEvents lblMYIP As System.Windows.Forms.Label <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(Form1)) Me.txtClientIP = New System.Windows.Forms.TextBox() Me.btnOK = New System.Windows.Forms.Button() Me.Label1 = New System.Windows.Forms.Label()
Me.rbShutdown = New System.Windows.Forms.RadioButton() Me.rbReboot = New System.Windows.Forms.RadioButton() Me.rbLogOff = New System.Windows.Forms.RadioButton() Me.rbNothing = New System.Windows.Forms.RadioButton() Me.btnExit = New System.Windows.Forms.Button() Me.Label4 = New System.Windows.Forms.Label() Me.lblMYIP = New System.Windows.Forms.Label() Me.SuspendLayout() ' 'txtClientIP ' Me.txtClientIP.Location = New System.Drawing.Point(211, 56) Me.txtClientIP.Multiline = True Me.txtClientIP.Name = "txtClientIP" Me.txtClientIP.Size = New System.Drawing.Size(201, 37) Me.txtClientIP.TabIndex = 0 Me.txtClientIP.TextAlign = System.Windows.Forms.HorizontalAlignment.Center ' 'btnOK ' Me.btnOK.FlatStyle = System.Windows.Forms.FlatStyle.System Me.btnOK.Font = New System.Drawing.Font("Microsoft Sans Serif", 21.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.btnOK.Location = New System.Drawing.Point(165, 223) Me.btnOK.Name = "btnOK" Me.btnOK.Size = New System.Drawing.Size(247, 46) Me.btnOK.TabIndex = 66 Me.btnOK.Text = "&EXECUTE" ' 'Label1 ' Me.Label1.AutoSize = True Me.Label1.Font = New System.Drawing.Font("Verdana", 15.75!) Me.Label1.Location = New System.Drawing.Point(3, 56) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(202, 25) Me.Label1.TabIndex = 69 Me.Label1.Text = "Client IP Address:" ' 'rbShutdown ' Me.rbShutdown.Font = New System.Drawing.Font("Verdana", 15.75!) Me.rbShutdown.Location = New System.Drawing.Point(283, 170) Me.rbShutdown.Name = "rbShutdown" Me.rbShutdown.Size = New System.Drawing.Size(150, 31) Me.rbShutdown.TabIndex = 72 Me.rbShutdown.Text = "Shutdown" ' 'rbReboot ' Me.rbReboot.AutoSize = True Me.rbReboot.Font = New System.Drawing.Font("Verdana", 15.75!) Me.rbReboot.Location = New System.Drawing.Point(24, 172) Me.rbReboot.Name = "rbReboot" Me.rbReboot.Size = New System.Drawing.Size(105, 29) Me.rbReboot.TabIndex = 73 Me.rbReboot.Text = "Reboot" '
'rbLogOff ' Me.rbLogOff.AutoSize = True Me.rbLogOff.Font = New System.Drawing.Font("Verdana", 15.75!) Me.rbLogOff.Location = New System.Drawing.Point(24, 127) Me.rbLogOff.Name = "rbLogOff" Me.rbLogOff.Size = New System.Drawing.Size(99, 29) Me.rbLogOff.TabIndex = 74 Me.rbLogOff.Text = "LogOff" ' 'rbNothing ' Me.rbNothing.AutoSize = True Me.rbNothing.Checked = True Me.rbNothing.Font = New System.Drawing.Font("Verdana", 15.75!) Me.rbNothing.Location = New System.Drawing.Point(283, 127) Me.rbNothing.Name = "rbNothing" Me.rbNothing.Size = New System.Drawing.Size(111, 29) Me.rbNothing.TabIndex = 75 Me.rbNothing.TabStop = True Me.rbNothing.Text = "Refresh" ' 'btnExit ' Me.btnExit.FlatStyle = System.Windows.Forms.FlatStyle.System Me.btnExit.Font = New System.Drawing.Font("Verdana", 20.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.btnExit.Location = New System.Drawing.Point(165, 275) Me.btnExit.Name = "btnExit" Me.btnExit.Size = New System.Drawing.Size(247, 46) Me.btnExit.TabIndex = 76 Me.btnExit.Text = "E&xit" ' 'Label4 ' Me.Label4.AutoSize = True Me.Label4.Font = New System.Drawing.Font("Verdana", 15.75!) Me.Label4.Location = New System.Drawing.Point(3, 9) Me.Label4.Name = "Label4" Me.Label4.Size = New System.Drawing.Size(171, 25) Me.Label4.TabIndex = 77 Me.Label4.Text = "My IP Address:" ' 'lblMYIP ' Me.lblMYIP.Location = New System.Drawing.Point(217, 18) Me.lblMYIP.Name = "lblMYIP" Me.lblMYIP.Size = New System.Drawing.Size(195, 35) Me.lblMYIP.TabIndex = 78 Me.lblMYIP.TextAlign = System.Drawing.ContentAlignment.MiddleCenter ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.BackColor = System.Drawing.SystemColors.MenuHighlight Me.ClientSize = New System.Drawing.Size(424, 328) Me.Controls.Add(Me.lblMYIP) Me.Controls.Add(Me.Label4)
Me.Controls.Add(Me.btnExit) Me.Controls.Add(Me.rbNothing) Me.Controls.Add(Me.rbLogOff) Me.Controls.Add(Me.rbReboot) Me.Controls.Add(Me.rbShutdown) Me.Controls.Add(Me.Label1) Me.Controls.Add(Me.btnOK) Me.Controls.Add(Me.txtClientIP) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon) Me.MaximizeBox = False Me.Name = "Form1" Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen Me.Text = "Computer Laboratory Management System Ver. 1.1" Me.ResumeLayout(False) Me.PerformLayout() End Sub #End Region Dim trSendMessage As Thread Sub SendMessage() Dim host As String = txtClientIP.Text Dim port As Integer = 53957 Try Dim tcpCli As New TcpClient(host, port) Dim ns As NetworkStream = tcpCli.GetStream ' Send data to the server. Dim sw As New StreamWriter(ns) If rbShutdown.Checked = True Then MessageBox.Show("Connected") End If If rbReboot.Checked = True Then sw.WriteLine("###REBOOT###") End If If rbLogOff.Checked = True Then sw.WriteLine("###LOGOFF###") End If If rbNothing.Checked = True Then sw.WriteLine("to") End If sw.Flush() ' Receive and display data. Dim sr As New StreamReader(ns) Dim result As String = sr.ReadLine() If result = "###OK###" Then MsgBox("Operation Performed!!!", MsgBoxStyle.Information, "Accepted by client") End If 'MsgBox(result) sr.Close() sw.Close() ns.Close() Catch ex As Exception MsgBox(ex.Message)
End Try End Sub Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click End End Sub Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click If Trim(txtClientIP.Text) = "" Then MsgBox("Please enter Client IP Address!!!", MsgBoxStyle.Information, "IP Address???") txtClientIP.Focus() Exit Sub End If If rbNothing.Checked = False Then trSendMessage = New Thread(AddressOf SendMessage) trSendMessage.Start() End If End Sub Dim ipAddress As IPAddress = Dns.GetHostEntry(Dns.GetHostName()).AddressList(0) Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load lblMYIP.Text = ipAddress.ToString End Sub Private Sub rbShutdown_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbShutdown.CheckedChanged End Sub Private Sub txtClientIP_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtClientIP.TextChanged End Sub
Private Sub lblMYIP_Click(sender As Object, e As EventArgs) Handles lblMYIP.Click End Sub End Class
Login Form
Imports Imports Imports Imports Imports Imports Microsoft.Win32 System.Net.Mail System System.ComponentModel System.Threading System.IO.Ports
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click If RadioButton1.Checked = Nothing And RadioButton2.Checked = Nothing Then MsgBox("Please select a login state", MsgBoxStyle.Exclamation, "Information") Exit Sub
ElseIf txtusername.Text = "" Then MsgBox("Please Fill in Username", MsgBoxStyle.Critical, "Information") Exit Sub ElseIf txtpassword.Text = "" Then MsgBox("Please Fill in Password", MsgBoxStyle.Critical, "Information") Exit Sub ElseIf txtusername.Text = "" And txtpassword.Text = "" Then MsgBox("Please Fill in Username and Password", MsgBoxStyle.Critical, "Information") Exit Sub
ElseIf ListView1.Items IsNot Nothing Then If ListView1.Items.Count > 0 Then ListView1.Items(0).Selected = True ListView1.Select()
End With
MsgBox("Login Successful", MsgBoxStyle.Information, "Information") Me.Hide() screenlock.Timer1.Enabled = False screenlock.Hide() Mainmenu.Show() txtusername.Clear() txtpassword.Clear()
If txtusername.Text = "" Then MsgBox("Please Fill in Username", MsgBoxStyle.Critical, "Information") ElseIf txtpassword.Text = "" Then MsgBox("Please Fill in Password", MsgBoxStyle.Critical, "Information")
ElseIf txtusername.Text = "" And txtpassword.Text = "" Then MsgBox("Please Fill in Username and Password", MsgBoxStyle.Critical, "Information")
If serialport.IsOpen Then serialport.Close() End If Try With serialport .PortName = ComboBox1.Text .BaudRate = 96000 .Parity = Parity.None .DataBits = 8 .StopBits = StopBits.One .Handshake = Handshake.RequestToSend .DtrEnable = True .RtsEnable = True
.NewLine = vbCrLf End With serialport.Open() serialport.WriteLine("AT+CMGF=1" & vbCr) System.Threading.Thread.Sleep(200) serialport.WriteLine("AT+CMGS=" & Chr(34) & txtcontact.Text & Chr(34) & vbCr) System.Threading.Thread.Sleep(200) serialport.WriteLine(RichTextBox1.Text & vbCrLf & Chr(26)) System.Threading.Thread.Sleep(200) MsgBox("Sent!", MsgBoxStyle.Information, "SMS") Catch ex As Exception MsgBox("Select Another Port", MsgBoxStyle.Critical, "Information") End Try
End If End If
End If
End Sub Private Sub login_Load(sender As Object, e As EventArgs) Handles MyBase.Load For i As Integer = 0 To My.Computer.Ports.SerialPortNames.Count - 1 ComboBox1.Items.Add(My.Computer.Ports.SerialPortNames(i)) Next Module1.connectadministrator()
ListView1.View = View.Details ListView1.GridLines = True ListView1.FullRowSelect = True ListView1.HideSelection = True ListView1.MultiSelect = False ListView1.Columns.Add("username", 50, HorizontalAlignment.Left) ListView1.Columns.Add("password", 50, HorizontalAlignment.Left) Me.filllistview1()
ListView2.View = View.Details ListView2.GridLines = True ListView2.FullRowSelect = True ListView2.HideSelection = True ListView2.MultiSelect = False ListView2.Columns.Add("Student Number", 50, HorizontalAlignment.Left) ListView2.Columns.Add("Name", 50, HorizontalAlignment.Left) ListView2.Columns.Add("MI", 50, HorizontalAlignment.Left) ListView2.Columns.Add("Last Name", 50, HorizontalAlignment.Left) ListView2.Columns.Add("Course", 50, HorizontalAlignment.Left) ListView2.Columns.Add("Year Level", 50, HorizontalAlignment.Left)
Me.filllistview2()
ListView3.View = View.Details ListView3.GridLines = True ListView3.FullRowSelect = True ListView3.HideSelection = True ListView3.MultiSelect = False ListView3.Columns.Add("username", 50, HorizontalAlignment.Left) ListView3.Columns.Add("password", 50, HorizontalAlignment.Left) ListView3.Columns.Add("contact", 50, HorizontalAlignment.Left) Me.filllistview3()
End Sub
Sub filllistview1() strsqladministrator = "select * from administrator" Dim acscmd As New OleDb.OleDbCommand acscmd.CommandText = strsqladministrator acscmd.Connection = acsconnadministrator acsdaadministrator.SelectCommand = acscmd
Sub filllistview2() strsqlstudentschedule = "select * from studentschedule" Dim acscmd As New OleDb.OleDbCommand acscmd.CommandText = strsqlstudentschedule acscmd.Connection = acsconnstudentschedule acsdastudentschedule.SelectCommand = acscmd acsdrstudentschedule = acscmd.ExecuteReader ListView1.Items.Clear() While (acsdrstudentschedule.Read()) With ListView2.Items.Add(acsdrstudentschedule("studentnumber")) .subitems.add(acsdrstudentschedule("name")) .subitems.add(acsdrstudentschedule("mi")) .subitems.add(acsdrstudentschedule("lastname")) .subitems.add(acsdrstudentschedule("course")) .subitems.add(acsdrstudentschedule("yearlevel"))
End With End While acscmd.Dispose() acsdrstudentschedule.Close() End Sub Sub filllistview3() strsqlstudentschedule = "select * from userpass" Dim acscmd As New OleDb.OleDbCommand acscmd.CommandText = strsqlstudentschedule acscmd.Connection = acsconnstudentschedule acsdastudentschedule.SelectCommand = acscmd acsdrstudentschedule = acscmd.ExecuteReader ListView1.Items.Clear() While (acsdrstudentschedule.Read()) With ListView1.Items.Add(acsdrstudentschedule("username")) .subitems.add(acsdrstudentschedule("password")) .subitems.add(acsdrstudentschedule("contact"))
Sub searchrecord(ByVal searchword As String) strsqladministrator = "select * from administrator where username like '" & txtusername.Text & "%'" Dim acscmd As New OleDb.OleDbCommand acscmd.CommandText = strsqladministrator acscmd.Connection = acsconnadministrator acsdaadministrator.SelectCommand = acscmd acsdradministrator = acscmd.ExecuteReader ListView1.Items.Clear() While (acsdradministrator.Read()) With ListView1.Items.Add(acsdradministrator("username")) .subitems.add(acsdradministrator("password"))
Sub searchrecord2(ByVal searchword As String) strsqlstudentschedule = "select * from studentschedule where studentnumber like '" & txtusername.Text & "%'" Dim acscmd As New OleDb.OleDbCommand acscmd.CommandText = strsqlstudentschedule acscmd.Connection = acsconnstudentschedule acsdastudentschedule.SelectCommand = acscmd acsdrstudentschedule = acscmd.ExecuteReader ListView2.Items.Clear() While (acsdrstudentschedule.Read()) With ListView2.Items.Add(acsdrstudentschedule("studentnumber")) .subitems.add(acsdrstudentschedule("name")) .subitems.add(acsdrstudentschedule("mi")) .subitems.add(acsdrstudentschedule("lastname")) .subitems.add(acsdrstudentschedule("course")) .subitems.add(acsdrstudentschedule("yearlevel"))
Sub searchrecord3(ByVal searchword As String) strsqlstudentschedule = "select * from userpass where username like '" & txtusername.Text & "%'" Dim acscmd As New OleDb.OleDbCommand acscmd.CommandText = strsqlstudentschedule acscmd.Connection = acsconnstudentschedule acsdastudentschedule.SelectCommand = acscmd acsdrstudentschedule = acscmd.ExecuteReader ListView3.Items.Clear() While (acsdrstudentschedule.Read()) With ListView3.Items.Add(acsdrstudentschedule("username")) .subitems.add(acsdrstudentschedule("password")) .subitems.add(acsdrstudentschedule("contact"))
Private Sub txtusername_TextChanged(sender As Object, e As EventArgs) Handles txtusername.TextChanged If RadioButton1.Checked = True Then searchrecord(txtusername.Text)
End If
ListView2.Items(0).Selected = True ListView2.Select() With ListView2.SelectedItems(0) txtstudentnum.Text = .SubItems(0).Text txtname.Text = .SubItems(1).Text txtmi.Text = .SubItems(2).Text txtlastname.Text = .SubItems(3).Text txtcourse.Text = .SubItems(4).Text txtyrlvl.Text = .SubItems(5).Text
End With
End If End If RichTextBox1.Text = "DCTI" + vbNewLine + "Your currently log-in Computer Laboratory RM203" + vbNewLine + txtname.Text + " " + txtmi.Text + txtlastname.Text + vbNewLine + "Time:" + " " + txttime.Text End If
searchrecord3(txtusername.Text)
If txtusername.TextLength = 7 Then If ListView3.Items IsNot Nothing Then If ListView3.Items.Count > 0 Then ListView3.Items(0).Selected = True ListView3.Select()
With ListView3.SelectedItems(0) TextBox3.Text = .SubItems(0).Text TextBox4.Text = .SubItems(1).Text txtcontact.Text = .SubItems(2).Text End With
End If End If End If End If End Sub Private Sub txtcontact_TextChanged(sender As Object, e As EventArgs) Handles txtcontact.TextChanged End Sub Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
txtcurrentday.Text = Format(Now, "dddd") client.txtdate.Text = DateString client.txttime.Text = TimeString txttime.Text = TimeString End Sub Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click screenlock.Timer1.Enabled = False screenlock.Close() End End Sub Private Sub Label1_Click(sender As Object, e As EventArgs) Handles Label1.Click studentschedule.Show() End Sub End Class
Public Class Mainmenu Inherits System.Windows.Forms.Form Dim client As New TcpClient Dim server As New TcpListener(8085) Dim nstream As NetworkStream Dim listening As New Thread(AddressOf Listen) Dim getImage As New Thread(AddressOf receiveImage) Private Sub receiveImage() Try Dim bf As New BinaryFormatter While client.Connected = True nstream = client.GetStream PictureBox1.Image = bf.Deserialize(nstream) End While Catch ex As Exception MsgBox("Streaming Disconnected!", MsgBoxStyle.Exclamation) End Try End Sub Private Sub Listen() While client.Connected = False server.Start() client = server.AcceptTcpClient End While getImage.Start() End Sub
Private Sub ClientRemoteToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ClientRemoteToolStripMenuItem.Click Form1.Show() End Sub
Private Sub Mainmenu_Load(sender As Object, e As EventArgs) Handles MyBase.Load MenuStrip1.ForeColor = Color.WhiteSmoke PictureBox1.Show() Dim childEntry As DirectoryEntry Dim ParentEntry As New DirectoryEntry()
Try ParentEntry.Path = "WinNT:" For Each childEntry In ParentEntry.Children Dim newNode As New TreeNode(childEntry.Name) Select Case childEntry.SchemaClassName Case "Domain" Dim ParentDomain As New TreeNode(childEntry.Name) TreeView1.Nodes.AddRange(New TreeNode() {ParentDomain}) Dim SubChildEntry As DirectoryEntry Dim SubParentEntry As New DirectoryEntry() SubParentEntry.Path = "WinNT://" & childEntry.Name For Each SubChildEntry In SubParentEntry.Children Dim newNode1 As New TreeNode(SubChildEntry.Name) Select Case SubChildEntry.SchemaClassName Case "Computer" ParentDomain.Nodes.Add(newNode1) End Select Next End Select Next Catch Excep As Exception MsgBox("Error While Reading Directories") Finally ParentEntry = Nothing End Try End Sub Private Sub TreeView1_AfterSelect(sender As Object, e As TreeViewEventArgs) Handles TreeView1.AfterSelect txtcomputer.Text = TreeView1.SelectedNode.Text TextBox1.Text = GetIPAddress(txtcomputer.Text) End Sub Function GetIPAddress(ByVal CompName As String) As String Dim oAddr As System.Net.IPAddress Dim sAddr As String Try With System.Net.Dns.Resolve(CompName) oAddr = New System.Net.IPAddress(.AddressList(0).Address) sAddr = oAddr.ToString End With GetIPAddress = sAddr Catch Excep As Exception MsgBox(Excep.Message, MsgBoxStyle.OkOnly, "Lan Messenger") Finally End Try End Function
Private Sub CmdPing_Click(sender As Object, e As EventArgs) Handles CmdPing.Click Shell("PING " & TextBox1.Text) End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click PictureBox1.Show()
listening.Start() End Sub Private Sub MenuStrip1_ItemClicked(sender As Object, e As ToolStripItemClickedEventArgs) Handles MenuStrip1.ItemClicked End Sub Private Sub ActiveSessionToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ActiveSessionToolStripMenuItem.Click activesession.Show() End Sub Private Sub FileToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles FileToolStripMenuItem.Click End Sub Private Sub ExitToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ExitToolStripMenuItem.Click Me.Hide() screenlock.Timer1.Enabled = True screenlock.Show() login.Show() End Sub Private Sub ToolStripMenuItem2_Click(sender As Object, e As EventArgs) Handles ToolStripMenuItem2.Click addstudent.Show() End Sub Private Sub ChangeAdministratorAccountToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ChangeAdministratorAccountToolStripMenuItem.Click changeadmin.Show() End Sub End Class
Screen Lock Form Public Class screenlock Dim mayclose As Boolean = True Private Sub screenlock_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing If mayclose = True Then e.Cancel = True ElseIf mayclose = False Then e.Cancel = False End If End Sub Private Sub screenlock_Load(sender As Object, e As EventArgs) Handles MyBase.Load login.Show() login.MdiParent = Me studentschedule.MdiParent = Me
End Sub Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick Me.TopMost = True End Sub End Class
Register Student
Private Sub studentschedule_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ListView1.View = View.Details ListView1.GridLines = True ListView1.FullRowSelect = True ListView1.HideSelection = True ListView1.MultiSelect = False ListView1.Columns.Add("studentnum", 60, HorizontalAlignment.Left) ListView1.Columns.Add("Name", 200, HorizontalAlignment.Left) ListView1.Columns.Add("MI", 40, HorizontalAlignment.Left) ListView1.Columns.Add("Last Name", 200, HorizontalAlignment.Left) ListView1.Columns.Add("course", 100, HorizontalAlignment.Left) ListView1.Columns.Add("Year Level", 100, HorizontalAlignment.Left)
Me.filllistview1() End Sub Sub filllistview1() strsqlstudentschedule = "select * from studentschedule" Dim acscmd As New OleDb.OleDbCommand acscmd.CommandText = strsqlstudentschedule acscmd.Connection = acsconnstudentschedule acsdastudentschedule.SelectCommand = acscmd acsdrstudentschedule = acscmd.ExecuteReader ListView1.Items.Clear() While (acsdrstudentschedule.Read()) With ListView1.Items.Add(acsdrstudentschedule("studentnumber")) .subitems.add(acsdrstudentschedule("name")) .subitems.add(acsdrstudentschedule("mi")) .subitems.add(acsdrstudentschedule("lastname")) .subitems.add(acsdrstudentschedule("course")) .subitems.add(acsdrstudentschedule("yearlevel"))
End With End While acscmd.Dispose() acsdrstudentschedule.Close() End Sub Sub searchrecord2(ByVal searchword As String) strsqlstudentschedule = "select * from studentschedule where studentnumber like '" & TextBox1.Text & "%'" Dim acscmd As New OleDb.OleDbCommand
acscmd.CommandText = strsqlstudentschedule acscmd.Connection = acsconnstudentschedule acsdastudentschedule.SelectCommand = acscmd acsdrstudentschedule = acscmd.ExecuteReader ListView1.Items.Clear() While (acsdrstudentschedule.Read()) With ListView1.Items.Add(acsdrstudentschedule("studentnumber")) .subitems.add(acsdrstudentschedule("name")) .subitems.add(acsdrstudentschedule("mi")) .subitems.add(acsdrstudentschedule("lastname")) .subitems.add(acsdrstudentschedule("course")) .subitems.add(acsdrstudentschedule("yearlevel"))
End With End While acscmd.Dispose() acsdrstudentschedule.Close() End Sub Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged searchrecord2(TextBox1.Text) If TextBox1.TextLength = 7 Then If ListView1.Items IsNot Nothing Then If ListView1.Items.Count > 0 Then ListView1.Items(0).Selected = True ListView1.Select()
With ListView1.SelectedItems(0) txtstudentnum.Text = .SubItems(0).Text TextBox1.Text = .SubItems(0).Text txtname.Text = .SubItems(1).Text txtlastname.Text = .SubItems(3).Text txtcourse.Text = .SubItems(4).Text End With
End If End If End If End Sub Private Sub cmdsave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdsave.Click
Try If txtlastname.Text = "" Then MsgBox("Please select record", MsgBoxStyle.Exclamation) Exit Sub ElseIf txtpassword.Text <> txtconfirmpassword.Text Then MsgBox("Password does not match!", MsgBoxStyle.Exclamation) Exit Sub
ElseIf txtpassword.TextLength < 7 Then MsgBox("Student Number must contain 8 character long!", MsgBoxStyle.Information, "Information") Else If MsgBox("Do you want to save?", vbYesNo, MsgBoxStyle.Information) = vbYes Then
strsqlstudentschedule = "insert into userpass ([username], [password]) values ('" _ & txtstudentnum.Text & "','" _ & txtpassword.Text & "')" Dim acscmd As New OleDb.OleDbCommand acscmd.CommandText = strsqlstudentschedule acscmd.Connection = acsconnstudentschedule acscmd.ExecuteNonQuery() acscmd.Dispose() MsgBox("Saved!", MsgBoxStyle.Information)
End If End If