Пример #1
0
        private bool doAction(int ndx)
        {
            bool   breakloop = false;
            string target    = cboCols.SelectedValue.ToString();

            int[] location = _badCells[ndx];
            int   rndx     = location[1];
            int   cndx     = location[0];

            #region replace cell value
            if (rbActionReplace.Checked)
            {
                if (target == "Only This Cell")
                {
                    _dgv.Rows[rndx].Cells[cndx].Selected = true;
                    _dgv[cndx, rndx].Value = _replacevalue;
                    _badCells.RemoveAt(ndx);
                    _dt.Rows[rndx][cndx] = _dgv[cndx, rndx].Value;
                    _dt.AcceptChanges();
                    breakloop = true;
                }
                else if (target == "Entire Row")
                {
                    if (_updatetargetrow)
                    {
                        _updatetargetrow = false;
                        _targetrow       = rndx;
                    }
                    if (rndx == _targetrow)
                    {
                        _dgv.Rows[rndx].Cells[cndx].Selected = true;
                        _dgv[cndx, rndx].Value = _replacevalue;
                        _dt.Rows[rndx][cndx]   = _dgv[cndx, rndx].Value;
                        _dt.AcceptChanges();
                    }
                    breakloop = false;
                }
                else if (target == "Entire Column")
                {
                    if (_updatetargetcol)
                    {
                        _updatetargetcol = false;
                        _targetcol       = cndx;
                    }
                    if (cndx == _targetcol)
                    {
                        _dgv.Rows[rndx].Cells[cndx].Selected = true;
                        _dgv[cndx, rndx].Value = _replacevalue;
                        _dt.Rows[rndx][cndx]   = _dgv[cndx, rndx].Value;
                        _dt.AcceptChanges();
                    }
                    breakloop = false;
                }
                else if (target == "Entire Sheet")
                {
                    _dgv.Rows[rndx].Cells[cndx].Selected = true;
                    _dgv[cndx, rndx].Value = _replacevalue;
                    _dt.Rows[rndx][cndx]   = _dgv[cndx, rndx].Value;
                    _dt.AcceptChanges();
                    breakloop = false;
                }
            }
            #endregion
            #region delete row
            else if (rbActionDelRow.Checked)
            {
                if (target == "Only This Row")
                {
                    _dgv.Rows[rndx].Cells[cndx].Selected = true;
                    _dtRI.setRowStatus(_dt.Rows[rndx][0].ToString(), false);
                    _dt = _tu.filterDataTableRows(_dt);
                    _dt.AcceptChanges();
                    _dgv.DataSource = _dt;
                    breakloop       = true;
                }
                else if (target == "Entire Column")
                {
                    for (int i = 0; i < _badCells.Count; i++)
                    {
                        int[] ndxs = _badCells[i];
                        int   c    = ndxs[0];
                        int   r    = ndxs[1];
                        if (c != cndx)
                        {
                            continue;
                        }
                        _dtRI.setRowStatus(_dt.Rows[r][0].ToString(), false);
                    }
                    _dt = _tu.filterDataTableRows(_dt);
                    _dt.AcceptChanges();
                    _dgv.DataSource = _dt;
                    breakloop       = true;
                }
                else if (target == "Entire Sheet")
                {
                    for (int i = 0; i < _badCells.Count; i++)
                    {
                        int[] ndxs = _badCells[i];
                        int   c    = ndxs[0];
                        int   r    = ndxs[1];
                        _dtRI.setRowStatus(_dt.Rows[r][0].ToString(), false);
                    }
                    _dt = _tu.filterDataTableRows(_dt);
                    _dt.AcceptChanges();
                    _dgv.DataSource = _dt;
                    breakloop       = true;
                }
            }
            #endregion


            return(breakloop);
        }
