private void OnInfoButtonClick(object sender, RoutedEventArgs e)
        {
            var button = sender as Button;

            if (button == null)
            {
                return;
            }

            var worker = button.DataContext as DataRowView;

            if (worker == null)
            {
                return;
            }

            var workerId   = System.Convert.ToInt64(worker["WorkerID"]);
            var mainWindow = Application.Current.MainWindow as MainWindow;

            if (mainWindow != null)
            {
                var hasFullAccess          = AdministrationClass.HasFullAccess(AdministrationClass.Modules.Workers);
                var workerPersonalInfoPage = new WorkerPersonalInfoPage(workerId, hasFullAccess);
                mainWindow.ShowCatalogGrid(workerPersonalInfoPage, "Информация по работнику");
            }
        }
Exemple #2
0
        private static string GetFilterString(NewsStatus newsStatus, int?prodStatusId)
        {
            var filterString = string.Format("WHERE NewsStatus = {0}", newsStatus.NewsStatusId);

            // Geting available production statuses for worker
            if (newsStatus.NewsStatusId == 6 || newsStatus.NewsStatusId == 7)
            {
                if (prodStatusId.HasValue)
                {
                    filterString += string.Format(" AND ProdStatusID = {0}", prodStatusId.Value);
                }

                // Return all messages if user is administrator
                else if (!AdministrationClass.IsAdministrator)
                {
                    //var workerGroups = GetWorkerGroupsIds(AdministrationClass.CurrentWorkerId);
                    //if (workerGroups.All(g => g != 1))
                    //{
                    var workerProdStatuses = GetWorkerProdStatuses(AdministrationClass.CurrentWorkerId);
                    if (workerProdStatuses.Any())
                    {
                        var workerProdStatusesString = workerProdStatuses.Aggregate(string.Empty, (current, prodStatus) => current + ", " + prodStatus).Remove(0, 2);
                        filterString += " AND (ProdStatusID IN (" + workerProdStatusesString + ") OR ProdStatusID IS NULL)";
                    }
                    else
                    {
                        filterString += " AND ProdStatusID IS NULL";
                    }
                    //}
                }
            }

            // Worker requests
            if (newsStatus.NewsStatusId == 9 && !AdministrationClass.IsAdministrator)
            {
                var fullAccess = AdministrationClass.HasFullAccess(AdministrationClass.Modules.WorkerRequests);
                if (!fullAccess)
                {
                    // Get personal worker requests
                    var workerRequestsGlobalIdsString = GetPersonalWorkerRequestsGlobalIds();
                    filterString += " AND GlobalID IN (" + workerRequestsGlobalIdsString + ")";
                }
            }

            // Worker tasks
            if (newsStatus.NewsStatusId == 11 && !AdministrationClass.IsAdministrator)
            {
                // Get GlobalIds of personal messages

                var globalIdsString = GetPersonalTasksGlobalIds();

                filterString += " AND GlobalID IN (" + globalIdsString + ")";
            }

            return(filterString);
        }
