Exemplo n.º 1
0
 ///<summary>Fills the grid with the contents of the corresponding wiki list table in the database.
 ///After filling the grid, FilterGrid() will get invoked to apply any advanced search options.</summary>
 private void FillGrid()
 {
     _listColumnHeaders = WikiListHeaderWidths.GetForList(WikiListCurName);
     _table             = WikiLists.GetByName(WikiListCurName);
     if (_table.Rows.Count > 0 && _listColumnHeaders.Count != _table.Columns.Count)         //if these do not match, something happened to be desynched at the right moment.
     {
         WikiListHeaderWidths.RefreshCache();
         _table             = WikiLists.GetByName(WikiListCurName);
         _listColumnHeaders = WikiListHeaderWidths.GetForList(WikiListCurName);
         if (_listColumnHeaders.Count != _table.Columns.Count)               //if they still do not match, one of them did not get synched correctly.
         {
             MsgBox.Show(this, "Unable to open the wiki list.");
             return;
         }
     }
     gridMain.BeginUpdate();
     gridMain.ListGridColumns.Clear();
     gridMain.ListGridColumns.AddRange(_listColumnHeaders.Select(x => new GridColumn(x.ColName, x.ColWidth)));
     gridMain.ListGridRows.Clear();
     gridMain.ListGridRows.AddRange(_table.Select().Select((x, index) => new GridRow(x.ItemArray.Select(y => y.ToString()).ToArray())
     {
         Tag = index
     }));
     gridMain.Title = WikiListCurName;
     gridMain.EndUpdate();
     FilterGrid();
 }
Exemplo n.º 2
0
        private void FormWikiListHeaders_Load(object sender, EventArgs e)
        {
            List <WikiListHeaderWidth> listTableHeadersShallow = WikiListHeaderWidths.GetForList(_wikiListCurName);

            _listTableHeaders = listTableHeadersShallow.Select(x => x.Copy()).ToList();
            FillGrid();
        }
Exemplo n.º 3
0
 private void butColumnAdd_Click(object sender, EventArgs e)
 {
     if (!Security.IsAuthorized(Permissions.WikiListSetup))             //gives a message box if no permission
     {
         return;
     }
     SetIsEdited();
     WikiLists.AddColumn(WikiListCurName);
     _table             = WikiLists.GetByName(WikiListCurName);
     _listColumnHeaders = WikiListHeaderWidths.GetForList(WikiListCurName);
     FillGrid();
 }
Exemplo n.º 4
0
        private void butAdvSearch_Click(object sender, EventArgs e)
        {
            List <WikiListHeaderWidth> colHeaderWidths = WikiListHeaderWidths.GetForList(WikiListCurName);
            FormWikiListAdvancedSearch FormWLAS        = new FormWikiListAdvancedSearch(colHeaderWidths);

            //FormWLAS.ShowDialog();
            if (FormWLAS.ShowDialog() == DialogResult.OK)
            {
                _arraySearchColIdxs = FormWLAS.SelectedColumnIndices;
                FillGrid();
            }
            ActiveControl = textSearch;
        }
Exemplo n.º 5
0
        /// <summary></summary>
        private void FillGridCur()
        {
            gridCur.BeginUpdate();
            gridCur.ListGridColumns.Clear();
            gridCur.ListGridRows.Clear();
            Dictionary <string, int> dictColWidths = WikiListHeaderWidths.GetForList(ListNameCur).ToDictionary(x => x.ColName, x => x.ColWidth);

            using (DataTable table = WikiLists.GetByName(ListNameCur)) {
                gridCur.ListGridColumns.AddRange(
                    table.Columns.OfType <DataColumn>().Select(x => new GridColumn(x.ColumnName, dictColWidths.TryGetValue(x.ColumnName, out int width)?width:100)));
                gridCur.ListGridRows.AddRange(table.Select().Select(x => new GridRow(x.ItemArray.Select(y => y.ToString()).ToArray())));
            }
            gridCur.EndUpdate();
        }
Exemplo n.º 6
0
        private void butHistory_Click(object sender, EventArgs e)
        {
            FormWikiListHistory FormWLH = new FormWikiListHistory();

            FormWLH.ListNameCur = WikiListCurName;
            FormWLH.ShowDialog();
            if (!FormWLH.IsReverted)
            {
                return;
            }
            //Reversion has already saved a copy of the current revision.
            _wikiListOld       = WikiListHists.GenerateFromName(WikiListCurName, Security.CurUser.UserNum);
            _table             = WikiLists.GetByName(WikiListCurName);
            _listColumnHeaders = WikiListHeaderWidths.GetForList(WikiListCurName);
            FillGrid();
            _isEdited = false;
            IsNew     = false;
        }
Exemplo n.º 7
0
        private void butColumnEdit_Click(object sender, EventArgs e)
        {
            if (!Security.IsAuthorized(Permissions.WikiListSetup))             //gives a message box if no permission
            {
                return;
            }
            FormWikiListHeaders FormWLH = new FormWikiListHeaders(WikiListCurName);

            FormWLH.ShowDialog();
            if (FormWLH.DialogResult != DialogResult.OK)
            {
                return;
            }
            SetIsEdited();
            _table             = WikiLists.GetByName(WikiListCurName);
            _listColumnHeaders = WikiListHeaderWidths.GetForList(WikiListCurName);
            FillGrid();
        }
