コード例 #1
0
        private void btnHoanThanh_Click(object sender, RoutedEventArgs e)
        {
            // TODO: Update Danh sách khách hàng thuê phòng cho _roomToRent

            Customer customer = dataGridCustomer.Items.GetItemAt(0) as Customer;

            if (String.IsNullOrEmpty(customer.Name) || String.IsNullOrEmpty(customer.Type) || customer.IdCardNumber == 0 || String.IsNullOrEmpty(customer.Address))
            {
                MessageBox.Show("Khách hàng đầu tiên là người đại diện thuê phòng! Vui lòng nhập đầy đủ thông tin! Không để trống dòng này!");
                return;
            }
            if (RentInfo.InsertCheckinInfo(_roomToRent.Name, App.Instance._Session.CurrentStaff.Username, customer.IdCardNumber, (DateTime)dprCheckinDate.SelectedDate) &&
                Customer.InsertCustomer(customer.Name, customer.Address, customer.IdCardNumber, customer.Type) && Room.UpdateRoomStatus(_roomToRent.Name))
            {
                foreach (Customer item in ListGuestsRenting)
                {
                    if (item.Name == null)
                    {
                        continue;
                    }
                    RoomRentalDetail.InsertRoomRentalDetail(_roomToRent.Name, item.Name, item.IdCardNumber, item.Address, item.Type);
                }
                PaymentDetail.InsertPaymentDetail(_roomToRent.Name, (DateTime)dprCheckinDate.SelectedDate, RoomRentalDetail.GetQuantumCustomerInRoom(_roomToRent.Name), RoomRentalDetail.GetQuantumForeignCustomerInRoom(_roomToRent.Name));
                MessageBox.Show("Thuê phòng thành công");
                this.Close();
            }
            else
            {
                MessageBox.Show("Có lỗi xảy ra! Vui lòng thực hiện lại thao tác!");
                this.Close();
            }
        }