/// <summary>
        /// Event handler for the click event of Clear Filter button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void clearFilterButton_Click(object sender, ImageClickEventArgs e)
        {
            try
            {
                //For each data bound and displayed column in the grid, clear its filter
                foreach (GridColumn c in this.Owner.Columns)
                {
                    IndGridBoundColumn col = c as IndGridBoundColumn;
                    if (col != null && col.Display)
                    {
                        col.CurrentFilterFunction = GridKnownFunction.NoFilter;
                        col.CurrentFilterValue    = String.Empty;
                    }
                }

                IndCatGrid parentGrid = (IndCatGrid)this.Owner.OwnerGrid;


                parentGrid.IndFilterExpression = String.Empty;
                parentGrid.IndFilterItem       = new IndFilterItem();

                parentGrid.Rebind();
            }
            catch (IndException ex)
            {
                ControlHierarchyManager.ReportError(ex);
                return;
            }
            catch (Exception ex)
            {
                ControlHierarchyManager.ReportError(new IndException(ex));
                return;
            }
        }
Example #2
0
        private void filterButton_Click(object sender, ImageClickEventArgs e)
        {
            try
            {
                //StringBuilder filterExpression = new StringBuilder();
                ((IndCatGrid)this.Owner.OwnerGrid).IndFilterItem = new IndFilterItem();

                foreach (GridColumn c in this.Owner.Columns)
                {
                    IndGridBoundColumn col = c as IndGridBoundColumn;
                    string             comparerStart;
                    string             comparerEnd;
                    GridKnownFunction  function;
                    if (col != null && col.Display)
                    {
                        SetFilterParameters(col, out comparerStart, out comparerEnd, out function);

                        if (col.Cell.Controls.Count > 2)
                        {
                            FilterSpecialColumn(col, ((IndCatGrid)this.Owner.OwnerGrid).IndFilterItem, comparerStart, comparerEnd, function);
                        }
                        else
                        {
                            TextBox t = (TextBox)col.Cell.Controls[0];
                            decimal value;
                            if (IsColumnNumeric(col) && decimal.TryParse(t.Text, out value) == false)
                            {
                                col.CurrentFilterValue = String.Empty;
                                continue;
                            }
                            FilterCommonColumn(col, t.Text.Replace("'", "''"), ((IndCatGrid)this.Owner.OwnerGrid).IndFilterItem, comparerStart, comparerEnd, function);
                        }
                    }
                }

                IndCatGrid parentGrid = (IndCatGrid)this.Owner.OwnerGrid;

                if (parentGrid.IndFilterItem.FilterExpression.Length > 0)
                {
                    parentGrid.IndFilterItem.FilterExpression.Append(")");
                }
                parentGrid.IndFilterExpression = parentGrid.IndFilterItem.FilterExpression.ToString();


                this.Owner.OwnerGrid.Rebind();
            }
            catch (IndException ex)
            {
                ControlHierarchyManager.ReportError(ex);
                return;
            }
            catch (Exception ex)
            {
                ControlHierarchyManager.ReportError(new IndException(ex));
                return;
            }
        }
Example #3
0
        private void AddDataColumns(DataSet sourceDS)
        {
            //For each column in the dataset
            foreach (DataColumn dataColumn in sourceDS.Tables[0].Columns)
            {
                //Build a new grid column, bound to the column in the dataset
                IndGridBoundColumn column = new IndGridBoundColumn();
                column.IsBooleanColumn = false;
                if (dataColumn.ExtendedProperties.Count != 0)
                {
                    if (dataColumn.ExtendedProperties.Contains("type"))
                    {
                        if (dataColumn.ExtendedProperties["type"].ToString().ToLower().Contains("bool"))
                        {
                            column = new IndBoolGridBoundColumn();
                        }
                    }
                    //Do not add columns that should not be added in the grid (this is set in DSUtils.ReplaceBooleanColumn() method)
                    if (dataColumn.ExtendedProperties.Contains("AddInGrid"))
                    {
                        if ((bool)dataColumn.ExtendedProperties["AddInGrid"] == false)
                        {
                            continue;
                        }
                    }
                }


                this.MasterTableView.Columns.Add(column);

                if (dataColumn.ColumnName == "LogicalKey")
                {
                    column.Display = false;
                    column.HeaderStyle.CssClass = "GridElements_IndGenericGrid_Hide";
                    column.ItemStyle.CssClass   = "GridElements_IndGenericGrid_Hide";
                }

                //Set the column data type, data field and header text
                column.DataType   = dataColumn.DataType;
                column.DataField  = dataColumn.ColumnName;
                column.HeaderText = dataColumn.ColumnName;
                column.Resizable  = false;
            }
        }
