tailieunhanh - Murach’s ado net _4 database programming with vb 2010 phần 5

Nó có nghĩa là đọc cho tất cả mọi người. Và nó làm cho cuốn sách hướng dẫn tham khảo nhanh chóng và dễ dàng sử dụng khi bạn đang thực hiện đào tạoĐã biết làm thế nào để mã trong Visual Basic 2010? Sau đó, tổng thể lập trình web với phiên bản 4. NET của cuốn sách đó là một yêu thích của các nhà phát triển. | 274 Section 3 Three-layer Windows Forms applications The code for the Transfer Payment form To show you how the TransferPayment method of the InvoiceDB database class is used by the Transfer Payment form figure 8-7 presents the code for the Click event of its Make Transfer button. If you want to see the other event handlers for this form you can of course open the application that you ve downloaded from our web site. But you shouldn t have any trouble envisioning what the other event handlers do. As you can see in this figure the code for the Click event handler of the Make Transfer button consists of nested If statements that check the validity of all the data before executing the TransferPayment method of the InvoiceDB class. If anything is invalid the related Else clause displays an appropriate error message. But if everything is valid the TransferPayment method is executed. When the TransferPayment method is executed it returns True returns False or throws a SQL exception. As a result the call for this method is coded as the condition for an If statement within the Try block of a Try. .Catch statement. Then if the method returns True a message is displayed that documents the payment transfer. If the method returns False a message is displayed that indicates that a concurrency error probably occurred. And if the method throws a SQL exception the exception message is displayed. Note that once the result is returned from the TransferPayment method of the InvoiceDB class the fromlnvoice and tolnvoice variables are set to Nothing after the ClearControls procedure is called. This is done whether or not the transfer was successful. If these variables aren t set to Nothing the user could transfer a payment without retrieving another to or from invoice. Download from Wow eBook Chapter 8 How to work with transactions 275 The code for the Click event of the Make Transfer button Private Sub btnTransfer_Click ByVai sender As ByVai e As .