using BBWY.Client.Models;
using BBWY.Controls;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;

namespace BBWY.Client.Views
{
    /// <summary>
    /// SelectShop.xaml 的交互逻辑
    /// </summary>
    public partial class SelectShopW : BWindow
    {
        public IList<Department> DepartmentList { get; set; }
        public Shop Shop { get; set; }

        public SelectShopW(IList<Department> departmentList)
        {
            InitializeComponent();
            this.DepartmentList = departmentList;
            this.Loaded += SelectShop_Loaded;
        }

        private void SelectShop_Loaded(object sender, RoutedEventArgs e)
        {
            var d = cbx_department.SelectedItem as Department;
            cbx_shop.ItemsSource = d.ShopList;

        }

        private void btn_ok_Click(object sender, RoutedEventArgs e)
        {
            Shop = cbx_shop.SelectedItem as Shop;
            this.DialogResult = true;
            this.Close();
        }

        private void cbx_department_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var d = cbx_department.SelectedItem as Department;
            cbx_shop.ItemsSource = d.ShopList;
            cbx_shop.SelectedIndex = 0;
        }
    }
}