public RecReg SetRecReg() { var rr = RecRegs.SingleOrDefault(); if (rr == null) { rr = new RecReg(); RecRegs.Add(rr); } return rr; }
private void detach_RecRegs(RecReg entity) { this.SendPropertyChanging(); entity.Person = null; }
private RecReg GetRecRegOrTemp(Person p) { var rr = p.RecRegs.SingleOrDefault(); if (rr == null) rr = new RecReg(); return rr; }
private void attach_RecRegs(RecReg entity) { this.SendPropertyChanging(); entity.Person = this; }
public void RepopulateRegistration(OrganizationMember om) { var reg = person.RecRegs.SingleOrDefault(); if (reg == null) { reg = new RecReg(); person.RecRegs.Add(reg); } foreach (var ask in setting.AskItems) { switch (ask.Type) { case "AskSize": shirtsize = om.ShirtSize; break; case "AskChurch": otherchurch = reg.ActiveInAnotherChurch ?? false; memberus = reg.Member ?? false; break; case "AskAllergies": medical = reg.MedicalDescription; break; case "AskParents": mname = reg.Mname; fname = reg.Fname; break; case "AskEmContact": emcontact = reg.Emcontact; emphone = reg.Emphone; break; case "AskTylenolEtc": tylenol = reg.Tylenol; advil = reg.Advil; robitussin = reg.Robitussin; maalox = reg.Maalox; break; case "AskDoctor": docphone = reg.Docphone; doctor = reg.Doctor; break; case "AskCoaching": coaching = reg.Coaching; break; case "AskInsurance": insurance = reg.Insurance; policy = reg.Policy; break; case "AskTickets": ntickets = om.Tickets; break; case "AskYesNoQuestions": PopulateYesNoChoices(om, ask); break; case "AskCheckboxes": PopulateCheckboxChoices(om, ask); break; case "AskExtraQuestions": PopulateExtraAnswers(om, ask); break; case "AskText": PopulateTextAnswers(om, ask); break; case "AskMenu": break; case "AskDropdown": PopulateDropdownChoices(om, ask); break; case "AskGradeOptions": PopulateGradeChoice(om); break; } } }
public OrganizationMember Enroll(Transaction ti, string paylink, bool? testing, string others) { var om = OrganizationMember.InsertOrgMembers(DbUtil.Db, org.OrganizationId, person.PeopleId, MemberTypeCode.Member, DateTime.Now, null, false); om.Amount = TotalAmount(); om.AmountPaid = ti.Amt; var reg = person.RecRegs.SingleOrDefault(); if (reg == null) { reg = new RecReg(); person.RecRegs.Add(reg); } foreach (var ask in setting.AskItems) { switch (ask.Type) { case "AskSize": om.ShirtSize = shirtsize; reg.ShirtSize = shirtsize; break; case "AskChurch": reg.ActiveInAnotherChurch = otherchurch; reg.Member = memberus; break; case "AskAllergies": reg.MedAllergy = medical.HasValue(); reg.MedicalDescription = medical; break; case "AskParents": reg.Mname = mname; reg.Fname = fname; break; case "AskEmContact": reg.Emcontact = emcontact; reg.Emphone = emphone; break; case "AskTylenolEtc": reg.Tylenol = tylenol; reg.Advil = advil; reg.Robitussin = robitussin; reg.Maalox = maalox; break; case "AskDoctor": reg.Docphone = docphone; reg.Doctor = doctor; break; case "AskCoaching": reg.Coaching = coaching; break; case "AskInsurance": reg.Insurance = insurance; reg.Policy = policy; break; case "AskTickets": om.Tickets = ntickets; break; case "AskYesNoQuestions": if (setting.TargetExtraValues == false) { foreach (var yn in ((AskYesNoQuestions)ask).list) { om.RemoveFromGroup(DbUtil.Db, "Yes:" + yn.SmallGroup); om.RemoveFromGroup(DbUtil.Db, "No:" + yn.SmallGroup); } foreach (var g in YesNoQuestion) om.AddToGroup(DbUtil.Db, (g.Value == true ? "Yes:" : "No:") + g.Key); } else foreach (var g in YesNoQuestion) person.AddEditExtraValue(g.Key, g.Value == true ? "Yes" : "No"); break; case "AskCheckboxes": if (setting.TargetExtraValues) { foreach (var ck in ((AskCheckboxes)ask).list) person.RemoveExtraValue(DbUtil.Db, ck.SmallGroup); foreach (var g in ((AskCheckboxes)ask).CheckboxItemsChosen(Checkbox)) person.AddEditExtraValue(g.SmallGroup, "true"); } else { foreach (var ck in ((AskCheckboxes)ask).list) ck.RemoveFromSmallGroup(DbUtil.Db, om); foreach (var i in ((AskCheckboxes)ask).CheckboxItemsChosen(Checkbox)) i.AddToSmallGroup(DbUtil.Db, om, PythonEvents); } break; case "AskExtraQuestions": foreach (var g in ExtraQuestion[ask.UniqueId]) if (g.Value.HasValue()) if (setting.TargetExtraValues) person.AddEditExtraData(g.Key, g.Value); else om.AddToMemberData("{0}: {1}".Fmt(g.Key, g.Value)); break; case "AskMenu": foreach (var i in MenuItem) om.AddToGroup(DbUtil.Db, i.Key, i.Value); { var menulabel = "Menu Items"; foreach (var i in ((AskMenu)ask).MenuItemsChosen(MenuItem)) { om.AddToMemberData(menulabel); string desc; if (i.amt > 0) desc = "{0} {1} (at {2:N2})".Fmt(i.number, i.desc, i.amt); else desc = "{0} {1}".Fmt(i.number, i.desc); om.AddToMemberData(desc); menulabel = string.Empty; } } break; case "AskDropdown": if (setting.TargetExtraValues) { foreach (var op in ((AskDropdown)ask).list) person.RemoveExtraValue(DbUtil.Db, op.SmallGroup); person.AddEditExtraValue(((AskDropdown)ask).SmallGroupChoice(option).SmallGroup, "true"); } else { foreach (var op in ((AskDropdown)ask).list) op.RemoveFromSmallGroup(DbUtil.Db, om); ((AskDropdown)ask).SmallGroupChoice(option).AddToSmallGroup(DbUtil.Db, om, PythonEvents); } break; case "AskGradeOptions": if (setting.TargetExtraValues) person.Grade = gradeoption.ToInt(); else { om.Grade = gradeoption.ToInt(); person.Grade = gradeoption.ToInt(); } break; } } if (setting.TargetExtraValues) { foreach (var ag in setting.AgeGroups) person.RemoveExtraValue(DbUtil.Db, ag.SmallGroup); if (setting.AgeGroups.Count > 0) person.AddEditExtraValue(AgeGroup(), "true"); } else { foreach (var ag in setting.AgeGroups) om.RemoveFromGroup(DbUtil.Db, ag.SmallGroup); if (setting.AgeGroups.Count > 0) om.AddToGroup(DbUtil.Db, AgeGroup()); } if (setting.LinkGroupsFromOrgs.Count > 0) { var q = from omt in DbUtil.Db.OrgMemMemTags where setting.LinkGroupsFromOrgs.Contains(omt.OrgId) where omt.PeopleId == om.PeopleId select omt.MemberTag.Name; foreach (var name in q) om.AddToGroup(DbUtil.Db, name); } var sb = new StringBuilder(); sb.AppendFormat("{0:g} ----------------\n", DateTime.Now); if (om.AmountPaid > 0) { sb.AppendFormat("{0:c} ({1} id) transaction amount\n", ti.Amt, ti.Id); sb.AppendFormat("{0:c} applied to this registrant\n", AmountToPay()); sb.AppendFormat("{0:c} total due all registrants\n", ti.Amtdue); if (others.HasValue()) sb.AppendFormat("Others: {0}\n", others); } om.AddToMemberData(sb.ToString()); var sbreg = new StringBuilder(); sbreg.AppendFormat("{0}\n".Fmt(org.OrganizationName)); sbreg.AppendFormat("{0:g} ----------------\n", DateTime.Now); if (om.AmountPaid > 0) { sbreg.AppendFormat("{0:c} ({1} id) transaction amount\n", ti.Amt, ti.Id); sbreg.AppendFormat("{0:c} applied to this registrant\n", AmountToPay()); sbreg.AppendFormat("{0:c} total due all registrants\n", ti.Amtdue); } if (paylink.HasValue()) { sbreg.AppendLine(paylink); om.PayLink = paylink; } if (request.HasValue()) { sbreg.AppendFormat("Request: {0}\n", request); om.Request = request; } sbreg.AppendFormat("{0}\n", email); reg.AddToComments(sbreg.ToString()); DbUtil.Db.SubmitChanges(); return om; }
public void PopulateRegistrationFromDb(OrganizationMember om) { var reg = person.RecRegs.SingleOrDefault(); if (reg == null) { reg = new RecReg(); person.RecRegs.Add(reg); } foreach (var ask in setting.AskItems) { switch (ask.Type) { case "AskSize": shirtsize = om.ShirtSize; break; case "AskChurch": otherchurch = reg.ActiveInAnotherChurch ?? false; memberus = reg.Member ?? false; break; case "AskAllergies": medical = reg.MedicalDescription; break; case "AskParents": mname = reg.Mname; fname = reg.Fname; break; case "AskEmContact": emcontact = reg.Emcontact; emphone = reg.Emphone; break; case "AskTylenolEtc": tylenol = reg.Tylenol; advil = reg.Advil; robitussin = reg.Robitussin; maalox = reg.Maalox; break; case "AskDoctor": docphone = reg.Docphone; doctor = reg.Doctor; break; case "AskCoaching": coaching = reg.Coaching; break; // case "AskSMS": // sms = person.ReceiveSMS; // break; case "AskInsurance": insurance = reg.Insurance; policy = reg.Policy; break; case "AskTickets": ntickets = om.Tickets; break; case "AskYesNoQuestions": if (setting.TargetExtraValues == false) foreach (var yn in ((AskYesNoQuestions)ask).list) { { if (om.IsInGroup("Yes:" + yn.SmallGroup)) YesNoQuestion[yn.SmallGroup] = true; if (om.IsInGroup("No:" + yn.SmallGroup)) YesNoQuestion[yn.SmallGroup] = false; } } else foreach (var yn in ((AskYesNoQuestions)ask).list) { if (person.GetExtra(yn.SmallGroup) == "Yes") YesNoQuestion[yn.SmallGroup] = true; if (person.GetExtra(yn.SmallGroup) == "No") YesNoQuestion[yn.SmallGroup] = false; } break; case "AskCheckboxes": if (setting.TargetExtraValues) { foreach (var ck in ((AskCheckboxes)ask).list) if (person.GetExtra(ck.SmallGroup).ToBool()) Checkbox.Add(ck.SmallGroup); } else foreach (var ck in ((AskCheckboxes)ask).list) if (om.IsInGroup(ck.SmallGroup)) Checkbox.Add(ck.SmallGroup); break; case "AskExtraQuestions": if (ExtraQuestion == null) ExtraQuestion = new List<Dictionary<string, string>>(); var eq = new Dictionary<string, string>(); ExtraQuestion.Add(eq); var lines = (om.UserData ?? "").Split('\n'); foreach (var q in ((AskExtraQuestions)ask).list) { if (setting.TargetExtraValues) { var v = person.GetExtra(q.Question); if (v.HasValue()) eq[q.Question] = v; } else { var v = (from li in lines where li.StartsWith(q.Question + ": ") select li.Substring(q.Question.Length + 2)).FirstOrDefault(); if (v.HasValue()) eq[q.Question] = v; } } break; case "AskMenu": // foreach (var i in MenuItem) // om.AddToGroup(DbUtil.Db, i.Key, i.Value); // { // var menulabel = "Menu Items"; // foreach (var i in ((AskMenu)ask).MenuItemsChosen(MenuItem)) // { // om.AddToMemberData(menulabel); // string desc; // if (i.amt > 0) // desc = "{0} {1} (at {2:N2})".Fmt(i.number, i.desc, i.amt); // else // desc = "{0} {1}".Fmt(i.number, i.desc); // om.AddToMemberData(desc); // menulabel = string.Empty; // } // } break; case "AskDropdown": if (option == null) option = new List<string>(); if (setting.TargetExtraValues) { foreach (var dd in ((AskDropdown)ask).list) if (person.GetExtra(dd.SmallGroup) == "true") option.Add(dd.SmallGroup); } else foreach (var dd in ((AskDropdown)ask).list) if (om.IsInGroup(dd.SmallGroup)) option.Add(dd.SmallGroup); break; case "AskGradeOptions": gradeoption = person.Grade.ToString(); if (!setting.TargetExtraValues) gradeoption = om.Grade.ToString(); break; } } // if (setting.TargetExtraValues) // { // foreach (var ag in setting.AgeGroups) // person.RemoveExtraValue(DbUtil.Db, ag.SmallGroup); // if (setting.AgeGroups.Count > 0) // person.AddEditExtraValue(AgeGroup(), "true"); // } // else // { // foreach (var ag in setting.AgeGroups) // om.RemoveFromGroup(DbUtil.Db, ag.SmallGroup); // if (setting.AgeGroups.Count > 0) // om.AddToGroup(DbUtil.Db, AgeGroup()); // } }
public void UpdateRecReg() { var p = DbUtil.Db.LoadPersonById(PeopleId); var rr = p.RecRegs.SingleOrDefault(r => r.PeopleId == PeopleId); if (rr == null) { rr = new RecReg(); p.RecRegs.Add(rr); } rr.Comments = Comments; rr.Coaching = coaching; rr.ActiveInAnotherChurch = otherchurch; rr.Docphone = docphone; rr.Doctor = doctor; rr.Emcontact = emcontact; rr.Emphone = emphone; rr.Fname = fname; rr.Insurance = insurance; rr.MedAllergy = medical.HasValue(); rr.MedicalDescription = medical; rr.Tylenol = tylenol; rr.Advil = advil; rr.Robitussin = robitussin; rr.Maalox = maalox; rr.Member = member; rr.Mname = mname; rr.Policy = policy; rr.ShirtSize = shirtsize; p.CustodyIssue = custody; p.OkTransport = transport; DbUtil.Db.SubmitChanges(); DbUtil.LogActivity("Updated RecReg: {0}".Fmt(p.Name)); }