示例#1
0
        public MainWindow()
        {
            InitializeComponent();
            saveFileDialog = new SaveFileDialog()
            {
                Filter = "JSON files|*.json"
            };
            openFileDialog = new OpenFileDialog()
            {
                Filter = "JSON files|*.json"
            };
            Tasks = new ObservableCollection <Task>();
            lbTasks.ItemsSource = Tasks;
            worker = new JsonWorker();

            //Rights
            if (!Authentication.Instance.CurrentUser.IsHaveAccessTo("TasksModule", "TasksModule.WRITE"))
            {
                bAddTask.IsEnabled = bDeleteTask.IsEnabled = false;
            }

            if (MessageBox.Show("Chose file with employers.", "File loading", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.Cancel) == MessageBoxResult.OK)
            {
                if (openFileDialog.ShowDialog() == true)
                {
                    try
                    {
                        Responsibles = worker.LoadResponsiblesFromJson(openFileDialog.FileName);
                    }
                    catch (Exception ex)
                    {
                        ShowErrorMessage(ex.Message);
                        Close();
                    }
                }
                else
                {
                    Close();
                }
            }
            else
            {
                Close();
            }
            if (Responsibles != null)
            {
                Responsibles.Add(new Responsible(-1, "Unknown"));
            }
        }
        public void AddResponsible(Responsible responsible)
        {
            Responsibles.Add(responsible);

            AddNotifications(responsible);
        }