public void SetPopupFilters(string[] excludedcols, DataTable dt) { try { foreach (string colname in excludedcols) { if (!DictFilterPopup.ContainsKey(colname)) { DictFilterPopup.Add(colname, new FilterPopupModel() { ColumnName = colname, Caption = dt.Columns[colname].Caption, IsApplied = false }); } FilterPopupModel s = new FilterPopupModel(); bool success = DictFilterPopup.TryGetValue(colname, out s); foreach (DataRow dr in dt.Rows) { if (s.FilterData.Count(x => x.Description == dr[colname].ToString()) == 0) { s.FilterData.Add(new FilterPopupDataModel() { Description = dr[colname].ToString(), IsChecked = true }); } } s.IsApplied = false; } } catch { } }
public static void FormatWithNoStatusFilterTemplate(string colname, ref DataTable dt, Window wd, ref DataGridAutoGeneratingColumnEventArgs e, ref FrameworkElementFactory f, ref Dictionary <string, FilterPopupModel> dictFilterPopup, List <string> filterfields) { if (filterfields.Contains(colname)) { if (!dictFilterPopup.ContainsKey(colname)) { dictFilterPopup.Add(colname, new FilterPopupModel() { ColumnName = colname, Caption = dt.Columns[colname].Caption, IsApplied = false }); } FilterPopupModel s = new FilterPopupModel(); bool success = dictFilterPopup.TryGetValue(colname, out s); foreach (DataRow dr in dt.Rows) { if (s.FilterData.Count(x => x.Description == dr[colname].ToString()) == 0 && !string.IsNullOrEmpty(dr[colname].ToString())) { s.FilterData.Add(new FilterPopupDataModel() { Description = dr[colname].ToString(), IsChecked = true }); } } //sort! if (colname == "Customer" || colname == "UserName") { s.FilterData = SortPopup(s.FilterData); } e.Column = new DataGridTemplateColumn() { Header = s, HeaderStyle = wd.FindResource("ColumnHeaderStyle") as Style, HeaderTemplate = wd.FindResource("ColumnHeaderFilterTemplate") as DataTemplate, CellTemplate = new DataTemplate() { VisualTree = f }, CellStyle = wd.FindResource("CellStyle") as Style }; e.Column.SortMemberPath = colname; } else { e.Column = new DataGridTemplateColumn() { Header = dt.Columns[colname].Caption, HeaderStyle = wd.FindResource("ColumnHeaderStyle") as Style, CellTemplate = new DataTemplate() { VisualTree = f }, CellStyle = wd.FindResource("CellStyle") as Style }; e.Column.SortMemberPath = colname; } }
private void ExecuteApplyFilterPopup(object parameter) { try { FilterPopupModel s = new FilterPopupModel(); bool success = DictFilterPopup.TryGetValue(parameter.ToString(), out s); if (success) { s.IsApplied = false; foreach (FilterPopupDataModel f in s.FilterData) { if (!f.IsChecked) { s.IsApplied = true; break; } } ApplyPopupFilter(); ExecuteUpdateActivities(); ExecuteClearActivities(); ExportIsEnabled = false; } } catch { } }
private void ExecuteClearDataFilters(object parameter) { foreach (KeyValuePair <string, FilterPopupModel> fd in DictFilterPopup) { FilterPopupModel fg = fd.Value; fg.IsApplied = false; foreach (FilterPopupDataModel fdata in fg.FilterData) { fdata.IsChecked = true; } } ApplyPopupFilter(); }
private void ExecuteApplyFilterPopup(object parameter) { try { //if (SalesFunnelSelected) //{ FilterPopupModel s = new FilterPopupModel(); bool success = DictFilterPopup.TryGetValue(parameter.ToString(), out s); if (success) { s.IsApplied = false; foreach (FilterPopupDataModel f in s.FilterData) { if (!f.IsChecked) { s.IsApplied = true; break; } } ApplyPopupFilter(); } //} //else //{ // FilterPopupModel s = new FilterPopupModel(); // bool success = NewBusinessDictFilterPopup.TryGetValue(parameter.ToString(), out s); // if (success) // { // s.IsApplied = false; // foreach (FilterPopupDataModel f in s.FilterData) // { // if (!f.IsChecked) // { // s.IsApplied = true; // break; // } // } // ApplyNewBusinessPopupFilter(); // } //} } catch { } }
private void ExecuteResetFilterPopup(object parameter) { try { FilterPopupModel s = new FilterPopupModel(); bool success = DictFilterPopup.TryGetValue(parameter.ToString(), out s); if (success) { foreach (FilterPopupDataModel fm in s.FilterData) { fm.IsChecked = true; } s.IsApplied = false; ApplyPopupFilter(); } } catch { } }
private void ExecuteClearDataFilters(object parameter) { foreach (KeyValuePair <string, FilterPopupModel> fd in DictFilterPopup) { FilterPopupModel fg = fd.Value; fg.IsApplied = false; foreach (FilterPopupDataModel fdata in fg.FilterData) { fdata.IsChecked = true; } } ApplyPopupFilter(); //foreach (KeyValuePair<string, FilterPopupModel> fd2 in NewBusinessDictFilterPopup) //{ // FilterPopupModel fg2 = fd2.Value; // fg2.IsApplied = false; // foreach (FilterPopupDataModel fdata2 in fg2.FilterData) // fdata2.IsChecked = true; //} //ApplyNewBusinessPopupFilter(); }
public static void FormatWithStatusColumn(ref DataTable dt, Window wd, ref DataGridAutoGeneratingColumnEventArgs e, ref Dictionary <string, FilterPopupModel> dictFilterPopup, List <string> filterfields) { try { var f = new FrameworkElementFactory(typeof(TextBlock)); Binding b = new Binding(e.Column.Header.ToString()) { Mode = BindingMode.OneTime }; string colname = e.PropertyName; switch (colname) { case "Status": f.SetValue(TextBlock.TextAlignmentProperty, TextAlignment.Center); f.SetValue(TextBlock.TextProperty, b); if (!dictFilterPopup.ContainsKey(colname)) { dictFilterPopup.Add(colname, new FilterPopupModel() { ColumnName = colname, Caption = dt.Columns[colname].Caption, IsApplied = false }); } FilterPopupModel s = new FilterPopupModel(); bool success = dictFilterPopup.TryGetValue(colname, out s); foreach (DataRow dr in dt.Rows) { if (s.FilterData.Count(x => x.Description == dr[colname].ToString()) == 0 && !string.IsNullOrEmpty(dr[colname].ToString())) { s.FilterData.Add(new FilterPopupDataModel() { Description = dr[colname].ToString(), IsChecked = true }); } } //sort! s.FilterData = SortSFStagePopup(s.FilterData); e.Column = new DataGridTemplateColumn() { Header = s, HeaderStyle = wd.FindResource("ColumnHeaderStyle") as Style, HeaderTemplate = wd.FindResource("ColumnHeaderFilterTemplate") as DataTemplate, CellTemplate = wd.FindResource("StatusTemplate") as DataTemplate }; e.Column.SortMemberPath = colname; break; case "StatusColour": e.Cancel = true; break; case "CultureCode": e.Cancel = true; break; case "ProjectTypeColour": e.Cancel = true; break; default: if (dt.Columns[colname].ExtendedProperties.ContainsKey("FieldType") && (int)dt.Columns[colname].ExtendedProperties["FieldType"] != (int)ReportFieldType.SystemAndHidden && (int)dt.Columns[colname].ExtendedProperties["FieldType"] != (int)ReportFieldType.SystemAndRemoved) { FormatGridColumn(ref dt, colname, ref b, ref f); FormatWithNoStatusFilterTemplate(colname, ref dt, wd, ref e, ref f, ref dictFilterPopup, filterfields); } else { e.Cancel = true; } break; } } catch { } }
private void InitializePopupFilters() { try { foreach (string colname in Constants.MasterProjectsPopupList) { if (!DictFilterPopup.ContainsKey(colname)) { DictFilterPopup.Add(colname, new FilterPopupModel() { ColumnName = colname, Caption = SalesFunnel.Columns[colname].Caption, IsApplied = false }); } FilterPopupModel s = new FilterPopupModel(); bool success = DictFilterPopup.TryGetValue(colname, out s); if (colname == "SalesDivision") { foreach (ModelBaseVM ev in BusinessUnits) { s.FilterData.Add(new FilterPopupDataModel() { Description = ev.Name, IsChecked = (ev.Name == "PT") }); } s.IsApplied = true; } else if (colname == "IndustrySegment") { FullyObservableCollection <IndustrySegmentModel> mktsegs = GetIndustrySegments(); foreach (IndustrySegmentModel ev in mktsegs) { s.FilterData.Add(new FilterPopupDataModel() { Description = ev.Name, IsChecked = true }); } s.IsApplied = false; } else if (colname == "KPM") { s.FilterData.Add(new FilterPopupDataModel() { Description = "Yes", IsChecked = true }); s.FilterData.Add(new FilterPopupDataModel() { Description = "No", IsChecked = true }); s.IsApplied = false; } else if (colname == "DifferentiatedTechnology") { s.FilterData.Add(new FilterPopupDataModel() { Description = "Yes", IsChecked = true }); s.FilterData.Add(new FilterPopupDataModel() { Description = "No", IsChecked = true }); s.IsApplied = false; } else if (colname == "Application") { FullyObservableCollection <ApplicationModel> appcats = GetApplications(); foreach (ApplicationModel ev in appcats) { s.FilterData.Add(new FilterPopupDataModel() { Description = ev.Name, IsChecked = true }); } s.IsApplied = false; } else if (colname == "ProjectStatus") { FullyObservableCollection <ModelBaseVM> salesstatuses = GetSalesStatuses(); foreach (ModelBaseVM ev in salesstatuses) { s.FilterData.Add(new FilterPopupDataModel() { Description = ev.Name, IsChecked = Config.DefaultSalesStatuses.Contains(ev.ID.ToString()) ? true : false }); } s.IsApplied = true; } else if (colname == "ProjectType") { foreach (ProjectTypeModel ev in ProjectTypes) { s.FilterData.Add(new FilterPopupDataModel() { Description = ev.Name, IsChecked = true }); } s.IsApplied = false; } else if (colname == "SMCode") { FullyObservableCollection <SMCodeModel> smcodes = GetSMCodes(); foreach (SMCodeModel ev in smcodes) { if (s.FilterData.Count(x => x.Description == ev.Name) == 0) { s.FilterData.Add(new FilterPopupDataModel() { Description = ev.Name, IsChecked = true }); } } s.IsApplied = false; } else if (colname == "SalesFunnelStage") { foreach (ActivityStatusCodesModel ev in ActivityStatusCodes) { s.FilterData.Add(new FilterPopupDataModel() { Description = ev.PlaybookDescription, IsChecked = true }); } s.IsApplied = false; } else if (colname == "NewBusinessCategory") { FullyObservableCollection <ModelBaseVM> newbusinesscategories = GetNewBusinessCategories(); foreach (ModelBaseVM ev in newbusinesscategories) { s.FilterData.Add(new FilterPopupDataModel() { Description = ev.Name, IsChecked = true }); } s.IsApplied = false; } //else //if (colname == "Priority") //{ // FullyObservableCollection<ModelBaseVM> priorities = GetPriorities(); // foreach (ModelBaseVM ev in priorities) // s.FilterData.Add(new FilterPopupDataModel() { Description = ev.Name, IsChecked = true }); // s.IsApplied = false; //} else { if (colname == "Customer" || colname == "UserName") { foreach (DataRow dr in SalesFunnel.Rows) { if (s.FilterData.Count(x => x.Description == dr[colname].ToString()) == 0 && !string.IsNullOrEmpty(dr[colname].ToString())) { s.FilterData.Add(new FilterPopupDataModel() { Description = dr[colname].ToString(), IsChecked = true }); } } s.IsApplied = false; } } } } catch { } }
private void InitializePopupFilters() { try { foreach (string colname in Constants.StatusReportPopupList) { if (!DictFilterPopup.ContainsKey(colname)) { DictFilterPopup.Add(colname, new FilterPopupModel() { ColumnName = colname, Caption = Data.Columns[colname].Caption, IsApplied = false }); } FilterPopupModel s = new FilterPopupModel(); bool success = DictFilterPopup.TryGetValue(colname, out s); if (colname == "SalesDivision") { foreach (ModelBaseVM ev in BusinessUnits) { s.FilterData.Add(new FilterPopupDataModel() { Description = ev.Name, IsChecked = (ev.Name == "PT") }); } s.IsApplied = true; } else if (colname == "KPM") { s.FilterData.Add(new FilterPopupDataModel() { Description = "Yes", IsChecked = true }); s.FilterData.Add(new FilterPopupDataModel() { Description = "No", IsChecked = true }); s.IsApplied = false; } else if (colname == "ProjectStatus") { foreach (EnumValue ev in EnumerationLists.ProjectStatusTypesList) { s.FilterData.Add(new FilterPopupDataModel() { Description = ev.Description, IsChecked = (ev.Description == "Active") }); } s.IsApplied = true; } else if (colname == "ProjectType") { foreach (ProjectTypeModel ev in ProjectTypes) { s.FilterData.Add(new FilterPopupDataModel() { Description = ev.Name, IsChecked = true }); } s.IsApplied = false; } else if (colname == "SalesFunnelStage") { foreach (ActivityStatusCodesModel ev in ActivityStatusCodes) { s.FilterData.Add(new FilterPopupDataModel() { Description = ev.PlaybookDescription, IsChecked = true }); } s.IsApplied = false; } else { if (colname == "Customer" || colname == "UserName") { foreach (DataRow dr in Data.Rows) { if (s.FilterData.Count(x => x.Description == dr[colname].ToString()) == 0 && !string.IsNullOrEmpty(dr[colname].ToString())) { s.FilterData.Add(new FilterPopupDataModel() { Description = dr[colname].ToString(), IsChecked = true }); } } s.IsApplied = false; } } } } catch { } }
private void ReportGrid_AutoGeneratingColumn(object sender, DataGridAutoGeneratingColumnEventArgs e) { try { var f = new FrameworkElementFactory(typeof(TextBlock)); Binding b = new Binding(e.Column.Header.ToString()) { Mode = BindingMode.OneTime }; string colname = e.PropertyName; switch (colname) { case "SalesFunnelStage": f.SetValue(TextBlock.TextAlignmentProperty, TextAlignment.Center); f.SetValue(TextBlock.TextProperty, b); if (!dictFilterPopup.ContainsKey(colname)) { dictFilterPopup.Add(colname, new FilterPopupModel() { ColumnName = colname, Caption = dt.Columns[colname].Caption, IsApplied = false }); } FilterPopupModel s = new FilterPopupModel(); bool success = dictFilterPopup.TryGetValue(colname, out s); foreach (DataRow dr in dt.Rows) { if (s.FilterData.Count(x => x.Description == dr[colname].ToString()) == 0 && !string.IsNullOrEmpty(dr[colname].ToString())) { s.FilterData.Add(new FilterPopupDataModel() { Description = dr[colname].ToString(), IsChecked = true }); } } //sort! s.FilterData = StaticCollections.SortSFStagePopup(s.FilterData); e.Column = new DataGridTemplateColumn() { Header = s, HeaderStyle = FindResource("ColumnHeaderStyle") as Style, HeaderTemplate = FindResource("ColumnHeaderFilterTemplate") as DataTemplate, CellTemplate = FindResource("SalesFunnelStageTemplate") as DataTemplate, CellStyle = FindResource("CellStyle") as Style }; e.Column.SortMemberPath = colname; break; case "StatusColour": e.Cancel = true; break; case "ProjectTypeColour": e.Cancel = true; break; default: if (dt.Columns[colname].ExtendedProperties.ContainsKey("FieldType") && (int)dt.Columns[colname].ExtendedProperties["FieldType"] != (int)ReportFieldType.SystemAndHidden && (int)dt.Columns[colname].ExtendedProperties["FieldType"] != (int)ReportFieldType.SystemAndRemoved) { StaticCollections.FormatGridColumn(ref dt, colname, ref b, ref f); if (dt.Columns[colname].ExtendedProperties.ContainsKey("FieldType") && (int)dt.Columns[colname].ExtendedProperties["FieldType"] == (int)ReportFieldType.PlaybookComments) { //comments e.Column = new DataGridTemplateColumn() { Header = dt.Columns[colname].Caption, Width = 120, HeaderStyle = FindResource("ColumnHeaderStyle") as Style, CellTemplate = new DataTemplate() { VisualTree = f }, }; } else //other non-comments colummns { StaticCollections.FormatWithNoStatusFilterTemplate(colname, ref dt, this, ref e, ref f, ref dictFilterPopup, Constants.MasterProjectsPopupList); } } else { e.Cancel = true; } break; } } catch { } }