Наследование: INotifyPropertyChanging, INotifyPropertyChanged
Пример #1
0
        private static void SummarizePayment(Transaction ti, OrganizationMember om, StringBuilder sb)
        {
            if ((ti.Amt ?? 0) == 0 || om == null)
                return;

            var ts = om.TransactionSummary(DbUtil.Db);
            if (ts != null)
                sb.AppendFormat(@"
            <tr><td colspan='2'>
            <table cellpadding=4>
            <tr>
            <td>Registrant Fee</td>
            <td>Amount Paid</td>
            <td>Amount Due</td>
            </tr>
            <tr>
            <td align='right'>{0}</td>
            <td align='right'>{1}</td>
            <td align='right'>{2}</td>
            </tr>
            </table>
            </td></tr>
            ", ts.IndAmt.ToString2("c"),
                    om.TotalPaid(DbUtil.Db).ToString("c"),
                    om.AmountDue(DbUtil.Db).ToString("c"));
        }
Пример #2
0
        public static OrganizationMember AddOrgMember(CMSDataContext db, int organizationId, int peopleId, int memberTypeId, DateTime enrollmentDate, string name)
        {
            var om = new OrganizationMember
            {
                OrganizationId = organizationId,
                PeopleId = peopleId,
                MemberTypeId = memberTypeId,
                EnrollmentDate = enrollmentDate,
                CreatedDate = Util.Now,
                SkipInsertTriggerProcessing = true
            };

            var et = new EnrollmentTransaction
            {
                OrganizationId = om.OrganizationId,
                PeopleId = om.PeopleId,
                MemberTypeId = om.MemberTypeId,
                OrganizationName = name,
                TransactionDate = enrollmentDate,
                EnrollmentDate = enrollmentDate,
                TransactionTypeId = 1,
                // join
                CreatedBy = Util.UserId1,
                CreatedDate = Util.Now,
                AttendancePercentage = om.AttendPct,
                SkipInsertTriggerProcessing = true
            };

            db.OrganizationMembers.InsertOnSubmit(om);
            db.EnrollmentTransactions.InsertOnSubmit(et);

            db.SubmitChanges();
            return om;
        }
Пример #3
0
 private void Populate()
 {
     var q = from mm in DbUtil.Db.OrganizationMembers
             let ts = DbUtil.Db.ViewTransactionSummaries.SingleOrDefault(tt => tt.RegId == mm.TranId && tt.PeopleId == mm.PeopleId)
             where mm.OrganizationId == OrgId && mm.PeopleId == PeopleId
             select new
             {
                 mm.Person.Name,
                 mm.Organization.OrganizationName,
                 om = mm,
                 mt = mm.Organization.IsMissionTrip ?? false,
                 ts
             };
     var i = q.SingleOrDefault();
     if (i == null)
         return;
     Name = i.Name;
     OrgName = i.OrganizationName;
     om = i.om;
     isMissionTrip = i.mt;
     TransactionSummary = i.ts;
     Due = isMissionTrip
         ? MissionTripFundingModel.TotalDue(peopleId, orgId)
         : i.ts != null ? i.ts.TotDue ?? 0 : 0;
 }
Пример #4
0
 public SummaryInfo(CMSDataContext db, OrganizationMember om)
 {
     this.om = om;
     First   = om.Person.PreferredName;
     Last    = om.Person.LastName;
     Orgname = om.Organization.OrganizationName;
     setting = new Settings(om.Organization.RegSetting, db, om.Organization.OrganizationId)
     {
         org = om.Organization
     };
 }
