Beispiel #1
0
        public static void PrintBusesByBranches(Panel resultPanel, List <Branch> branches)
        {
            foreach (Branch branch in branches)
            {
                Label label = new Label()
                {
                    Text = $@"{branch.City}, {branch.Address} buses:"
                };
                Table          t   = new Table();
                TableHeaderRow thr = new TableHeaderRow();
                thr.Cells.Add(new TableHeaderCell()
                {
                    Text = "Car plate"
                });
                thr.Cells.Add(new TableHeaderCell()
                {
                    Text = "Manufacturer"
                });
                thr.Cells.Add(new TableHeaderCell()
                {
                    Text = "Model"
                });
                thr.Cells.Add(new TableHeaderCell()
                {
                    Text = "Year made"
                });
                thr.Cells.Add(new TableHeaderCell()
                {
                    Text = "Month made"
                });
                thr.Cells.Add(new TableHeaderCell()
                {
                    Text = "Last Tech Date"
                });
                thr.Cells.Add(new TableHeaderCell()
                {
                    Text = "Fuel type"
                });
                thr.Cells.Add(new TableHeaderCell()
                {
                    Text = "Fuel/100km"
                });
                thr.Cells.Add(new TableHeaderCell()
                {
                    Text = "Seat Count"
                });
                t.Rows.Add(thr);

                List <Bus> buses = CompanyProgram.FilterBuses(branch.Vehicles);
                if (buses.Count == 0)
                {
                    continue;
                }
                buses.Sort();
                foreach (Bus bus in buses)
                {
                    t.Rows.Add(bus.ConvertToRow());
                }
                resultPanel.Controls.Add(label);
                resultPanel.Controls.Add(t);
                resultPanel.Controls.Add(new LiteralControl("<br/>"));
            }
        }
Beispiel #2
0
        public static void PrintBestVehicles(Panel resultPanel, List <Transport> list)
        {
            Table t          = new Table();
            Label tableLabel = new Label()
            {
                Text = "Best vehicles of it's type"
            };

            Car   car   = CompanyProgram.GetBest <Car>(list);
            Bus   bus   = CompanyProgram.GetBest <Bus>(list);
            Truck truck = CompanyProgram.GetBest <Truck>(list);

            TableHeaderRow thr = new TableHeaderRow();

            thr.Controls.Add(new TableHeaderCell()
            {
                Text = "Type"
            });
            thr.Controls.Add(new TableHeaderCell()
            {
                Text = "Manufacturer"
            });
            thr.Controls.Add(new TableHeaderCell()
            {
                Text = "Model"
            });
            thr.Controls.Add(new TableHeaderCell()
            {
                Text = "Car Plate"
            });
            thr.Controls.Add(new TableHeaderCell()
            {
                Text = "Age"
            });
            t.Rows.Add(thr);

            if (car != null)
            {
                DateTime carDate = new DateTime(DateTime.Now.Ticks - new DateTime(car.YearMade, car.MonthMade, 1).Ticks);

                TableRow carTr = new TableRow();
                carTr.Cells.Add(new TableCell()
                {
                    Text = "Car"
                });
                carTr.Cells.Add(new TableCell()
                {
                    Text = car.Manufacturer
                });
                carTr.Cells.Add(new TableCell()
                {
                    Text = car.Model
                });
                carTr.Cells.Add(new TableCell()
                {
                    Text = car.CarPlate
                });
                carTr.Cells.Add(new TableCell()
                {
                    Text = $@"{carDate.Year}-{carDate.Month}"
                });
                t.Rows.Add(carTr);
            }
            if (bus != null)
            {
                DateTime busDate = new DateTime(DateTime.Now.Ticks - new DateTime(bus.YearMade, bus.MonthMade, 1).Ticks);

                TableRow busTr = new TableRow();
                busTr.Cells.Add(new TableCell()
                {
                    Text = "Bus"
                });
                busTr.Cells.Add(new TableCell()
                {
                    Text = bus.Manufacturer
                });
                busTr.Cells.Add(new TableCell()
                {
                    Text = bus.Model
                });
                busTr.Cells.Add(new TableCell()
                {
                    Text = bus.CarPlate
                });
                busTr.Cells.Add(new TableCell()
                {
                    Text = $@"{busDate.Year}-{busDate.Month}"
                });
                t.Rows.Add(busTr);
            }
            if (truck != null)
            {
                DateTime truckDate = new DateTime(DateTime.Now.Ticks - new DateTime(truck.YearMade, truck.MonthMade, 1).Ticks);

                TableRow truckTr = new TableRow();
                truckTr.Cells.Add(new TableCell()
                {
                    Text = "Truck"
                });
                truckTr.Cells.Add(new TableCell()
                {
                    Text = truck.Manufacturer
                });
                truckTr.Cells.Add(new TableCell()
                {
                    Text = truck.Model
                });
                truckTr.Cells.Add(new TableCell()
                {
                    Text = truck.CarPlate
                });
                truckTr.Cells.Add(new TableCell()
                {
                    Text = $@"{truckDate.Year}-{truckDate.Month}"
                });
                t.Rows.Add(truckTr);
            }
            if (t.Rows.Count < 2)
            {
                throw new Exception();
            }
            resultPanel.Controls.Add(tableLabel);
            resultPanel.Controls.Add(t);
            resultPanel.Controls.Add(new LiteralControl("<br/>"));
        }
        protected void ExecButton_Click(object sender, EventArgs e)
        {
            string selectedBranchName = BranchDDL.SelectedValue;

            CompanyProgram.Run(DataPanel, ResultPanel, selectedBranchName);
        }