30.07.2013 Views

Visual Basic.NET How to Program (PDF)

Visual Basic.NET How to Program (PDF)

Visual Basic.NET How to Program (PDF)

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

824 Files and Streams Chapter 17<br />

Fig. 17.22 FrmUpdateDialog class enables users <strong>to</strong> update records in transactionprocessor<br />

case study (part 6 of 6).<br />

The Transaction TextBox initially contains the string Charge or Payment. The<br />

user should select this text, type the transaction amount (a positive value for a charge or a<br />

negative value for a payment) and then press Enter. The program calls method<br />

txtTransactionNumber_KeyDown (lines 85–129) <strong>to</strong> add the user-specified transaction<br />

amount <strong>to</strong> the current balance.<br />

The user clicks the Save Changes but<strong>to</strong>n <strong>to</strong> write the altered contents of the Text-<br />

Boxes <strong>to</strong> the file. (Note that pressing Save Changes does not update the Balance<br />

field—the user must press Enter <strong>to</strong> update this field before pressing Save Changes.)<br />

When the user clicks Save Changes, the program invokes method cmdSave_Click<br />

(lines 132–147), which calls Private method UpdateRecord (lines 159–190). This<br />

method calls method AddRecord of the CTransaction object (lines 174–175) <strong>to</strong> s<strong>to</strong>re<br />

the TextBox values in a CRandomAccessRecord and overwrite the existing file<br />

record with the CRandomAccessRecord containing the new data.<br />

When the user clicks the Delete Record but<strong>to</strong>n of the Start Dialog, the program<br />

invokes method cmdDelete_Click of class FrmStartDialog (Fig. 17.20, lines

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!