Пример #1
0
        private bool loadModels()
        {
            CRMSettingViewModel.instance();

            ComplectationItemViewModel.instance();

            EquipmentViewModel.instance();
            ModificationViewModel.instance();
            SellerViewModel.instance();
            BuyerViewModel.instance();
            BidStatusViewModel.instance();
            PaymentStatusViewModel.instance();
            MessageTemplatesViewModel.instance();

            RoleViewModel.instance();
            ManagerViewModel.instance();

            BidViewModel.instance();



            //EquipmentBidViewModel.instance();
            //ComplectationViewModel.instance();

            //ComplectationItemViewModel.instance();

            return(true);
        }
Пример #2
0
        public MainControlID1(CollectionViewSource viewSource)
        {
            InitializeComponent();
            this.viewSource = viewSource;
            this.viewSource.SortDescriptions.Add(new SortDescription("Date_created", ListSortDirection.Descending));

            List <Manager> manager        = ManagerViewModel.instance().Collection.ToList();
            Manager        currentManager = ManagerViewModel.instance().getById(Auth.getInstance().Id);

            if (manager.Contains(currentManager))
            {
                manager.Remove(currentManager);
            }
            manager.RemoveAll(x => (x.Id_role != (int)Classes.Role.Manager) && (x.Id_role != (int)Classes.Role.Director));


            List <BidStatus> status = BidStatusViewModel.instance().Collection.ToList();

            status.Remove(BidStatusViewModel.instance().getById((int)Classes.BidStatus.New));

            SetViewSources();

            DataContext = new
            {
                BidCollection            = this.viewSource.View,
                CurrentManagerCollection = manager,
                CurrentStatusCollection  = status,
                EquipmentBidCollection   = equipmentBidViewSource.View,
                ComplectationCollection  = complectationViewSource.View,
                BuyerCollection          = buyerViewSource.View,
            };
        }
Пример #3
0
        public ManagerWindow()
        {
            InitializeComponent();
            viewSource.Source = ManagerViewModel.instance().Collection;

            viewSource.Filter += delegate(object sender, FilterEventArgs e)
            {
                Manager manager = e.Item as Manager;
                if (manager == null)
                {
                    return;
                }
                e.Accepted = manager.IsVisible;
            };
            DataContext = new { ManagerCollection = viewSource.View };
        }
Пример #4
0
        public MainControlID2(CollectionViewSource viewSource)
        {
            InitializeComponent();
            this.viewSource = viewSource;

            //Список менеджеров
            List <Manager> manager = ManagerViewModel.instance().Collection.ToList();
            //Находим текущего менеджера
            Manager currentManager = ManagerViewModel.instance().getById(Auth.getInstance().Id);

            //Если есть в списке
            if (manager.Contains(currentManager))
            {
                //Удаляем из списка
                manager.Remove(currentManager);
            }
            manager.RemoveAll(x => (x.Id_role != (int)Classes.Role.Manager) && (x.Id_role != (int)Classes.Role.Director));

            //Установка сортировки ---->
            //1: По статусу оплаты в порядке убывания (по id статусов)
            this.viewSource.SortDescriptions.Add(new SortDescription("Id_payment_status", ListSortDirection.Descending));
            //2: По дате отгрузки в порядке убывания
            this.viewSource.SortDescriptions.Add(new SortDescription("Shipment_date", ListSortDirection.Descending));
            //3: По дате создания в порядке убывания
            this.viewSource.SortDescriptions.Add(new SortDescription("Date_created", ListSortDirection.Descending));

            //Список статусов
            List <BidStatus> status = BidStatusViewModel.instance().Collection.ToList();

            //Удаляем из списка статусов текущий
            status.Remove(BidStatusViewModel.instance().getById((int)Classes.BidStatus.InWork));

            //Функция установки фильтров
            SetViewSources();
            //Установка контекста данных
            DataContext = new
            {
                BidCollection            = this.viewSource.View,
                CurrentManagerCollection = manager,
                CurrentStatusCollection  = status,
                EquipmentBidCollection   = equipmentBidViewSource.View,
                ComplectationCollection  = complectationViewSource.View,
                BuyerCollection          = buyerViewSource.View
            };
        }
