Example #1
0
 /// <summary>
 /// constructor optionally calls method to init the column information structure 
 /// and return the itself - singleton
 /// </summary>
 /// <param name="dt">table</param>
 /// <param name="init">if true, initialize; for example, on import</param>
 /// <returns></returns>
 public static dtColumnInformation getdtCI(DataTable dt, bool init)
 {
     //pass null after initialization to access the DTcolInfo property
     //or pass init=true (after import) to initialize
     if (dtCI == null || init) dtCI = new dtColumnInformation(dt);
     return dtCI;
 }
Example #2
0
        /// <summary>
        /// Constructor takes the datagridview to show changes implemented in this class
        /// </summary>
        /// <param name="dgv">datasheet grid reference</param>
        /// <param name="dt">datasource for the grid</param>
        public frmMissingValues(DataGridView dgv, DataTable dt)
        {
            InitializeComponent();

            _tu = new Utilities.TableUtils(dt);
            _dtRI = dtRowInformation.getdtRI(_dt, false);
            _dtCI = dtColumnInformation.getdtCI(dt, false);

            //get a working copy of the dataset
            _dt = dt.Copy();
            _dgv = dgv;

            cboCols.DataSource = strArrDdlReplaceWith;
            btnReturn.Enabled = false;
        }
Example #3
0
        /// <summary>
        /// Constructor takes the datagridview to show changes implemented in this class
        /// </summary>
        /// <param name="dgv">datasheet grid reference</param>
        /// <param name="dt">datasource for the grid</param>
        public frmMissingValues(DataGridView dgv, DataTable dt)
        {
            InitializeComponent();

            _tu   = new Utilities.TableUtils(dt);
            _dtRI = VBCommon.Metadata.dtRowInformation.getdtRI(_dt, false);
            _dtCI = VBCommon.Metadata.dtColumnInformation.getdtCI(dt, false);

            //get a working copy of the dataset
            _dt  = dt.Copy();
            _dgv = dgv;

            cboCols.DataSource = strArrDdlReplaceWith;
            btnReturn.Enabled  = false;
        }
Example #4
0
            public DataTable filterDisabledCols(DataTable dt)
            {
                //filter out disabled columns
                DataTable dtCopy = dt.Copy();

                dtColumnInformation dtCI = dtColumnInformation.getdtCI(dt, false);

                foreach (KeyValuePair <string, bool> kv in dtCI.DTColInfo)
                {
                    if (kv.Value)
                    {
                        continue;
                    }
                    if (dtCopy.Columns.Contains(kv.Key))
                    {
                        dtCopy.Columns.Remove(kv.Key);
                    }
                }
                dtCopy.AcceptChanges();
                return(dtCopy);
            }
Example #5
0
 public TableUtils(DataTable dt)
 {
     _dt   = dt;
     _dtCI = dtColumnInformation.getdtCI(dt, false);
     _dtRI = dtRowInformation.getdtRI(dt, false);
 }
Example #6
0
            public void registerNewCols(DataTable dt)
            {
                _dtCI = dtColumnInformation.getdtCI(dt, false);
                foreach (DataColumn c in dt.Columns)
                {
                    if (!_dtCI.getColStatus(c.ColumnName))
                    {
                        _dtCI.addColumnNameToDic(c.ColumnName);
                    }

                }
            }
Example #7
0
 public TableUtils(DataTable dt)
 {
     _dt = dt;
     _dtCI = dtColumnInformation.getdtCI(dt, false);
     _dtRI = dtRowInformation.getdtRI(dt, false);
 }
Example #8
0
        // user click captured - decide what menu items are appropriate and show them
        public void showContextMenus(DataGridView dgv, MouseEventArgs me, DataTable dt)
        {
            dtColumnInformation dtCI = new dtColumnInformation(dt);
            Utilities utils = new Utilities();

            DataGridView.HitTestInfo ht = dgv.HitTest(me.X, me.Y);
            int colndx = ht.ColumnIndex;
            int rowndx = ht.RowIndex;

            if (rowndx > 0 && colndx > 0) return; //cell hit, go away

            if (rowndx < 0 && colndx >= 0)
            {
                //col header hit, show proper menu
                intSelectedColIndex = colndx;

                //do nothing if col 0 selected
                if (colndx >= 1)
                {
                    string colname = dt.Columns[colndx].Caption;
                    if (colname == strResponseVarColName)
                    {
                        if (utils.testValueAttribute(dt.Columns[intResponseVarColIndex], VBCommon.Globals.DEPENDENTVAR))
                        {
                            cmforResponseVar.MenuItems[0].Enabled = true; //we can transform a response variable
                        }
                        else
                        {
                            cmforResponseVar.MenuItems[0].Enabled = false; //but we cannot transform a transformed response
                        }

                        if (utils.testValueAttribute(dt.Columns[intResponseVarColIndex], VBCommon.Globals.DEPENDENTVARIBLETRANSFORM))
                        {
                            cmforResponseVar.MenuItems[2].Enabled = true; //we can untransform the transformed response variable
                        }
                        else
                        {
                            cmforResponseVar.MenuItems[2].Enabled = false; //but cannot untransform a response variable
                        }

                        cmforResponseVar.Show(dgv, new Point(me.X, me.Y));
                    }
                    else
                    {

                        //show context menu for ivs
                        if (dtCI.getColStatus(dt.Columns[intSelectedColIndex].ColumnName.ToString()))
                        {
                            //here if col enabled
                            cmforIVs.MenuItems[0].Enabled = true;
                            cmforIVs.MenuItems[1].Enabled = false; //cannot enable enabled col
                            cmforIVs.MenuItems[2].Enabled = true;

                            //response variable must be a ME, T(RV) or I(IV) not created by general transform
                            //if they do this then we're to remove all general operations performed,
                            if (canSetRV(utils)) cmforIVs.MenuItems[2].Enabled = true;
                            else cmforIVs.MenuItems[2].Enabled = false;

                            if (dt.Columns[intSelectedColIndex].ExtendedProperties.ContainsKey(VBCommon.Globals.MAINEFFECT))
                                cmforIVs.MenuItems[4].Enabled = false;  //cannot remove maineffect column
                            else cmforIVs.MenuItems[4].Enabled = true;
                        }
                        else
                        {
                            //here if col disabled
                            cmforIVs.MenuItems[0].Enabled = false; //cannot disable disabled col
                            cmforIVs.MenuItems[1].Enabled = true;
                            cmforIVs.MenuItems[2].Enabled = false; //cannot disabled the response variable
                        }
                        cmforIVs.Show(dgv, new Point(me.X, me.Y));
                    }
                }
            }
            else if (rowndx >= 0 && colndx < 0)
            {
                //row header hit, show menu
                intSelectedRowIndex = rowndx;
                if (dtRI.getRowStatus(dt.Rows[intSelectedRowIndex][0].ToString()))
                {
                    //here if row is enabled
                    cmforRows.MenuItems[0].Enabled = true;
                    cmforRows.MenuItems[1].Enabled = false; //cannot enable enabled row
                }
                else
                {
                    //here if row is disabled
                    cmforRows.MenuItems[0].Enabled = false; //cannot disable disabled row
                    cmforRows.MenuItems[1].Enabled = true;
                }
                cmforRows.Show(dgv, new Point(me.X, me.Y));
            }
        }