Ejemplo n.º 1
0
        public static Color ChangeLicensePlateTextBoxBackColor(string licensePlate)
        {
            licensePlate = HelperClass.StringWash(licensePlate);
            Color color;

            if (licensePlate != null)
            {
                color = Color.LightGreen;
            }
            else
            {
                color = Color.White; //Används aldrig.
            }
            return(color);
        }
Ejemplo n.º 2
0
        private void btnCheckIn_Click(object sender, EventArgs e)
        {
            try
            {
                int vehicleType = 0;
                if (radCar.Checked)
                {
                    vehicleType = 1;
                }
                else if (radMC.Checked)
                {
                    vehicleType = 2;
                }

                string regnr = HelperClass.StringWash(txtLicensePlate.Text.ToUpper());
                if (regnr != null)
                {
                    if (vehicleType != 0)
                    {
                        var vehicle = HelperClass.BackEndIO.BackEndCheckIn(regnr, vehicleType);
                        txtLicensePlate.Text = string.Empty;
                        radCar.Checked       = false;
                        radMC.Checked        = false;
                        MessageBox.Show($"{vehicle.Regnr} successfully parked at parking spot {vehicle.ParkingSpotNum}.");
                    }
                    else
                    {
                        MessageBox.Show("Invalid Vehicle type.");
                    }
                }
                else
                {
                    MessageBox.Show("Invalid license plate.");
                    if (txtLicensePlate.CanFocus)
                    {
                        txtLicensePlate.Focus();
                    }
                }
            }
            catch (FormatException fe)
            {
                MessageBox.Show(fe.Message);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void btnFindParkingSlots_Click(object sender, EventArgs e)
        {
            try
            {
                string regNr   = HelperClass.StringWash(txtLicensePlate.Text);
                var    vehicle = HelperClass.BackEndIO.VehicleInfo(regNr);
                lblLicensePlate2.Text = vehicle.Regnr;
                lblArrivalTime2.Text  = vehicle.ArrivalTime.ToString();
                lblNowOnSpot2.Text    = vehicle.ParkingSpotNum.ToString();

                lstAvailableParkingSpots.DataSource = ListFreeSpots(vehicle.VehicleType);
            }
            catch (Exception)
            {
                MessageBox.Show("Could not find vehicle.");
            }
        }
 private void btnSearchVehicle_Click(object sender, EventArgs e)
 {
     try
     {
         string regnr   = HelperClass.StringWash(txtLicensePlate.Text.ToUpper());
         var    vehicle = HelperClass.BackEndIO.VehicleInfo(regnr);
         if (regnr != null)
         {
             txtArrivalTime.Text = vehicle.ArrivalTime.ToString();
             txtCost.Text        = HelperClass.BackEndIO.PrintMoney(vehicle.Regnr);
             txtParkingSpot.Text = vehicle.ParkingSpotNum.ToString();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show($"Cannot find vehicle.");
     }
 }
Ejemplo n.º 5
0
        public void btnCheckOut_Click(object sender, EventArgs e)
        {
            try
            {
                string regNr = HelperClass.StringWash(txtLicensePlate.Text.ToUpper());
                if (regNr != null)
                {
                    if (radFreeOfCharge.Checked)
                    {
                        if (HelperClass.BackEndIO.BackEndCheckOutNoCost(regNr))
                        {
                            Vehicle checkedOutVehicle = new Vehicle(regNr);
                            checkedOutVehicle = HelperClass.BackEndIO.CheckOutInfo(regNr);
                            DateTime UpdatedTime = checkedOutVehicle.ArrivalTime ?? DateTime.Now;
                            TimeSpan span        = DateTime.Now - UpdatedTime;
                            MessageBox.Show($"Vehicle {regNr} is now checked out from the parking.\n" +
                                            $"Arrived at {checkedOutVehicle.ArrivalTime}\n" +
                                            $"Checked out at {checkedOutVehicle.DepartureTime} \n" +
                                            $"Parked for {span.Days} days ,{span.Hours} hours and {span.Minutes} minutes \n" +
                                            $"Total cost {checkedOutVehicle.PricePaid} CZK" +
                                            $"\n\nPress enter for main menu");
                        }
                        else
                        {
                            MessageBox.Show("Could not find vehicle in the parking lot.");
                        }
                    }
                    else
                    {
                        if (HelperClass.BackEndIO.BackEndCheckOut(regNr))
                        {
                            Vehicle checkedOutVehicle = new Vehicle(regNr);
                            checkedOutVehicle = HelperClass.BackEndIO.CheckOutInfo(regNr);
                            DateTime UpdatedTime = checkedOutVehicle.ArrivalTime ?? DateTime.Now;
                            TimeSpan span        = DateTime.Now - UpdatedTime;
                            MessageBox.Show($"Vehicle {regNr} is now checked out from the parking.\n" +
                                            $"Arrived at {checkedOutVehicle.ArrivalTime}\n" +
                                            $"Checked out at {checkedOutVehicle.DepartureTime} \n" +
                                            $"Parked for {span.Days} days ,{span.Hours} hours and {span.Minutes} minutes \n" +
                                            $"Total cost {checkedOutVehicle.PricePaid} CZK" +
                                            $"\n\nPress enter for main menu");
                        }
                        else
                        {
                            MessageBox.Show("Could not find vehicle in the parking lot.");
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Invalid input.");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                //throw;
            }


            txtLicensePlate.Text    = string.Empty;
            radFreeOfCharge.Checked = false;
        }