Public Sub updatePlannedItEquip(ByVal PlannedListID As Integer, ByVal ItemNo As String, ByVal ItemType As String, ByVal DateTimePicker1 As String, ByVal Contractor As String, ByVal Orderedtime As String, ByVal Qty As Integer, ByVal Unit As String, ByVal Remark As String)
Connect()
Dim olecom As OleDbCommand = Nothing
sqlcom = "UPDATE IT_PlannedList SET ItemNo = '" & ItemNo & "',ItemType = '" & ItemType & "',Qty = '" & Qty & "',Unit = '" & Unit & "',Remark = '" & Remark & "',OrderedTimes = '" & Orderedtime & "',ContractorID = '" & Contractor & "',DateCreated = '" & DateTimePicker1 & "'WHERE PlannedListID=" & PlannedListID & " "
olecom = New OleDbCommand(sqlcom, conn)
olecom.ExecuteNonQuery()
End Sub
Private Sub BNedit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BNedit.Click
Connect()
If txtPlannedListID.Text = "" Or txtItemNo.Text = "" Or cmbItemType.Text = "" Or cmbContractor.Text = "" Or txtOrderedtime.Text = "" Or txtQty.Text = "" Or cmbData.Text = "" Or cmbUnit.Text = "" Or txtRemark.Text = "" Then
MessageBox.Show("กรุณาใส่ข้อมูล")
Else
Dim dt2 As DataTable = Nothing
Dim ds2 As New DataSet
Dim sqlCon As String = "SELECT * FROM Contractor where Contractor_Name LIKE '" & cmbContractor.Text & "'"
'MessageBox.Show(sqlSubSec)
Dim da2 As OleDbDataAdapter
da2 = New OleDbDataAdapter(sqlCon, conn)
da2.Fill(ds2, "Contractor")
dt2 = ds2.Tables("Contractor")
'TxtTemp
TxtTemp.DataBindings.Add(New Binding("text", dt2, "Contractor_ID"))
Dim NumDateM As String
Dim NumDate As String
NumDateM = condata.CheckData(cmbData.Text)
' MessageBox.Show(NumDateM)
Dim str = cmbData.Text
Dim strArr() As String
strArr = str.Split(CChar(" "))
NumDate = strArr(0) & "/" & NumDateM & "/" & strArr(2)
' MessageBox.Show(NumDate)
Dim Result As MsgBoxResult
Result = CType(MessageBox.Show("คุณต้องการบันทึกข้อมูลใช่หรือไม่", "คำเตือน", MessageBoxButtons.YesNo), MsgBoxResult)
If Result = MsgBoxResult.Yes Then
' MessageBox.Show(txtCVNo.Text)
Dim cmd As OleDbCommand = Nothing
Dim sqlSave As String = ""
condata.updatePlannedItEquip(PlannedListID:=txtPlannedListID.Text, ItemNo:=txtItemNo.Text, ItemType:=cmbItemType.Text, DateTimePicker1:=NumDate, Contractor:=TxtTemp.Text, Orderedtime:=txtOrderedtime.Text, Qty:=txtQty.Text, Unit:=cmbUnit.Text, Remark:=txtRemark.Text)
MessageBox.Show("ข้อมูลถูกบันทึกเรียบร้อย")
'MessageBox.Show(TextBox1.Text)
ElseIf Result = MsgBoxResult.No Then
MessageBox.Show("การบันทึก ถูกยกเลิก")
End If
' clearAllData()
End If
' DataGridView1.Refresh()
End Sub
Public Sub Connect()
With conn
If .State = ConnectionState.Open Then .Close()
.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\PMCBL_ITINV_V0.8.accdb"
.Open()
End With
End Sub
Tag : .NET, Ms Access, Win (Windows App), VB.NET, VS 2010 (.NET 4.x), Windows