Пример #5
0
        private void LogRegistrationOnOrgMember(Transaction transaction, OrganizationMember om, string paylink)
        {
            var reg = person.GetRecReg();
            var sb = new StringBuilder();

            sb.AppendFormat("{0:g} ----------------\n", DateTime.Now);
            if (om.AmountPaid > 0)
            {
                var others = GetOthersInTransaction(transaction);
                sb.AppendFormat("{0:c} ({1} id) transaction amount\n", transaction.Amt, transaction.Id);
                sb.AppendFormat("{0:c} applied to this registrant\n", AmountToPay());
                sb.AppendFormat("{0:c} total due all registrants\n", transaction.Amtdue);
                if (others.HasValue())
                    sb.AppendFormat("Others: {0}\n", others);
            }
            om.AddToMemberDataBelowComments(sb.ToString());

            var sbreg = new StringBuilder();
            sbreg.Append($"{org.OrganizationName}\n");
            sbreg.AppendFormat("{0:g} ----------------\n", DateTime.Now);
            if (om.AmountPaid > 0)
            {
                sbreg.AppendFormat("{0:c} ({1} id) transaction amount\n", transaction.Amt, transaction.Id);
                sbreg.AppendFormat("{0:c} applied to this registrant\n", AmountToPay());
                sbreg.AppendFormat("{0:c} total due all registrants\n", transaction.Amtdue);
            }
            if (paylink.HasValue())
            {
                sbreg.AppendLine(paylink);
                om.PayLink = paylink;
            }
            if (request.HasValue())
            {
                sbreg.AppendFormat("Request: {0}\n", request);
                om.Request = request.Truncate(140);
            }
            sbreg.AppendFormat("{0}\n", EmailAddress);

            reg.AddToComments(sbreg.ToString());
        }
Пример #6
0
        private void Populate()
        {
            if (dopopulate)
            {
                dopopulate = false;
                if (!OrgId.HasValue || !PeopleId.HasValue)
                    return;
            }
            var i = (from mm in DbUtil.Db.OrganizationMembers
                     where mm.OrganizationId == OrgId && mm.PeopleId == PeopleId
                     select new
                     {
                         mm,
                         mm.Person.Name,
                         mm.Organization.OrganizationName,
                         mm.Organization,
                         mm.OrgMemMemTags,
                         mm.Organization.IsMissionTrip,
                         ts = DbUtil.Db.ViewTransactionSummaries.SingleOrDefault(tt => tt.RegId == mm.TranId && tt.PeopleId == PeopleId && tt.OrganizationId == OrgId)
                     }).SingleOrDefault();
            if (i == null)
                throw new Exception($"missing OrgMember at oid={OrgId}, pid={PeopleId}");
            OrgMember = i.mm;
            TransactionSummary = i.ts;
            this.CopyPropertiesFrom(OrgMember);
            Name = i.Name;

            IsMissionTrip = i.IsMissionTrip ?? false;
            AmtFee = i.ts?.IndPaid + i.ts?.IndDue;
            AmtDonation = i.ts?.IndAmt - AmtFee;
            AmtCoupon = i.ts?.TotCoupon;
            AmtPaid = OrgMember.AmountPaidTransactions(DbUtil.Db);
            AmtDue = OrgMember.AmountDueTransactions(DbUtil.Db);

            OrgName = i.OrganizationName;
            Organization = i.Organization;
            OrgMemMemTags = i.OrgMemMemTags.ToList();
            Setting = DbUtil.Db.CreateRegistrationSettings(OrgId ?? 0);
        }
Пример #7
0
		private void attach_OrganizationMembers(OrganizationMember entity)
		{
			this.SendPropertyChanging();
			entity.Person = this;
		}
Пример #8
0
 private string PrepareSummaryText2(OrganizationMember om)
 {
     const string razorTemplate = @"@model CmsData.API.APIOrganization.SummaryInfo
     <table>
     <tr><td>Org:</td><td>@Model.Orgname</td></tr>
     <tr><td>First:</td><td>@Model.First</td></tr>
     <tr><td>Last:</td><td>@Model.Last</td></tr>
     @foreach(var ask in Model.List())
     {
     foreach(var row in ask.List())
     {
     <tr><td>@row.Label</td><td>@row.Description</td></tr>
     }
     }
     </table>
     ";
     return Razor.Parse(razorTemplate, new SummaryInfo(Db, om));
 }
Пример #9
0
 public void UpdateModel()
 {
     om = DbUtil.Db.OrganizationMembers.Single(mm => mm.OrganizationId == OrgId && mm.PeopleId == PeopleId);
     this.CopyPropertiesTo(om);
     DbUtil.Db.SubmitChanges();
     Populate();
 }
Пример #10
0
 private void SaveAgeGroupChoice(OrganizationMember om)
 {
     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());
     }
 }
