Ejemplo n.º 1
0
        public void FillLorryList()
        {
            IList <Lorry> allLorrys = lorryServicesObj.GetAll();

            lorryList.Items.Clear();

            foreach (var item in allLorrys)
            {
                ListViewItem lorryItem = new ListViewItem(item.vehicleName);
                lorryItem.SubItems.Add(item.numberPlate);
                lorryItem.SubItems.Add(string.Format("{0} kg",
                                                     decimal.Round(item.weight.kilograms, 2)));
                lorryItem.SubItems.Add(string.Format("{0}/{1} l",
                                                     decimal.Round(item.currentFuel.litres, 2),
                                                     decimal.Round(item.maximumFuel.litres, 2)));
                lorryItem.SubItems.Add(string.Format("{0} mpg",
                                                     decimal.Round(item.milage.milesPerGallon, 2)));
                lorryItem.SubItems.Add(string.Format("{0}/{1}",
                                                     item.passengers.Count,
                                                     item.maximumPassengers));
                lorryItem.SubItems.Add((item.hasLoad)?"True":"False");
                if (item.hasLoad)
                {
                    lorryItem.SubItems.Add(
                        string.Format("{0} kg",
                                      decimal.Round(item.loadWeight.kilograms, 2)));
                }
                lorryList.Items.Add(lorryItem);
            }
        }
        public void List()
        {
            IList <Lorry> lorryList = lorryServicesObj.GetAll();

            foreach (Lorry selectedLorry in lorryList)
            {
                PrintInfo(selectedLorry, true);
            }
        }