public void FillTableDesignOfNewParking(int parkingName) { TableDesignOfNewParking.Rows.Clear(); ParkingBusiness parkingBusiness = new ParkingBusiness(); BookingBusiness bookingBusiness = new BookingBusiness(); ParkingLot parkingspotTable = new ParkingLot(); ParkingSpot parking = new ParkingSpot(); int counter = 0; parkingspotTable.Id = parkingName; parkingspotTable = parkingBusiness.GetDimensions(parkingspotTable); TableDesignOfNewParking = parkingBusiness.GetSpotData(parkingspotTable, TableDesignOfNewParking); for (int counterRow = 0; counterRow < parkingspotTable.DimensionX; counterRow++) { for (int counterColumn = 0; counterColumn < parkingspotTable.DimensionY; counterColumn++) { TableDesignOfNewParking.Rows[counterRow].Cells[counterColumn].Controls.Add(addButton(counter)); counter++; } } TableDesignOfNewParking = bookingBusiness.VerifySpots(parkingspotTable, TableDesignOfNewParking, DateTime.Parse(DropDownListInitialHour.SelectedValue), DateTime.Parse(DropDownListFinalHour.SelectedValue)); for (int counterRow = 0; counterRow < parkingspotTable.DimensionX; counterRow++) { for (int counterColumn = 0; counterColumn < parkingspotTable.DimensionY; counterColumn++) { if (TableDesignOfNewParking.Rows[counterRow].Cells[counterColumn].BackColor == Color.Red) { TableDesignOfNewParking.Rows[counterRow].Cells[counterColumn].Enabled = true; } else { TableDesignOfNewParking.Rows[counterRow].Cells[counterColumn].Enabled = false; } } } }
protected void btnBookingSpot_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; bookingParking.Name = DropDownListParking.SelectedItem.Text; 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) { } else { bookingBusiness.InsertBooking(newBooking); Session["BOOKING"] = newBooking; bookingParking = parkingBusiness.GetDimensions(bookingParking); selectedPosition = -1; bookingParking = removeSelected(Int32.Parse(DropDownListParking.SelectedValue)); Session["BOOKINGALERT"] = SendMail(newBooking); TableDesignOfNewParking = bookingBusiness.VerifySpots(bookingParking, TableDesignOfNewParking, DateTime.Parse(DropDownListInitialHour.SelectedValue), DateTime.Parse(DropDownListFinalHour.SelectedValue)); Response.Redirect("bookingdone.aspx"); } }