Vous êtes sur la page 1sur 11

Declaration Imports System.Collections Imports System.ComponentModel Imports System.Windows.Forms Imports System.Data Imports System.Data.

OleDb Public Class login Inherits System.Windows.Forms.Form Dim Cnn As New ADODB.Connection Dim daTransactions As New OleDbDataAdapter() Dim dsTransactions As New DataSet() Dim flag As Boolean Dim con As New OleDb.OleDbConnection Dim rs As New ADODB.Recordset Private Sub login_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Cnn.Open("Provider=Microsoft.ACE.OLEDB.12.0;Data Source= C:\iconnect\iconnect.accdb") ICback.Show() txtu.Focus() End Sub Private Sub NetButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsignin.Click ICback.Close() camera.btncapnew.Visible = False camera.cmd3.Visible = True Mainform.linkDelete.Visible = True Mainform.linkDelete.Visible = False Mainform.lblSchedule.Visible = False Mainform.post2.Visible = True Mainform.mU.Visible = False Mainform.txtPOSTTO.Text = "---" If txtu.Text = "admin" Then MsgBox("INVALID username or password", MsgBoxStyle.Critical) txtu.Text = "" txtp.Text = "" Exit Sub End If rs.Open("userlogin", Cnn, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic) Do While Not rs.EOF If txtu.Text = rs.Fields(1).Value And txtp.Text = rs.Fields(2).Value Then MsgBox("Discover the World of Connection!...." & txtu.Text, vbInformation, "Access successful") Mainform.txtpic.Text = rs.Fields(5).Value Mainform.txtbackground.Text = rs.Fields(6).Value Mainform.lblname.Text = rs.Fields(4).Value

Mainform.homeimg.Text = rs.Fields(5).Value Mainform.txtname.Text = txtu.Text Mainform.txtid.Text = rs.Fields(0).Value Mainform.txtDes.Text = rs.Fields(3).Value Mainform.txtCourse.Text = rs.Fields(13).Value Mainform.txtYear.Text = rs.Fields(14).Value Mainform.txtContactNo.Text = rs.Fields(7).Value Mainform.txtAddress.Text = rs.Fields(8).Value Mainform.txtCODEName.Text = rs.Fields(1).Value Mainform.gbInfo.Visible = True Mainform.Show() Me.Hide() rs.Close() Exit Sub End If rs.MoveNext() Loop rs.Close() rs.Open("userlogin", Cnn, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic) Do While Not rs.EOF If txtu.Text <> rs.Fields(1).Value And txtp.Text <> rs.Fields(2).Value Then MsgBox("INVALID username or password", MsgBoxStyle.Critical) txtu.Text = "" txtp.Text = "" rs.Close() Exit Sub End If rs.MoveNext() Loop If txtu.Text = "" Then MsgBox("Your account was invalid!....", vbCritical, "Check Your Account") txtu.Text = "" txtp.Text = "" Exit Sub End If Cnn.Close() Me.Hide() Mainform.personalinfo.Visible = True Mainform.LinkLabel7.Visible = False End Sub Private Sub NetButton1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NetButton1.Click MsgBox("Thank You For Using I-Connect Application!", MsgBoxStyle.Information, "I-Connect Application") Me.Close() End Sub

Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles lblregister.LinkClicked signup.Show() camera.btncapnew.Visible = True camera.cmd3.Visible = False signup.btnjoinIns.Visible = False signup.btnStudJoin.Visible = True signup.NetPanel1.Visible = True signup.txtDES.Text = "Student" Me.Hide() If btnselect.Text = "INSTRUCTOR" Then signup.btnjoinIns.Visible = True signup.btnStudJoin.Visible = False signup.NetPanel1.Visible = False signup.txtDES.Text = "Instructor" End If End Sub Private Sub usersignin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) rs.Open("userlogin", Cnn, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic) Do While Not rs.EOF If txtu.Text = rs.Fields(1).Value And txtp.Text = rs.Fields(2).Value Then MsgBox("Discover the World of Connection!...." & txtu.Text, vbInformation, "Access successful") Mainform.txtpic.Text = rs.Fields(5).Value Mainform.txtbackground.Text = rs.Fields(6).Value Mainform.lblname.Text = rs.Fields(4).Value Mainform.homeimg.Text = rs.Fields(5).Value Mainform.txtname.Text = txtu.Text Mainform.txtid.Text = rs.Fields(0).Value Mainform.Show() Me.Hide() rs.Close() Exit Sub End If rs.MoveNext() Loop rs.Close() rs.Open("userlogin", Cnn, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic) Do While Not rs.EOF If txtu.Text <> rs.Fields(1).Value And txtp.Text <> rs.Fields(2).Value Then MsgBox("INVALID username or password", MsgBoxStyle.Critical) txtu.Text = "" txtp.Text = "" rs.Close() Exit Sub

