Ejemplo n.º 1
0
        private void VehInfo_Load(object sender, EventArgs e)
        {
            #region Graphics
            // External band colors
            titlePnl.BackColor = ColorTranslator.FromHtml("#263238");
            titleLbl.ForeColor = ColorTranslator.FromHtml("#eceff1");
            //this.BackColor = ColorTranslator.FromHtml("#90a4ae");

            titleLbl.Text         = newVeh ? titleLbl.Text = "Add Vehicle" : titleLbl.Text = "Update Vehicle";
            typeCmb.SelectedIndex = 0;
            licPltTxb.Focus();
            #endregion

            if (!newVeh) // Vehicle update
            {
                // Fill all fields
                Vehicle v = hub.GetVeh(licPlt);
                licPltTxb.Text  = licPlt;
                modelTxb.Text   = v.Mod;
                gasKmTxb.Text   = v.GasKm.ToString();
                priceKmTxb.Text = v.PriceKm.ToString();
                totalKmTxb.Text = v.TotalKm.ToString();
                switch (hub.Type(v))
                {
                case "car":
                    typeCmb.SelectedIndex = 0;
                    maxPassTxb.Text       = (v as Car).MaxPass.ToString();
                    break;

                case "truck":
                    typeCmb.SelectedIndex = 1;
                    maxWgTxb.Text         = (v as Truck).MaxWg.ToString();
                    maxVolTxb.Text        = (v as Truck).MaxVol.ToString();
                    break;

                case "van":
                    typeCmb.SelectedIndex = 2;
                    maxPassTxb.Text       = (v as Van).MaxPass.ToString();
                    maxWgTxb.Text         = (v as Van).MaxWg.ToString();
                    maxVolTxb.Text        = (v as Van).MaxVol.ToString();
                    break;
                }
                // Disables not editable components
                typeCmb.Enabled   = false;
                licPltTxb.Enabled = false;
            }
        }
Ejemplo n.º 2
0
        private void DisplayRide(Ride ride)
        {
            // type  licPlt   Km   Pass  Wg   Vol   StartTm

            ListViewItem row = null;                // Listview row

            if (ride.GetType() == typeof(PassRide)) // Passenger ride
            {
                string[] param = { "",                                    ride.VehLicPlt, ride.Km.ToString(), ride.StartTm.ToString(),
                                   (ride as PassRide).NumPass.ToString(), "-",            "-" };
                // Vehicle type
                if (hub.Type(hub.GetVeh(ride.VehLicPlt)) == "car")
                {
                    row = new ListViewItem(param, 0); // Adds row with image
                }
                else if (hub.Type(hub.GetVeh(ride.VehLicPlt)) == "van")
                {
                    row = new ListViewItem(param, 2); // Adds row with image
                }
            }
            else // Freight ride
            {
                string[] param = { "",  ride.VehLicPlt,                      ride.Km.ToString(), ride.StartTm.ToString(),
                                   "-", (ride as FreightRide).Wg.ToString(), (ride as FreightRide).Vol.ToString() };
                // Vehicle type
                if (hub.Type(hub.GetVeh(ride.VehLicPlt)) == "truck")
                {
                    row = new ListViewItem(param, 1); // Adds row with image
                }
                else if (hub.Type(hub.GetVeh(ride.VehLicPlt)) == "van")
                {
                    row = new ListViewItem(param, 2); // Adds row with image
                }
            }
            // Adds the row
            currentRidesList.Items.Add(row);
        }