Exemplo n.º 1
0
 public override int GetHashCode() =>
 ColumnDataTypes.Select(ct => ct.GetHashCode()).GenerateListHashCode();
Exemplo n.º 2
0
 public override string ToString() => $"RowType({ColumnDataTypes.CommaDelimit()})";
Exemplo n.º 3
0
        private string GetFilter()
        {
            string   str      = String.Empty;
            string   strQuote = "'";
            DataView dataView = null;

            ColumnDataTypes dataType = ColumnDataTypes.NotSupported;

            if (this._dataView != null)
            {
                dataView = this._dataView;
            }
            else if (this._bindingSource != null)
            {
                dataView = ((DataRowView)this._bindingSource[0]).DataView;
            }

            if (!base.DesignMode)
            {
                this._rowFilterCount++;
            }

            if (this.ValidateInput())
            {
                for (int i = 0; i < this.grdCr.Rows.Count; i++)
                {
                    dataType = this.GetColumnDataType(dataView.Table.Columns[i].DataType.ToString());
                    if (this.grdCr[0, i].Value.ToString() == "True")
                    {
                        if (str.Length > 0)
                        {
                            str += " And ";
                        }

                        str += this.grdCr.Rows[i].HeaderCell.Value.ToString() + " = True";
                    }
                    else if (this.grdCr[0, i].Value.ToString() == "False")
                    {
                        if (str.Length > 0)
                        {
                            str += " And ";
                        }

                        str += this.grdCr.Rows[i].HeaderCell.Value.ToString() + " = False";
                    }
                    else if (this.grdCr[0, i].Value.ToString() == "Null")
                    {
                        if (str.Length > 0)
                        {
                            str += " And ";
                        }

                        str += this.grdCr.Rows[i].HeaderCell.Value.ToString() + " Is Null";
                    }
                    else if (this.grdCr[0, i].Value.ToString() == "Not Null")
                    {
                        if (str.Length > 0)
                        {
                            str += " And ";
                        }

                        str += this.grdCr.Rows[i].HeaderCell.Value.ToString() + " Is Not Null";
                    }
                    else if (this.grdCr[0, i].Value.ToString() == "Like")
                    {
                        if (str.Length > 0)
                        {
                            str += " And ";
                        }

                        str += this.grdCr.Rows[i].HeaderCell.Value.ToString() + " Like " + strQuote + this.grdCr[1, i].Value.ToString() + strQuote;
                    }
                    else if (this.grdCr[0, i].Value.ToString() == "Not Like")
                    {
                        if (str.Length > 0)
                        {
                            str += " And ";
                        }

                        str += this.grdCr.Rows[i].HeaderCell.Value.ToString() + " Not Like " + strQuote + this.grdCr[1, i].Value.ToString() + strQuote;
                    }
                    else if ((((this.grdCr[0, i].Value.ToString() == "=") || (this.grdCr[0, i].Value.ToString() == ">")) || ((this.grdCr[0, i].Value.ToString() == "<") || (this.grdCr[0, i].Value.ToString() == ">="))) || ((this.grdCr[0, i].Value.ToString() == "<=") || (this.grdCr[0, i].Value.ToString() == "<>")))
                    {
                        if (str.Length > 0)
                        {
                            str += " And ";
                        }

                        switch (dataType)
                        {
                        case ColumnDataTypes.Text:
                            str += this.grdCr.Rows[i].HeaderCell.Value.ToString() + " " + this.grdCr[0, i].Value.ToString() + " " + strQuote + this.grdCr[1, i].Value.ToString() + strQuote;
                            break;

                        case ColumnDataTypes.Integer:
                        case ColumnDataTypes.Float:
                            str += this.grdCr.Rows[i].HeaderCell.Value.ToString() + " " + this.grdCr[0, i].Value.ToString() + " " + this.grdCr[1, i].Value.ToString();
                            break;

                        case ColumnDataTypes.DateTime:
                            str += this.grdCr.Rows[i].HeaderCell.Value.ToString() + " " + this.grdCr[0, i].Value.ToString() + " " + this.GetDateAsSQLString(this.grdCr[1, i].Value.ToString());
                            break;
                        }
                    }
                }
            }
            return(str);
        }