End If rs.MoveNext() Loop If txtu.Text = "" Then MsgBox("Your account was invalid!....", vbCritical, "Check Your Account") txtu.Text = "" txtp.Text = "" Exit Sub End If Cnn.Close() End Sub Private Sub NetButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnadmin.Click ICback.Close() Mainform.txtPOSTTO.Text = "ALL" Mainform.txtCourse.Text = "-" Mainform.txtYear.Text = "-" Mainform.lblEval.Visible = False Mainform.linkDelete.Visible = False Mainform.DELETEadmin.Visible = True Mainform.mU.Visible = True Mainform.personalinfo.Visible = False Mainform.LinkLabel7.Visible = True If btnselect.Text = "" Then MsgBox("Please Select Designation!....", vbCritical, "Log IN") txtu.Text = "" txtp.Text = "" btnselect.Focus() End If If txtu.Text = "" Then MsgBox("Your account was invalid!....", vbCritical, "Check Your Account") txtu.Text = "" txtp.Text = "" txtu.Focus() End If rs.Open("admin", Cnn, 2, 3) With rs Do While Not rs.EOF If txtu.Text = rs.Fields(1).Value And txtp.Text = rs.Fields(2).Value Then rs.Close() rs.Open("userlogin", Cnn, 2, 3) With rs Do While Not rs.EOF If txtu.Text = rs.Fields(1).Value And txtp.Text = rs.Fields(2).Value Then MsgBox("Discover the World of Connection!...." & txtu.Text, vbInformation, "Access successful") Mainform.txtpic.Text = rs.Fields(5).Value Mainform.txtbackground.Text = rs.Fields(6).Value Mainform.lblname.Text = rs.Fields(4).Value

Mainform.homeimg.Text = rs.Fields(5).Value Mainform.txtname.Text = txtu.Text Mainform.txtid.Text = rs.Fields(0).Value Mainform.Label8.Text = rs.Fields(2).Value Mainform.txtDes.Text = rs.Fields(3).Value Mainform.gbInfo.Visible = False Mainform.Show() Me.Hide() rs.Close() Exit Sub End If rs.MoveNext() Loop End With ElseIf txtu.Text <> rs.Fields(1).Value And txtp.Text <> rs.Fields(2).Value MsgBox("INVALID username or password", MsgBoxStyle.Critical) txtu.Text = "" txtp.Text = "" txtu.Focus() rs.Close() Exit Sub End If Loop End With End Sub

Then

Private Sub signIn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles signInuser.Click ICback.Close() camera.btncapnew.Visible = False camera.cmd3.Visible = True rs.Open("Instructor", Cnn, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic) Do While Not rs.EOF If txtu.Text = rs.Fields(1).Value And txtp.Text = rs.Fields(2).Value Then MsgBox("Discover the World of Connection!...." & txtu.Text, vbInformation, "Access successful") Instructor.txtpic.Text = rs.Fields(5).Value Instructor.txtbackground.Text = rs.Fields(6).Value Instructor.lblname.Text = rs.Fields(4).Value Instructor.homeimg.Text = rs.Fields(5).Value Instructor.txtname.Text = txtu.Text Instructor.txtid.Text = rs.Fields(0).Value Instructor.txtStatusIN.Text = rs.Fields(3).Value Instructor.txtCnoIN.Text = rs.Fields(7).Value Instructor.txtAddressIN.Text = rs.Fields(8).Value Instructor.Show() Me.Hide() rs.Close() Exit Sub End If

