Пример #1
0
 //Конструктор
 public TrucksPageViewModel()
 {
     db = new localDbContext();
     db.Trucks.Load();
     Items         = CollectionViewSource.GetDefaultView(db.Trucks.Local);
     Items.Filter += FilterTruck;
 }
Пример #2
0
 // Конструктор
 public DriversViewModel()
 {
     db = new localDbContext();
     db.Drivers.Load();
     Items         = CollectionViewSource.GetDefaultView(db.Drivers.Local);
     Items.Filter += FilterDriver;
 }
        //Конструктор
        public StatsPageViewModel()
        {
            StartDate = DateTime.Now;
            EndDate   = DateTime.Now;
            db        = new localDbContext();
            db.Trucks.Load();
            db.Orders.Load();
            orders = db.Orders.Local.ToBindingList();
            Trucks = new ObservableCollection <TruckRevenue>();
            //Получение статистики по грузовиками за весь период
            foreach (var truck in db.Trucks.Local)
            {
                var orderList = from order in orders
                                where (order.TruckId == truck.TruckId && order.OrderState == "Завершен")
                                select order;
                Trucks.Add(new TruckRevenue {
                    TruckId = truck.TruckId, TruckName = truck.TruckName, TruckModel = truck.TruckModel, TruckTotalRevenues = (int)orderList.Sum(s => s.OrderPrice)
                });
            }



            var totalPrice = from order in orders
                             where (order.OrderState == "Завершен")
                             select order;

            //Общая прибыль за все время
            TotalRevenue = (int)totalPrice.Sum(o => o.OrderPrice);


            Trucks = new ObservableCollection <TruckRevenue>(Trucks.OrderByDescending(o => o.TruckTotalRevenues));
        }
Пример #4
0
 //Конструктор
 public OrdersViewModel()
 {
     db = new localDbContext();
     db.Orders.Load();
     Items     = CollectionViewSource.GetDefaultView(db.Orders.Local.OrderByDescending(s => s.OrderId));
     StartDate = DateTime.Now;
     EndDate   = DateTime.Now;
 }
        public DriverWindow(Driver d)
        {
            InitializeComponent();

            using (var db = new localDbContext())
            {
                db.Trucks.Load();
                Trucks = db.Trucks.Local;
            }

            DriverWind = d;
            comboBoxTrucks.ItemsSource = Trucks;
            DataContext = DriverWind;
            comboBoxTrucks.SelectedItem = SelectedTruck;

            Loaded += DriverWindow_Loaded;
        }