private void btnSend_Click(object sender, EventArgs e) { int groupid = -1; string strLeaderEmail = ""; string strClusterLeaderEmail = ""; foreach (DataGridItem item in dgResults.Items) { RadioButton rb = (RadioButton)item.FindControl("rbSelect"); if (rb.Checked) { groupid = Int32.Parse(rb.Attributes["groupid"]); break; } } bool sendClusterLeaderEmail = bool.Parse(SendClusterLeaderEmailSetting); Group group = new Group(groupid); strLeaderEmail = group.Leader.Emails.FirstActive; if (strLeaderEmail.Length == 0 || sendClusterLeaderEmail) { GroupCluster parentCluster = group.GroupCluster; while (parentCluster.GroupClusterID != -1) { if (parentCluster.Leader.Emails.FirstActive != string.Empty) { strLeaderEmail = (!string.IsNullOrEmpty(strLeaderEmail) ? strLeaderEmail : parentCluster.Leader.Emails.FirstActive); strClusterLeaderEmail = parentCluster.Leader.Emails.FirstActive; break; } else if (parentCluster.Admin != null && parentCluster.Admin.PersonID != parentCluster.Leader.PersonID && parentCluster.Admin.Emails.FirstActive != string.Empty) { strLeaderEmail = (!string.IsNullOrEmpty(strLeaderEmail) ? strLeaderEmail : parentCluster.Admin.Emails.FirstActive); strClusterLeaderEmail = parentCluster.Admin.Emails.FirstActive; break; } parentCluster = new GroupCluster(parentCluster.ParentClusterID); } } if (strLeaderEmail.Length == 0 && GroupLeaderEmailSetting != string.Empty) { strLeaderEmail = GroupLeaderEmailSetting; } else if (strLeaderEmail.Length == 0) { strLeaderEmail = CurrentOrganization.Settings["GroupLocatorEmail"]; } SmallGroupLocator smallGroupLocator = new SmallGroupLocator(); Dictionary <string, string> fields = new Dictionary <string, string>(); fields.Add("##GroupName##", group.Title); fields.Add("##GroupID##", group.GroupID.ToString()); fields.Add("##Name##", tbName.Text); fields.Add("##Phone##", tbPhone.PhoneNumber); fields.Add("##Email##", tbEmail.Text); fields.Add("##Notes##", tbNotes.Text); smallGroupLocator.Send(strLeaderEmail, fields); if (sendClusterLeaderEmail && strLeaderEmail != strClusterLeaderEmail) { smallGroupLocator.Send(strClusterLeaderEmail, fields); } //set pending registratant if (PendingRegistraintSetting.ToLower() == "true" && CurrentPerson != null && CurrentPerson.PersonID != -1) { Registration registration = new Registration(); registration.OrganizationID = CurrentPortal.OrganizationID; if (_useGroupType) { Lookup grpType = group.GroupType; try { registration.ClusterType = new ClusterType(Int32.Parse(grpType.Qualifier)); } catch { throw new ArenaApplicationException(string.Format("Invalid Cluster Type ID for Small Group Type '{0}'", grpType.Value)); } registration.GroupType = grpType; } else { registration.ClusterType = group.ClusterType; registration.GroupType = null; } if (group.GroupType.ToString() != string.Empty) { registration.GroupType = group.GroupType; } registration.Notes = tbNotes.Text; registration.Persons.Add(CurrentPerson); registration.DayOfWeek.Add(group.MeetingDay); registration.AgeRange.Add(group.PrimaryAge); registration.MaritalPreference.Add(group.PrimaryMaritalStatus); registration.SetCluster(); registration.GroupID = group.GroupID; registration.Save(CurrentPortal.OrganizationID, CurrentUser.Identity.Name); } Response.Redirect(string.Format("~/default.aspx?page={0}", RedirectPageIDSetting.ToString()), true); }
private void btnSend_Click(object sender, EventArgs e) { int groupid = -1; string strLeaderEmail = ""; string strClusterLeaderEmail = ""; foreach (DataGridItem item in dgResults.Items) { RadioButton rb = (RadioButton)item.FindControl("rbSelect"); if (rb.Checked) { groupid = Int32.Parse(rb.Attributes["groupid"]); break; } } bool sendClusterLeaderEmail = bool.Parse(SendClusterLeaderEmailSetting); Group group = new Group(groupid); strLeaderEmail = group.Leader.Emails.FirstActive; if (strLeaderEmail.Length == 0 || sendClusterLeaderEmail) { GroupCluster parentCluster = group.GroupCluster; while (parentCluster.GroupClusterID != -1) { if (parentCluster.Leader.Emails.FirstActive != string.Empty) { strLeaderEmail = (!string.IsNullOrEmpty(strLeaderEmail) ? strLeaderEmail : parentCluster.Leader.Emails.FirstActive); strClusterLeaderEmail = parentCluster.Leader.Emails.FirstActive; break; } else if (parentCluster.Admin != null && parentCluster.Admin.PersonID != parentCluster.Leader.PersonID && parentCluster.Admin.Emails.FirstActive != string.Empty) { strLeaderEmail = (!string.IsNullOrEmpty(strLeaderEmail) ? strLeaderEmail : parentCluster.Admin.Emails.FirstActive); strClusterLeaderEmail = parentCluster.Admin.Emails.FirstActive; break; } parentCluster = new GroupCluster(parentCluster.ParentClusterID); } } if (strLeaderEmail.Length == 0 && GroupLeaderEmailSetting != string.Empty) strLeaderEmail = GroupLeaderEmailSetting; else if (strLeaderEmail.Length == 0) strLeaderEmail = CurrentOrganization.Settings["GroupLocatorEmail"]; SmallGroupLocator smallGroupLocator = new SmallGroupLocator(); Dictionary<string, string> fields = new Dictionary<string, string>(); fields.Add("##GroupName##", group.Title); fields.Add("##GroupID##", group.GroupID.ToString()); fields.Add("##Name##", tbName.Text); fields.Add("##Phone##", tbPhone.PhoneNumber); fields.Add("##Email##", tbEmail.Text); fields.Add("##Notes##", tbNotes.Text); smallGroupLocator.Send(strLeaderEmail, fields); if (sendClusterLeaderEmail && strLeaderEmail != strClusterLeaderEmail) smallGroupLocator.Send(strClusterLeaderEmail, fields); //set pending registratant if (PendingRegistraintSetting.ToLower() == "true" && CurrentPerson != null && CurrentPerson.PersonID != -1) { Registration registration = new Registration(); registration.OrganizationID = CurrentPortal.OrganizationID; if (_useGroupType) { Lookup grpType = group.GroupType; try { registration.ClusterType = new ClusterType(Int32.Parse(grpType.Qualifier)); } catch { throw new ArenaApplicationException(string.Format("Invalid Cluster Type ID for Small Group Type '{0}'", grpType.Value)); } registration.GroupType = grpType; } else { registration.ClusterType = group.ClusterType; registration.GroupType = null; } if (group.GroupType.ToString() != string.Empty) registration.GroupType = group.GroupType; registration.Notes = tbNotes.Text; registration.Persons.Add(CurrentPerson); registration.DayOfWeek.Add(group.MeetingDay); registration.AgeRange.Add(group.PrimaryAge); registration.MaritalPreference.Add(group.PrimaryMaritalStatus); registration.SetCluster(); registration.GroupID = group.GroupID; registration.Save(CurrentPortal.OrganizationID, CurrentUser.Identity.Name); } Response.Redirect(string.Format("~/default.aspx?page={0}", RedirectPageIDSetting.ToString()), true); }