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 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 btnDeleteCustomer_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(deleteCustomerTxt.Text);
     client.DeleteCustomer(request);
     deleteMessage.Text = "Customer is deleted";
 }
Ejemplo n.º 4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         CarRentalService.ICustomerService client    = new CarRentalService.CustomerServiceClient("WSHttpBinding_ICustomerService");
         List <CarRentalService.Customer>  customers = client.GetCustomers().ToList();
         var contractCustomers = customers.Where(c => Convert.ToInt32(c.CustomerType) == 2).ToList();
         rptCustomers.DataSource = contractCustomers;
         rptCustomers.DataBind();
     }
 }
        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";
        }
Ejemplo n.º 6
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;
            }
        }