O'Reilly logo

Python Programming On Win32 by Mark Hammond, Andy Robinson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding and Editing Transactions

Now we are ready to add and edit transactions. The natural thing to do is to allow a double-click on a transaction to lead to a special dialog for editing. This should perform the necessary validation to ensure that the transaction balances before the dialog is closed, and, if there is a change, it should update all of the current views. We’ve built a pair of dialogs in VB: one to edit transactions and the other (called from it) to edit individual line items. Figure 7.3 shows the transaction dialog.

Transaction editing dialog
Figure 7.3. Transaction editing dialog

The code to edit the transaction is exposed as a method of the form as follows:

Public Function Edit(index As Integer) As Boolean 'returns true is the transaction was successfully edited Dim i As Integer Dim linecount As Integer Set tran = frmMain.BookServer.getTransaction(index) 'display the transaction details lblTranIndex.Caption = Str(index) txtDate.text = FormatDateTime(tran.getCOMDate) txtComment.text = tran.getComment linecount = tran.getLineCount grdItems.rows = linecount + 1 For i = 0 To linecount - 1 grdItems.TextMatrix(i + 1, 0) = tran.GetAccount(i) grdItems.TextMatrix(i + 1, 1) = tran.getAmount(i) Next i Set tran = Nothing UpdateFormState 'display and allow editing Me.Show vbModal If FormExit = vbOK Then Set tran = frmMain.BookServer.CreateTransaction tran.setComment txtComment.text If IsDate(txtDate.text) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required