Пример #11
0
        public static OrganizationMember InsertOrgMembers(CMSDataContext db, int organizationId, int peopleId, int memberTypeId, DateTime enrollmentDate, DateTime? inactiveDate, bool pending, string name, bool skipTriggerProcessing = false)
        {
            db.SubmitChanges();
            var ntries = 2;
            while (true)
            {
                try
                {
                    var m = db.OrganizationMembers.SingleOrDefault(m2 => m2.PeopleId == peopleId && m2.OrganizationId == organizationId);
                    if (m != null)
                    {
                        m.Pending = pending;
                        m.MemberTypeId = memberTypeId;
                        db.SubmitChanges();
                        return m;
                    }
                    var om = new OrganizationMember
                    {
                        OrganizationId = organizationId,
                        PeopleId = peopleId,
                        MemberTypeId = memberTypeId,
                        EnrollmentDate = enrollmentDate,
                        InactiveDate = inactiveDate,
                        CreatedDate = Util.Now,
                        Pending = pending,
                        SkipInsertTriggerProcessing = skipTriggerProcessing
                    };

                    var et = new EnrollmentTransaction
                    {
                        OrganizationId = om.OrganizationId,
                        PeopleId = om.PeopleId,
                        MemberTypeId = om.MemberTypeId,
                        OrganizationName = name,
                        TransactionDate = enrollmentDate,
                        EnrollmentDate = enrollmentDate,
                        TransactionTypeId = 1,
                        // join
                        CreatedBy = Util.UserId1,
                        CreatedDate = Util.Now,
                        Pending = pending,
                        AttendancePercentage = om.AttendPct,
                        SkipInsertTriggerProcessing = skipTriggerProcessing
                    };

                    db.OrganizationMembers.InsertOnSubmit(om);
                    db.EnrollmentTransactions.InsertOnSubmit(et);

                    db.SubmitChanges();
                    return om;
                }
                catch (SqlException ex)
                {
                    if (ex.Number == 1205)
                        if (--ntries > 0)
                        {
                            System.Threading.Thread.Sleep(500);
                            continue;
                        }
                    throw;
                }
            }
        }
Пример #12
0
 private void detach_OrganizationMembers(OrganizationMember entity)
 {
     this.SendPropertyChanging();
     entity.MemberType = null;
 }
Пример #13
0
        private void SummarizeAnswers(StringBuilder sb, OrganizationMember om)
        {
            if (Parent.SupportMissionTrip)
                return;

            var rr = person.RecRegs.Single();

            foreach (var ask in setting.AskItems)
            {
                switch (ask.Type)
                {
                    case "AskTickets":
                        sb.AppendFormat("<tr><td>Tickets:</td><td>{0}</td></tr>\n", om.Tickets);
                        break;
                    case "AskSize":
                        sb.AppendFormat("<tr><td>Shirt:</td><td>{0}</td></tr>\n", om.ShirtSize);
                        break;
                    case "AskEmContact":
                        sb.AppendFormat("<tr><td>Emerg Contact:</td><td>{0}</td></tr>\n", rr.Emcontact);
                        sb.AppendFormat("<tr><td>Emerg Phone:</td><td>{0}</td></tr>\n", rr.Emphone);
                        break;
                    case "AskDoctor":
                        sb.AppendFormat("<tr><td>Physician Name:</td><td>{0}</td></tr>\n", rr.Doctor);
                        sb.AppendFormat("<tr><td>Physician Phone:</td><td>{0}</td></tr>\n", rr.Docphone);
                        break;
                    case "AskInsurance":
                        sb.AppendFormat("<tr><td>Insurance Carrier:</td><td>{0}</td></tr>\n", rr.Insurance);
                        sb.AppendFormat("<tr><td>Insurance Policy:</td><td>{0}</td></tr>\n", rr.Policy);
                        break;
                    case "AskRequest":
                        sb.AppendFormat("<tr><td>{1}:</td><td>{0}</td></tr>\n", om.Request, ((AskRequest) ask).Label);
                        break;
                    case "AskHeader":
                        sb.AppendFormat("<tr><td colspan='2'><h4>{0}</h4></td></tr>\n", ((AskHeader) ask).Label);
                        break;
                    case "AskInstruction":
                        break;
                    case "AskAllergies":
                        sb.AppendFormat("<tr><td>Medical:</td><td>{0}</td></tr>\n", rr.MedicalDescription);
                        break;
                    case "AskTylenolEtc":
                        sb.AppendFormat("<tr><td>Tylenol?: {0},", tylenol == true ? "Yes" : tylenol == false ? "No" : "");
                        sb.AppendFormat(" Advil?: {0},", advil == true ? "Yes" : advil == false ? "No" : "");
                        sb.AppendFormat(" Robitussin?: {0},", robitussin == true ? "Yes" : robitussin == false ? "No" : "");
                        sb.AppendFormat(" Maalox?: {0}</td></tr>\n", maalox == true ? "Yes" : maalox == false ? "No" : "");
                        break;
                    case "AskChurch":
                        sb.AppendFormat("<tr><td>Member:</td><td>{0}</td></tr>\n", rr.Member);
                        sb.AppendFormat("<tr><td>OtherChurch:</td><td>{0}</td></tr>\n", rr.ActiveInAnotherChurch);
                        break;
                    case "AskParents":
                        sb.AppendFormat("<tr><td>Mother's name:</td><td>{0}</td></tr>\n", rr.Mname);
                        sb.AppendFormat("<tr><td>Father's name:</td><td>{0}</td></tr>\n", rr.Fname);
                        break;
                    case "AskCoaching":
                        sb.AppendFormat("<tr><td>Coaching:</td><td>{0}</td></tr>\n", rr.Coaching);
                        break;
                    case "AskSMS":
                        sb.AppendFormat("<tr><td>Receive Texts:</td><td>{0}</td></tr>\n", person.ReceiveSMS);
                        break;
                    case "AskDropdown":
                        SummarizeDropdownChoice(sb, ask);
                        break;
                    case "AskMenu":
                        SummarizeMenuChoices(sb, ask);
                        break;
                    case "AskCheckboxes":
                        SummarizeCheckboxChoices(sb, ask);
                        break;
                    case "AskYesNoQuestions":
                        SummarizeYesNoChoices(sb, ask);
                        break;
                    case "AskExtraQuestions":
                        SummarizeExtraAnswers(sb, ask);
                        break;
                    case "AskText":
                        SummarieTextAnswers(sb, ask);
                        break;
                    case "AskGradeOptions":
                        SummarizeGradeOption(sb, ask);
                        break;
                }
            }
            if (setting.AgeGroups.Count > 0)
                sb.AppendFormat("<tr><td>AgeGroup:</td><td>{0}</td></tr>\n", AgeGroup());
        }
