예제 #1
0
        private void ConfigureOrganisationReferences()
        {
            // Add any custom organisation reference fields
            Facade.IOrganisation facOrganisation = new Facade.Organisation();
            var organisationReferences           = facOrganisation.GetAllOrganisationReferences().Tables[0].AsEnumerable();

            if (organisationReferences.Any())
            {
                var groupedReferences = organisationReferences.GroupBy(or => or.Field <string>("Description"));

                foreach (var gr in groupedReferences)
                {
                    var columnDescription = gr.Key;
                    var uniqueName        = OrganisationReferenceColumnUniqueName(columnDescription);

                    // Add a check box to allow the user to toggle visibility of this column
                    var listItem = new ListItem(columnDescription, uniqueName);
                    listItem.Attributes["title"] = gr.Count() > 10 ? string.Format("{0} clients", gr.Count()) : Entities.Utilities.MergeStrings("\n", gr.Select(or => or.Field <string>("OrganisationName")));
                    this.cblOrganisationReferenceColumns.Items.Add(listItem);

                    // Add the column to the grid
                    var column = new GridTemplateColumn();
                    this.grdOrders.MasterTableView.Columns.Add(column);
                    column.UniqueName = uniqueName;
                    column.HeaderText = columnDescription;
                    column.Visible    = false;
                }
            }
        }