private void setupSections(msMembershipOrganization mo, msMembershipDuesProduct product) { SectionMode cm = mo.SectionMode; // check to see if we need to override on product if (product[msMembershipDuesProduct.FIELDS.SectionMode] != null) { cm = product.SafeGetValue <SectionMode>(msMembershipDuesProduct.FIELDS.SectionMode); } switch (cm) { case SectionMode.SectionsDisabled: divSections.Visible = false; return; } // let's pull all of the chapters Search sSections = new Search { Type = msSection.CLASS_NAME }; sSections.AddCriteria(Expr.Equals(msSection.FIELDS.MembershipOrganization, targetMembership.MembershipOrganization)); sSections.AddCriteria(Expr.Equals(msSection.FIELDS.IsActive, true)); sSections.AddSortColumn("Type.Name"); sSections.AddSortColumn("Name"); sSections.AddOutputColumn("Name"); sSections.AddOutputColumn("Type.Name"); _sections = APIExtensions.GetSearchResult(sSections, 0, null).Table; // ok, let's pull out all of the section types List <string> sectionTypes = new List <string>(); foreach (DataRow dr in _sections.Rows) { string typeName = ""; if (dr["Type.Name"] != DBNull.Value) { typeName = Convert.ToString(dr["Type.Name"]); } if (!sectionTypes.Contains(typeName)) { sectionTypes.Add(typeName); } } rptSections.DataSource = sectionTypes; rptSections.DataBind(); }
private void setupChapters(msMembershipOrganization mo, msMembershipDuesProduct product) { ChapterMode cm = mo.ChapterMode; // check to see if we need to override on product if (product[msMembershipDuesProduct.FIELDS.ChapterMode] != null) { cm = product.SafeGetValue <ChapterMode>(msMembershipDuesProduct.FIELDS.ChapterMode); } switch (cm) { case ChapterMode.ChaptersDisabled: divChapter.Visible = false; // don't show it return; case ChapterMode.MemberJoinsOneChapter: divChapter.Visible = true; divAdditionalChapters.Visible = false; break; case ChapterMode.MemberCanJoinMultipleChapters: divChapter.Visible = true; divAdditionalChapters.Visible = true; break; } // let's pull all of the chapters List <NameValueStringPair> tblChapters; using (var api = GetServiceAPIProxy()) { tblChapters = api.GetApplicableChaptersForMembershipType(targetMembership.Type).ResultValue; } ddlSelectChapter.DataSource = tblChapters; ddlSelectChapter.DataTextField = "Name"; ddlSelectChapter.DataValueField = "Value"; ddlSelectChapter.DataBind(); if (divAdditionalChapters.Visible) // bind the list box, too { lbAdditionalChapters.DataSource = tblChapters; lbAdditionalChapters.DataTextField = "Name"; lbAdditionalChapters.DataValueField = "Value"; lbAdditionalChapters.DataBind(); } ddlSelectChapter.Items.Insert(0, new ListItem("---- Select a Chapter ----", "")); // ok - are we suggesting a chapter based on zip code? var cpm = mo.ChapterPostalCodeMappingMode; // check to see if we need to override on product if (product[msMembershipDuesProduct.FIELDS.ChapterPostalCodeMappingMode] != null) { cpm = product.SafeGetValue <ChapterPostalCodeMappingMode>(msMembershipDuesProduct.FIELDS.ChapterPostalCodeMappingMode); } if (cpm != ChapterPostalCodeMappingMode.Disabled) { MemberSuiteObject msoChapter = null; using (var api = GetServiceAPIProxy()) msoChapter = api.SuggestChapter(mo.ID, targetEntity.ID).ResultValue; if (msoChapter != null) // have have a chapter { ListItem li = ddlSelectChapter.Items.FindByValue(msoChapter.SafeGetValue <string>("ID")); if (li != null) // we have a match { li.Selected = true; if (cpm == ChapterPostalCodeMappingMode.Assign) { ddlSelectChapter.Enabled = false; // can't be changed trChapterAssigned.Visible = true; } // if a chapter matches, that's it, we're done return; } } } // let's try and set to the default chapter if (targetMembership != null && targetMembership.Chapters != null) { // find the primary var cPrimary = (targetMembership.Chapters.Find(x => x.IsPrimary)); // MS-4984 - only set the default chapter if it's set up in the mem org if (cPrimary != null && mo.MembersShouldInheritPreviousChapterUponRenewal) { ddlSelectChapter.SafeSetSelectedValue(cPrimary.Chapter); } // now, let's try to select the additional if (divAdditionalChapters.Visible) { foreach (var c in targetMembership.Chapters) { if ((c.ExpirationDate == null || c.ExpirationDate == targetMembership.ExpirationDate) && (cPrimary == null || c.Chapter != cPrimary.Chapter)) { ListItem li = lbAdditionalChapters.Items.FindByValue(c.Chapter); if (li != null) { li.Selected = true; } } } } } }