Esempio n. 1
0
        void InitializeEditWindow()
        {
            doctypes = DatabaseHandler.GetDocumentTypes();
            DocTypeCombo.ItemsSource = doctypes;

            //addedIds = new HashSet<int>();
            docHistoryChanges = new List <DocHistoryChange>();
            Tuple <int, string> doc = DatabaseHandler.GetDocument(id);

            originalDocType            = doc.Item1;
            originalName               = doc.Item2;
            DocumentName.Text          = originalName;
            DocTypeCombo.SelectedValue = originalDocType;
            PointsCountLabel.Content   = $"Связано с {DatabaseHandler.GetPointDocumentCount(id)} точками";
            PopulateHistoryTable();

            if (!DatabaseHandler.userRole.Documents.HasFlag(Permissions.UPDATE))
            {
                DocumentName.IsEnabled = false;
                DocTypeCombo.IsEnabled = false;
                if (!(DatabaseHandler.userRole.DocumentHistory.HasFlag(Permissions.INSERT) ||
                      DatabaseHandler.userRole.DocumentHistory.HasFlag(Permissions.UPDATE)))
                {
                    SaveButton.Visibility   = Visibility.Collapsed;
                    CancelButton.Visibility = Visibility.Collapsed;
                }
            }

            if (!DatabaseHandler.userRole.DocumentHistory.HasFlag(Permissions.INSERT))
            {
                ChangeDocument.Visibility    = Visibility.Collapsed;
                CancelChange.Visibility      = Visibility.Collapsed;
                SaveHistoryChange.Visibility = Visibility.Collapsed;
            }

            if (!(DatabaseHandler.userRole.PointDocConnections.HasFlag(Permissions.DELETE) &&
                  DatabaseHandler.userRole.PointDocConnections.HasFlag(Permissions.INSERT)))
            {
                AddPoints.Visibility = Visibility.Collapsed;
            }
        }