Beispiel #1
0
        private void loadReservations()
        {
            listView1.Items.Clear();
            try
            {
                reservations = service.getCustomerReservations(customer.id);

                this.reservationsInfo.Text = "You have " + reservations.Length + " reservations:";

                foreach (CarWS.reservation r in reservations)
                {
                    CarWS.car    c    = service.getCar(r.car_id);
                    ListViewItem item = new ListViewItem(r.id.ToString());
                    double       days = DaysBetween(r.from, r.to);
                    double       cost = Math.Round((days * c.dayCost), 2);

                    item.SubItems.Add(r.car_id.ToString());
                    item.SubItems.Add(c.brand + " " + c.model);
                    item.SubItems.Add(days.ToString());
                    item.SubItems.Add(r.from.ToString());
                    item.SubItems.Add(r.to.ToString());
                    item.SubItems.Add(cost.ToString() + " zł");
                    listView1.Items.Add(item);
                }
            }
            catch
            {
                this.reservationsInfo.Text = "You have 0 reservation:";
            }
        }
Beispiel #2
0
        private void loadReservationCarDetails()
        {
            if (listView1.SelectedItems.Count == 0)
            {
                currentReservation = null;
                brand.Text         = "-";
                model.Text         = "-";
                doors.Text         = "-";
                fuelCap.Text       = "-";
                fuelType.Text      = "-";
                range.Text         = "-";
                gearbox.Text       = "-";
                gears.Text         = "-";
                dayCost.Text       = "-";
                new Task(() => {
                    pictureBox2.Image = pictureBox2.InitialImage;
                }).Start();
                return;
            }

            int resId = int.Parse(listView1.SelectedItems[0].SubItems[0].Text);

            currentReservation = service.getReservation(resId);
            int carId = int.Parse(listView1.SelectedItems[0].SubItems[1].Text);

            CarWS.car car = service.getCar(carId);

            brand.Text    = car.brand;
            model.Text    = car.model;
            doors.Text    = car.doors.ToString();
            fuelCap.Text  = car.fuelCap.ToString();
            fuelType.Text = car.fuelType;
            range.Text    = car.range.ToString();
            gearbox.Text  = car.gearbox;
            gears.Text    = car.gears.ToString();
            dayCost.Text  = car.dayCost.ToString() + " zł";

            new Task(() => {
                var bytes = service.downloadCarImage(car.id);
                System.Drawing.Image carImage = (Bitmap)((new ImageConverter()).ConvertFrom(bytes));
                pictureBox2.Image             = carImage;
            }).Start();
        }