Ejemplo n.º 1
0
 public entervalue(string[] s, clsWritableGrid grid,int col)
 {
     this.column = col;
     this.grid = grid;
     InitializeComponent();
     comboBox1.Visible = true;
     comboBox1.DataSource = s;
 }
Ejemplo n.º 2
0
        public entervalue(string s,clsWritableGrid grid,int col)
        {
            this.grid = grid;
            this.column = col;
            InitializeComponent();

            if (s == "date")
            {
                dateTimePicker1.Visible = true;
            }
            if (s == "text")
            {
                textBox1.Visible = true;
            }
        }
Ejemplo n.º 3
0
        public bool DoReordering(clsWritableGrid _MasterGrid)
        {
            try
            {
                if (this.Rows.Count <= 0)
                    return false;
                //ArrayList _ReorderList = _MasterGrid.ReorderList;
                //UnitType _TypeOfUnit = _MasterGrid.TypeOfUnit;

                ReorderList = _MasterGrid.ReorderList;
                TypeOfUnit = _MasterGrid.TypeOfUnit;

                for (int i = 0; i < this.ReorderList.Count; i++)
                {
                    string str1 = this.ReorderList[i].ToString();
                    int RowNum = -1;
                    if (!DoRowExist(str1, ref RowNum))
                        continue;
                    if (RowNum == -1)
                        continue;
                    if (this.TypeOfUnit == UnitType.Margin && this.SCREEN_NAME!= ScreenGroup.Product && RowNum <= (i + 3))
                        continue;
                    if (RowNum <= (i + 2))
                        continue;
                    int SwapRow1 = RowNum;
                    //int SwapRow2 = RowNum - 1;
                    int SwapRow2 = 0;
                    if (this.TypeOfUnit == UnitType.Margin && this.SCREEN_NAME != ScreenGroup.Product)
                        SwapRow2 = i + 3;
                    else
                        SwapRow2 = i + 2;
                    #region Commented
                    //object[] objArr = new object[this.Columns.Count];
                    //dvSource.BeginInit();
                    //for (int j = 0; j < this.Columns.Count; j++)
                    //{
                    //    objArr[j] = (object)dvSource[SwapRow1][j];
                    //}

                    //for (int j = 0; j < this.Columns.Count; j++)
                    //{
                    //    this.dvSource[SwapRow1][j] = this.dvSource[SwapRow2][j];
                    //}

                    //for (int j = 0; j < this.Columns.Count; j++)
                    //{
                    //    this.dvSource[SwapRow2][j] = objArr[j];
                    //}
                    //dvSource.EndInit();
                    //dvSource.Table.AcceptChanges();
                    //this.DataSource = dvSource.Table;
                    //this.Update();
                    #endregion

                    object[] objArr = new object[this.dvSource.Table.Columns.Count];
                    dvSource.BeginInit();
                    for (int j = 0; j < this.dvSource.Table.Columns.Count; j++)
                    {
                        objArr[j] = (object)dvSource[SwapRow1][j];
                    }

                    for (int j = 0; j < this.dvSource.Table.Columns.Count; j++)
                    {
                        this.dvSource[SwapRow1][j] = this.dvSource[SwapRow2][j];
                    }

                    for (int j = 0; j < this.dvSource.Table.Columns.Count; j++)
                    {
                        this.dvSource[SwapRow2][j] = objArr[j];
                    }
                    dvSource.EndInit();
                    dvSource.Table.AcceptChanges();
                    this.DataSource = dvSource.Table;
                    this.Update();
                }

                return true;
            }
            catch
            {
                return false;
            }
        }
