Beispiel #1
0
 /// <summary>
 /// Initializes a new instance of the class.
 /// </summary>
 public FrmFilter(DataGridView dataGridView)
     : this()
 {
     this.dataGridView = dataGridView ?? throw new ArgumentNullException("dataGridView");
     currentFilter     = null;
     DataTable         = null;
 }
Beispiel #2
0
 /// <summary>
 /// Initializes a new instance of the class.
 /// </summary>
 public FrmFilter(DataGridView dataGridView, DataTable dataTable)
     : this()
 {
     this.dataGridView = dataGridView ?? throw new ArgumentNullException(nameof(dataGridView));
     this.dataTable    = dataTable ?? throw new ArgumentNullException(nameof(dataTable));
     currentFilter     = null;
     FormTranslator.Translate(this, GetType().FullName);
 }
Beispiel #3
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     try
     {
         currentFilter = CreateFilter(SelectedColumnInfo);
         dataTable.DefaultView.RowFilter = currentFilter == null ? "" : currentFilter.GetRowFilter();
         DialogResult = DialogResult.OK;
     }
     catch
     {
         ScadaUiUtils.ShowError(AppPhrases.IncorrectTableFilter);
     }
 }
Beispiel #4
0
        /// <summary>
        /// Creates a new filter according to the controls.
        /// </summary>
        private FilterExtended CreateFilter(ColumnInfo columnInfo)
        {
            FilterExtended filter = new FilterExtended
            {
                ColumnName      = columnInfo.Column.Name,
                StringOperation = cbStringOperation.SelectedIndex,
                MathOperation   = cbMathOperation.SelectedIndex
            };

            if (columnInfo.IsText)
            {
                filter.Value = columnInfo.IsNumber ? (object)ScadaUtils.ParseDouble(txtValue.Text) : txtValue.Text;
            }
            else if (columnInfo.IsComboBox)
            {
                filter.Value = (cbValue.SelectedValue is int val) ? val : -1;
            }
            else if (columnInfo.IsCheckBox)
            {
                filter.Value = cbBoolean.SelectedIndex > 0;
            }

            return(filter);
        }
Beispiel #5
0
 private void btnClearFilter_Click(object sender, EventArgs e)
 {
     currentFilter = null;
     dataTable.DefaultView.RowFilter = "";
     DialogResult = DialogResult.OK;
 }