public void LoadDefaults() { DojoAccessControlGroupCollection accessControls; DojoAttendanceEntryCollection attendanceEntries; DojoBulkAttendanceEntryCollection bulkAttendances; DojoClassCollection classes; DojoClassDefinitionCollection classDefinitions; DojoMemberCollection members; DojoMembershipCollection memberships; DojoMembershipTemplateCollection membershipTemplates; DojoMemberTypeCollection memberTypes; DojoMemberTypeTemplateCollection memberTypeTemplates; DojoOrganizationCollection organizations; DojoPromotionCollection promotions; DojoPromotionFlagCollection promotionFlags; DojoPromotionStatusCollection promotionStatuses; DojoRankCollection ranks; DojoTestCollection tests; DojoTestListCollection testLists; DojoTestListJournalEntryCollection testListJournalEntries; DojoTestListJournalEntryTypeCollection testListJournalEntryTypes; DojoTestListStatusCollection testListStatuses; DojoSeminarCollection seminars; DojoSeminarOptionCollection seminarOptions; DojoSeminarRegistrationCollection seminarRegistrations; DojoSeminarRegistrationOptionCollection seminarRegistrationOptions; GreyFoxContactCollection locations; accessControls = new DojoAccessControlGroupCollection(); attendanceEntries = new DojoAttendanceEntryCollection(); bulkAttendances = new DojoBulkAttendanceEntryCollection(); classes = new DojoClassCollection(); classDefinitions = new DojoClassDefinitionCollection(); members = new DojoMemberCollection(); memberships = new DojoMembershipCollection(); membershipTemplates = new DojoMembershipTemplateCollection(); memberTypes = new DojoMemberTypeCollection(); memberTypeTemplates = new DojoMemberTypeTemplateCollection(); organizations = new DojoOrganizationCollection(); promotions = new DojoPromotionCollection(); promotionFlags = new DojoPromotionFlagCollection(); promotionStatuses = new DojoPromotionStatusCollection(); ranks = new DojoRankCollection(); tests = new DojoTestCollection(); testLists = new DojoTestListCollection(); testListJournalEntries = new DojoTestListJournalEntryCollection(); testListJournalEntryTypes = new DojoTestListJournalEntryTypeCollection(); testListStatuses = new DojoTestListStatusCollection(); seminars = new DojoSeminarCollection(); seminarOptions = new DojoSeminarOptionCollection(); seminarRegistrations = new DojoSeminarRegistrationCollection(); seminarRegistrationOptions = new DojoSeminarRegistrationOptionCollection(); locations = new GreyFoxContactCollection(); organizations = new DojoOrganizationManager().GetCollection(string.Empty, string.Empty, null); memberTypes = new DojoMemberTypeManager().GetCollection(string.Empty, string.Empty); memberTypeTemplates = new DojoMemberTypeTemplateManager().GetCollection(string.Empty, string.Empty, null); ranks = new DojoRankManager().GetCollection(string.Empty, string.Empty, null); membershipTemplates = new DojoMembershipTemplateManager().GetCollection(string.Empty, string.Empty, null); Dictionary <string, DojoMemberType> memberTypesDictionary = new Dictionary <string, DojoMemberType>(); foreach (DojoMemberType memberType in memberTypes) { memberTypesDictionary.Add(memberType.Name, memberType); } Dictionary <string, DojoMemberTypeTemplate> memberTypeTemplatesDictionary = new Dictionary <string, DojoMemberTypeTemplate>(); foreach (DojoMemberTypeTemplate typeTemplate in memberTypeTemplates) { memberTypeTemplatesDictionary.Add(typeTemplate.Name, typeTemplate); } Dictionary <string, DojoRank> ranksDictionary = new Dictionary <string, DojoRank>(); foreach (DojoRank rank in ranks) { ranksDictionary.Add(rank.Name, rank); } Dictionary <string, DojoMembershipTemplate> membershipTemplatesDictionary = new Dictionary <string, DojoMembershipTemplate>(); foreach (DojoMembershipTemplate template in membershipTemplates) { membershipTemplatesDictionary.Add(template.Name, template); } CsvParser.CsvStream csv = CsvParser.StreamParse(Localization.Defaults.Defaults_en_US, false); string rowType; string[] r = csv.GetNextRow(); while (r != null) { rowType = r[0]; if (rowType == Localization.Defaults.CSVMembershipTemplate) { DojoMembershipTemplate template = TessenFactory.MembershipTemplate( r[1], r[2], bool.Parse(r[3]), bool.Parse(r[4]), bool.Parse(r[5]), decimal.Parse(r[6]), decimal.Parse(r[7]), (DojoMembershipDayType)Enum.Parse(typeof(DojoMembershipDayType), r[8]), (DojoMembershipDayType)Enum.Parse(typeof(DojoMembershipDayType), r[9]), DojoOrganization.NewPlaceHolder(0), 1, int.Parse(r[11]), int.Parse(r[12]), decimal.Parse(r[13]), (DojoMembershipDayType)Enum.Parse(typeof(DojoMembershipDayType), r[14]), int.Parse(r[15]), int.Parse(r[16]), decimal.Parse(r[17]), (DojoMembershipDayType)Enum.Parse(typeof(DojoMembershipDayType), r[18]), int.Parse(r[19]), int.Parse(r[20]), decimal.Parse(r[21]), (DojoMembershipDayType)Enum.Parse(typeof(DojoMembershipDayType), r[22]), int.Parse(r[23]), int.Parse(r[24]), int.Parse(r[25]), int.Parse(r[26]), ranksDictionary.ContainsKey(r[27]) ? ranksDictionary[r[27]] : null, ranksDictionary.ContainsKey(r[28]) ? ranksDictionary[r[28]] : null); membershipTemplates.Add(template); membershipTemplatesDictionary.Add(template.Name, template); template.Save(); } else if (rowType == Localization.Defaults.CSVMemberTypeTemplate) { DojoMemberTypeTemplate template = TessenFactory.MemberTypeTemplate( r[1], r[2], memberTypeTemplatesDictionary.ContainsKey(r[3].ToString()) ? memberTypeTemplatesDictionary[r[3]] : null, memberTypesDictionary.ContainsKey(r[4]) ? memberTypesDictionary[r[4]] : null, bool.Parse(r[5]), bool.Parse(r[6]), bool.Parse(r[7]), bool.Parse(r[8]), int.Parse(r[9]), int.Parse(r[10]), int.Parse(r[11]), int.Parse(r[12]), ranksDictionary.ContainsKey(r[13]) ? ranksDictionary[r[13]] : null, ranksDictionary.ContainsKey(r[14]) ? ranksDictionary[r[14]] : null, membershipTemplatesDictionary.ContainsKey(r[15]) ? membershipTemplatesDictionary[r[15]] : null, membershipTemplatesDictionary.ContainsKey(r[16]) ? membershipTemplatesDictionary[r[16]] : null, membershipTemplatesDictionary.ContainsKey(r[17]) ? membershipTemplatesDictionary[r[17]] : null, membershipTemplatesDictionary.ContainsKey(r[18]) ? membershipTemplatesDictionary[r[18]] : null, membershipTemplatesDictionary.ContainsKey(r[19]) ? membershipTemplatesDictionary[r[19]] : null); memberTypeTemplates.Add(template); memberTypeTemplatesDictionary.Add(template.Name, template); template.Save(); } r = csv.GetNextRow(); } }
protected void ok_Click(object sender, EventArgs e) { if (dojoMembershipTemplateID == 0) { obj = new DojoMembershipTemplate(); } else { obj = new DojoMembershipTemplate(dojoMembershipTemplateID); } obj.Name = tbName.Text; obj.Description = tbDescription.Text; obj.Duration = TimeSpan.Parse(tbDuration.Text); obj.Fee = decimal.Parse(tbFee.Text); obj.AutoRenewalEnabled = cbAutoRenewalEnabled.Checked; obj.AutoPayEnabled = cbAutoPayEnabled.Checked; if (msParentTemplate.SelectedItem != null && msParentTemplate.SelectedItem.Value != "Null") { obj.ParentTemplate = DojoMembershipTemplate.NewPlaceHolder( int.Parse(msParentTemplate.SelectedItem.Value)); } else { obj.ParentTemplate = null; } if (msMemberType1.SelectedItem != null && msMemberType1.SelectedItem.Value != "Null") { obj.MemberType1 = DojoMemberType.NewPlaceHolder( int.Parse(msMemberType1.SelectedItem.Value)); } else { obj.MemberType1 = null; } if (msMemberType2.SelectedItem != null && msMemberType2.SelectedItem.Value != "Null") { obj.MemberType2 = DojoMemberType.NewPlaceHolder( int.Parse(msMemberType2.SelectedItem.Value)); } else { obj.MemberType2 = null; } if (msMemberType3.SelectedItem != null && msMemberType3.SelectedItem.Value != "Null") { obj.MemberType3 = DojoMemberType.NewPlaceHolder( int.Parse(msMemberType3.SelectedItem.Value)); } else { obj.MemberType3 = null; } if (msMemberType4.SelectedItem != null && msMemberType4.SelectedItem.Value != "Null") { obj.MemberType4 = DojoMemberType.NewPlaceHolder( int.Parse(msMemberType4.SelectedItem.Value)); } else { obj.MemberType4 = null; } if (msMemberType5.SelectedItem != null && msMemberType5.SelectedItem.Value != "Null") { obj.MemberType5 = DojoMemberType.NewPlaceHolder( int.Parse(msMemberType5.SelectedItem.Value)); } else { obj.MemberType5 = null; } if (msMemberType6.SelectedItem != null && msMemberType6.SelectedItem.Value != "Null") { obj.MemberType6 = DojoMemberType.NewPlaceHolder( int.Parse(msMemberType6.SelectedItem.Value)); } else { obj.MemberType6 = null; } if (msMemberType7.SelectedItem != null && msMemberType7.SelectedItem.Value != "Null") { obj.MemberType7 = DojoMemberType.NewPlaceHolder( int.Parse(msMemberType7.SelectedItem.Value)); } else { obj.MemberType7 = null; } if (msMemberType8.SelectedItem != null && msMemberType8.SelectedItem.Value != "Null") { obj.MemberType8 = DojoMemberType.NewPlaceHolder( int.Parse(msMemberType8.SelectedItem.Value)); } else { obj.MemberType8 = null; } if (msItem.SelectedItem != null && msItem.SelectedItem.Value != "Null") { obj.Item = RHItem.NewPlaceHolder( int.Parse(msItem.SelectedItem.Value)); } else { obj.Item = null; } if (editOnAdd) { dojoMembershipTemplateID = obj.Save(); } else { obj.Save(); } if (resetOnAdd) { tbName.Text = string.Empty; tbDescription.Text = string.Empty; tbDuration.Text = string.Empty; tbFee.Text = string.Empty; cbAutoRenewalEnabled.Checked = false; cbAutoPayEnabled.Checked = false; msParentTemplate.SelectedIndex = 0; msMemberType1.SelectedIndex = 0; msMemberType2.SelectedIndex = 0; msMemberType3.SelectedIndex = 0; msMemberType4.SelectedIndex = 0; msMemberType5.SelectedIndex = 0; msMemberType6.SelectedIndex = 0; msMemberType7.SelectedIndex = 0; msMemberType8.SelectedIndex = 0; msItem.SelectedIndex = 0; } OnUpdated(EventArgs.Empty); }