コード例 #1
0
        /// <summary>
        /// Returns a js array used by client to populate dropdowns
        /// </summary>
        /// <returns></returns>
        public string GetCallbackResult()
        {
            string[]            keys            = _callbackOrgId.Split(';');
            string              orgId           = keys[0];
            string              contactClientId = keys[1];
            ProjectManagementDa da = new ProjectManagementDa();

            DataTable contacts     = da.GetAllContactsByOrgId(int.Parse(orgId));
            string    clientArray  = PageUtil.DataTableToJSArray(contacts, new string[] { "Name", "ContactId" }, true);
            string    clientObject = "['" + contactClientId + "'," + clientArray + " ]";

            return(clientObject);
        }
コード例 #2
0
        protected void menuFilter_MenuItemClick(object sender, MenuEventArgs e)
        {
            MenuItem item = (MenuItem)e.Item;

            if (item.ValuePath.StartsWith("Organization"))
            {
                ProjectManagementDa projDA = new ProjectManagementDa();
                ContactsGrid.DataSource = CombineRows(projDA.GetAllContactsByOrgId(Int32.Parse(item.Value)), "Organization");
            }
            else if (item.ValuePath.StartsWith("Protocols"))
            {
                ProjectManagementDa projDA = new ProjectManagementDa();
                ContactsGrid.DataSource = CombineRows(projDA.GetAllContactsByProtocol(Int32.Parse(item.Value)), "Organization");
            }

            ContactsGrid.DataBind();
        }
コード例 #3
0
        protected void BindOrganizationsAndContacts(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                // Get the org drop down, contact drop down and contactid hidden field
                CaisisSelect organizationIdField = e.Row.FindControl("OrganizationEdit") as CaisisSelect;
                HtmlSelect   contactDropDown     = e.Row.FindControl("ContactNameEdit") as HtmlSelect;
                CaisisHidden contactIdField      = e.Row.FindControl("ContactId") as CaisisHidden;

                // Attach change events to the dropdowns to handle respective client events
                string onOrgChange = "onOrgChange(this,'" + organizationIdField.ClientID + "','" + contactDropDown.ClientID + "');";
                PageUtil.AttachClientEventToControl(organizationIdField as WebControl, "onchange", onOrgChange);
                string onContactSelChange = "copyToContactId(this,'" + contactIdField.ClientID + "');";
                contactDropDown.Attributes["onchange"] = onContactSelChange;

                // Populate Organizations and Contacts
                organizationIdField.DataSource = orgList;
                organizationIdField.DataBind();

                string orgId = DataBinder.Eval(e.Row.DataItem, "OrganizationId").ToString();
                // Set selected orgid
                organizationIdField.Value = orgId;

                // Populate Contacts
                if (!string.IsNullOrEmpty(orgId))
                {
                    ProjectManagementDa da       = new ProjectManagementDa();
                    DataTable           contacts = da.GetAllContactsByOrgId(int.Parse(orgId));
                    contactDropDown.DataSource = contacts;
                    contactDropDown.DataBind();
                    // Add blank item at beginning
                    contactDropDown.Items.Insert(0, new ListItem(string.Empty, string.Empty));

                    // Set value of associated contact
                    string contactId = DataBinder.Eval(e.Row.DataItem, "ContactId").ToString();
                    if (!string.IsNullOrEmpty(contactId))
                    {
                        contactDropDown.Value = contactId;
                        contactIdField.Value  = contactId;
                    }
                }
            }
        }
コード例 #4
0
        protected void OnContactsOrgBind(object sender, RepeaterItemEventArgs e)
        {
            Repeater contactsRptr       = sender as Repeater;
            Repeater singleContactsRptr = e.Item.FindControl("SingleContactsRptr") as Repeater;

            if (singleContactsRptr != null)
            {
                int orgId = int.Parse(DataBinder.Eval(e.Item.DataItem, ProjectOrganization.OrganizationId).ToString());
                ProjectManagementDa da = new ProjectManagementDa();

                DataView view;

                List <string> associatedContacts = new List <string>();
                DataTable     tmp = da.GetAllContactsByOrgId(orgId);
                if (tmp.Rows.Count > 0)
                {
                    foreach (DataRow row in tmp.Rows)
                    {
                        string contactId = row[Contact.ContactId].ToString();
                        associatedContacts.Add(contactId);
                    }
                    view = da.GetProjectContactsByProjectId(projectId).DefaultView;
                    string uniqueContacts = String.Join(",", associatedContacts.ToArray());
                    string rowFilter      = "ContactId IN (" + uniqueContacts + ")";
                    view.RowFilter = rowFilter;
                    if (view.Table.Select(rowFilter).Length == 0)
                    {
                        e.Item.Visible = false;
                    }
                }
                else
                {
                    e.Item.Visible = false;
                    return;
                }



                singleContactsRptr.DataSource = view;
                singleContactsRptr.DataBind();
            }
        }
コード例 #5
0
        private void LoadContactsGrid()
        {
            ProjectManagementDa projDA             = new ProjectManagementDa();
            DataTable           contactsDataSource = new DataTable();

            string     filterBy   = Request.QueryString["FilterBy"];
            ContactsDa contactsDa = new ContactsDa();

            if (isAdmin)
            {
                contactsDataSource = contactsDa.GetAllContacts();
            }
            else if (string.IsNullOrEmpty(filterBy))
            {
                if (contactType == "Project")
                {
                    contactsDataSource = CombineRows(projDA.GetAllContactsWithOrgNameByProjectId(projectId), "Organization");
                }
                else
                {
                    if (!string.IsNullOrEmpty(contactType))
                    {
                        contactsDataSource = contactsDa.GetContactByContactType(contactType);
                    }
                }
            }
            else
            {
                switch (filterBy)
                {
                case ("Organization"):
                    contactsDataSource = CombineRows(projDA.GetAllContactsByOrgId(Int32.Parse(Request.QueryString["FilterID"])), "Organization");
                    break;

                case ("Protocols"):
                    contactsDataSource = CombineRows(projDA.GetAllContactsByProtocol(Int32.Parse(Request.QueryString["FilterID"])), "Organization");
                    break;

                case ("Projects"):
                    contactsDataSource = CombineRows(projDA.GetAllContactsWithOrgNameByProjectId(Int32.Parse(Request.QueryString["FilterID"])), "Organization");
                    break;

                default:
                    break;
                }
            }

            // Bind grid to datasource
            ContactsGrid.DataSource = contactsDataSource;
            ContactsGrid.DataBind();

            // Determine if there are any records and show message
            if (contactsDataSource.Rows.Count == 0)
            {
                EmptyMessageLabel.Visible = true;
            }
            else
            {
                EmptyMessageLabel.Visible = false;
            }
        }