Пример #14
0
        public string SmallGroupChanged(int sgtagid, bool ck)
        {
            if (OrgMember == null)
                OrgMember = DbUtil.Db.OrganizationMembers.Single(mm => mm.OrganizationId == OrgId && mm.PeopleId == PeopleId);

            if (OrgMember == null)
                return "error";
            if (ck)
            {
                var name = (from mt in DbUtil.Db.MemberTags
                            where mt.Id == sgtagid
                            where mt.OrgId == OrgId
                            select mt.Name).Single();
                OrgMember.OrgMemMemTags.Add(new OrgMemMemTag { MemberTagId = sgtagid });
                DbUtil.LogActivity("OrgMem AddSubGroup " + name, OrgId, PeopleId);
            }
            else
            {
                var i = (from mt in OrgMember.OrgMemMemTags
                         where mt.MemberTagId == sgtagid
                         select new
                         {
                             mt,
                             name = mt.MemberTag.Name
                         }).SingleOrDefault();
                if (i == null)
                    return "not found";
                DbUtil.Db.OrgMemMemTags.DeleteOnSubmit(i.mt);
                DbUtil.LogActivity("OrgMem RemoveSubGroup " + i.name, OrgId, PeopleId);
            }
            DbUtil.Db.SubmitChanges();
            return "ok";
        }
Пример #15
0
 public void UpdateModel()
 {
     if (OrgMember == null)
         OrgMember = DbUtil.Db.OrganizationMembers.Single(mm => mm.OrganizationId == OrgId && mm.PeopleId == PeopleId);
     var changes = this.CopyPropertiesTo(OrgMember);
     DbUtil.Db.SubmitChanges();
     foreach (var g in changes)
         DbUtil.LogActivity($"OrgMem {GroupName} change {g.Field}", OrgId, PeopleId);
     Populate();
 }
