Beispiel #1
0
        private void editButton_Click(object sender, EventArgs e)
        {
            if (listView1.SelectedItems.Count == 0)
            {
                return;
            }
            if (currentReservation == null)
            {
                return;
            }

            if (DateTime.Parse(currentReservation.to).CompareTo(DateTime.Today) < 0)
            {
                return;
            }

            CarWS.reservation tmp = currentReservation;
            tabControl1.SelectedIndex = 1;

            currentReservation    = tmp;
            dateTimePicker1.Value = DateTime.Parse(currentReservation.from);
            dateTimePicker3.Value = DateTime.Parse(currentReservation.to);
            reservationLabel.Text = "You Are Editing Reservation: #" + currentReservation.id;

            foreach (ListViewItem item in listView2.Items)
            {
                if (item.SubItems[0].Text == currentReservation.car_id.ToString())
                {
                    item.Selected  = true;
                    item.BackColor = Color.LightSteelBlue;
                    break;
                }
            }
        }
Beispiel #2
0
 private void loadAsNewRes()
 {
     currentReservation    = null;
     reservationLabel.Text = "New Reservation:";
     loadCars();
     dateTimePicker1.Value = DateTime.Today.AddDays(1);
     dateTimePicker3.Value = DateTime.Today.AddDays(1);
 }
Beispiel #3
0
 private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (tabControl1.SelectedIndex == 0)
     {
         listView1.SelectedItems.Clear();
         currentReservation = null;
     }
     else
     {
         loadAsNewRes();
     }
 }
Beispiel #4
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();
        }