Exemple #1
0
        protected void btnGetAvailableCars_Click(object sender, EventArgs e)
        {
            lblLabelReservations.Text = " ";
            lblCarModel.Text          = " ";
            lblCarBrand.Text          = " ";
            lblCarReg.Text            = " ";
            lblCarYear.Text           = " ";
            lblBookingStart.Text      = " ";
            lblReservationResult.Text = " ";

            txtAvailableRegCar.Visible = false;
            lblAvailableModel.Visible  = false;
            lblAvailableBrand.Visible  = false;
            txtFirstName.Visible       = false;
            txtLastName.Visible        = false;
            txtPhonenumber.Visible     = false;
            txtEmailAddress.Visible    = false;
            txtBookStartDate.Visible   = false;
            txtBookuntil.Visible       = false;
            btnSaveBook.Visible        = false;

            ServiceReference1.IHelloService client = new ServiceReference1.HelloServiceClient("wsHttpBinding_IHelloService");

            ServiceReference1.ReservationRequestByDate request = new ServiceReference1.ReservationRequestByDate();
            request.LicenseKey = "SuperSecret123";
            request.Startdate  = calStartdate.SelectedDate.ToShortDateString();
            lblDateFrom.Text   = request.Startdate;
            request.Enddate    = calEnddate.SelectedDate.ToShortDateString();
            lblDateTo.Text     = request.Enddate;

            ServiceReference1.ListReservationsInfo reservationsInfo = new ServiceReference1.ListReservationsInfo();
            reservationsInfo = client.GetAvailableCars(request);

            List <ServiceReference1.Reservation> allReser = client.GetAllReservations();
            List <int> carId = new List <int>();

            foreach (ServiceReference1.Reservation res in allReser)
            {
                carId.Add(res.CarId);
            }
            List <ServiceReference1.Car> allCars = client.GetAllCars();

            foreach (ServiceReference1.Car car1 in allCars)
            {
                if (!carId.Contains(car1._Id))
                {
                    carsRegnum.Add(car1._Regnumber);
                    lblCarModel.Text     += ": " + car1._Model + "|| ";
                    lblCarReg.Text       += ": " + car1._Regnumber + "|| ";
                    lblCarBrand.Text     += ": " + car1._Brand + "|| ";
                    lblCarYear.Text      += ": " + car1._Year.ToString() + "|| ";
                    lblBookingStart.Text += ": never been booked || ";
                }
            }

            if (reservationsInfo.ReservationCollection != null && reservationsInfo.ReservationCollection.Count() != 0)
            {
                lblLabelReservations.Text = "Available car(s)";

                foreach (ServiceReference1.ReservationInfo reservation in reservationsInfo.ReservationCollection)
                {
                    carsRegnum.Add(reservation.Regnumber);
                    lblCarModel.Text     += ": " + reservation.Model + "|| ";
                    lblCarReg.Text       += ": " + reservation.Regnumber + "|| ";
                    lblCarBrand.Text     += ": " + reservation.Brand + "|| ";
                    lblCarYear.Text      += ": " + reservation.Year.ToString() + "|| ";
                    lblBookingStart.Text += ": " + reservation.StartDate.ToShortDateString() + " - " + reservation.EndDate.ToShortDateString() + "|| ";
                }

                txtBookStartDate.Text      = lblDateFrom.Text;
                txtBookuntil.Text          = lblDateTo.Text;
                btnMakeReservation.Visible = true;
                lblReservationResult.Text  = "Found available car(s)";
            }
            else
            {
                lblCarModel.Text     = "-";
                lblCarBrand.Text     = "-";
                lblCarReg.Text       = "-";
                lblCarYear.Text      = "-";
                lblBookingStart.Text = "-";


                btnMakeReservation.Visible = true;
                lblReservationResult.Text  = "No available car(s)";
            }
        }
Exemple #2
0
        protected void btnGetBookedCars_Click(object sender, EventArgs e)
        {
            lblLabelReservations.Text = " ";
            lblCarModel.Text          = " ";
            lblCarBrand.Text          = " ";
            lblCarReg.Text            = " ";
            lblCarYear.Text           = " ";
            lblBookingStart.Text      = " ";
            lblReservationResult.Text = " ";

            txtAvailableRegCar.Visible = false;
            lblAvailableModel.Visible  = false;
            lblAvailableBrand.Visible  = false;
            txtFirstName.Visible       = false;
            txtLastName.Visible        = false;
            txtPhonenumber.Visible     = false;
            txtEmailAddress.Visible    = false;
            txtBookStartDate.Visible   = false;
            txtBookuntil.Visible       = false;
            btnSaveBook.Visible        = false;

            txtAvailableRegCar.Text = " ";
            lblAvailableModel.Text  = " ";
            lblAvailableBrand.Text  = " ";
            txtFirstName.Text       = " ";
            txtLastName.Text        = " ";
            txtPhonenumber.Text     = " ";
            txtEmailAddress.Text    = " ";
            txtBookStartDate.Text   = " ";
            txtBookuntil.Text       = " ";
            btnSaveBook.Text        = " ";


            ServiceReference1.IHelloService client = new ServiceReference1.HelloServiceClient("wsHttpBinding_IHelloService");

            ServiceReference1.ReservationRequestByDate request = new ServiceReference1.ReservationRequestByDate();
            request.LicenseKey = "SuperSecret123";
            request.Startdate  = calStartdate.SelectedDate.ToShortDateString();
            lblDateFrom.Text   = request.Startdate;
            request.Enddate    = calEnddate.SelectedDate.ToShortDateString();
            lblDateTo.Text     = request.Enddate;

            ServiceReference1.ListReservationsInfo reservationsInfo = new ServiceReference1.ListReservationsInfo();
            reservationsInfo = client.GetReservationByDate(request);

            if (reservationsInfo.ReservationCollection != null && reservationsInfo.ReservationCollection.Count() != 0)
            {
                lblLabelReservations.Text = "Reserved car(s)";
                foreach (ServiceReference1.ReservationInfo reservation in reservationsInfo.ReservationCollection)
                {
                    string number = reservationsInfo.ReservationCollection.IndexOf(reservation).ToString();
                    lblCarModel.Text     += number + ": " + reservation.Model + "|| ";
                    lblCarReg.Text       += number + ": " + reservation.Regnumber + "|| ";
                    lblCarBrand.Text     += number + ": " + reservation.Brand + "|| ";
                    lblCarYear.Text      += number + ": " + reservation.Year.ToString() + "|| ";
                    lblBookingStart.Text += number + ": " + reservation.StartDate.ToShortDateString() + " - " + reservation.EndDate.ToShortDateString() + "|| ";
                }


                lblReservationResult.Text = "Found reservations";
            }
            else
            {
                lblCarModel.Text     = "-";
                lblCarBrand.Text     = "-";
                lblCarReg.Text       = "-";
                lblCarYear.Text      = "-";
                lblBookingStart.Text = "-";


                lblReservationResult.Text = "Didn't find any reservations";
            }
        }