public Confirmation(Rent rent)
 {
     InitializeComponent();
     this.rent = rent;
     StartDate.Text = rent.StartDate.ToShortDateString();
     EndDate.Text = rent.EndDate.ToShortDateString();
     CarType.Text = rent.SelectedCar.ToString();
     MileageCost.Text = rent.SelectedCar.MilageCost.ToString() + " kr/km";
     DailyFee.Text = rent.SelectedCar.DailyCost.ToString() + " kr/day";
     if (rent.SelectedCar is SportCar)
     {
         InsuranceLabel.Visible = true;
         ExtraInsurance.Visible = true;
         ExtraInsurance.Text = rent.SelectedCar.ExtraInsurance.ToString() + " kr";
     }
 }
        public Rent Rent(DatePeriod period)
        {
            if (!IsAvailableOnPeriod(period))
            {
                throw new InvalidOperationException(
                          $"Car {Id} is unavailable to rent on choisen period");
            }

            var rent = new Rent(Guid.NewGuid(), Id, period);

            _rents.Add(rent);

            ScheduleMaintenanceIfNeeded();

            return(rent);
        }
        public void AddRent(Rent rent)
        {
            foreach (var existantRents in _rents)
            {
                if (existantRents.Id == rent.Id)
                {
                    throw new InvalidOperationException(
                              $"Rent with id {rent.Id} is already added to user {Id}");
                }
            }

            if (!CanRentAtPeriod(rent.Period))
            {
                throw new InvalidOperationException(
                          $"User {Id} can't rent another car for this period");
            }

            _rents.Add(rent);
        }
 public ReturnCar(Rent rent)
 {
     InitializeComponent();
     this.rent = rent;
     carType.Text = rent.SelectedCar.ToString();
     daysBooked.Text = rent.calcDaysRent(rent.StartDate, rent.EndDate).ToString();
     returnDate.Value = rent.EndDate;
     actualDays.Text = rent.Days.ToString();
     totalDailyCost.Text = (rent.SelectedCar.DailyCost * rent.Days).ToString();
     totalMilesCost.Text = "0";
     totalPenaltyCost.Text = "0";
     totalCostAmount.Text = "0";
     if(rent.SelectedCar is SportCar)
     {
         extraInsurance.Text = rent.SelectedCar.ExtraInsurance.ToString();
         extraInsurance.Visible = true;
         extraInsuranceLabel.Visible = true;
     }
 }
Exemple #5
0
 private void button1_Click_1(object sender, EventArgs e)
 {
     //"Rent" menu
     Rent form2 = new Rent();
     form2.Show();
 }