Imports System.Data.SqlClient
Imports System.Data.OleDb
Public Class info_com
Private Sub info_com_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'ฐานข้อมูลงานซ่อมDataSet.info_com' table. You can move, or remove it, as needed.
Me.Info_comTableAdapter.Fill(Me.ฐานข้อมูลงานซ่อมDataSet.info_com)
End Sub
Private Sub Linkpage1ToolStripButton_Click(sender As Object, e As EventArgs)
Try
Me.Info_comTableAdapter.linkpage1(Me.ฐานข้อมูลงานซ่อมDataSet.info_com)
Catch ex As System.Exception
System.Windows.Forms.MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub ToolStripButton1_Click(sender As Object, e As EventArgs) Handles ToolStripButton1.Click
Dim incom As New info_com
incom.Show()
incom.Hide()
End Sub
Private Sub ToolStripButton2_Click(sender As Object, e As EventArgs) Handles ToolStripButton2.Click
Dim sale As New Sale
sale.Show()
End Sub
Private Sub ToolStripButton3_Click(sender As Object, e As EventArgs) Handles ToolStripButton3.Click
Dim sm As New SaveModify
sm.Show()
End Sub
Private Sub save_Click(sender As Object, e As EventArgs) Handles save.Click
Dim sqlADD As String 'เก็บคำสั่ง sql สำหรับเพิ่มข้อมูล
Dim cm As New SqlCommand
sqlADD = "INSERT INTO info_com([รหัสเครื่อง],IP_Address,Computer_Name,User_Login,location)"
sqlADD &= " VALUES ('" & tb1.Text & "','" & tb2.Text & "','" & tb3.Text & "','" & tb4.Text & "','" & tb5.Text & "')"
If MessageBox.Show("คุณต้องการเพิ่มรายชื่อใหม่ใช่หรือไม่?", "ยืนยัน", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
With cm
.CommandType = CommandType.Text
.CommandText = sqlADD
.ExecuteNonQuery()
End With
MessageBox.Show("เพิ่มรายชื่อพนักงานแล้ว", "ผลการทำงาน", MessageBoxButtons.OK, MessageBoxIcon.Information)
tb1.Clear()
tb2.Clear()
tb3.Clear()
tb4.Clear()
tb5.Clear()
End If
End Sub
Private Sub tb1_TextChanged(sender As Object, e As EventArgs) Handles tb1.TextChanged
End Sub
End Class
Imports System.Data.SqlClient
Imports System.Data.OleDb
Public Class info_com
Private Property OleDbConnection As OleDbConnection
Private Sub info_com_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'ฐานข้อมูลงานซ่อมDataSet.info_com' table. You can move, or remove it, as needed.
Me.Info_comTableAdapter.Fill(Me.ฐานข้อมูลงานซ่อมDataSet.info_com)
End Sub
Private Sub Linkpage1ToolStripButton_Click(sender As Object, e As EventArgs)
Try
Me.Info_comTableAdapter.linkpage1(Me.ฐานข้อมูลงานซ่อมDataSet.info_com)
Catch ex As System.Exception
System.Windows.Forms.MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub ToolStripButton1_Click(sender As Object, e As EventArgs) Handles ToolStripButton1.Click
Dim incom As New info_com
incom.Show()
incom.Hide()
End Sub
Private Sub ToolStripButton2_Click(sender As Object, e As EventArgs) Handles ToolStripButton2.Click
Dim sale As New Sale
sale.Show()
End Sub
Private Sub ToolStripButton3_Click(sender As Object, e As EventArgs) Handles ToolStripButton3.Click
Dim sm As New SaveModify
sm.Show()
End Sub
Private Sub save_Click(sender As Object, e As EventArgs) Handles save.Click
Dim sqlADD As String = ""
Dim cm As New OleDbCommand
sqlADD = "INSERT INTO info_com(รหัสเครื่อง,IP_Address,Computer_Name,User_Login,Location)"
sqlADD &= "VALUES ('" & tb1.Text & "','" & tb2.Text & "','" & tb3.Text & "','" & tb4.Text & "','" & tb5.Text & "')"
If MessageBox.Show("คุณต้องการเพิ่มรายชื่อใหม่ใช่หรือไม่?", "ยืนยัน", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
With cm
.CommandType = CommandType.Text
.CommandText = sqlADD
.Connection = Conn()
'cm.ExecuteNonQuery()
End With
MessageBox.Show("เพิ่มรายชื่อพนักงานแล้ว", "ผลการทำงาน", MessageBoxButtons.OK, MessageBoxIcon.Information)
tb1.Clear()
tb2.Clear()
tb3.Clear()
tb4.Clear()
tb5.Clear()
DataGridView1.Refresh()
End If
End Sub
Private Function Conn() As OleDbConnection
Conn = New OleDbConnection(" Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\parn\Documents\Visual Studio 2012\Projects\โปรแกรมงานซ่อม\โปรแกรมงานซ่อม.mdb;Persist Security Info=False;")
Conn.Open()
End Function
End Class