示例#1
0
        protected void SaveClick(object sender, EventArgs e)
        {
            Contact contact = new Contact();
            bool    isNew   = !ContactId.HasValue;

            // edit user
            if (ContactId.HasValue)
            {
                contact.Get(ContactId.Value);
            }
            CICHelper.SetBOValues(EditPanel.Controls, contact, -1);
            if (!contact.IsEmpty)
            {
                contact.Save();

                // associate organization
                string organizationId = Request.QueryString["organizationId"];
                if (isNew && !string.IsNullOrEmpty(organizationId))
                {
                    ProjectOrganization_ProjectContact contactOrg = new ProjectOrganization_ProjectContact();
                    contactOrg[ProjectOrganization_ProjectContact.ContactId]      = (int)contact[contact.PrimaryKeyName];
                    contactOrg[ProjectOrganization_ProjectContact.OrganizationId] = int.Parse(organizationId);
                    contactOrg[ProjectOrganization_ProjectContact.ContactType]    = 0;
                    contactOrg.Save();
                }
                ReloadMain(false);
            }
            else
            {
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "errorUpdating", "alert('Please validate all required fields.');", true);
            }
        }
        private int AddOrganizationContact(int organizationId, int contactId)
        {
            ProjectOrganization_ProjectContact organizationContact = new ProjectOrganization_ProjectContact();

            organizationContact[ProjectOrganization_ProjectContact.OrganizationId] = organizationId;
            organizationContact[ProjectOrganization_ProjectContact.ContactId]      = contactId;
            organizationContact[ProjectOrganization_ProjectContact.ContactType]    = 0;
            organizationContact.Save();
            return((int)organizationContact[organizationContact.PrimaryKeyName]);
        }