예제 #1
0
        public PointView(int id)
        {
            InitializeComponent();

            this.id = id;


            typeToTable = new Dictionary <int, DataGrid>();
            categories  = new Dictionary <int, Expander>();

            pointTypes = DatabaseHandler.GetPointTypes();
            CategoryCombo.ItemsSource = pointTypes;

            Point point = DatabaseHandler.GetPoint(id);

            origName                    = point.Name;
            origType                    = point.CategoryID;
            PointName.Text              = point.Name;
            tabLabel                    = new TabLabel();
            tabLabel.tabName            = point.Name;
            CategoryCombo.SelectedValue = point.CategoryID;
            //CategoryName.Content = DatabaseHandler.GetPointCategory(point.id);

            docPoint = DatabaseHandler.GetDocumentsID(id);
            List <DocumentType> sortedCategories = DatabaseHandler.GetSortedCategories(id, docPoint);

            foreach (var category in sortedCategories)
            {
                CreateCategory(category.id, category.Name);
            }

            if (!DatabaseHandler.userRole.Points.HasFlag(Permissions.UPDATE))
            {
                CategoryCombo.IsEditable     = false;
                CategoryCombo.IsEnabled      = false;
                PointName.IsEnabled          = false;
                SavePointButton.Visibility   = Visibility.Collapsed;
                CancelPointButton.Visibility = Visibility.Collapsed;
            }

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

            isDirty = false;
        }
예제 #2
0
        public void UpdateCategories()
        {
            System.Diagnostics.Debug.WriteLine("ddddasdasdasddd");
            docPoint = DatabaseHandler.GetDocumentsID(id);
            List <DocumentType> sortedCategories = DatabaseHandler.GetSortedCategories(id, docPoint);

            foreach (var category in sortedCategories)
            {
                if (categories.ContainsKey(category.id))
                {
                    if (typeToTable.ContainsKey(category.id))
                    {
                        UpdateTable(category.id);
                    }
                }
                else
                {
                    CreateCategory(category.id, category.Name);
                }
            }
            SortCategories(sortedCategories);
        }