protected void customerSearchByHttpBtn_Click(object sender, EventArgs e) { CarRentalService.ICustomerService client = new CarRentalService.CustomerServiceClient("WSHttpBinding_ICustomerService"); CarRentalService.CustomerRequest request = new CarRentalService.CustomerRequest(); request.LicenseKey = "secret"; request.CustomerId = Convert.ToInt32(customerIdTxt.Text); CarRentalService.CustomerInfo customer = null; try { customer = client.GetCustomer(request); txtFirstName.Text = customer.FirstName; txtLastName.Text = customer.LastName; txtMobile.Text = customer.Mobile; txtEmail.Text = customer.Email; customerTypeDropDownList.SelectedValue = ((int)customer.CustomerType).ToString(); if (customer.CustomerType == CarRentalService.CustomerType.ContractCustomer) { txtDiscount.Text = customer.Discount.ToString(); trdiscount.Visible = true; } else { txtDiscount.Visible = false; } lblMessageUpdateCustomer.Text = "Customer Found"; } catch (Exception ex) { lblMessageUpdateCustomer.Text = "Customer Not Found"; client = new CarRentalService.CustomerServiceClient("WSHttpBinding_ICustomerService"); customer = null; } }
protected void btnUpdateCustomer_Click(object sender, EventArgs e) { CarRentalService.ICustomerService client = new CarRentalService.CustomerServiceClient("WSHttpBinding_ICustomerService"); CarRentalService.CustomerInfo customer = new CarRentalService.CustomerInfo(); if (customerTypeDropDownList.SelectedValue == "-1") { lblMessageUpdateCustomer.Text = "Please select Employee Type"; } else if (((CarRentalService.CustomerType)Convert.ToInt32(customerTypeDropDownList.SelectedValue)) == CarRentalService.CustomerType.PayAsGoCustomer) { customer.CustomerType = CarRentalService.CustomerType.PayAsGoCustomer; } else { customer.CustomerType = CarRentalService.CustomerType.ContractCustomer; customer.Discount = Convert.ToDecimal(txtDiscount.Text); } customer.Id = Convert.ToInt32(customerIdTxt.Text); customer.FirstName = txtFirstName.Text; customer.LastName = txtLastName.Text; customer.Mobile = txtMobile.Text; customer.Email = txtEmail.Text; client.UpdateCustomer(customer); lblMessageUpdateCustomer.Text = "Customer updated"; }
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"; }