rs.MoveNext() Loop rs.Close() rs.Open("Instructor", Cnn, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic) Do While Not rs.EOF If txtu.Text <> rs.Fields(1).Value And txtp.Text <> rs.Fields(2).Value Then MsgBox("INVALID username or password", MsgBoxStyle.Critical) txtu.Text = "" txtp.Text = "" rs.Close() Exit Sub End If rs.MoveNext() Loop If txtu.Text = "" Then MsgBox("Your account was invalid!....", vbCritical, "Check Your Account") txtu.Text = "" txtp.Text = "" Exit Sub End If Cnn.Close() Me.Close() End Sub Private Sub txtu_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtu.KeyDown If e.KeyCode = Keys.F2 Then btnselect.Visible = True btnsignin.Visible = False btnadmin.Visible = True signInuser.Visible = False ElseIf e.KeyCode = Keys.F1 Then btnselect.Visible = False btnsignin.Visible = True btnadmin.Visible = False signInuser.Visible = False ElseIf e.KeyCode = Keys.End Then MsgBox("Thank You For Using The System, Godbless!!!", MsgBoxStyle.Information) End End If End Sub Private Sub ToolStripMenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem2.Click btnadmin.Visible = True btnsignin.Visible = False signInuser.Visible = False btnadmin.Visible = True btnselect.Text = "ADMIN" picreg.Visible = False

lblregister.Visible = False btnadmin.Visible = True End Sub Private Sub INSTRUCTORToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles INSTRUCTORToolStripMenuItem.Click signInuser.Visible = True btnsignin.Visible = False btnadmin.Visible = False picreg.Visible = True btnselect.Text = "INSTRUCTOR" lblregister.Visible = True End Sub End Class Sub GenderItems() With cbgen Items.Clear() .Items.Add("MALE") .Items.Add("FEMALE") End With End Sub Sub saveMsg() rs = New ADODB.Recordset With rs .Open("Select * from PMsg ", Cnn, 2, 3) Do While Not rs.EOF If rs.Fields(3).Value = lblname.Text And rs.Fields(6).Value = linkName.Text Then .Open("Select * from PMsg where Message like '%" & lblmessage.Text & "%' and Time like '%" & lbltime.Text & "%' ", Cnn, 2, 3) .Fields(2).Value = txtmsg.Text .Fields(4).Value = DateAndTime.Now .Update() Exit Sub End If rs.MoveNext() Loop End With End Sub Sub status() With cbstatus .Items.Clear() .Items.Add("SINGLE") .Items.Add("WIDDOW") .Items.Add("MARRIES") End With End Sub Dim lst lbMessage.Items.Clear() rs = New ADODB.Recordset

With rs Open("Select * from Reply where Reciever like '%" & lnkName.Text & "%' and Message like '%" & lblMsg.Text & "%'", Cnn, 2, 3) Do While Not .EOF lst = New ListViewItem lst = lbMessage.Items.Add(.Fields("ID").Value) lst.SubItems.Add(.Fields("Sender").Value) lst.SubItems.Add(.Fields("Reciever").Value) lst.SubItems.Add(.Fields("Message").Value) lst.SubItems.Add(.Fields("Time").Value) lst.SubItems.Add(.Fields("Designation").Value) lst.SubItems.Add(.Fields("Course").Value) lst.SubItems.Add(.Fields("Year").Value) lst.SubItems.Add(.Fields("Response").Value) .MoveNext() Loop End With End Sub Sub wallAdmin() Private Declare Function AnimateWindow Lib "user32" (ByVal hwnd As Int32, ByVal dwTime As Int32, ByVal dwFlags As Int32) As Boolean Private Const AW_HOR_POSITIVE = &H1 'Animates the window from left to right. This flag can be used with roll or slide animation. Private Const AW_HOR_NEGATIVE = &H2 'Animates the window from right to left. This flag can be used with roll or slide animation. Private Const AW_VER_POSITIVE = &H4 'Animates the window from top to bottom. This flag can be used with roll or slide animation. Private Const AW_VER_NEGATIVE = &H8 'Animates the window from bottom to top. This flag can be used with roll or slide animation. Private Const AW_CENTER = &H10 'Makes the window appear to collapse inward if AW_HIDE is used or expand outward if the AW_HIDE is not used. ' Private Const AW_HIDE = &H10000 'Hides the window. By default, the window is shown. Private Const AW_ACTIVATE = &H20000 'Activates the window. Private Const AW_SLIDE = &H40000 'Uses slide animation. By default, roll animation is used. Private Const AW_BLEND = &H80000 'Uses a fade effect. This flag can be used only if hwnd is a top-level window. Dim winHide As Integer = &H10000 Dim winCenter As Integer ' = &H10 Dim winActivate As Integer ' = &H20000 Dim winSlide As Integer ' = &H40000 Dim winBlend As Integer ' = &H80000 ' #Region "Fuction for filling Listview" LVuploadpic.Columns.Clear() LVuploadpic.Items.Clear() 'If LV.Items.Count > 0 Then 'LV.Items.Clear() 'End If