Exemple #3
0
        private void LoadPageById(int moduleId)
        {
            switch (moduleId)
            {
            case (int)AdministrationClass.Modules.OperationCatalog:
            {
                MinimazeMenu();

                if (!MainFrame.HasContent || !(MainFrame.Content is CatalogPage))
                {
                    var hasFullAccess =
                        AdministrationClass.HasFullAccess(AdministrationClass.Modules.OperationCatalog);
                    if (_cp == null)
                    {
                        _cp = new CatalogPage(hasFullAccess);
                    }
                    _cp.Tag = moduleId;
                    MainFrame.Navigate(_cp);
                    ShowWaitAnimation();
                }
            }
            break;

            case (int)AdministrationClass.Modules.Workers:
            {
                MinimazeMenu();

                if (!MainFrame.HasContent || !(MainFrame.Content is StaffPage))
                {
                    var hasFullAccess =
                        AdministrationClass.HasFullAccess(AdministrationClass.Modules.Workers);
                    if (_staffPage == null)
                    {
                        _staffPage = new StaffPage(hasFullAccess);
                    }
                    _staffPage.Tag = moduleId;
                    MainFrame.Navigate(_staffPage);
                    ShowWaitAnimation();
                }
            }
            break;

            case (int)AdministrationClass.Modules.TimeTracking:
            {
                if (_ttc.GetIsDayEnd(AdministrationClass.CurrentWorkerId))
                {
                    //MenuTogleButton.IsChecked = false;

                    //MessageBox.Show("Для запуска данного модуля необходимо начать рабочий день!", "Информация",
                    //    MessageBoxButton.OK, MessageBoxImage.Information);
                    //break;


                    BlinkWorkingDayButton();
                }
                else
                {
                    if (!MainFrame.HasContent || !(MainFrame.Content is TimeTrackingPage))
                    {
                        if (_ttp == null)
                        {
                            _ttp = new TimeTrackingPage();
                        }
                        _ttp.Tag = moduleId;
                        MainFrame.Navigate(_ttp);
                        ShowWaitAnimation();
                    }
                }
                MinimazeMenu();
            }
            break;

            case (int)AdministrationClass.Modules.Administration:
            {
                MinimazeMenu();

                if (!MainFrame.HasContent || !(MainFrame.Content is AdministrationPage))
                {
                    var hasFullAccess =
                        AdministrationClass.HasFullAccess(AdministrationClass.Modules.Administration);
                    if (_administrationPage == null)
                    {
                        _administrationPage = new AdministrationPage(hasFullAccess);
                    }
                    _administrationPage.Tag = moduleId;
                    MainFrame.Navigate(_administrationPage);
                    ShowWaitAnimation();
                }
            }
            break;

            case (int)AdministrationClass.Modules.ControlTimeTracking:
            {
                MinimazeMenu();

                if (!MainFrame.HasContent || !(MainFrame.Content is TimeControlPage))
                {
                    if (_timeControlPage == null)
                    {
                        _timeControlPage = new TimeControlPage();
                    }
                    _timeControlPage.Tag = moduleId;
                    MainFrame.Navigate(_timeControlPage);
                    ShowWaitAnimation();
                }
            }
            break;

            case (int)AdministrationClass.Modules.ServiceEquipment:
            {
                MinimazeMenu();

                if (!MainFrame.HasContent || !(MainFrame.Content is ServiceEquipmentPage))
                {
                    var hasFullAccess =
                        AdministrationClass.HasFullAccess(AdministrationClass.Modules.ServiceEquipment);
                    if (_serviceEquipmentPage == null)
                    {
                        _serviceEquipmentPage = new ServiceEquipmentPage(hasFullAccess);
                    }
                    _serviceEquipmentPage.Tag = moduleId;
                    MainFrame.Navigate(_serviceEquipmentPage);
                    ShowWaitAnimation();
                }
            }
            break;

            case (int)AdministrationClass.Modules.TasksPage:
            {
                MinimazeMenu();

                if (!MainFrame.HasContent || !(MainFrame.Content is TaskPage))
                {
                    var hasFullAccess =
                        AdministrationClass.HasFullAccess(AdministrationClass.Modules.TasksPage);
                    if (_taskPage == null)
                    {
                        _taskPage = new TaskPage(hasFullAccess);
                    }
                    _taskPage.Tag = moduleId;
                    MainFrame.Navigate(_taskPage);
                    ShowWaitAnimation();
                }
            }
            break;

            case (int)AdministrationClass.Modules.TechnologyProblem:
            {
                MinimazeMenu();

                if (!MainFrame.HasContent || !(MainFrame.Content is TechnologyProblemPage))
                {
                    var hasFullAccess =
                        AdministrationClass.HasFullAccess(AdministrationClass.Modules.TechnologyProblem);
                    if (_technologyProblemPage == null)
                    {
                        _technologyProblemPage = new TechnologyProblemPage(hasFullAccess);
                    }
                    _technologyProblemPage.Tag = moduleId;
                    MainFrame.Navigate(_technologyProblemPage);
                    ShowWaitAnimation();
                }
            }
            break;

            case (int)AdministrationClass.Modules.WorkersStimulation:
            {
                MinimazeMenu();

                if (!MainFrame.HasContent || !(MainFrame.Content is StimulationPage))
                {
                    var hasFullAccess =
                        AdministrationClass.HasFullAccess(AdministrationClass.Modules.WorkersStimulation);
                    if (_stimulationPage == null)
                    {
                        _stimulationPage = new StimulationPage(hasFullAccess);
                    }
                    _stimulationPage.Tag = moduleId;
                    MainFrame.Navigate(_stimulationPage);
                    ShowWaitAnimation();
                }
            }
            break;

            case (int)AdministrationClass.Modules.ProductionRooms:
            {
                if (!MainFrame.HasContent || !(MainFrame.Content is ProdRoomsPage))
                {
                    var hasFullAccess =
                        AdministrationClass.HasFullAccess(AdministrationClass.Modules.ProductionRooms);
                    if (_prodRoomsPage == null)
                    {
                        _prodRoomsPage = new ProdRoomsPage(hasFullAccess);
                    }
                    _prodRoomsPage.Tag = moduleId;
                    MainFrame.Navigate(_prodRoomsPage);
                    ShowWaitAnimation();
                }

                MinimazeMenu();
            }
            break;

            case (int)AdministrationClass.Modules.WorkshopMap:
            {
                MinimazeMenu();

                if (!MainFrame.HasContent || !(MainFrame.Content is WorkshopMapPage))
                {
                    var hasFullAccess =
                        AdministrationClass.HasFullAccess(AdministrationClass.Modules.WorkshopMap);
                    if (_workshopMapPage == null)
                    {
                        _workshopMapPage = new WorkshopMapPage(hasFullAccess);
                    }
                    _workshopMapPage.Tag = moduleId;
                    MainFrame.Navigate(_workshopMapPage);
                    ShowWaitAnimation();
                }
            }
            break;

            case (int)AdministrationClass.Modules.WorkerRequests:
            {
                MinimazeMenu();

                if (!MainFrame.HasContent || !(MainFrame.Content is WorkerRequestsPage))
                {
                    var hasFullAccess =
                        AdministrationClass.HasFullAccess(AdministrationClass.Modules.WorkerRequests);
                    if (_workerRequestsPage == null)
                    {
                        _workerRequestsPage = new WorkerRequestsPage(hasFullAccess);
                    }
                    _workerRequestsPage.Tag = moduleId;
                    MainFrame.Navigate(_workerRequestsPage);
                    ShowWaitAnimation();
                }
            }
            break;

            case (int)AdministrationClass.Modules.TimeSheet:
            {
                MinimazeMenu();

                if (!MainFrame.HasContent || !(MainFrame.Content is TimesheetPage))
                {
                    var hasFullAccess =
                        AdministrationClass.HasFullAccess(AdministrationClass.Modules.TimeSheet);
                    if (_timeSheetPage == null)
                    {
                        _timeSheetPage = new TimesheetPage();
                    }
                    _timeSheetPage.Tag = moduleId;
                    MainFrame.Navigate(_timeSheetPage);
                    ShowWaitAnimation();
                }
            }
            break;

            case (int)AdministrationClass.Modules.PlannedWorks:
            {
                MinimazeMenu();

                if (!MainFrame.HasContent || !(MainFrame.Content is PlannedWorksPage))
                {
                    var hasFullAccess =
                        AdministrationClass.HasFullAccess(AdministrationClass.Modules.PlannedWorks);
                    if (_plannedWorksPage == null)
                    {
                        _plannedWorksPage = new PlannedWorksPage(hasFullAccess);
                    }
                    _plannedWorksPage.Tag = moduleId;
                    MainFrame.Navigate(_plannedWorksPage);
                    ShowWaitAnimation();
                }
            }
            break;
            }
        }
