Exemple #1
0
        /// <summary>
        /// Builds a list of Organizations associated with the current Project
        /// </summary>
        private void BuildOrganizations()
        {
            var organizations = BusinessObject.GetAllAsDataView <ProjectOrganization>();

            organizations.Sort           = ProjectOrganization.Name + " ASC";
            OrganizationsRptr.DataSource = organizations;
            OrganizationsRptr.DataBind();

            NoResultsMsg.Visible = organizations.Count == 0;
        }
Exemple #2
0
        private void BuildProtocolOrganizations(int protocolId)
        {
            var      organizations = BusinessObject.GetAll <ProjectOrganization>();
            Protocol protocol      = new Protocol();

            protocol.Get(protocolId);
            if (!protocol.IsNull(Protocol.ProjectId))
            {
                int     projectId = (int)protocol[Protocol.ProjectId];
                Project project   = new Project();
                project.Get(projectId);
                string projectName = project[Project.Title].ToString();

                // get contacts
                ContactsDa da           = new ContactsDa();
                var        userContacts = da.GetAllContactsAndUser();

                var projectOrganizations = BusinessObject.GetByFields <Project_ProjectOrganization>(new Dictionary <string, object> {
                    { Project_ProjectOrganization.ProjectId, projectId }
                });
                var data_source = from organization in organizations
                                  let organizationId = (int)organization[ProjectOrganization.OrganizationId]
                                                       join po in projectOrganizations on organizationId equals(int) po[Project_ProjectOrganization.OrganizationId] into g
                                                       let organizationName = organization[ProjectOrganization.Name].ToString()
                                                                              let organizationType = g.Count() > 0 ? g.First()[Project_ProjectOrganization.OrganizationType] + "" : ""
                                                                                                     orderby organizationName ascending
                                                                                                     let contacts = (from contact in userContacts.AsEnumerable()
                                                                                                                         where !contact.IsNull(ProjectOrganization_ProjectContact.OrganizationId)
                                                                                                                         where (int)contact[ProjectOrganization_ProjectContact.OrganizationId] == organizationId
                                                                                                                     let lastName = contact[Contact.LastName].ToString()
                                                                                                                                    let firstName = contact[Contact.FirstName].ToString()
                                                                                                                                                    orderby lastName ascending
                                                                                                                                                    select lastName + ", " + firstName).Distinct()
                                                                                                                    select new
                {
                    Name                  = organizationName,
                    OrganizationId        = organizationId,
                    OrganizationType      = organizationType,
                    ProjectOrganizationId = g.Count() > 0 ? g.First()[Project_ProjectOrganization.ProjectOrganizationId] + "" : "",
                    Contacts              = contacts.Count() > 0 ? Server.HtmlEncode("CONTACTS \n" + string.Join("\n", contacts.ToArray())) : "NO CONTACTS"
                };

                updateItems.Clear();

                OrganizationsRptr.DataSource = data_source;
                OrganizationsRptr.DataBind();

                // show data entry panel
                DataEntryPanel.Visible = true;
                ProjectLabel.Text      = "PROJECT: " + projectName;

                ProjectIdField.Value = projectId.ToString();
            }
        }