예제 #1
0
        private void ProjectList_AutoGeneratingColumn(object sender, DataGridAutoGeneratingColumnEventArgs e)
        {
            try
            {
                var     f = new FrameworkElementFactory(typeof(TextBlock));
                Binding b = new Binding(e.Column.Header.ToString())
                {
                    Mode = BindingMode.OneWay,
                };
                string colname = e.PropertyName;
                switch (colname)
                {
                case "StatusColour":
                    e.Cancel = true;
                    break;

                case "Colour":
                    e.Cancel = true;
                    break;

                case "ProjectTypeColour":
                    e.Cancel = true;
                    break;

                case "Actions":
                    f.SetValue(TextBlock.TextAlignmentProperty, TextAlignment.Center);
                    f.SetValue(TextBlock.TextProperty, b);

                    e.Column = new DataGridTemplateColumn()
                    {
                        Header       = dt.Columns[colname].Caption,
                        HeaderStyle  = FindResource("ColumnHeaderStyle") as Style,
                        CellTemplate = FindResource("ActionsTemplate") as DataTemplate
                    };
                    break;

                default:
                    StaticCollections.FormatGridColumn(ref dt, colname, ref b, ref f);

                    if (dt.Columns[colname].ExtendedProperties.ContainsKey("FieldType") && (int)dt.Columns[colname].ExtendedProperties["FieldType"] == (int)ReportFieldType.General)
                    {
                        StaticCollections.FormatWithNoStatusFilterTemplate(colname, ref dt, this, ref e, ref f, ref dictFilterPopup, Constants.MainviewPopupList);
                    }
                    else
                    {
                        e.Cancel = true;
                    }
                    break;
                }
            }
            catch
            {
            }
        }
예제 #2
0
        public static DataTable FilterDataTable(DataTable masterprojectlist, List <string> FieldList, Dictionary <string, FilterPopupModel> DictFilterPopup)
        {
            Dictionary <string, List <string> > locdictFilterPopup = new Dictionary <string, List <string> >();

            foreach (string s in FieldList)
            {
                if (DictFilterPopup[s].IsApplied)
                {
                    locdictFilterPopup.Add(s, DictFilterPopup[s].FilterData.Where(y => y.IsChecked == true).Select(x => x.Description).ToList <string>());
                }
            }

            string s1  = "";
            int    ctr = 0;

            List <string>[] arrayoflists = new List <string> [locdictFilterPopup.Count()];
            foreach (var c in locdictFilterPopup)
            {
                if (ctr > 0)
                {
                    s1 = s1 + " And ";
                }
                s1 = s1 + "@" + ctr.ToString() + ".Contains(outerIt[\"" + c.Key + "\"].ToString())";
                arrayoflists[ctr] = locdictFilterPopup[c.Key];
                ctr++;
            }
            IQueryable <DataRow> t1;

            if (locdictFilterPopup.Count() > 0)
            {
                t1 = masterprojectlist.AsEnumerable().AsQueryable().Where(s1, arrayoflists);
                if (t1.Count() > 0)
                {
                    DataTable tblFiltered = t1.CopyToDataTable();
                    StaticCollections.ReFormatColumns(ref masterprojectlist, ref tblFiltered);
                    return(tblFiltered);
                }
                else
                {
                    return(masterprojectlist.Clone());
                }
            }
            else
            {
                return(masterprojectlist);
            }
        }