protected void btnDeleteCar_Click(object sender, EventArgs e)
 {
     CarRentalService.ICarRentalService client  = new CarRentalService.CarRentalServiceClient("WSHttpBinding_ICarRentalService");
     CarRentalService.CarRequest        request = new CarRentalService.CarRequest();
     request.LicenseKey = "secret";
     request.CarId      = Convert.ToInt32(deleteCarTxt.Text);
     client.DeleteCar(request);
     deleteCarMessage.Text = "Car is deleted";
 }
Exemple #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                CarRentalService.CarRentalServiceClient client = new CarRentalService.CarRentalServiceClient("WSHttpBinding_ICarRentalService");
                List <CarRentalService.Car>             cars   = client.GetCars().ToList();

                rptCars.DataSource = cars;
                rptCars.DataBind();
            }
        }
        protected void btnNewCar_Click(object sender, EventArgs e)
        {
            CarRentalService.ICarRentalService client = new CarRentalService.CarRentalServiceClient("WSHttpBinding_ICarRentalService");

            CarRentalService.CarInfo car = new CarRentalService.CarInfo();
            car.Id             = Convert.ToInt32(txtCarId.Text);
            car.RegisterNumber = txtRegisterNumber.Text;
            car.Brand          = txtBrand.Text;
            car.Model          = txtModel.Text;
            car.DayRent        = Convert.ToInt32(txtDayRent.Text);
            car.Year           = Convert.ToInt32(txtYear.Text);
            car.Status         = txtStatus.Text;

            //CarRentalService.CarRentalServiceClient client = new CarRentalService.CarRentalServiceClient();

            client.SaveCar(car);

            lblMessageCar.Text = "Car saved";
        }
Exemple #4
0
        protected void bookBtn_Click(object sender, EventArgs e)
        {
            CarRentalService.IBookingService   client  = new CarRentalService.BookingServiceClient("WSHttpBinding_IBookingService");
            CarRentalService.ICarRentalService client1 = new CarRentalService.CarRentalServiceClient("WSHttpBinding_ICarRentalService");

            CarRentalService.BookingInfo booking = new CarRentalService.BookingInfo();
            CarRentalService.CarInfo     car     = new CarRentalService.CarInfo();
            booking.Id         = Convert.ToInt32(txtBooking.Text);
            booking.CarId      = carList.SelectedIndex + 1;
            booking.CustomerId = customerList.SelectedIndex + 1;
            booking.StartTime  = startCalenda.SelectedDate;
            booking.ReturnTime = endCalenda.SelectedDate;

            car.Id     = booking.CarId;
            car.Status = "rented";


            client.SaveBooking(booking);
            client1.UpdateCarStatus(car);

            lblMessageBooking.Text = "Booking saved";
        }
        protected void btnReturningCar_Click(object sender, EventArgs e)
        {
            CarRentalService.IBookingService   client  = new CarRentalService.BookingServiceClient("WSHttpBinding_IBookingService");
            CarRentalService.ICarRentalService client1 = new CarRentalService.CarRentalServiceClient("WSHttpBinding_ICarRentalService");
            CarRentalService.BookingRequest    request = new CarRentalService.BookingRequest();

            CarRentalService.CarRequest carRequest = new CarRentalService.CarRequest();
            request.LicenseKey = "secret";
            request.BookingId  = Convert.ToInt32(txtReturningCar.Text);

            CarRentalService.BookingInfo booking = client.GetBooking(request);


            carRequest.CarId      = booking.CarId;
            carRequest.LicenseKey = "secret";
            CarRentalService.CarInfo car = new CarRentalService.CarInfo();


            car.Id     = booking.CarId;
            car.Status = "available";
            client1.UpdateCarStatus(car);

            lblMessageReturning.Text = "Car Returned";
        }
        protected void searchingBookingBtn_Click(object sender, EventArgs e)
        {
            CarRentalService.ICarRentalService client  = new CarRentalService.CarRentalServiceClient("WSHttpBinding_ICarRentalService");
            CarRentalService.IBookingService   client1 = new CarRentalService.BookingServiceClient("WSHttpBinding_IBookingService");
            CarRentalService.ICustomerService  client2 = new CarRentalService.CustomerServiceClient("WSHttpBinding_ICustomerService");

            CarRentalService.BookingRequest  request         = new CarRentalService.BookingRequest();
            CarRentalService.CustomerRequest customerRequest = new CarRentalService.CustomerRequest();
            CarRentalService.CarRequest      carRequest      = new CarRentalService.CarRequest();
            request.LicenseKey = "secret";
            request.BookingId  = Convert.ToInt32(txtReturningCar.Text);

            CarRentalService.BookingInfo booking = client1.GetBooking(request);
            customerRequest.LicenseKey = "secret";
            customerRequest.CustomerId = booking.CustomerId;

            carRequest.CarId      = booking.CarId;
            carRequest.LicenseKey = "secret";

            CarRentalService.CustomerInfo customer = client2.GetCustomer(customerRequest);
            CarRentalService.CarInfo      car      = client.GetCar(carRequest);

            startTimeTxt.Text  = booking.StartTime.ToString();
            returnTimeTxt.Text = booking.ReturnTime.ToString();

            customerFirstNameTxt.Text = customer.FirstName;
            customerLastNameTxt.Text  = customer.LastName;
            customerEmailTxt.Text     = customer.Email;

            carRegisterNumberTxt.Text = car.RegisterNumber;
            carBrandTxt.Text          = car.Brand;
            carModelTxt.Text          = car.Model;
            carYearTxt.Text           = car.Year.ToString();
            carDayRentTxt.Text        = car.DayRent.ToString();
            lblMessageReturning.Text  = "Booking found";
        }
Exemple #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                CarRentalService.ICarRentalService client    = new CarRentalService.CarRentalServiceClient("WSHttpBinding_ICarRentalService");
                CarRentalService.ICustomerService  client1   = new CarRentalService.CustomerServiceClient("WSHttpBinding_ICustomerService");
                List <CarRentalService.Car>        cars      = client.GetCars().ToList();
                List <CarRentalService.Customer>   customers = client1.GetCustomers().ToList();


                List <String> carDropDownList      = new List <string>();
                List <String> customerDropDownList = new List <string>();

                foreach (var car in cars)
                {
                    string carItem = String.Format("{0} {1}, Year {2}", car.Brand, car.Model, car.Year);
                    carDropDownList.Add(carItem);
                }

                foreach (var customer in customers)
                {
                    string customerItem = String.Format("{0} {1}", customer.FirstName, customer.LastName);
                    customerDropDownList.Add(customerItem);
                }

                carList.DataSource = carDropDownList;
                carList.DataBind();


                customerList.DataSource = customerDropDownList;
                customerList.DataBind();

                startCalenda.Visible = false;
                endCalenda.Visible   = false;
            }
        }