Пример #16
0
 public void Drop()
 {
     if (OrgMember == null)
         OrgMember = DbUtil.Db.OrganizationMembers.Single(mm => mm.OrganizationId == OrgId && mm.PeopleId == PeopleId);
     if (DropDate.HasValue)
         OrgMember.Drop(DbUtil.Db, DropDate.Value);
     else
         OrgMember.Drop(DbUtil.Db);
     DbUtil.Db.SubmitChanges();
     DbUtil.LogActivity("OrgMem Drop", OrgId, PeopleId);
     if (RemoveFromEnrollmentHistory)
     {
         DbUtil.DbDispose();
         DbUtil.Db = DbUtil.Create(Util.Host);
         var q = DbUtil.Db.EnrollmentTransactions.Where(tt => tt.OrganizationId == OrgId && tt.PeopleId == PeopleId);
         DbUtil.Db.EnrollmentTransactions.DeleteAllOnSubmit(q);
         DbUtil.Db.SubmitChanges();
         DbUtil.LogActivity("OrgMem RemoveEnrollmentHistory", OrgId, PeopleId);
     }
 }
Пример #17
0
 private void attach_OrganizationMembers(OrganizationMember entity)
 {
     this.SendPropertyChanging();
     entity.MemberType = this;
 }
Пример #18
0
 public void MoveToOrg(int pid, int fromOrg, int toOrg, bool?moveregdata = true, int toMemberTypeId = -1)
 {
     db.LogActivity($"PythonModel.MoveToOrg({pid},{fromOrg},{toOrg})");
     using (var db2 = NewDataContext())
         OrganizationMember.MoveToOrg(db2, pid, fromOrg, toOrg, moveregdata, toMemberTypeId);
 }
Пример #19
0
 private void Populate()
 {
     var i = (from mm in DbUtil.Db.OrganizationMembers
              where mm.OrganizationId == OrgId && mm.PeopleId == PeopleId
              select new
                  {
                      mm,
                      mm.Person.Name,
                      mm.Organization.OrganizationName,
                      mm.Organization.RegSetting,
                      mm.Organization,
                      mm.OrgMemMemTags,
                      mm.Organization.IsMissionTrip
                  }).SingleOrDefault();
     if (i == null)
         throw new Exception("missing OrgMember at oid={0}, pid={0}".Fmt(OrgId, PeopleId));
     om = i.mm;
     this.CopyPropertiesFrom(om);
     Name = i.Name;
     AmountPaidTransactions = om.TotalPaid(DbUtil.Db);
     OrgName = i.OrganizationName;
     Organization = i.Organization;
     OrgMemMemTags = i.OrgMemMemTags.ToList();
     IsMissionTrip = i.IsMissionTrip ?? false;
     Setting = new Settings(i.RegSetting, DbUtil.Db, OrgId.Value);
 }
Пример #20
0
        public static OrganizationMember InsertOrgMembers(CMSDataContext Db,
			 int OrganizationId,
			 int PeopleId,
			 int MemberTypeId,
			 DateTime EnrollmentDate,
			 DateTime? InactiveDate, bool pending
			)
        {
            Db.SubmitChanges();
            int ntries = 2;
            while (true)
            {
                try
                {
                    var m = Db.OrganizationMembers.SingleOrDefault(m2 => m2.PeopleId == PeopleId && m2.OrganizationId == OrganizationId);
                    if (m != null)
                    {
                        m.MemberTypeId = MemberTypeId;
                        Db.SubmitChanges();
                        return m;
                    }
                    var org = Db.Organizations.SingleOrDefault(oo => oo.OrganizationId == OrganizationId);
                    if (org == null)
                        return null;
                    var name = org.OrganizationName;

                    var om = new OrganizationMember
                             {
                                 OrganizationId = OrganizationId,
                                 PeopleId = PeopleId,
                                 MemberTypeId = MemberTypeId,
                                 EnrollmentDate = EnrollmentDate,
                                 InactiveDate = InactiveDate,
                                 CreatedDate = Util.Now,
                                 Pending = pending,
                             };

                    var et = new EnrollmentTransaction
                             {
                                 OrganizationId = om.OrganizationId,
                                 PeopleId = om.PeopleId,
                                 MemberTypeId = om.MemberTypeId,
                                 OrganizationName = name,
                                 TransactionDate = EnrollmentDate,
                                 EnrollmentDate = EnrollmentDate,
                                 TransactionTypeId = 1,
                                 // join
                                 CreatedBy = Util.UserId1,
                                 CreatedDate = Util.Now,
                                 Pending = pending,
                                 AttendancePercentage = om.AttendPct
                             };
                    Db.OrganizationMembers.InsertOnSubmit(om);
                    Db.EnrollmentTransactions.InsertOnSubmit(et);

                    Db.SubmitChanges();
                    return om;
                }
                catch (SqlException ex)
                {
                    if (ex.Number == 1205)
                        if (--ntries > 0)
                        {
                            System.Threading.Thread.Sleep(500);
                            continue;
                        }
                    throw;
                }
            }
        }