Dim fillLV_comstr As String = "Select * from uploadpic where uploader like '%" & lblname.Text & "%' " Dim fillLV_Con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source= C:\iconnect\iconnect.accdb") Dim NewQuery As New OleDbCommand(fillLV_comstr, fillLV_Con) Try Try fillLV_Con.Open() Catch e As Exception MsgBox(e.Message) End Try Dim NewReader As OleDbDataReader = NewQuery.ExecuteReader() Dim i As Integer For i = 0 To NewReader.FieldCount - 1 Dim header As New ColumnHeader() header.Text = NewReader.GetName(i) LVuploadpic.Columns.Add(header) Next While NewReader.Read() ' Create list view item Dim NewItem As New ListViewItem() NewItem.Text = NewReader.GetValue(0).ToString() For i = 1 To NewReader.FieldCount - 1 NewItem.SubItems.Add(NewReader.GetValue(i).ToString()) Next LVuploadpic.Items.Add(NewItem) End While NewReader.Close() Catch ex As OleDbException ' Create and error column header Dim ErrorHeader As New ColumnHeader() ErrorHeader.Text = "oledb Error" LVuploadpic.Columns.Add(ErrorHeader) ' Add Error List Item Dim ErrorItem As New ListViewItem(ex.Message) LVuploadpic.Items.Add(ErrorItem) Catch ex As Exception ' Create and error column header Dim ErrorHeader As New ColumnHeader() ErrorHeader.Text = "Error" LVuploadpic.Columns.Add(ErrorHeader) ' Add Error List Item Dim ErrorItem As New ListViewItem("An error has occurred") LVuploadpic.Items.Add(ErrorItem) Finally fillLV_Con.Close()

End Try LVuploadpic.Columns(0).Width = 0 LVuploadpic.Columns(1).Width = 0 LVuploadpic.Columns(2).Width = 150 LVuploadpic.Columns(3).Width = 150 LVuploadpic.Columns(4).Width = 150 'LVmessage.Columns(5).Width = 0 'LVmessage.Columns(6).Width = 0 'LVmessage.Columns(7).Width = 0 End Sub #End Region Private Sub homechangepix_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Dim dlg As OpenFileDialog Dim img As Image Try dlg = New OpenFileDialog dlg.Filter = "All Pictures|*.bmp;*.gif;*.jpg;*.png|" & _ "Bitmaps|*.bmp|GIFs|*.gif|JPEGs|*.jpg|PNGs|*.png" If dlg.ShowDialog = DialogResult.OK Then Me.Cursor = Cursors.WaitCursor homeimg.Image = New Bitmap(dlg.FileName) End If Catch ex As Exception MsgBox("Error", MsgBoxStyle.Critical, "error") Finally img = Nothing dlg = Nothing Me.Cursor = Cursors.Default End Try Dim adapter As New SqlDataAdapter Dim SqlCmd As New SqlClient.SqlCommand SqlCmd.Connection = con Mainform.lbuser.Text & "' " Try Dim picphoto As New SqlClient.SqlParameter("@pics", SqlDbType.Image) SqlCmd.Parameters.Add(picphoto) Dim c As Integer = SqlCmd.ExecuteNonQuery() If c <> 0 Then MsgBox("Record Saved Successfully.", MsgBoxStyle.Information, "Message") homeimg.Image = Nothing End If Catch ex As Exception MsgBox(ex.ToString) End Try End Sub Dim counter As Integer = 1

Private Sub OpenFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk txtpic.Text = OpenFileDialog1.FileName End Sub Private Sub ButBlue_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) 'ContextMenuStrip2.Show() End Sub Private Sub txtpost_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) txtpost.Text = "" End Sub Private Sub OpenFileDialog2_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog2.FileOk txtbackground.Text = OpenFileDialog2.FileName ' BackgroundImage = OpenFileDialog2.FileName End Sub