Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Dim conn As ADODB.Connection
- Dim admin As ADODB.Recordset
- Dim adm As String
- Dim addnew As Boolean
- Private Sub Command1_Click()
- addnew = True
- Command1.Enabled = False
- Text1.Locked = False
- Text2.Locked = False
- Text3.Locked = False
- Text4.Locked = False
- Text5.Locked = False
- Text6.Locked = False
- Text1.Text = ""
- Text2.Text = ""
- Text3.Text = ""
- Text4.Text = ""
- Text5.Text = ""
- Text6.Text = ""
- End Sub
- Private Sub Command2_Click()
- conn.Execute "delete from employeesrecord where EmpID='" & Text1.Text & "'"
- showgrid
- showdata
- End Sub
- Private Sub showgrid()
- Set admin = New ADODB.Recordset
- admin.CursorLocation = adUseClient
- adm = "select * from employeesrecord"
- admin.Open adm, conn, adoOpenDynamic, adLockBatchOptimistic
- Set DataGrid1.DataSource = admin
- DataGrid1.Refresh
- End Sub
- Private Sub Command3_Click()
- Command3.Enabled = False
- conn.Execute "insert into employeesrecord (EmpID, F_name, L_name, Address, City, Phone) values ('" & Text1.Text & "', '" & Text2.Text & "','" & Text3.Text & "','" & Text4.Text & "','" & Text5.Text & "','" & Text6.Text & "')"
- Set admin = New ADODB.Recordset
- admin.CursorLocation = adUseClient
- adm = "select * from employeesrecord"
- admin.Open adm, conn, adoOpenDynamic, adLockBatchOptimistic
- Set DataGrid1.DataSource = admin
- DataGrid1.Refresh
- Command1.Enabled = True
- showgrid
- showdata
- Text1.Locked = True
- Text2.Locked = True
- Text3.Locked = True
- Text4.Locked = True
- Text5.Locked = True
- Text6.Locked = True
- End Sub
- Private Sub Command4_Click()
- showgrid
- showdata
- Text1.Locked = True
- Text2.Locked = True
- Text3.Locked = True
- Text4.Locked = True
- Text5.Locked = True
- Text6.Locked = True
- End Sub
- Private Sub Command5_Click()
- Unload Me
- Menu.Show
- End Sub
- Private Sub DataGrid1_Click()
- Text1.Text = DataGrid1.Columns(0)
- Text2.Text = DataGrid1.Columns(1)
- Text3.Text = DataGrid1.Columns(2)
- Text4.Text = DataGrid1.Columns(3)
- Text5.Text = DataGrid1.Columns(4)
- Text6.Text = DataGrid1.Columns(5)
- End Sub
- Private Sub DataGrid1_KeyPress(KeyAscii As Integer)
- KeyAscii = 0
- End Sub
- Private Sub Form_Load()
- connserver
- Set admin = New ADODB.Recordset
- admin.CursorLocation = adUseClient
- adm = "select * from employeesrecord"
- admin.Open adm, conn, adoOpenDynamic, adLockBatchOptimistic
- Set DataGrid1.DataSource = admin
- DataGrid1.Refresh
- showgrid
- showdata
- End Sub
- Private Sub showdata()
- On Error GoTo a
- Text1.Text = admin!EmpID
- Text2.Text = admin!F_name
- Text3.Text = admin!L_name
- Text4.Text = admin!Address
- Text5.Text = admin!City
- Text6.Text = admin!Phone
- Exit Sub
- a:
- Text1.Text = ""
- Text2.Text = ""
- Text3.Text = ""
- Text4.Text = ""
- Text5.Text = ""
- Text6.Text = ""
- End Sub
- Private Sub connserver()
- Set conn = New ADODB.Connection
- conn.Open "Driver={MySQL ODBC 3.51 Driver};SERVER=localhost;DATABASE=alps;USER=root;PASSWORD=;OPTION=3"
- Set admin = New ADODB.Recordset
- End Sub
- Private Sub Text1_Change()
- chk
- End Sub
- Private Sub Text1_KeyPress(KeyAscii As Integer)
- Select Case KeyAscii
- Case Asc(vbCr)
- KeyAscii = 0
- Case 8, 46
- Case 47 To 58
- Case Else
- KeyAscii = 0
- End Select
- End Sub
- Private Sub Text2_Change()
- chk
- End Sub
- Private Sub Text3_Change()
- chk
- End Sub
- Private Sub Text4_Change()
- chk
- End Sub
- Private Sub Text5_Change()
- chk
- End Sub
- Private Sub Text6_Change()
- chk
- End Sub
- Private Sub chk()
- If addnew = True Then
- If Len(Text1.Text) = 0 Or Len(Text2.Text) = 0 Or Len(Text3.Text) = 0 Or Len(Text4.Text) = 0 Or Len(Text5.Text) = 0 Or Len(Text6.Text) = 0 Then
- Command3.Enabled = False
- Else
- Command3.Enabled = True
- End If
- End If
- End Sub
- Private Sub Text6_KeyPress(KeyAscii As Integer)
- Select Case KeyAscii
- Case Asc(vbCr)
- KeyAscii = 0
- Case 8, 46
- Case 47 To 58
- Case Else
- KeyAscii = 0
- End Select
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement