Imports System.Data
Imports System.Data.OracleClient
Public Class Form4
Dim strConn As String
Dim Conn As OracleConnection
Dim cmd As OracleCommand
Dim dr As OracleDataReader
Dim dt As DataTable
Dim ds As New DataSet
Dim Sql As String
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Conn = New OracleConnection(strConn)
Conn.Open()
Sql = "select * from computer_service order by cs_id"
cmd = New OracleCommand(Sql, Conn)
dr = cmd.ExecuteReader
If dr.HasRows Then
dt = New DataTable
dt.Load(dr)
DataGridView1.DataSource = dt
Else
MessageBox.Show("No Data !!")
Exit Sub
End If
Conn.Close()
End Sub
Private Sub Form4_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
strConn = "Data Source=ambassader;User Id=ambassader;Password=Amb12;"
Conn = New OracleConnection(strConn)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Conn.Open()
Sql = "INSERT INTO COMPUTER_SERVICE values('" & TextBox1.Text() & "','" & TextBox2.Text() & "','" & MaskedTextBox2.Text() & "',TO_DATE('" & MaskedTextBox1.Text() & "','yyyy-mm-dd'))"
'MessageBox.Show(Sql)"
cmd = New OracleCommand(Sql, Conn)
cmd.ExecuteNonQuery()
TextBox4.Visible = False
TextBox3.Visible = True
'MessageBox.Show("Insert Complete")"
Conn = New OracleConnection(strConn)
Conn.Open()
Sql = "select * from computer_service order by cs_id"
cmd = New OracleCommand(Sql, Conn)
dr = cmd.ExecuteReader
If dr.HasRows Then
dt = New DataTable
dt.Load(dr)
DataGridView1.DataSource = dt
Else
MessageBox.Show("No Data !!")
Exit Sub
End If
Conn.Close()
Catch ex As OracleException
MessageBox.Show("Insert Incomplete : กรุณาตรวจสอบข้อมูลการป้อน")
'MessageBox.Show("Case : " & ex.ToString())
Exit Sub
Finally
Conn.Close()
End Try
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Try
Conn.Open()
Sql = "delete computer_service where cs_id = ('" & TextBox1.Text() & "')"
'MessageBox.Show(Sql)"
cmd = New OracleCommand(Sql, Conn)
cmd.ExecuteNonQuery()
TextBox3.Visible = False
TextBox4.Visible = True
'MessageBox.Show("Delete Complete")"
Conn = New OracleConnection(strConn)
Conn.Open()
Sql = "select * from computer_service order by cs_id"
cmd = New OracleCommand(Sql, Conn)
dr = cmd.ExecuteReader
If dr.HasRows Then
dt = New DataTable
dt.Load(dr)
DataGridView1.DataSource = dt
Else
MessageBox.Show("No Data !!")
Exit Sub
End If
Conn.Close()
Catch ex As OracleException
MessageBox.Show("Delete Incomplete : กรุณาตรวจสอบข้อมูล")
'MessageBox.Show("Case : " & ex.ToString())
Exit Sub
Finally
Conn.Close()
End Try
End Sub
End Class