Newer
Older
SubCabinetSolution / SubCabinetSolution / ViewModel / InquirePageViewModel.cs
using System.Collections.Generic;
using System.Windows.Controls;
using CommonServiceLocator;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using GalaSoft.MvvmLight.Views;
using SubCabinetSolution.Model;

namespace SubCabinetSolution.ViewModel
{
    public class InquirePageViewModel : ViewModelBase
    {
        public List<FunctionModel> InquireModels { get; set; }
        public RelayCommand<object> InquireSelectedCommand { get; set; }

        public InquirePageViewModel()
        {
            this.InquireModels = new List<FunctionModel>
            {
                new FunctionModel("/Images/库存查询.png", "库存查询"),
                new FunctionModel("/Images/领用未归还.png", "领用未归还"),
                new FunctionModel("/Images/入柜查询.png", "入柜查询"),
                new FunctionModel("/Images/退SPD查询.png", "退SPD查询"),
                new FunctionModel("/Images/指定耗材查询.png", "指定耗材查询"),
                new FunctionModel("/Images/消耗查询.png", "消耗查询"),
                new FunctionModel("/Images/监控查询.png", "监控查询"),
                new FunctionModel("/Images/综合查询.png", "综合查询")
            };
            this.InquireSelectedCommand = new RelayCommand<object>(InquireSelected);
        }

        private void InquireSelected(object sender)
        {
            var listBox = (ListBox)sender;
            if (listBox.SelectedIndex == -1)
            {
                return;
            }

            var functionModel = (FunctionModel)listBox.SelectedItem;
            var navigationService = ServiceLocator.Current.GetInstance<INavigationService>();
            switch (functionModel.Title)
            {
                case "库存查询":
                    navigationService.NavigateTo("InventoryQueryPage");
                    break;
                case "领用未归还":
                    navigationService.NavigateTo("NotReturnedQueryPage");
                    break;
                case "入柜查询":
                    navigationService.NavigateTo("PutCabinetQueryPage");
                    break;
                case "退SPD查询":
                    navigationService.NavigateTo("SpdQueryPage");
                    break;
                case "指定耗材查询":
                    navigationService.NavigateTo("GoodsQueryPage");
                    break;
                case "消耗查询":
                    navigationService.NavigateTo("ConsumeQueryPage");
                    break;
                case "监控查询":
                    navigationService.NavigateTo("MonitorQueryPage");
                    break;
                case "综合查询":
                    navigationService.NavigateTo("TotalQueryPage");
                    break;
            }

            listBox.SelectedIndex = -1;
        }
    }
}