Exemplo n.º 8
0
 private void FormWikiListEdit_Load(object sender, EventArgs e)
 {
     if (!WikiLists.CheckExists(WikiListCurName))
     {
         IsNew = true;
         WikiLists.CreateNewWikiList(WikiListCurName);
     }
     _table       = WikiLists.GetByName(WikiListCurName);
     _wikiListOld = WikiListHists.GenerateFromName(WikiListCurName, Security.CurUser.UserNum);
     if (_wikiListOld == null)
     {
         _wikiListOld = new WikiListHist();
     }
     //Fill _columnHeaders
     _listColumnHeaders        = WikiListHeaderWidths.GetForList(WikiListCurName);
     radioButHighlight.Checked = true;
     radioButFilter.Checked    = false;
     FillGrid();
     ActiveControl = textSearch;          //start in search box.
 }
Exemplo n.º 9
0
        private void butColumnRight_Click(object sender, EventArgs e)
        {
            if (!Security.IsAuthorized(Permissions.WikiListSetup))             //gives a message box if no permission
            {
                return;
            }
            if (gridMain.SelectedCell.X == -1)
            {
                return;
            }
            SetIsEdited();
            Point pointNewSelectedCell = gridMain.SelectedCell;

            pointNewSelectedCell.X = Math.Min(gridMain.Columns.Count - 1, pointNewSelectedCell.X + 1);
            WikiLists.ShiftColumnRight(WikiListCurName, _table.Columns[gridMain.SelectedCell.X].ColumnName);
            _table             = WikiLists.GetByName(WikiListCurName);
            _listColumnHeaders = WikiListHeaderWidths.GetForList(WikiListCurName);
            FillGrid();
            gridMain.SetSelected(pointNewSelectedCell);
        }
Exemplo n.º 10
0
 private void butColumnDelete_Click(object sender, EventArgs e)
 {
     if (!Security.IsAuthorized(Permissions.WikiListSetup))             //gives a message box if no permission
     {
         return;
     }
     if (gridMain.SelectedCell.X == -1)
     {
         MsgBox.Show(this, "Select cell in column to be deleted first.");
         return;
     }
     if (!WikiLists.CheckColumnEmpty(WikiListCurName, _table.Columns[gridMain.SelectedCell.X].ColumnName))
     {
         MsgBox.Show(this, "Column cannot be deleted because it contains data.");
         return;
     }
     SetIsEdited();
     WikiLists.DeleteColumn(WikiListCurName, _table.Columns[gridMain.SelectedCell.X].ColumnName);
     _table             = WikiLists.GetByName(WikiListCurName);
     _listColumnHeaders = WikiListHeaderWidths.GetForList(WikiListCurName);
     FillGrid();
 }
Exemplo n.º 11
0
        /// <summary></summary>
        private void FillGridCur()
        {
            List <WikiListHeaderWidth> listColHeaderWidths = WikiListHeaderWidths.GetForList(ListNameCur);

            _tableCur = WikiLists.GetByName(ListNameCur);
            gridCur.BeginUpdate();
            gridCur.Columns.Clear();
            ODGridColumn col;

            for (int c = 0; c < _tableCur.Columns.Count; c++)
            {
                int colWidth = 100;              //100 = default value in case something is malformed in the database.
                foreach (WikiListHeaderWidth colHead in listColHeaderWidths)
                {
                    if (colHead.ColName == _tableCur.Columns[c].ColumnName)
                    {
                        colWidth = colHead.ColWidth;
                        break;
                    }
                }
                col = new ODGridColumn(_tableCur.Columns[c].ColumnName, colWidth, false);
                gridCur.Columns.Add(col);
            }
            gridCur.Rows.Clear();
            ODGridRow row;

            for (int i = 0; i < _tableCur.Rows.Count; i++)
            {
                row = new ODGridRow();
                for (int c = 0; c < _tableCur.Columns.Count; c++)
                {
                    row.Cells.Add(_tableCur.Rows[i][c].ToString());
                }
                gridCur.Rows.Add(row);
                gridCur.Rows[i].Tag = i;
            }
            gridCur.EndUpdate();
        }
Exemplo n.º 12
0
        /// <summary></summary>
        private void FillGrid()
        {
            List <WikiListHeaderWidth> colHeaderWidths = WikiListHeaderWidths.GetForList(WikiListCurName);

            gridMain.BeginUpdate();
            gridMain.Columns.Clear();
            ODGridColumn col;

            for (int c = 0; c < Table.Columns.Count; c++)
            {
                int colWidth = 100;                //100 = default value in case something is malformed in the database.
                foreach (WikiListHeaderWidth colHead in colHeaderWidths)
                {
                    if (colHead.ColName == Table.Columns[c].ColumnName)
                    {
                        colWidth = colHead.ColWidth;
                        break;
                    }
                }
                col = new ODGridColumn(Table.Columns[c].ColumnName, colWidth, false);
                gridMain.Columns.Add(col);
            }
            gridMain.Rows.Clear();
            ODGridRow row;

            for (int i = 0; i < Table.Rows.Count; i++)
            {
                row = new ODGridRow();
                for (int c = 0; c < Table.Columns.Count; c++)
                {
                    row.Cells.Add(Table.Rows[i][c].ToString());
                }
                gridMain.Rows.Add(row);
            }
            gridMain.EndUpdate();
            gridMain.Title = WikiListCurName;
        }
Exemplo n.º 13
0
 private void FormWikiListHeaders_Load(object sender, EventArgs e)
 {
     ListTableHeaders = WikiListHeaderWidths.GetForList(WikiListCurName);
     FillGrid();
 }