//cbType 与cbItem的联动 private void cbType_SelectionChanged(object sender, SelectionChangedEventArgs e) { IdNameBLL bll = new IdNameBLL(); if (cbType.SelectedIndex == 0) { cbItem.ItemsSource = bll.GetByCategory("收入类型"); } else { cbItem.ItemsSource = bll.GetByCategory("支出类型"); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { IdNameBLL idnamebll = new IdNameBLL(); Account account = new Account(); //获得用户的Id account.OperatorId = LoginWindow.GetOperatorId(); // MessageBox.Show("执行了!"); //添加 if (IsAddNew) { //设置默认值 account.Date = DateTime.Now; account.Money = 0; account.Remarks = "无"; gridEditAccount.DataContext = account; cbType.ItemsSource = idnamebll.GetByCategory("收支类型"); //cbType.SelectedIndex = 0; } //编辑 else { //拿出要编辑的对象的值 account = new AccountBLL().GetById(EditingId); gridEditAccount.DataContext = account; cbType.ItemsSource = idnamebll.GetByCategory("收支类型"); } }
//搜索coatType Item 联动 private void cmbSearchCostType_SelectionChanged(object sender, SelectionChangedEventArgs e) { cmbSearchItem.IsEnabled = true; IdNameBLL bll = new IdNameBLL(); if (cmbSearchCostType.SelectedIndex == 0) { cmbSearchItem.ItemsSource = bll.GetByCategory("收入类型"); } else { cmbSearchItem.ItemsSource = bll.GetByCategory("支出类型"); } }