Пример #5
0
        public TransferToManagerWindow(Bid bid, Action callback = null)
        {
            InitializeComponent();
            Title = "Передача заявки №" + bid.Id.ToString() + " другому менеджеру.";
            List <Manager> manager        = ManagerViewModel.instance().Collection.ToList();
            Manager        currentManager = ManagerViewModel.instance().getById(Auth.getInstance().Id);

            if (manager.Contains(currentManager))
            {
                manager.Remove(currentManager);
            }

            //Удаление всех пользователей, роль которых != менеджер или директор
            manager.RemoveAll(x => (x.Id_role != (int)Classes.Role.Manager) && (x.Id_role != (int)Classes.Role.Director));

            tbxComment.Text = bid.Comment;

            DataContext = new
            {
                ManagerCollection = manager
            };
            this.bid      = bid;
            this.callback = callback;
        }
Пример #6
0
        //продажи менеджеров
        private void ManagerSales()
        {
            //Словарь сумм по менеджерам
            Dictionary <int, double> managerDict
                = new Dictionary <int, double>();
            //Словарь количества по менеджерам
            Dictionary <int, int> managerBidsCountDict
                = new Dictionary <int, int>();

            for (int i = 0; i < archiveBid.Count; i++)
            {
                //Подсчет суммы заявок менеджера ---->
                if (!managerDict.ContainsKey(archiveBid[i].Id_manager))
                {
                    managerDict.Add(archiveBid[i].Id_manager, archiveBid[i].Amount);
                }
                else
                {
                    managerDict[archiveBid[i].Id_manager] += archiveBid[i].Amount;
                }
                //<----/

                //Подсчет количества заявок менеджера ---->
                if (!managerBidsCountDict.ContainsKey(archiveBid[i].Id_manager))
                {
                    managerBidsCountDict.Add(archiveBid[i].Id_manager, 1);
                }
                else
                {
                    managerBidsCountDict[archiveBid[i].Id_manager]++;
                }
                //<----/
            }
            if (managerDict.Count == 0)
            {
                return;
            }

            ReportRow rowH = new ReportRow();

            rowH.Add(new ReportCell("Продажи менеджеров:"));
            Rows.Add(rowH);

            ReportRow rowT = new ReportRow();

            rowT.Add(new ReportCell("Менеджер")
            {
                BorderColor = System.Drawing.Color.Black, ColumnSpan = 1
            });
            rowT.Add(null);
            rowT.Add(new ReportCell("Сумма")
            {
                BorderColor = System.Drawing.Color.Black
            });
            rowT.Add(new ReportCell("Кол-во")
            {
                BorderColor = System.Drawing.Color.Black
            });
            Rows.Add(rowT);

            foreach (KeyValuePair <int, double> kv in managerDict.OrderByDescending(x => x.Value))
            {
                Manager manager = ManagerViewModel.instance().getById(kv.Key);
                if (manager == null)
                {
                    continue;
                }

                ReportRow row = new ReportRow();
                row.Add(new ReportCell(manager.Name)
                {
                    ColumnSpan = 1, BorderColor = System.Drawing.Color.Black
                });
                row.Add(null);
                row.Add(new ReportCell(kv.Value.ToString().Replace(',', '.'))
                {
                    BorderColor = System.Drawing.Color.Black
                });
                int managerBidsCount = 0;
                if (managerBidsCountDict.ContainsKey(kv.Key))
                {
                    managerBidsCount = managerBidsCountDict[kv.Key];
                }
                row.Add(new ReportCell(managerBidsCount.ToString())
                {
                    BorderColor = System.Drawing.Color.Black
                });
                Rows.Add(row);
            }
        }
Пример #7
0
 void TbxSearch_TextChanged(object sender, TextChangedEventArgs e)
 {
     ManagerViewModel.instance().search(tbxSearch.Text);
     viewSource.View.Refresh();
 }