Private Function pSqlUpdateRecord(ByVal sender As System.Object, ByVal e As System.EventArgs) As Boolean
pSqlUpdateRecord = False
' Establish Connection
Dim conn As New SqlConnection(vpConnStr)
Try
Dim strSql As String = " UPDATE m08Disb SET " & _
" Code=@txtCode," & _
" Module=@txtModule," & _
" Type=@txtType ," & _
" SubType=@txtSubType ," & _
" Description=@txtDescription ," & _
" Unit=@txtUnit ," & _
" RateCost=@txtRateCost , " & _
" RateBill=@txtRateBill, " & _
" LedgerCost=@txtLedgerCost, " & _
" LedgerBill=@txtLedgerBill ," & _
" Gst=@txtGst , " & _
" GstRate=@txtGstRate, " & _
" Memo=@txtMemo, " & _
" LastAddEditStaff=@txtLastAddEditStaff, " & _
" LastAddEditDate=@txtLastAddEditDate " & _
" WHERE SQLCode=@SQLCode "
conn.Open()
' Create SQL Command
Dim MyCommand As SqlCommand = conn.CreateCommand()
MyCommand.CommandText = strSql
' Add Parameter
MyCommand.Parameters.Add(New SqlParameter("@txtCode", SqlDbType.VarChar))
MyCommand.Parameters.Add(New SqlParameter("@txtModule", SqlDbType.VarChar))
MyCommand.Parameters.Add(New SqlParameter("@txtType", SqlDbType.VarChar))
MyCommand.Parameters.Add(New SqlParameter("@txtSubType", SqlDbType.VarChar))
MyCommand.Parameters.Add(New SqlParameter("@txtDescription", SqlDbType.VarChar))
MyCommand.Parameters.Add(New SqlParameter("@txtUnit", SqlDbType.VarChar))
MyCommand.Parameters.Add(New SqlParameter("@txtRateCost", SqlDbType.Decimal))
MyCommand.Parameters.Add(New SqlParameter("@txtRateBill", SqlDbType.Decimal))
MyCommand.Parameters.Add(New SqlParameter("@txtLedgerCost", SqlDbType.VarChar))
MyCommand.Parameters.Add(New SqlParameter("@txtLedgerBill", SqlDbType.VarChar))
MyCommand.Parameters.Add(New SqlParameter("@txtGst", SqlDbType.VarChar))
MyCommand.Parameters.Add(New SqlParameter("@txtMemo", SqlDbType.VarChar))
MyCommand.Parameters.Add(New SqlParameter("@txtGstRate", SqlDbType.Decimal))
MyCommand.Parameters.Add(New SqlParameter("@txtLastAddEditStaff", SqlDbType.VarChar))
MyCommand.Parameters.Add(New SqlParameter("@txtLastAddEditDate", SqlDbType.DateTime))
MyCommand.Parameters.Add(New SqlParameter("@SQLCode", SqlDbType.Decimal))
' Set Parameter
MyCommand.Parameters("@txtCode").Value = Me.txtCode.Text
MyCommand.Parameters("@txtModule").Value = Me.txtModule.Text
MyCommand.Parameters("@txtType").Value = Me.txtType.Text
MyCommand.Parameters("@txtSubType").Value = Me.txtSubType.Text
MyCommand.Parameters("@txtDescription").Value = Me.txtDescription.Text
MyCommand.Parameters("@txtUnit").Value = Me.txtUnitMs.Text
MyCommand.Parameters("@txtRateCost").Value = Val(Me.txtCostRate.Text)
MyCommand.Parameters("@txtRateBill").Value = Val(Me.txtBillRate.Text)
MyCommand.Parameters("@txtLedgerCost").Value = Me.txtCostLedger.Text
MyCommand.Parameters("@txtLedgerBill").Value = Me.txtBillLedger.Text
MyCommand.Parameters("@txtGst").Value = Me.txtGST.Text
MyCommand.Parameters("@txtGstRate").Value = Val(Me.txtRate.Text)
MyCommand.Parameters("@txtMemo").Value = Me.txtMemo.Text
MyCommand.Parameters("@txtLastAddEditStaff").Value = vpStaffId
MyCommand.Parameters("@txtLastAddEditDate").Value = Now
MyCommand.Parameters("@SQLCode").Value = Val(Me.vEventCode)
' Execute SQL Query
MyCommand.ExecuteNonQuery()
pSqlUpdateRecord = True
Catch ex As Exception
MsgBox("<f08DisbEdit.pSqlUpdateRecord> " & ex.Message)
Finally
' Close Connection
If (conn.State = ConnectionState.Open) Then
conn.Close()
End If
End Try
End Function
pSqlUpdateRecord = False
' Establish Connection
Dim conn As New SqlConnection(vpConnStr)
Try
Dim strSql As String = " UPDATE m08Disb SET " & _
" Code=@txtCode," & _
" Module=@txtModule," & _
" Type=@txtType ," & _
" SubType=@txtSubType ," & _
" Description=@txtDescription ," & _
" Unit=@txtUnit ," & _
" RateCost=@txtRateCost , " & _
" RateBill=@txtRateBill, " & _
" LedgerCost=@txtLedgerCost, " & _
" LedgerBill=@txtLedgerBill ," & _
" Gst=@txtGst , " & _
" GstRate=@txtGstRate, " & _
" Memo=@txtMemo, " & _
" LastAddEditStaff=@txtLastAddEditStaff, " & _
" LastAddEditDate=@txtLastAddEditDate " & _
" WHERE SQLCode=@SQLCode "
conn.Open()
' Create SQL Command
Dim MyCommand As SqlCommand = conn.CreateCommand()
MyCommand.CommandText = strSql
' Add Parameter
MyCommand.Parameters.Add(New SqlParameter("@txtCode", SqlDbType.VarChar))
MyCommand.Parameters.Add(New SqlParameter("@txtModule", SqlDbType.VarChar))
MyCommand.Parameters.Add(New SqlParameter("@txtType", SqlDbType.VarChar))
MyCommand.Parameters.Add(New SqlParameter("@txtSubType", SqlDbType.VarChar))
MyCommand.Parameters.Add(New SqlParameter("@txtDescription", SqlDbType.VarChar))
MyCommand.Parameters.Add(New SqlParameter("@txtUnit", SqlDbType.VarChar))
MyCommand.Parameters.Add(New SqlParameter("@txtRateCost", SqlDbType.Decimal))
MyCommand.Parameters.Add(New SqlParameter("@txtRateBill", SqlDbType.Decimal))
MyCommand.Parameters.Add(New SqlParameter("@txtLedgerCost", SqlDbType.VarChar))
MyCommand.Parameters.Add(New SqlParameter("@txtLedgerBill", SqlDbType.VarChar))
MyCommand.Parameters.Add(New SqlParameter("@txtGst", SqlDbType.VarChar))
MyCommand.Parameters.Add(New SqlParameter("@txtMemo", SqlDbType.VarChar))
MyCommand.Parameters.Add(New SqlParameter("@txtGstRate", SqlDbType.Decimal))
MyCommand.Parameters.Add(New SqlParameter("@txtLastAddEditStaff", SqlDbType.VarChar))
MyCommand.Parameters.Add(New SqlParameter("@txtLastAddEditDate", SqlDbType.DateTime))
MyCommand.Parameters.Add(New SqlParameter("@SQLCode", SqlDbType.Decimal))
' Set Parameter
MyCommand.Parameters("@txtCode").Value = Me.txtCode.Text
MyCommand.Parameters("@txtModule").Value = Me.txtModule.Text
MyCommand.Parameters("@txtType").Value = Me.txtType.Text
MyCommand.Parameters("@txtSubType").Value = Me.txtSubType.Text
MyCommand.Parameters("@txtDescription").Value = Me.txtDescription.Text
MyCommand.Parameters("@txtUnit").Value = Me.txtUnitMs.Text
MyCommand.Parameters("@txtRateCost").Value = Val(Me.txtCostRate.Text)
MyCommand.Parameters("@txtRateBill").Value = Val(Me.txtBillRate.Text)
MyCommand.Parameters("@txtLedgerCost").Value = Me.txtCostLedger.Text
MyCommand.Parameters("@txtLedgerBill").Value = Me.txtBillLedger.Text
MyCommand.Parameters("@txtGst").Value = Me.txtGST.Text
MyCommand.Parameters("@txtGstRate").Value = Val(Me.txtRate.Text)
MyCommand.Parameters("@txtMemo").Value = Me.txtMemo.Text
MyCommand.Parameters("@txtLastAddEditStaff").Value = vpStaffId
MyCommand.Parameters("@txtLastAddEditDate").Value = Now
MyCommand.Parameters("@SQLCode").Value = Val(Me.vEventCode)
' Execute SQL Query
MyCommand.ExecuteNonQuery()
pSqlUpdateRecord = True
Catch ex As Exception
MsgBox("<f08DisbEdit.pSqlUpdateRecord> " & ex.Message)
Finally
' Close Connection
If (conn.State = ConnectionState.Open) Then
conn.Close()
End If
End Try
End Function