123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- 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 WpfApp1.SQL;
- using WpfApp1.Windows;
- namespace WpfApp1
- {
- public partial class Agent
- {
- public string ImagePres
- {
- get
- {
- if(Logo == null)
- {
- return "\\image\\picture.png";
- }
- else
- {
- return Logo;
- }
- }
- }
- public string TypAndNameAgent
- {
- get
- {
- return AgentType.Title + " | " + Title;
- }
- }
- public string ProdazhZaGod
- {
- get
- {
- int str = 0;
- foreach (var item in ProductSale)
- {
- str = item.ProductCount;
- }
- return str + " продаж за год";
- }
- }
- public string Prioritys
- {
- get
- {
- return "Приоритетность: " + Priority;
- }
- }
- public string BackgroundColor
- {
- get
- {
- if (ProductSale.Count > 0.025) return "#46B29D";
- return "#C6D7FF";
-
- }
- }
- //public string Prozents
- //{
- // get
- // {
-
- // }
- //}
- }
- /// <summary>
- /// Логика взаимодействия для MainWindow.xaml
- /// </summary>
- public partial class MainWindow : Window, INotifyPropertyChanged
- {
- public string[] SotrList { get; set; } =
- {
- "Без сортировки",
- "Название по убыванию",
- "Название по повзрастанию",
- "Скидка по убыванию",
- "Скидка по повзрастанию",
- "Приоритета по убыванию",
- "Приоритета по повзрастанию",
- };
- private int SortType = 0;
- private int Poiskid = 0;
- private IEnumerable<Agent> _AgentList;
- public IEnumerable<Agent> AgentList
- {
- get
- {
- var Result =_AgentList;
- if (Poiskid > 0) Result = Result.Where(i => i.AgentType.ID == Poiskid);
-
- switch (SortType)
- {
- case 1:
- Result = Result.OrderBy(p => Title);
- break;
- case 2:
- Result = Result.OrderByDescending(p => Title);
- break;
- }
-
-
- return Result;
- }
- set
- {
- _AgentList = value;
- //PropertyChanged(this, new PropertyChangedEventArgs("AgentList"));
- }
- }
- public MainWindow()
- {
- InitializeComponent();
- DataContext = this;
- AgentList = Core.DB.Agent.ToList();
- }
- private void Exit_Click(object sender, RoutedEventArgs e)
- {
- if (MessageBox.Show("Выйти из приложения?", "Внимание!", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
- {
- Application.Current.Shutdown();
- }
- }
- private void AddAgent_Click(object sender, RoutedEventArgs e)
- {
- var NewAgent = new Agent();
- var NewAgentWindow = new AddEditAgent(NewAgent);
- if ((bool)NewAgentWindow.ShowDialog())
- {
- AgentList = Core.DB.Agent.ToList();
- Core.DB.SaveChanges();
- PropertyChanged(this, new PropertyChangedEventArgs("AgentList"));
- }
- }
- private void MainListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- }
- public event PropertyChangedEventHandler PropertyChanged;
- private void MainListView_MouseDoubleClick(object sender, MouseButtonEventArgs e)
- {
- var MouseWindow = MainListView.SelectedItem as Agent;
- var NewMouseWindow = new AddEditAgent(MouseWindow);
- if ((bool)NewMouseWindow.ShowDialog())
- {
- AgentList = Core.DB.Agent.ToList();
- Core.DB.SaveChanges();
- PropertyChanged(this, new PropertyChangedEventArgs("AgentList"));
- }
- }
- private void Sort_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- SortType = Sort.SelectedIndex;
- return;
- }
- private void Poisk_SelectionChanged(object sender, RoutedEventArgs e)
- {
- }
- }
- }
|