using System;
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;
using PleasantRustle.Class;
namespace PleasantRustle.Pages
{
///
/// Логика взаимодействия для Main.xaml
///
public partial class Main : Page
{
public static class Agents
{
public static Frame frm;
}
List agents = BaseConnect.baseConnect.Agent.ToList();
List agentstype = BaseConnect.baseConnect.AgentType.ToList();
public Main()
{
InitializeComponent();
listboxPleasant.ItemsSource = agents;
}
private void Search_TextChanged(object sender, TextChangedEventArgs e)
{
if (Search.Text != "")
{
List agents1 = agents.Where(x => x.Title.Contains(Search.Text)).ToList();
listboxPleasant.ItemsSource = agents1;
}
else
{
listboxPleasant.ItemsSource = agents;
}
}
private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
ComboBox comboBox = sender as ComboBox;
switch (comboBox.SelectedIndex)
{
case 0:
agents = agents.OrderBy(x => x.Title).ToList();
break;
case 1:
agents = agents.OrderBy(x => x.Title).ToList();
agents.Reverse();
break;
case 2:
agents = agents.OrderBy(x => x.Title).ToList();
break;
case 3:
agents = agents.OrderBy(x => x.Title).ToList();
agents.Reverse();
break;
case 4:
agents = agents.OrderBy(x => x.Priority).ToList();
break;
case 5:
agents = agents.OrderBy(x => x.Priority).ToList();
agents.Reverse();
break;
}
listboxPleasant.ItemsSource = agents;
}
private void ComboBox_SelectionChanged_1(object sender, SelectionChangedEventArgs e)
{
ComboBox comboBox = sender as ComboBox;
int agentType = (int)comboBox.SelectedIndex+1;
if (agentType != 1)
{
List agents1 = agents.Where(x => x.AgentTypeID == agentType).ToList();
listboxPleasant.ItemsSource = agents1;
}
else
{
listboxPleasant.ItemsSource = agents;
}
}
private void buttonAdd_Click(object sender, RoutedEventArgs e)
{
Add add = new Add();
add.ShowDialog();
}
private void buttonUpdate_Click(object sender, RoutedEventArgs e)
{
}
}
}