ประมาณว่า ผมต้องให้มันมันอัพเดตหากเลข 6 ชุดถูกใช้งานไปแล้วลงช่อง status น่ะครับ
ช่วยผมหน่อยน่ะครับ
ขอบคุณล้วงหน้าครับ Code (VB.NET)
Public Class fmRegister
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Dim conStr As String = "Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=D:\PoundManagement\PoundManagement\db.mdf;Integrated Security=True;Connect Timeout=30"
Dim connection As New SqlConnection(conStr)
connection.Open()
Dim sql As String = "SELECT * FROM registerP WHERE txt1 = '" & Me.TextBox1.Text & "' AND txt2 = '" & Me.TextBox2.Text & "' AND txt3 = '" & Me.TextBox3.Text & "' AND txt4 = '" & Me.TextBox4.Text & "' AND txt5 = '" & Me.TextBox5.Text & "' AND txt6 = '" & Me.TextBox6.Text & "'"
Dim command As New SqlCommand(sql, connection)
Dim result As SqlDataReader = command.ExecuteReader()
If (result.Read()) Then
Dim sql1 As String = "UPDATE registerP SET status = '" & Me.TextBox7.Text & "' WHERE txt1 = '" & Me.TextBox1.Text & "' AND txt2 = '" & Me.TextBox2.Text & "' AND txt3 = '" & Me.TextBox3.Text & "' AND txt4 = '" & Me.TextBox4.Text & "' AND txt5 = '" & Me.TextBox5.Text & "' AND txt6 = '" & Me.TextBox6.Text & "'"
Dim command1 As New SqlCommand(sql1, connection)
command1.Parameters.AddWithValue("status", TextBox7.Text)
If command1.ExecuteNonQuery() = 1 Then
MessageBox.Show("ลงทะเบียนผลิตภัณฑ์เรียบร้อย", "ขอขอบคุณ", MessageBoxButtons.OK, MessageBoxIcon.Information)
connection.Close()
Me.Hide()
End If
Else
MessageBox.Show("หมายเลขผลิตภัณฑ์ไม่ถูกต้อง หรือ การลงทะเบียนล้มเหลว โปรดลองอีกครั้ง", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning)
connection.Close()
End If
End Sub
Code (VB.NET)
Private Sub TextBox7_TextChanged(sender As Object, e As EventArgs) Handles TextBox7.TextChanged
TextBox7.Visible = False
End Sub