Exemplo n.º 4
0
        private void PrepareGridView()
        {
            DataView dataView = null;

            if (this._dataView != null)
            {
                dataView = this._dataView;
            }
            else if (this._bindingSource != null)
            {
                DataRowView view2 = (DataRowView)this._bindingSource[0];
                dataView = view2.DataView;
            }

            this.EmptyControl();
            ColumnDataTypes dataType = ColumnDataTypes.NotSupported;

            this.grdCr.RowHeadersWidth = 100;

            DataGridViewComboBoxCell cellTemplate = new DataGridViewComboBoxCell();

            this.grdCr.Columns.Add(new DataGridViewColumn(cellTemplate));
            this.grdCr.Columns[0].Name = "Condition";

            DataGridViewTextBoxCell cell3 = new DataGridViewTextBoxCell();

            this.grdCr.Columns.Add(new DataGridViewColumn(cell3));
            this.grdCr.Columns[1].Name = "Value";

            for (int i = 0; i < dataView.Table.Columns.Count; i++)
            {
                dataType = this.GetColumnDataType(dataView.Table.Columns[i].DataType.ToString());
                this.grdCr.Rows.Add(new object[] { "(none)", String.Empty });
                this.grdCr.Rows[i].HeaderCell.Value = dataView.Table.Columns[i].ColumnName;
                DataGridViewComboBoxCell cell = (DataGridViewComboBoxCell)this.grdCr[0, i];
                switch (dataType)
                {
                case ColumnDataTypes.Text:
                    cell.Items.AddRange(new object[] { "(none)", "=", ">", "<", ">=", "<=", "<>", "Like", "Not Like", "Null", "Not Null" });
                    cell.Value            = "(none)";
                    cell.MaxDropDownItems = 11;
                    break;

                case ColumnDataTypes.Integer:
                    cell.Items.AddRange(new object[] { "(none)", "=", ">", "<", ">=", "<=", "<>", "Null", "Not Null" });
                    cell.Value            = "(none)";
                    cell.MaxDropDownItems = 9;
                    break;

                case ColumnDataTypes.Float:
                    cell.Items.AddRange(new object[] { "(none)", "=", ">", "<", ">=", "<=", "<>", "Null", "Not Null" });
                    cell.Value            = "(none)";
                    cell.MaxDropDownItems = 9;
                    break;

                case ColumnDataTypes.DateTime:
                    cell.Items.AddRange(new object[] { "(none)", "=", ">", "<", ">=", "<=", "<>", "Null", "Not Null" });
                    cell.Value            = "(none)";
                    cell.MaxDropDownItems = 11;
                    break;

                case ColumnDataTypes.Boolean:
                    cell.Items.AddRange(new object[] { "(none)", "True", "False", "Null", "Not Null" });
                    cell.Value                                = "(none)";
                    cell.MaxDropDownItems                     = 5;
                    this.grdCr[1, i].Style.BackColor          = SystemColors.GradientInactiveCaption;
                    this.grdCr[1, i].Style.SelectionBackColor = SystemColors.GradientInactiveCaption;
                    this.grdCr[1, i].ReadOnly                 = true;
                    break;

                case ColumnDataTypes.NotSupported:
                    cell.Items.AddRange(new object[] { String.Empty });
                    cell.Value = "";
                    this.grdCr[0, i].Style.BackColor          = SystemColors.GradientInactiveCaption;
                    this.grdCr[0, i].Style.SelectionBackColor = SystemColors.GradientInactiveCaption;
                    this.grdCr[0, i].ReadOnly                 = true;
                    this.grdCr[1, i].Style.BackColor          = SystemColors.GradientInactiveCaption;
                    this.grdCr[1, i].Style.SelectionBackColor = SystemColors.GradientInactiveCaption;
                    this.grdCr[1, i].ReadOnly                 = true;
                    break;
                }
            }
            this.grdCr.CurrentCell = null;
        }
