TAILIEUCHUNG - Beginning C# 2005 Databases PHẦN 9

Tùy chọn Không sử dụng các đối tượng dữ liệu, truyền dữ liệu đọc các đối tượng nơi họ là cần thiết. Ưu điểm nhanh và dễ dàng. Giải pháp tốt cho tình huống chỉ đọc và các ứng dụng web. Nhanh chóng để thực hiện. Mã linh hoạt thường có thể được tái sử dụng với nhiều nguồn dữ liệu. Cú pháp đơn giản khi các lớp thiết kế một cách chính xác. Khả năng để thêm logic kinh doanh và chức năng bổ sung đến các lớp học. Mạnh mẽ gõ. đối tượng. | Chapter 10 The code in the event handler must add a row to the CharacterAddress table to associate the character with an address. As with other rows a new GUID ID is required so the first step is to generate one private void addressView_UserAddedRow object sender DataGridViewRowEventArgs e Guid characterAddressId Next the new row is added directly to the typed data set that stores your data namely the data component. The method can do this using an overload that accepts a GUID ID value a CharacterRow object an AddressRow object and a Boolean value determining whether the address is the primary one for the character. You can get both of the row objects a CharacterRow and an AddressRow from the Current properties of the relevant binding sources using the property and casting as per usual characterAddressId as DataRowView .Row as as DataRowView .Row as false The primary address aspect of the database isn t actually used in this example but it still needs to be set. Once a new row is added it s necessary to re-filter the address view to make it display because the GUID ID value of the new address won t be included in the current filter. This cannot be done as part of the preceding event handler that would result in problems adding data to the new row. Re-filtering data will lose the current cell selection and make users swear. Instead the re-filtering is performed when the selected row in the address view changes private void addressBindingSource_CurrentChanged object sender EventArgs e SetAddressFilter Now that adding rows is possible it s time to look at deleting rows. Here the problem is that multiple characters may reference a single Address row. If you don t deal with it deleting an address from one character will result in it

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.