Exemple #4
0
        private string GetFilterString(NewsStatusGroup newsStatusGroup)
        {
            var newsStatusIds = newsStatusGroup.NewsStatuses.Any()
                ? (newsStatusGroup.NewsStatuses
                   .Aggregate(string.Empty, (current, newsStatus) => current + ", " + newsStatus.NewsStatusId))
                                .Remove(0, 2)
                : "-1";
            var filterString = string.Format("WHERE NewsStatus IN ({0})", newsStatusIds);

            // Return all messages if user is administrator
            if (AdministrationClass.IsAdministrator)
            {
                return(filterString);
            }

            if (newsStatusGroup.NewsStatusGroupId == 2)
            {
                var fullAccess = AdministrationClass.HasFullAccess(AdministrationClass.Modules.WorkerRequests);
                if (!fullAccess)
                {
                    // Get news statuses without worker requests
                    newsStatusIds = newsStatusGroup.NewsStatuses.Where(newsStatus => newsStatus.NewsStatusId != 9).Any()
                    ? (newsStatusGroup.NewsStatuses.Where(newsStatus => newsStatus.NewsStatusId != 9)
                       .Aggregate(string.Empty, (current, newsStatus) => current + ", " + newsStatus.NewsStatusId))
                                    .Remove(0, 2)
                    : "-1";

                    filterString = string.Format("WHERE (NewsStatus IN ({0})", newsStatusIds);

                    // Get personal worker requests
                    var workerRequestsGlobalIdsString = GetPersonalWorkerRequestsGlobalIds();
                    filterString += " OR GlobalID IN (" + workerRequestsGlobalIdsString + "))";
                }

                // Geting available production statuses for worker
                //var workerGroups = GetWorkerGroupsIds(AdministrationClass.CurrentWorkerId);
                //if(workerGroups.All(g => g != 1))
                //{
                var workerProdStatuses = GetWorkerProdStatuses(AdministrationClass.CurrentWorkerId);
                if (workerProdStatuses.Any())
                {
                    var workerProdStatusesString = workerProdStatuses.Aggregate(string.Empty, (current, prodStatus) => current + ", " + prodStatus).Remove(0, 2);
                    filterString += " AND (ProdStatusID IN (" + workerProdStatusesString + ") OR ProdStatusID IS NULL)";
                }
                else
                {
                    filterString += " AND ProdStatusID IS NULL";
                }
                //}
            }

            if (newsStatusGroup.NewsStatusGroupId == 3)
            {
                // Get GlobalIds of personal messages

                var globalIdsString = GetPersonalTasksGlobalIds();

                filterString += " AND GlobalID IN (" + globalIdsString + ")";
            }

            return(filterString);
        }