Пример #2
0
        private bool doAction(int ndx)
        {
            bool   boolBreakloop = false;
            string strTarget     = cboCols.SelectedValue.ToString();

            int[] intArrLocation = lstBadCells[ndx];
            int   intRndx        = intArrLocation[1];
            int   intCndx        = intArrLocation[0];

            #region replace cell value
            if (rbActionReplace.Checked)
            {
                if (strTarget == "Only This Cell")
                {
                    _dgv.Rows[intRndx].Cells[intCndx].Selected = true;
                    _dgv[intCndx, intRndx].Value = dblReplacevalue;
                    lstBadCells.RemoveAt(ndx);
                    _dt.Rows[intRndx][intCndx] = _dgv[intCndx, intRndx].Value;
                    _dt.AcceptChanges();
                    boolBreakloop = true;
                }
                else if (strTarget == "Entire Row")
                {
                    if (boolUpdatetargetrow)
                    {
                        boolUpdatetargetrow = false;
                        intTargetrow        = intRndx;
                    }
                    if (intRndx == intTargetrow)
                    {
                        _dgv.Rows[intRndx].Cells[intCndx].Selected = true;
                        _dgv[intCndx, intRndx].Value = dblReplacevalue;
                        _dt.Rows[intRndx][intCndx]   = _dgv[intCndx, intRndx].Value;
                        _dt.AcceptChanges();
                    }
                    boolBreakloop = false;
                }
                else if (strTarget == "Entire Column")
                {
                    if (boolUpdatetargetcol)
                    {
                        boolUpdatetargetcol = false;
                        intTargetcol        = intCndx;
                    }
                    if (intCndx == intTargetcol)
                    {
                        _dgv.Rows[intRndx].Cells[intCndx].Selected = true;
                        _dgv[intCndx, intRndx].Value = dblReplacevalue;
                        _dt.Rows[intRndx][intCndx]   = _dgv[intCndx, intRndx].Value;
                        _dt.AcceptChanges();
                    }
                    boolBreakloop = false;
                }
                else if (strTarget == "Entire Sheet")
                {
                    _dgv.Rows[intRndx].Cells[intCndx].Selected = true;
                    _dgv[intCndx, intRndx].Value = dblReplacevalue;
                    _dt.Rows[intRndx][intCndx]   = _dgv[intCndx, intRndx].Value;
                    _dt.AcceptChanges();
                    boolBreakloop = false;
                }
            }
            #endregion
            #region delete row
            else if (rbActionDelRow.Checked)
            {
                if (strTarget == "Only This Row")
                {
                    _dgv.Rows[intRndx].Cells[intCndx].Selected = true;
                    _dtRI.setRowStatus(_dt.Rows[intRndx][0].ToString(), false);
                    _dt = _tu.filterDataTableRows(_dt);
                    _dt.AcceptChanges();
                    _dgv.DataSource = _dt;
                    boolBreakloop   = true;
                }
                else if (strTarget == "Entire Column")
                {
                    for (int i = 0; i < lstBadCells.Count; i++)
                    {
                        int[] intArrNdxs = lstBadCells[i];
                        int   c          = intArrNdxs[0];
                        int   r          = intArrNdxs[1];
                        if (c != intCndx)
                        {
                            continue;
                        }
                        _dtRI.setRowStatus(_dt.Rows[r][0].ToString(), false);
                    }
                    _dt = _tu.filterDataTableRows(_dt);
                    _dt.AcceptChanges();
                    _dgv.DataSource = _dt;
                    boolBreakloop   = true;
                }
                else if (strTarget == "Entire Sheet")
                {
                    for (int i = 0; i < lstBadCells.Count; i++)
                    {
                        int[] ndxs = lstBadCells[i];
                        int   c    = ndxs[0];
                        int   r    = ndxs[1];
                        _dtRI.setRowStatus(_dt.Rows[r][0].ToString(), false);
                    }
                    _dt = _tu.filterDataTableRows(_dt);
                    _dt.AcceptChanges();
                    _dgv.DataSource = _dt;
                    boolBreakloop   = true;
                }
            }
            #endregion

            return(boolBreakloop);
        }