Пример #21
0
 public void JoinOrg(int orgId, Person p)
 {
     OrganizationMember.InsertOrgMembers(db, orgId, p.PeopleId, 220, DateTime.Now, null, false);
 }
Пример #22
0
 public AskItem(Ask ask, OrganizationMember om)
 {
     this.ask = ask;
     this.om = om;
 }
Пример #23
0
 private void SaveGradeChoice(OrganizationMember om)
 {
     if (setting.TargetExtraValues)
         person.Grade = gradeoption.ToInt();
     else
     {
         om.Grade = gradeoption.ToInt();
         person.UpdateValue("Grade", gradeoption.ToInt());
         Log("GradeUpdate " + person.Grade);
     }
 }
Пример #24
0
        public static OrganizationMember InsertOrgMembers(CMSDataContext db, int organizationId, int peopleId, int memberTypeId, DateTime enrollmentDate, DateTime?inactiveDate, bool pending, string name, bool skipTriggerProcessing = false)
        {
            db.SubmitChanges();
            var ntries = 2;

            while (true)
            {
                try
                {
                    var m = db.OrganizationMembers.SingleOrDefault(m2 => m2.PeopleId == peopleId && m2.OrganizationId == organizationId);
                    if (m != null)
                    {
                        m.Pending = pending;
                        if (m.MemberTypeId == MemberTypeCode.Member || m.MemberTypeId == 0 || m.MemberTypeId == MemberTypeCode.Prospect)
                        {
                            m.MemberTypeId = memberTypeId;
                        }
                        db.SubmitChanges();
                        return(m);
                    }
                    var om = new OrganizationMember
                    {
                        OrganizationId = organizationId,
                        PeopleId       = peopleId,
                        MemberTypeId   = memberTypeId,
                        EnrollmentDate = enrollmentDate,
                        InactiveDate   = inactiveDate,
                        CreatedDate    = Util.Now,
                        Pending        = pending,
                        SkipInsertTriggerProcessing = skipTriggerProcessing
                    };

                    var et = new EnrollmentTransaction
                    {
                        OrganizationId    = om.OrganizationId,
                        PeopleId          = om.PeopleId,
                        MemberTypeId      = om.MemberTypeId,
                        OrganizationName  = name,
                        TransactionDate   = enrollmentDate,
                        EnrollmentDate    = enrollmentDate,
                        TransactionTypeId = 1,
                        // join
                        CreatedBy                   = db.UserId1,
                        CreatedDate                 = Util.Now,
                        Pending                     = pending,
                        AttendancePercentage        = om.AttendPct,
                        SkipInsertTriggerProcessing = skipTriggerProcessing
                    };

                    db.OrganizationMembers.InsertOnSubmit(om);
                    db.EnrollmentTransactions.InsertOnSubmit(et);

                    db.SubmitChanges();
                    return(om);
                }
                catch (SqlException ex)
                {
                    if (ex.Number == 1205)
                    {
                        if (--ntries > 0)
                        {
                            System.Threading.Thread.Sleep(500);
                            continue;
                        }
                    }

                    throw;
                }
            }
        }
Пример #25
0
 private void SaveMenuChoices(OrganizationMember om, Ask ask)
 {
     foreach (var i in MenuItem[ask.UniqueId])
         om.AddToGroup(DbUtil.Db, i.Key, i.Value);
     {
         var menulabel = ((AskMenu) ask).Label;
         foreach (var i in ((AskMenu) ask).MenuItemsChosen(MenuItem[ask.UniqueId]))
         {
             om.AddToMemberDataBelowComments(menulabel);
             var desc = i.amt > 0 
                 ? $"{i.number} {i.desc} (at {i.amt:N2})" 
                 : $"{i.number} {i.desc}";
             om.AddToMemberDataBelowComments(desc);
             menulabel = string.Empty;
         }
     }
 }
