コード例 #1
0
 private void btnPay_Click(object sender, RoutedEventArgs e)
 {
     if (RentInfo.UpdateChechoutDate(_roomToPay.Name) && RoomRentalDetail.DeleteRoomRentalDetail(_roomToPay.Name) &&
         Room.UpdateRoomStatus(_roomToPay.Name) && RevenueReport.InsertRevenueReport(_roomToPay.Name, _roomToPay.Type, RentInfo.GetDateCheckin(_roomToPay.Name), DateTime.Now, totalMoney) &&
         PaymentDetail.UpdatePaymentDetail(_roomToPay.Name, daysRent.Days + 1, totalMoney))
     {
         MessageBox.Show("Thanh toán thành công!");
     }
     else
     {
         MessageBox.Show("Thanh toán không thành công! Vui lòng thực hiện lại thao tác!");
     }
     this.Close();
 }
コード例 #2
0
        private void CbCustomerName_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            txbAddress.Text    = ((Customer)cbCustomerName.SelectedItem).Address;
            txbCustomerID.Text = ((Customer)cbCustomerName.SelectedItem).IdCardNumber.ToString();
            //Update payment detail
            List <Room> rooms = new List <Room>();

            rooms.Clear();
            rooms.AddRange(Room.GetRoomsByCustomerID(((Customer)cbCustomerName.SelectedItem).IdCardNumber));

            DateTime dateRent = new DateTime();
            DateTime datePay  = new DateTime();

            foreach (var item in rooms)
            {
                dateRent = RentInfo.GetDateCheckin(item.Name);
                datePay  = DateTime.Now;
                TimeSpan daysRent = datePay.Subtract(dateRent);

                double roomPrice = (float)item.Price * (daysRent.Days + 1); // Tiền phòng gốc theo ngày thuê (chưa tính phụ thu).
                int    quantum   = 0;
                if (RoomRentalDetail.GetQuantumCustomerInRoom(item.Name) > RoomType.GetMaxCustomerInRoom(item.Type))
                {
                    quantum = RoomRentalDetail.GetQuantumCustomerInRoom(item.Name) - RoomType.GetMaxCustomerInRoom(item.Type); // Số lượng khách vượt quá số khách tối đa theo quy định của loại phòng đó.
                }
                double surchargeCustomerType    = RoomRentalDetail.GetSurchargeCustomerInRoom(item.Name) / 100;                // Phụ thu theo loại khách trong phòng.
                double surchargeQuantumCustomer = CustomerSurcharge.GetSurchargeByQuantum(quantum) / 100;                      // Phụ thu theo số khách vượt quá số khách tối đa theo quy định của loại phòng đó.
                totalMoney = roomPrice + roomPrice * surchargeCustomerType + roomPrice * surchargeQuantumCustomer;

                PaymentDetail.UpdatePaymentDetail(item.Name, daysRent.Days + 1, totalMoney);
            }

            //Calculate total fee
            txbTotalFee.Text = TotalFee;

            LoadPaymentDetailFromDB();
        }