コード例 #1
0
    protected void btnDeleteReserve_Click(object sender, EventArgs e)
    {
        Booking newBooking = new Booking();
        BookingBusiness bookingBusiness = new BookingBusiness();
        ParkingBusiness parkingBusiness = new ParkingBusiness();
        User currentUser = (User)Session["USER"];
        Vehicle bookingVehicle = new Vehicle();
        ParkingSpot bookingSpot = new ParkingSpot();
        ParkingLot bookingParking = new ParkingLot();

        bookingSpot.IdParking = Int32.Parse(DropDownListParking.SelectedValue);
        bookingSpot = parkingBusiness.GetSpotForReserve(bookingSpot, (int)Session["Position"]);
        newBooking.IdVehicle = bookingVehicle;
        newBooking.IdUser = currentUser;
        newBooking.IdParkingSpot = bookingSpot;
        newBooking.IdParkingLot = bookingParking;
        newBooking.EntryTime = DateTime.Parse(DropDownListInitialHour.SelectedValue);
        newBooking.ExitTime = DateTime.Parse(DropDownListFinalHour.SelectedValue);
        newBooking.IdVehicle.Id = DropDownListVehicleFormUser.SelectedValue.Trim();
        newBooking.Date = DateTime.Today;
        newBooking.IdParkingSpot.Id = bookingSpot.Id;
        newBooking.IdParkingLot.Id = Int32.Parse(DropDownListParking.SelectedValue);

        if (bookingSpot.Id == 0)
        {
            //Return error here
        }
        else
        {
            bookingBusiness.DenyBooking(newBooking, newBooking.EntryTime, newBooking.ExitTime);
            bookingParking = parkingBusiness.GetDimensions(bookingParking);
            selectedPosition = -1;
            bookingParking = removeSelected(Int32.Parse(DropDownListParking.SelectedValue));
            FillTableDesignOfNewParking(newBooking.IdParkingLot.Id);

        }
    }