Пример #26
0
 public SummaryInfo(CMSDataContext db, OrganizationMember om)
 {
     this.om = om;
     First = om.Person.PreferredName;
     Last = om.Person.LastName;
     Orgname = om.Organization.OrganizationName;
     setting = new Settings(om.Organization.RegSetting, db, om.Organization.OrganizationId) { org = om.Organization };
 }
Пример #27
0
 private void SaveYesNoChoices(OrganizationMember om, Ask ask)
 {
     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");
 }
Пример #28
0
 private void DoLinkGroupsFromOrgs(OrganizationMember om)
 {
     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);
     }
     if (om.Organization.IsMissionTrip == true)
         om.AddToGroup(DbUtil.Db, "Goer");
 }
Пример #29
0
 private OrganizationMember RecordAllFamilyAttends(OrganizationMember om)
 {
     om.AddToGroup(DbUtil.Db, "Attended");
     om.AddToGroup(DbUtil.Db, "Registered");
     foreach (var fm in FamilyAttend)
     {
         if (fm.PeopleId == -1)
             continue;
         Person pp = null;
         OrganizationMember omm = null;
         if (!fm.PeopleId.HasValue && fm.Attend)
         {
             if (!fm.Name.HasValue())
                 continue;
             string first, last;
             Util.NameSplit(fm.Name, out first, out last);
             if (!first.HasValue())
             {
                 first = last;
                 last = LastName;
             }
             var uperson = DbUtil.Db.LoadPersonById(PeopleId ?? 0);
             var p = new OnlineRegPersonModel()
             {
                 FirstName = first,
                 LastName = last,
                 DateOfBirth = fm.Birthday,
                 EmailAddress = fm.Email,
                 gender = fm.GenderId,
                 married = fm.MaritalId
             };
             p.AddPerson(uperson, org.EntryPointId ?? 0);
             pp = p.person;
             omm = OrganizationMember.InsertOrgMembers(DbUtil.Db, org.OrganizationId, pp.PeopleId,
                 MemberTypeCode.Member, DateTime.Now, null, false);
         }
         else
         {
             pp = DbUtil.Db.LoadPersonById(fm.PeopleId ?? 0);
             if (fm.Attend)
                 omm = OrganizationMember.InsertOrgMembers(DbUtil.Db, org.OrganizationId, pp.PeopleId,
                     MemberTypeCode.Member, DateTime.Now, null, false);
             else
             {
                 omm = OrganizationMember.Load(DbUtil.Db, pp.PeopleId, org.OrganizationId);
                 omm?.RemoveFromGroup(DbUtil.Db, "Attended");
             }
         }
         if (omm == null)
             continue;
         if (fm.Attend)
             omm.AddToGroup(DbUtil.Db, "Attended");
         if (!fm.PeopleId.HasValue)
             omm.AddToGroup(DbUtil.Db, "Added");
     }
     return om;
 }
Пример #30
0
        private void SaveAnswers(OrganizationMember om)
        {
            om.OnlineRegData = Util.Serialize(this); // saves all answers

            var reg = person.SetRecReg();
            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 "AskSMS":
                        SaveSMSChoice();
                        break;
                    case "AskInsurance":
                        reg.Insurance = insurance;
                        reg.Policy = policy;
                        break;
                    case "AskTickets":
                        om.Tickets = ntickets;
                        break;
                    case "AskYesNoQuestions":
                        SaveYesNoChoices(om, ask);
                        break;
                    case "AskCheckboxes":
                        SaveCheckboxChoices(om, ask);
                        break;
                    case "AskExtraQuestions":
                        foreach (var g in ExtraQuestion[ask.UniqueId])
                            if (g.Value.HasValue())
                                if (setting.TargetExtraValues)
                                    person.AddEditExtraData(g.Key, g.Value);
                        break;
                    case "AskText":
                        foreach (var g in Text[ask.UniqueId])
                            if (g.Value.HasValue())
                                if (setting.TargetExtraValues)
                                    person.AddEditExtraData(g.Key, g.Value);
                        break;
                    case "AskMenu":
                        SaveMenuChoices(om, ask);
                        break;
                    case "AskDropdown":
                        SaveDropdownChoice(om, ask);
                        break;
                    case "AskGradeOptions":
                        SaveGradeChoice(om);
                        break;
                }
        }
