Imports System.Data
Imports System.Data.OleDb
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
End Sub
Private Sub TextBox11_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
Private Sub TextBox4_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox4.TextChanged
End Sub
Private Sub TextBox3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox3.TextChanged
If TextBox3.Text = "1" Then TextBox4.Text = "2:00"
If TextBox3.Text = "1" Then
Else : TextBox4.Text = "Error"
End If
If TextBox3.Text = "2" Then TextBox4.Text = "3:00"
End Sub
Private Sub TextBox6_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox6.TextChanged
If Val(TextBox4.Text) >= Val(TextBox6.Text) Then
TextBox9.Text = "Pass"
Else
TextBox9.Text = "Fail"
End If
If TextBox6.Text = "Over Day" Then TextBox9.Text = "Over"
End Sub
Private Sub TextBox9_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox9.TextChanged
End Sub
Private Sub TextBox12_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox12.TextChanged
End Sub
Private Sub TextBox7_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox7.TextChanged
Dim a As Single
a = Val(TextBox7.Text) - Val(TextBox5.Text)
If TextBox12.Text = TextBox13.Text Then
TextBox6.Text = a
Else
TextBox6.Text = "Over Day"
End If
End Sub
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button14.Click
setupScreen()
End Sub
Sub setupScreen()
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
TextBox7.Text = ""
TextBox8.Text = ""
TextBox9.Text = ""
TextBox10.Text = ""
TextBox11.Text = ""
TextBox12.Text = ""
TextBox13.Text = ""
End Sub
Private Sub Button16_Click() Handles Button16.Click
End
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
End Sub
Private Sub TextBox10_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox10.TextChanged
End Sub
Private Sub TextBox5_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox5.TextChanged
End Sub
Private Sub Button15_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button15.Click
Dim Conn As System.Data.OleDb.OleDbConnection
Dim objCmd As System.Data.OleDb.OleDbCommand
Dim strConnString As String
strConnString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\Database1.accdb"
Conn = New System.Data.OleDb.OleDbConnection(strConnString)
Conn.Open()
Dim comm As String = "INSERT INTO Table2 (Log ID,Branch,Severity,No Hour,Open Date,Open Time,Time Receive,Close Date,Close Time,Time Usage,Over SLA,Technical,Description) "
comm &= " VALUES ('" & TextBox1.Text & "',"
comm &= "'" & TextBox2.Text & "',"
comm &= "'" & TextBox3.Text & "',"
comm &= "'" & TextBox4.Text & "',"
comm &= "'" & TextBox12.Text & "',"
comm &= "'" & TextBox5.Text & "',"
comm &= "'" & TextBox8.Text & "',"
comm &= "'" & TextBox13.Text & "',"
comm &= "'" & TextBox7.Text & "',"
comm &= "'" & TextBox6.Text & "',"
comm &= "'" & TextBox9.Text & "',"
comm &= "'" & TextBox10.Text & "',"
comm &= "'" & TextBox11.Text & "')"
Dim command As New OleDbCommand(comm, Conn)
Try
command.ExecuteNonQuery()
MessageBox.Show("Connect OK")
Conn.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
objCmd = Nothing
Conn = Nothing
End Sub
End Class
Private Sub Button15_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button15.Click
Dim Connection As System.Data.OleDb.OleDbConnection
Dim Command As System.Data.OleDb.OleDbCommand
Dim ConnectionString As String
ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\Database1.accdb"
Connection = New System.Data.OleDb.OleDbConnection(ConnectionString)
Dim CommandString As String
CommandString = "Insert Into [Table2] " &_
"([Log ID], [Branch], [Severity], [No Hour], [Open Date], [Open Time], [Time Receive], " &_
"[Close Date], [Close Time], [Time Usage], [Over SLA], [Technical], [Description]) " &_
"Values " &_
"(@LogID, @Branch, @Severity, @NoHour, @OpenDate, @OpenTime, @TimeReceive, " &_
"@CloseDate, @CloseTime, @TimeUsage, @OverSLA, @Technical, @Description)"
Command = New System.Data.OleDb.OleDbCommand(CommandString, Connection)
Command.Parameters.AddWithValue("@LogID", TextBox1.Text)
Command.Parameters.AddWithValue("@Branch", TextBox2.Text)
Command.Parameters.AddWithValue("@Severity", TextBox3.Text)
Command.Parameters.AddWithValue("@NoHour", TextBox4.Text)
Command.Parameters.AddWithValue("@OpenDate", TextBox12.Text)
Command.Parameters.AddWithValue("@OpenTime", TextBox5.Text)
Command.Parameters.AddWithValue("@TimeReceive", TextBox8.Text)
Command.Parameters.AddWithValue("@CloseDate", TextBox13.Text)
Command.Parameters.AddWithValue("@CloseTime", TextBox7.Text)
Command.Parameters.AddWithValue("@TimeUsage", TextBox6.Text)
Command.Parameters.AddWithValue("@OverSLA", TextBox9.Text)
Command.Parameters.AddWithValue("@Technical", TextBox10.Text)
Command.Parameters.AddWithValue("@Description", TextBox11.Text)
Try
Connection.Open()
Command.ExecuteNonQuery()
Connection.Close()
MessageBox.Show("Success!")
Catch ex As Exception
MessageBox.Show("Error " & ex.Message)
End Try
End Sub
Date :
2009-12-10 20:37:20
By :
tungman
No. 11
Guest
Imports System.Data
Imports System.Data.OleDb
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
End Sub
Private Sub TextBox11_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
Private Sub TextBox4_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox4.TextChanged
End Sub
Private Sub TextBox3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox3.TextChanged
If TextBox3.Text = "1" Then TextBox4.Text = "2:00"
If TextBox3.Text = "1" Then
Else : TextBox4.Text = "Error"
End If
If TextBox3.Text = "2" Then TextBox4.Text = "3:00"
End Sub
Private Sub TextBox6_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox6.TextChanged
If Val(TextBox4.Text) >= Val(TextBox6.Text) Then
TextBox9.Text = "Pass"
Else
TextBox9.Text = "Fail"
End If
If TextBox6.Text = "Over Day" Then TextBox9.Text = "Over"
End Sub
Private Sub TextBox9_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox9.TextChanged
End Sub
Private Sub TextBox12_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox12.TextChanged
End Sub
Private Sub TextBox7_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox7.TextChanged
Dim a As Single
a = Val(TextBox7.Text) - Val(TextBox5.Text)
If TextBox12.Text = TextBox13.Text Then
TextBox6.Text = a
Else
TextBox6.Text = "Over Day"
End If
End Sub
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button14.Click
setupScreen()
End Sub
Sub setupScreen()
Private Sub Button16_Click() Handles Button16.Click
End
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
End Sub
Private Sub TextBox10_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox10.TextChanged
End Sub
Private Sub TextBox5_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox5.TextChanged
End Sub
Private Sub Button15_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button15.Click
Dim Connection As System.Data.OleDb.OleDbConnection
Dim Command As System.Data.OleDb.OleDbCommand
Dim ConnectionString As String
ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\Database1.accdb"
Connection = New System.Data.OleDb.OleDbConnection(ConnectionString)
Try
Connection.Open()
Command.ExecuteNonQuery()
Connection.Close()
MessageBox.Show("Success!")
Catch ex As Exception
MessageBox.Show("Error " & ex.Message)
End Try