123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
- namespace ShabaninDemoEkz
- {
- /// <summary>
- /// Логика взаимодействия для AgentPage.xaml
- /// </summary>
- public partial class AgentPage : Page
- {
- VModel VM = new VModel();
- List<Agent> agents;
- public AgentPage()
- {
- InitializeComponent();
- DataContext = VM;
- agents = VM.agent;
- AgentList.ItemsSource = agents;
- SortCMB.SelectedIndex = 0;
- FilterCmb.ItemsSource = BaseConnect.BaseModel.AgentType.ToList();
- FilterCmb.SelectedValuePath = "ID";
- FilterCmb.DisplayMemberPath = "Title";
- FilterCmb.SelectedIndex = 0;
- }
- private void FilterCmb_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- Filter();
- }
- private void SortCMB_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- Filter();
- }
- public void Filter()
- {
- agents = VM.agent;
- try
- {
- switch (SortCMB.SelectedIndex)
- {
- case 0:
- break;
- case 1:
- agents = agents.OrderBy(x => x.Title).ToList();
- break;
- case 2:
- agents = agents.OrderBy(x => x.Title).ToList();
- agents.Reverse();
- break;
- case 3:
- agents = agents.OrderBy(x => x.skidka).ToList();
- break;
- case 4:
- agents = agents.OrderBy(x => x.skidka).ToList();
- agents.Reverse();
- break;
- case 5:
- agents = agents.OrderBy(x => x.Priority).ToList();
- break;
- case 6:
- agents = agents.OrderBy(x => x.Priority).ToList();
- agents.Reverse();
- break;
- }
- }
- catch
- {
- }
- try
- {
- if (FilterCmb.SelectedIndex != 0)
- agents = agents.Where(x => x.AgentTypeID == FilterCmb.SelectedIndex).ToList();
- }
- catch { }
- try
- {
- agents = agents.Where(x => x.Title.Contains(searchBar.Text) || x.Email.Contains(searchBar.Text) || x.Phone.Contains(searchBar.Text)).ToList();
- }
- catch { }
- AgentList.ItemsSource = agents;
- }
- private void searchBar_TextChanged(object sender, TextChangedEventArgs e)
- {
- Filter();
- }
- private void AgentList_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- if (AgentList.SelectedItems.Count > 1)
- {
- ChangePrior.Visibility = Visibility.Visible;
-
- }
- else
- {
- ChangePrior.Visibility = Visibility.Collapsed;
- }
- }
- private void ChangePrior_Click(object sender, RoutedEventArgs e)
- {
- IList ls = AgentList.SelectedItems;
- new ChangedPrior(ls).ShowDialog();
- Filter();
- }
- private void AgentList_MouseDoubleClick(object sender, MouseButtonEventArgs e)
- {
- IList ls = AgentList.SelectedItems;
- new AddChanged(ls).ShowDialog();
- VM = new VModel();
- Filter();
- }
- private void AddAgent_Click(object sender, RoutedEventArgs e)
- {
- new AddChanged().ShowDialog();
- VM = new VModel();
- Filter();
- }
- }
- }
|