Пример #31
0
 private void detach_OrganizationMembers(OrganizationMember entity)
 {
     this.SendPropertyChanging();
     entity.RegistrationDatum = null;
 }
Пример #32
0
 private void SaveDropdownChoice(OrganizationMember om, Ask ask)
 {
     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, PythonModel);
     }
 }
Пример #33
0
 public void AddToSmallGroup(CMSDataContext Db, OrganizationMember om, PythonModel pe)
 {
     if (om == null)
         return;
     if (pe != null)
         pe.instance.AddToSmallGroup(SmallGroup, om);
     om.AddToGroup(Db, SmallGroup);
     if (MeetingTime.HasValue)
         Attend.MarkRegistered(Db, om.OrganizationId, om.PeopleId, MeetingTime.Value, 1);
 }
Пример #34
0
 private void SaveCheckboxChoices(OrganizationMember om, Ask ask)
 {
     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.AddEditExtraBool(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, PythonModel);
     }
 }
Пример #35
0
 public void RemoveFromSmallGroup(CMSDataContext Db, OrganizationMember om)
 {
     om.RemoveFromGroup(Db, SmallGroup);
 }
Пример #36
0
 private static OrganizationMember AddSender(OrganizationMember om)
 {
     if (!om.IsInGroup("Goer"))
         om.MemberTypeId = MemberTypeCode.InActive;
     om.AddToGroup(DbUtil.Db, "Sender");
     return om;
 }
Пример #37
0
 private void detach_OrganizationMembers(OrganizationMember entity)
 {
     this.SendPropertyChanging();
     entity.Transaction = null;
 }
Пример #38
0
 public void MoveToOrg(object pid, object fromOrg, object toOrg, bool?moveregdata = true, int toMemberTypeId = -1)
 {
     db.LogActivity($"PythonModel.MoveToOrg({pid},{fromOrg},{toOrg})");
     using (var db2 = NewDataContext())
         OrganizationMember.MoveToOrg(db2, CMSImageDataContext.Create(db2.Host), pid.ToInt(), fromOrg.ToInt(), toOrg.ToInt(), moveregdata, toMemberTypeId);
 }
Пример #39
0
        public static OrganizationMember InsertOrgMembers
            (CMSDataContext Db,
            int OrganizationId,
            int PeopleId,
            int MemberTypeId,
            DateTime EnrollmentDate,
            DateTime?InactiveDate, bool pending
            )
        {
            Db.SubmitChanges();
            int ntries = 2;

            while (true)
            {
                try
                {
                    var m = Db.OrganizationMembers.SingleOrDefault(m2 => m2.PeopleId == PeopleId && m2.OrganizationId == OrganizationId);
                    if (m != null)
                    {
                        return(m);
                    }
                    var org = Db.Organizations.SingleOrDefault(oo => oo.OrganizationId == OrganizationId);
                    if (org == null)
                    {
                        return(null);
                    }
                    var name = org.OrganizationName;

                    var om = new OrganizationMember
                    {
                        OrganizationId = OrganizationId,
                        PeopleId       = PeopleId,
                        MemberTypeId   = MemberTypeId,
                        EnrollmentDate = EnrollmentDate,
                        InactiveDate   = InactiveDate,
                        CreatedDate    = Util.Now,
                        Pending        = pending,
                    };

                    var et = new EnrollmentTransaction
                    {
                        OrganizationId    = om.OrganizationId,
                        PeopleId          = om.PeopleId,
                        MemberTypeId      = om.MemberTypeId,
                        OrganizationName  = name,
                        TransactionDate   = EnrollmentDate,
                        EnrollmentDate    = EnrollmentDate,
                        TransactionTypeId = 1,
                        // join
                        CreatedBy            = Util.UserId1,
                        CreatedDate          = Util.Now,
                        Pending              = pending,
                        AttendancePercentage = om.AttendPct
                    };
                    Db.OrganizationMembers.InsertOnSubmit(om);
                    Db.EnrollmentTransactions.InsertOnSubmit(et);

                    Db.SubmitChanges();
                    return(om);
                }
                catch (SqlException ex)
                {
                    if (ex.Number == 1205)
                    {
                        if (--ntries > 0)
                        {
                            System.Threading.Thread.Sleep(500);
                            continue;
                        }
                    }
                    throw;
                }
            }
        }