protected void btnGetOtherCarDetails_Click(object sender, EventArgs e) { ServiceReference1.HelloServiceClient client = new ServiceReference1.HelloServiceClient("wsHttpBinding_IHelloService"); ServiceReference1.Car car = client.GetCarByString("regnumber", txtAvailableRegCar.Text.ToString()); if (car != null) { lblAvailableModel.Text = car._Model; lblAvailableBrand.Text = car._Brand; lblReservationResult.Text = "Fill in customer details"; } else { lblReservationResult.Text = "Car not found"; } }
protected void btnSaveBook_Click(object sender, EventArgs e) { ServiceReference1.IHelloService client = new ServiceReference1.HelloServiceClient("wsHttpBinding_IHelloService"); ServiceReference1.Car car = client.GetCarByReg(txtAvailableRegCar.Text); ServiceReference1.ReservationInfo1 reservation = new ServiceReference1.ReservationInfo1(); ServiceReference1.CustomerInfo customer = new ServiceReference1.CustomerInfo(); if (carsRegnum.Contains(car._Regnumber)) { customer.FirstName = txtFirstName.Text; customer.LastName = txtLastName.Text; customer.Phone = txtPhonenumber.Text; customer.Email = txtEmailAddress.Text; try { client.SaveCustomer(customer); } catch (FaultException faultException) { lblReservationResult.Text = faultException.Message; } reservation.Brand = car._Brand; reservation.Model = car._Model; reservation.Regnumber = car._Regnumber; reservation.Year = car._Year; reservation.StartDate = Convert.ToDateTime(txtBookStartDate.Text); reservation.EndDate = Convert.ToDateTime(txtBookuntil.Text); reservation.LastName = customer.LastName; reservation.Returned = false; try { client.AddReservation(reservation); lblReservationResult.Text = "Reservation successfully saved"; } catch (FaultException faultException) { lblReservationResult.Text = faultException.Message; } } else { lblReservationResult.Text = "Car is not available during the period of choice"; } }
protected void btnGetCarByReg_Click(object sender, EventArgs e) { ServiceReference1.HelloServiceClient client = new ServiceReference1.HelloServiceClient("wsHttpBinding_IHelloService"); ServiceReference1.Car car = client.GetCarByReg(txtGetCar.Text); if (car != null) { lblBrand.Text = car._Brand; lblModel.Text = car._Model; lblYear.Text = Convert.ToString(car._Year); lblReg.Text = car._Regnumber; lblMessage.Text = "The car is retrieved"; } else { lblBrand.Text = "-"; lblModel.Text = "-"; lblYear.Text = "-"; lblReg.Text = "-"; lblMessage.Text = "The search didn't brig any cars"; } }
protected void btnGetReservationByBrand_Click(object sender, EventArgs e) { try { ServiceReference1.IHelloService client = new ServiceReference1.HelloServiceClient("wsHttpBinding_IHelloService"); ServiceReference1.Car car = client.GetCarByString("brand", txtResBrand.Text); ServiceReference1.ReservationRequestByBrand request = new ServiceReference1.ReservationRequestByBrand(); request.LicenseKey = "SuperSecret123"; request.CarBrand = txtResBrand.Text; ServiceReference1.ReservationInfo1 reservation = client.GetReservationByBrand(request); if (reservation.Model != null && reservation.Returned == true) { lblResModel.Text = reservation.Model; lblResReg.Text = reservation.Regnumber; lblStartDate.Text = reservation.StartDate.ToShortDateString(); lblEndDate.Text = reservation.EndDate.ToShortDateString(); lblResMessage.Text = "Reservation is found and car is returned"; } else { lblResModel.Text = car._Model; lblResReg.Text = car._Regnumber; lblStartDate.Text = "-"; lblEndDate.Text = "-"; lblResMessage.Text = "Car is not returned"; } } catch (FaultException faultException) { lblResMessage.Text = faultException.Message; } }