public PaymentWindow(Room roomToPay) { InitializeComponent(); _roomToPay = roomToPay; DateTime dateRent = new DateTime(); dateRent = RentInfo.GetDateCheckin(_roomToPay.Name); DateTime datePay = new DateTime(); datePay = DateTime.Now; daysRent = datePay.Subtract(dateRent); double roomPrice = (float)_roomToPay.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(_roomToPay.Name) > RoomType.GetMaxCustomerInRoom(_roomToPay.Type)) { quantum = RoomRentalDetail.GetQuantumCustomerInRoom(_roomToPay.Name) - RoomType.GetMaxCustomerInRoom(_roomToPay.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(_roomToPay.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; txbRoomName.Text = roomToPay.Name; txbRoomType.Text = roomToPay.Type; txbDateRented.Text = dateRent.ToString("dd/MM/yyyy"); txbDaysRented.Text = (daysRent.Days + 1).ToString(); txbNumberGuests.Text = "" + RoomRentalDetail.GetQuantumCustomerInRoom(_roomToPay.Name); txbIsForeigns.Text = "" + RoomRentalDetail.GetQuantumForeignCustomerInRoom(_roomToPay.Name); txbTotalMoney.Text = "" + string.Format("{0:N0}", totalMoney); }
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(); }
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(); } }