Datagridview - Writing Journal Transactions for a Datagridview

Datagridview - Writing Journal Transactions for a Datagridview

Post by Qm9iIFJvZ2 » Thu, 02 Nov 2006 22:40:02


I would like to write transaction activity to a journal table, specifying
Add, Update, or Delete and some information regarding each transaction when a
user works in a datagridview.

I have tried:

Dim deletedChildRecords As dsVersaPress.RoutingDataTable = _

CType(DsVersaPress.Routing.GetChanges(Data.DataRowState.Deleted),
dsVersaPress.RoutingDataTable)

Dim newChildRecords As dsVersaPress.RoutingDataTable = _
CType(DsVersaPress.Routing.GetChanges(Data.DataRowState.Added),
dsVersaPress.RoutingDataTable)

Dim modifiedChildRecords As dsVersaPress.RoutingDataTable = _

CType(DsVersaPress.Routing.GetChanges(Data.DataRowState.Modified),
dsVersaPress.RoutingDataTable)

Try
If deletedChildRecords IsNot Nothing Then
Dim hCount As Integer
Dim hOperation As String
Dim hOperDesc As String
Dim hDeleteRecCount As Integer = deletedChildRecords.Count
For hCount = 0 To hDeleteRecCount - 1
hItemNo = deletedChildRecords.Rows(hCount)("Operation")
hOperation = deletedChildRecords.Rows(hCount)("Operation")
hOperDesc = deletedChildRecords.Rows(hCount)("OperDesc")
Next

RoutingTableAdapter.Update(deletedChildRecords)

End If

If newChildRecords IsNot Nothing Then

Dim hNewRecCount As Integer = newChildRecords.Count
RoutingTableAdapter.Update(newChildRecords)

End If

If modifiedChildRecords IsNot Nothing Then

Dim hModifiedRecCount As Integer = modifiedChildRecords.Count
RoutingTableAdapter.Update(modifiedChildRecords)
End If

DsVersaPress.Routing.AcceptChanges()

Catch ex As Exception
MessageBox.Show("An error occurred during the update process")

' Add code to handle error here.

Finally
If deletedChildRecords IsNot Nothing Then
deletedChildRecords.Dispose()
End If

If newChildRecords IsNot Nothing Then
newChildRecords.Dispose()
End If

If modifiedChildRecords IsNot Nothing Then
modifiedChildRecords.Dispose()
End If

End Try

This isolates the Insert, Delete, and Update tranactions ; but I can not
access deletedChildRecords rows and individual fields. Is there a way to do
this?
 
 
 

1. Binding List<T> to a DataGridView = DataGridView Empty

2. ~ write with color in datagridview

Set up multiple DataGridViewCellStyles and then
apply it to the cells you want to change.

Dim MakeItRed as New DataGridViewCellStyle()
MakeItRed.ForeColor = Color.Red

You can do a whole column:
thisGrid.Columns("price").DefaultCellStyle = MakeItRed

To apply this to a cell, you have to access the cell
through the row.

For Each row1 As DataGridViewRow In thisGrid.Rows
If row1.Cells("price").Value IsNot DBNull.Value Then
If CType(row1.Cells("price").Value, Decimal) > 5 Then
row1.Cells("price").Style = MakeItRed
Else
row1.Cells("price").Style = MakeItBlue
End If
End If
Next

Hope this helps.
Robin S.
----------------------------------

3. How do I write in the DataGridView

4. Writing to crystal report from datagridview

5. Writing Excel (binary) XLS from datagridview

6. write with color in datagridview

7. write data of unbound datagridview to XML

8. What is the difference between Open transaction editing, Closed transaction editing and Journal Reversal.

9. Where can I find DataGridView for VBA? DataGridView vs DataGrid?

10. Where can I find DataGridView for VBA? DataGrid vs DataGridView

11. Where can I find DataGridView for VBA? DataGridView vs DataGrid?

12. Can i write a method not use transaction in a class which require transaction?

13. Where can I find DataGridView for VBA? DataGridView vs DataGri

14. DataTable with UDT issue with DataGridView

15. How to Sinchronize a DataGridView with a database.