/// <summary>
 /// Calculate rental fee for rental bike
 /// </summary>
 /// <param name="timeRent">The time that the user has rented the car</param>
 /// <param name="category">The category of rental bike</param>
 /// <returns>The rental money that use must rent</returns>
 public int CalculateFee(string timeRent, Config.SQL.BikeCategory category)
 {
     string[] times = timeRent.Split(':');
     double hour = Int64.Parse(times[0]);
     double minute = Int64.Parse(times[1]);
     double second = Int64.Parse(times[2]);
     double timeMinutes = 60 * hour + minute + Math.Abs(second / 60) - 10;
     if (category != Config.SQL.BikeCategory.BIKE) timeMinutes = 1.5 * timeMinutes;
     if (timeMinutes <= 0) return 0;
     timeMinutes -= 30;
     if (timeMinutes <= 0) return 10000;
     return (int)(10000 + Math.Abs(timeMinutes / 15));
 }
Beispiel #2
0
 /// <summary>
 /// Fill ListBikeForm with bike's information in specified category
 /// </summary>
 /// <param name="station">The station contain list bike is displayed</param>
 /// <param name="category">The specified bike's category</param>
 public void FillListBikes(int stationId, Config.SQL.BikeCategory category)
 {
     if (category == Config.SQL.BikeCategory.BIKE)
     {
         FillListBikes(stationId);
     }
     else if (category == Config.SQL.BikeCategory.ELECTRIC)
     {
         FillListElectric(stationId);
     }
     else
     {
         FillListTandems(stationId);
     }
 }
        /// <summary>
        /// Fill transaction form with transaction's information when user process transaction for pay rental money
        /// </summary>
        /// <param name="stationId">The return station id</param>
        public void FillTransactionInformationWhenPay(int stationId)
        {
            this.status             = TRANSACTION_STATUS.PAY;
            this.stationId          = stationId;
            remainMoneyTxt.Text     = "111";
            transactionDateTxt.Text = DateTime.Now.ToString("f");
            cancelBut.Visible       = false;

            Config.SQL.BikeCategory category = SQL.BikeCategory.BIKE;
            if (Config.RENTAL_BIKE is Bike)
            {
                category = SQL.BikeCategory.BIKE;
            }
            else if (Config.RENTAL_BIKE is ElectricBike)
            {
                category = SQL.BikeCategory.ELECTRIC;
            }
            else if (Config.RENTAL_BIKE is Tandem)
            {
                category = SQL.BikeCategory.TANDEM;
            }
            rentalMoney         = returnBikeController.CalculateFee(Config.TIME_RENTAL_BIKE, category);
            rentalMoneyTxt.Text = (rentalMoney == 0) ? "Miễn phí" : rentalMoney.ToString();
        }
 /// <summary>
 /// Update bike status after rent bike
 /// </summary>
 /// <param name="stationId">The return station</param>
 /// <param name="category">The type of bike</param>
 /// <returns></returns>
 public void UpdateStationAfterReturnbike(int stationId, Config.SQL.BikeCategory category)
 {
     if (category == Config.SQL.BikeCategory.BIKE) bikeService.UpdateBike(Config.RENTAL_BIKE.BikeId, new UpdateBikeInfo { StationId = stationId, BikeStatus = -1 });
     else if (category == Config.SQL.BikeCategory.ELECTRIC) electricBikeService.UpdateBike(Config.RENTAL_BIKE.BikeId, new UpdateBikeInfo { StationId = stationId, BikeStatus = -1 });
     else tandemService.UpdateBike(Config.RENTAL_BIKE.BikeId, new UpdateBikeInfo { StationId = stationId, BikeStatus = -1 });
 }