Example #4
0
 private void FilterCommonColumn(IndGridBoundColumn col, string value, IndFilterItem filterItem, string comparerStart, string comparerEnd, GridKnownFunction function)
 {
     if (String.IsNullOrEmpty(value))
     {
         col.CurrentFilterFunction = function;
         col.CurrentFilterValue    = value;
         return;
     }
     if (filterItem.FilterExpression.Length == 0)
     {
         filterItem.FilterExpression.Append("([" + col.UniqueName + "] " + comparerStart + value + comparerEnd);
     }
     else
     {
         filterItem.FilterExpression.Append(" AND [" + col.UniqueName + "] " + comparerStart + value + comparerEnd);
     }
     col.CurrentFilterFunction = function;
     col.CurrentFilterValue    = value.Replace("''", "'");
     filterItem.FilterValues.Add(col.UniqueName, value.Replace("''", "'"));
 }
Example #5
0
        private void FilterSpecialColumn(IndGridBoundColumn col, IndFilterItem filterItem, string comparerStart, string comparerEnd, GridKnownFunction function)
        {
            if (col.Cell.Controls[1] is DropDownList)
            {
                DropDownList d = (DropDownList)col.Cell.Controls[1];
                if (filterItem.FilterExpression.Length == 0)
                {
                    filterItem.FilterExpression.Append("([" + col.UniqueName + "] " + comparerStart + ((d.SelectedValue == "All") ? String.Empty : d.SelectedValue) + comparerEnd);
                }
                else
                {
                    filterItem.FilterExpression.Append(" AND [" + col.UniqueName + "] " + comparerStart + ((d.SelectedValue == "All") ? String.Empty : d.SelectedValue) + comparerEnd);
                }
                col.CurrentFilterFunction = function;
                col.CurrentFilterValue    = ((d.SelectedValue == "All") ? String.Empty : d.SelectedValue);
                filterItem.FilterValues.Add(col.UniqueName, (d.SelectedValue == "All") ? String.Empty : d.SelectedValue);
            }

            if (col.Cell.Controls[1] is IndDatePicker)
            {
                IndDatePicker datePicker = (IndDatePicker)col.Cell.Controls[1];
                if (datePicker.SelectedDate != null)
                {
                    if (filterItem.FilterExpression.Length == 0)
                    {
                        filterItem.FilterExpression.Append("([" + col.UniqueName + "] >= '" + ((DateTime)datePicker.SelectedDate).ToShortDateString() + " 00:00:00.000' AND " +
                                                           "[" + col.UniqueName + "] <= '" + ((DateTime)datePicker.SelectedDate).ToShortDateString() + " 23:59:59.999'");
                    }
                    else
                    {
                        filterItem.FilterExpression.Append(" AND [" + col.UniqueName + "] >= '" + ((DateTime)datePicker.SelectedDate).ToShortDateString() + " 00:00:00.000' AND " +
                                                           "[" + col.UniqueName + "] <= '" + ((DateTime)datePicker.SelectedDate).ToShortDateString() + " 23:59:59.999'");
                    }
                }
                col.CurrentFilterFunction = function;
                col.CurrentFilterValue    = (datePicker.SelectedDate != null) ? ((DateTime)datePicker.SelectedDate).ToShortDateString() : null;
                filterItem.FilterValues.Add(col.UniqueName, (datePicker.SelectedDate != null) ? ((DateTime)datePicker.SelectedDate).ToShortDateString() : String.Empty);
            }
        }
Example #6
0
 private void SetFilterParameters(IndGridBoundColumn col, out string comparerStart, out string comparerEnd, out GridKnownFunction function)
 {
     comparerStart = String.Empty;
     comparerEnd   = String.Empty;
     function      = GridKnownFunction.NoFilter;
     if (IsColumnNumeric(col))
     {
         comparerStart = "= ";
         comparerEnd   = String.Empty;
         function      = GridKnownFunction.EqualTo;
     }
     if (col.DataType == typeof(string))
     {
         comparerStart = "LIKE '%";
         comparerEnd   = "%'";
         function      = GridKnownFunction.Contains;
     }
     if (col.DataType == typeof(DateTime))
     {
         //comparerStart = "= '";
         //comparerEnd = "'";
         function = GridKnownFunction.Between;
     }
 }
Example #7
0
 private bool IsColumnNumeric(IndGridBoundColumn col)
 {
     return(col.DataType == typeof(int) || col.DataType == typeof(decimal));
 }