Ejemplo n.º 4
0
        private void swapRows(clsWritableGrid _Grid, int iSelectedRow, SwapMode range)
        {
            try
            {
                SetFreezedRows();
                //int iSelectedRow = -1;
                //for (int iTmp = 0; iTmp <= _ParentGrid.Rows.Count - 1; iTmp++)
                //{
                //    if (_ParentGrid.Rows[iTmp].Selected)
                //    {
                //        if (listFreezedRows.Contains(iTmp))
                //            return;
                //        iSelectedRow = iTmp;
                //        if (range == SwapMode.Up)
                //            iSelectedRow--;
                //        else
                //            iSelectedRow++;
                //        break; // TODO: might not be correct. Was : Exit For
                //    }
                //}

                if (iSelectedRow != -1)
                {
                    string[] sTmp = new string[_Grid.dvSource.Table.Columns.Count];
                    for (int iTmp = 0; iTmp <= _Grid.dvSource.Table.Columns.Count - 1; iTmp++)
                    {
                        //sTmp[iTmp] = _Grid.Rows[iSelectedRow].Cells[iTmp].Value.ToString();
                        sTmp[iTmp] = _Grid.dvSource[iSelectedRow][iTmp].ToString();
                    }

                    int iNewRow = 0;
                    if (range == SwapMode.Down)
                    {
                        iNewRow = iSelectedRow + 1;
                    }
                    else if (range == SwapMode.Up)
                    {
                        iNewRow = iSelectedRow - 1;
                        if (listFreezedRows.Contains(iNewRow))
                            iNewRow = -1;
                    }

                    if (iNewRow > -1)
                    {
                        if (range == SwapMode.Up | range == SwapMode.Down)
                        {
                            _Grid.dvSource.BeginInit();
                            for (int iTmp = 0; iTmp <= _Grid.dvSource.Table.Columns.Count - 1; iTmp++)
                            {

                                //this.Rows[iSelectedRow].Cells[iTmp].Value = this.Rows[iNewRow].Cells[iTmp].Value;
                                _Grid.dvSource[iSelectedRow][iTmp] = _Grid.dvSource[iNewRow][iTmp];
                                //this.Rows[iNewRow].Cells[iTmp].Value = sTmp[iTmp];
                                _Grid.dvSource[iNewRow][iTmp] = sTmp[iTmp];
                            }
                            _Grid.dvSource.EndInit();
                            _Grid.dvSource.Table.AcceptChanges();
                            _Grid.DataSource = _Grid.dvSource.Table;
                            _Grid.Update();

                            for (int i = 0; i < _Grid.Rows.Count - 1; i++)
                            {
                                _Grid.Rows[i].Selected = false;
                            }
                            _Grid.Rows[iNewRow].Selected = true;
                        }
                        else if (range == SwapMode.Top | range == SwapMode.Bottom)
                        {
                            reshuffleRows(sTmp, iSelectedRow, range);
                        }
                    }
                }
            }
            catch (Exception ex)
            {

            }
        }
        public StringBuilder get_filter(clsWritableGrid _grid)
        {
            try
            {
                System.Text.StringBuilder sb = new System.Text.StringBuilder();
                DataTable dt = (DataTable)_DgView.DataSource;
                for (int i = 0; i < dt.Columns.Count; i++)
                {
                    if (dt.Columns[i].ColumnName.ToString().ToUpper().StartsWith("MASK_"))
                        continue;
                    string s = String.Empty;
                    WritableGridFilterHeader filter;
                    if (i == get_actual_colum_index(_CurrentColumnIndex, _grid.dvSource.Table))
                    {
                        s = txtSearch.Text;
                    }
                    else
                    {
                        filter = (WritableGridFilterHeader)_DgView.Columns[get_unreal_colum_index(i, _grid.dvSource.Table)].HeaderCell;

                        Type p = ((object)filter.SearchText).GetType();
                        if (p.ToString() == "System.String")
                        {
                            s = (string)filter.SearchText;
                        }
                    }

                    if (s == String.Empty)
                    {
                        continue;
                    }
                    else
                    {
                        if (!boolWildCardSearch)
                        {
                            sb.Append("(" + dt.Columns[i].ColumnName + " LIKE  '" + s + "%' ) AND ");
                        }
                        else
                        {
                            sb.Append("(" + dt.Columns[i].ColumnName + " LIKE  '%" + s + "%' ) AND ");
                            boolWildCardSearch = false;
                        }

                        //if (!boolWildCardSearch)
                        //{
                        //    sb.Append("(" + convert/( dt.Columns[i].ColumnName,"System.String") + " LIKE  '" + s + "%' ) AND ");
                        //}
                        //else
                        //{
                        //    sb.Append("(" + dt.Columns[i].ColumnName + " LIKE  '%" + s + "%' ) AND ");
                        //    boolWildCardSearch = false;
                        //}
                    }

                    //if (s == String.Empty)
                    //{
                    //    continue;
                    //}
                    //else
                    //{
                    //    if (!boolWildCardSearch)
                    //    {
                    //        sb.Append("(" + dt.Columns[i].ColumnName + " LIKE  '" + s + "%' ) AND ");
                    //    }
                    //    else
                    //    {
                    //        sb.Append("(" + dt.Columns[i].ColumnName + " LIKE  '%" + s + "%' ) AND ");
                    //        boolWildCardSearch = false;
                    //    }
                    //}
                }
                if (sb.ToString() != "")
                {
                    sb.Replace(" AND ", "", sb.Length - 5, 5);
                }
                return sb;
            }
            catch (Exception ex)
            {
                return null;
            }
        }