Exemplo n.º 5
0
        public bool ValidateInput()
        {
            ColumnDataTypes dataType = ColumnDataTypes.NotSupported;
            string          error    = String.Empty;

            DataView dataView = null;

            if (this._dataView != null)
            {
                dataView = this._dataView;
            }
            else if (this._bindingSource != null)
            {
                dataView = ((DataRowView)this._bindingSource[0]).DataView;
            }


            for (int i = 0; i < dataView.Table.Columns.Count; i++)
            {
                dataType = this.GetColumnDataType(dataView.Table.Columns[i].DataType.ToString());

                if (this.grdCr[0, i].Style.BackColor == SystemColors.Info)
                {
                    this.grdCr[0, i].Style.BackColor = this.grdCr.DefaultCellStyle.BackColor;
                }

                if (this.grdCr[1, i].Style.BackColor == SystemColors.Info)
                {
                    this.grdCr[1, i].Style.BackColor = this.grdCr.DefaultCellStyle.BackColor;
                }

                if (grdCr[1, i].Value != null && !String.IsNullOrEmpty(grdCr[1, i].Value.ToString()))
                {
                    switch (dataType)
                    {
                    case ColumnDataTypes.Integer:
                        long tmp1 = 0;
                        if (!Int64.TryParse(this.grdCr[1, i].Value.ToString(), out tmp1))
                        {
                            error += String.Format("{0} is invalid.\n", this.grdCr.Rows[i].HeaderCell.Value);
                            this.grdCr[1, i].Style.BackColor = SystemColors.Info;
                        }
                        break;

                    case ColumnDataTypes.Float:
                        double tmp2 = 0;
                        if (!Double.TryParse(this.grdCr[1, i].Value.ToString(), out tmp2))
                        {
                            error += String.Format("{0} is invalid.\n", this.grdCr.Rows[i].HeaderCell.Value);
                            this.grdCr[1, i].Style.BackColor = SystemColors.Info;
                        }
                        break;

                    case ColumnDataTypes.DateTime:
                        DateTime tmp3 = DateTime.Now;
                        if (!DateTime.TryParse(this.grdCr[1, i].Value.ToString(), out tmp3))
                        {
                            error += String.Format("{0} is invalid.\n", this.grdCr.Rows[i].HeaderCell.Value);
                            this.grdCr[1, i].Style.BackColor = SystemColors.Info;
                        }
                        break;

                    default:
                        break;
                    }
                }


                if ((((dataType != ColumnDataTypes.Boolean) && (dataType != ColumnDataTypes.NotSupported)) && ((this.grdCr[0, i].Value.ToString() != "Null") && (this.grdCr[0, i].Value.ToString() != "Not Null"))) && ((this.grdCr[0, i].Value.ToString() != "(none)") && (this.grdCr[1, i].Value == null || this.grdCr[1, i].Value.ToString() == String.Empty)))
                {
                    error += String.Format("{0} value missing.\n", this.grdCr.Rows[i].HeaderCell.Value);
                    this.grdCr[1, i].Style.BackColor = SystemColors.Info;
                }

                if ((((dataType != ColumnDataTypes.Boolean) && (dataType != ColumnDataTypes.NotSupported)) && (((this.grdCr[0, i].Value.ToString() == "Null") || (this.grdCr[0, i].Value.ToString() == "Not Null")) || (this.grdCr[0, i].Value.ToString() == "(none)"))) && (this.grdCr[1, i].Value == null || this.grdCr[1, i].Value.ToString() != String.Empty))
                {
                    error += String.Format("{0} condition missing.\n", this.grdCr.Rows[i].HeaderCell.Value);
                    this.grdCr[0, i].Style.BackColor = SystemColors.Info;
                }
            }

            if (!String.IsNullOrEmpty(error))
            {
                if (this._invalidCriteriaAction == InvalidCriteriaActions.RaiseException)
                {
                    throw new Exception(error);
                }

                MessageService.ShowError(error);
                return(false);
            }

            return(true);
        }