Exemplo n.º 1
0
    public string VisibleColumnsToString()
    {
        string strVisible = "";

        try
        {
            GridColsCollection columns = VisibleColumns();
            foreach (GridColsColumn sColumn in columns)
            {
                if (sColumn.Visible == true)
                {
                    if (string.IsNullOrEmpty(strVisible))
                    {
                        strVisible = sColumn.ColumnName;
                    }
                    else
                    {
                        strVisible += _SortDelimeter + sColumn.ColumnName;
                    }
                }
            }
        }
        catch (Exception ex)
        {
        }

        return(strVisible);
    }
Exemplo n.º 2
0
    private void RemoveExcelColumns(ref DataTable dt)
    {
        try
        {
            GridColsCollection cols = columnData.VisibleColumns();
            DataColumn         col  = null;

            //this has to be done in reverse order (RemoveAt)
            //OR by name(Remove) or it will have undesired result
            for (int i = dt.Columns.Count - 1; i >= 0; i--)
            {
                col = dt.Columns[i];
                if (cols.ItemByColumnName(col.ColumnName) == null && col.ColumnName != "WorkAreaID" && col.ColumnName != " ")
                {
                    dt.Columns.Remove(col);
                }
            }

            if (dt.Columns.Contains("A"))
            {
                dt.Columns.Remove("A");
            }
            if (dt.Columns.Contains("X"))
            {
                dt.Columns.Remove("X");
            }

            dt.AcceptChanges();
        }
        catch (Exception ex)
        {
            LogUtility.LogException(ex);
        }
    }
Exemplo n.º 3
0
    public GridColsCollection SortableColumns()
    {
        GridColsCollection sColumns = new GridColsCollection();

        foreach (GridColsColumn sColumn in _Columns)
        {
            if (sColumn.CanSort == true)
            {
                sColumns.Add(sColumn.ColumnName, sColumn.DisplayName, sColumn.Visible, sColumn.CanSort);
                sColumns.Item(sColumns.Count - 1).ColumnIndex = sColumn.ColumnIndex;
                sColumns.Item(sColumns.Count - 1).Viewable    = sColumn.Viewable;
            }
        }
        return(Columns);
    }
Exemplo n.º 4
0
    private void FormatExcelRows(ref DataTable dt)
    {
        GridColsCollection cols = columnData.VisibleColumns();

        bool hasArchive = false;

        hasArchive = (cols.ItemByColumnName("ARCHIVE") != null);

        if (hasArchive)
        {
            dt.Columns.Add("ARCHIVE_NEW");
        }

        int flag = 0;

        if (hasArchive)
        {
            foreach (DataRow row in dt.Rows)
            {
                if (hasArchive)
                {
                    if (int.TryParse(row["ARCHIVE"].ToString(), out flag) && flag == 1)
                    {
                        row["ARCHIVE_NEW"] = "Yes";
                    }
                    else
                    {
                        row["ARCHIVE_NEW"] = "No";
                    }
                }
            }

            dt.Columns["ARCHIVE_NEW"].SetOrdinal(dt.Columns["ARCHIVE"].Ordinal);
            dt.Columns.Remove("ARCHIVE");
            dt.Columns["ARCHIVE_NEW"].ColumnName = "ARCHIVE";
        }

        dt.Columns.Add(" ");
        dt.Columns.Add("  ");
        if (dt.Columns.Contains("WTS_SystemID"))
        {
            dt.Columns["WTS_SystemID"].SetOrdinal(dt.Columns.Count - 1);
        }

        dt.AcceptChanges();
    }
Exemplo n.º 5
0
    public GridColsCollection VisibleColumns()
    {
        GridColsCollection columns = new GridColsCollection();
        GridColsColumn     gcc     = null;

        for (int i = 0; i <= _Columns.Count; i++)
        {
            gcc = _Columns.ItemByColumnOrder(i);
            if ((gcc == null) == false && gcc.Visible == true)
            {
                columns.Add(gcc.ColumnName, gcc.DisplayName, gcc.Visible, gcc.CanSort);
                columns.Item(columns.Count - 1).ColumnIndex = gcc.ColumnIndex;
                columns.Item(columns.Count - 1).Viewable    = gcc.Viewable;
            }
        }

        return(columns);
    }
Exemplo n.º 6
0
    private void RenameExcelColumns(ref DataTable dt)
    {
        GridColsCollection cols  = columnData.VisibleColumns();
        GridColsColumn     gcCol = null;
        DataColumn         col   = null;

        for (int i = dt.Columns.Count - 1; i >= 0; i--)
        {
            col = dt.Columns[i];

            gcCol = cols.ItemByColumnName(col.ColumnName);
            if (gcCol != null)
            {
                dt.Columns[col.ColumnName].ColumnName = gcCol.DisplayName;
            }
        }

        dt.AcceptChanges();
    }
Exemplo n.º 7
0
    public GridColsCollection CurrentOrderedColumns()
    {
        GridColsCollection oColumns = new GridColsCollection();

        for (int i = 0; i < _Columns.Count; i++)
        {
            GridColsColumn testColumn = _Columns.ItemByColumnOrder(i);
            if ((testColumn == null) == false)
            {
                if (testColumn.CanReorder == true & testColumn.Viewable == true)
                {
                    oColumns.Add(testColumn.ColumnName, testColumn.DisplayName, testColumn.Visible, testColumn.CanSort);
                    oColumns.Item(oColumns.Count - 1).ColumnIndex = testColumn.ColumnIndex;
                    oColumns.Item(oColumns.Count - 1).Viewable    = testColumn.Viewable;
                }
            }
        }
        return(oColumns);
    }
Exemplo n.º 8
0
    public string[] VisibleColumnNamesArray()
    {
        GridColsCollection columns = VisibleColumns();

        if ((columns == null) || columns.Count == 0)
        {
            return(new string[] { "" });
        }
        string[]       colArray = new string[columns.Count + 1];
        GridColsColumn gcc      = null;

        for (int i = 0; i <= columns.Count; i++)
        {
            gcc = columns.ItemByColumnOrder(i);
            if ((gcc != null) && gcc.Visible)
            {
                colArray[i] = gcc.ColumnName;
            }
        }

        return(colArray);
    }