예제 #1
0
        public static IEnumerable <ContributorInfo> contributors(CMSDataContext Db,
                                                                 DateTime fromDate, DateTime toDate, int PeopleId, int?SpouseId, int FamilyId, bool noaddressok, bool useMinAmt,
                                                                 string startswith = null, string sort = null, bool singleStatement = false, int?tagid = null, bool excludeelectronic = false)
        {
            var MinAmt = Db.Setting("MinContributionAmount", "5").ToDecimal();

            if (!useMinAmt)
            {
                MinAmt = 0;
            }

            var endswith = "";

            if (startswith != null && startswith.Contains("-"))
            {
                var a = startswith.SplitStr("-", 2);
                startswith = a[0];
                endswith   = a[1];
            }
            var q = from p in Db.Contributors(fromDate, toDate, PeopleId, SpouseId, FamilyId, noaddressok, tagid)
                    select p;

            if (startswith.HasValue() && !endswith.HasValue())
            {
                q = from p in q
                    where p.LastName.StartsWith(startswith)
                    select p;
            }
            else if (startswith.HasValue() && endswith.HasValue())
            {
                q = from p in q
                    // ReSharper disable StringCompareToIsCultureSpecific
                    where (p.LastName.CompareTo(startswith) >= 0 && p.LastName.CompareTo(endswith) < 0) || SqlMethods.Like(p.LastName, endswith + "%")
                    select p;
            }

            if (sort == "zip")
            {
                q = from p in q
                    orderby p.PrimaryZip, p.FamilyId, p.PositionInFamilyId, p.HohFlag, p.Age
                select p;
            }
            else if (sort == "name")
            {
                q = from p in q
                    orderby p.LastName, p.FamilyId, p.PositionInFamilyId, p.HohFlag, p.Age
                select p;
            }
            else
            {
                q = from p in q
                    orderby p.FamilyId, p.PositionInFamilyId, p.HohFlag, p.Age
                select p;
            }

            if (singleStatement)
            {
                var familylist = q.ToList();
                if (familylist.Any(m => m.DeceasedDate != null && m.ContributionOptionsId == 2))
                {
                    return(GetInfo(familylist));
                }
            }

            const int NOTSPEC = 0;
            const int NONE    = StatementOptionCode.None;
            const int JOINT   = StatementOptionCode.Joint;
            const int INDIV   = StatementOptionCode.Individual;

            if (MinAmt > 0)
            {
                q = from p in q
                    let option = (p.ContributionOptionsId ?? NOTSPEC) == NOTSPEC
                            ? (p.SpouseId > 0 && (p.SpouseContributionOptionsId ?? NOTSPEC) != INDIV ? JOINT : INDIV)
                            : p.ContributionOptionsId
                                 where option != NONE || noaddressok
                                 where (option == INDIV && (p.Amount >= MinAmt)) ||
                                 (option == JOINT && p.HohFlag == 1 && ((p.Amount + p.SpouseAmount) >= MinAmt))
                                 where p.ElectronicStatement == false || excludeelectronic == false
                                 select p;
            }
            else
            {
                q = from p in q
                    let option =
                    (p.ContributionOptionsId ?? NOTSPEC) == NOTSPEC
                            ? (p.SpouseId > 0 && (p.SpouseContributionOptionsId ?? 0) != INDIV ? JOINT : INDIV)
                            : p.ContributionOptionsId
                    where option != NONE || noaddressok
                    where p.ElectronicStatement == false || excludeelectronic == false
                    where
                    (option == INDIV && (p.Amount > 0 || p.GiftInKind == true)) ||   // GiftInKind = NonTaxDeductible Fund or Pledge OR GiftInkind
                    (option == JOINT && p.HohFlag == 1 && ((p.Amount + p.SpouseAmount) > 0 || p.GiftInKind == true))
                    select p;
            }

            IEnumerable <ContributorInfo> q2 = null;

            if (Db.Setting("NoTitlesOnStatements", "false").ToBool())
            {
                q2 = from p in q
                     let option = (p.ContributionOptionsId ?? 0) == 0
                         ? (p.SpouseId > 0 && (p.SpouseContributionOptionsId ?? 0) != 1 ? 2 : 1)
                         : p.ContributionOptionsId
                                  let name =
                    option == 1
                             ? p.Name
                             : (p.SpouseId == null
                                 ? p.Name
                                 : (p.HohFlag == 1
                                     ? p.CoupleName ?? (p.Name + " and " + p.SpouseName)
                                     : p.CoupleName ?? (p.SpouseName + " and " + p.Name)))
                    select new ContributorInfo
                {
                    Name             = name,
                    MailingAddress   = MailingAddress(p),
                    PeopleId         = p.PeopleId,
                    SpouseID         = p.SpouseId,
                    DeacesedDate     = p.DeceasedDate,
                    FamilyId         = p.FamilyId,
                    Age              = p.Age,
                    FamilyPositionId = p.PositionInFamilyId,
                    hohInd           = p.HohFlag,
                    Joint            = option == 2,
                    CampusId         = p.CampusId,
                }
            }
            ;
            else
            {
                q2 = GetInfo(q);
            }

            return(q2);
        }
예제 #2
0
        public static IEnumerable<ContributorInfo> contributors(CMSDataContext Db, DateTime fromDate, DateTime toDate, int PeopleId, int? SpouseId, int FamilyId, bool noaddressok, bool useMinAmt, string startswith = null)
        {
            var MinAmt = Db.Setting("MinContributionAmount", "5").ToDecimal();
            if (!useMinAmt)
                MinAmt = 0;
            var q11 = from p in Db.Contributors(fromDate, toDate, PeopleId, SpouseId, FamilyId, noaddressok)
                      let option =
                          (p.ContributionOptionsId ?? 0) == 0
                              ? (p.SpouseId > 0 && (p.SpouseContributionOptionsId ?? 0) != 1 ? 2 : 1)
                              : p.ContributionOptionsId
                      let option2 =
                          (p.SpouseContributionOptionsId ?? 0) == 0
                              ? (p.SpouseId > 0 ? 2 : 1)
                              : p.SpouseContributionOptionsId
                      let name = (option == 1
                                      ? (p.Title != null ? p.Title + " " + p.Name : p.Name)
                                      : (p.SpouseId == null
                                             ? (p.Title != null ? p.Title + " " + p.Name : p.Name)
                                             : (p.HohFlag == 1
                                                    ? ((p.Title != null && p.Title != "")
                                                           ? p.Title + " and Mrs. " + p.Name
                                                           : "Mr. and Mrs. " + p.Name)
                                                    : ((p.SpouseTitle != null && p.SpouseTitle != "")
                                                           ? p.SpouseTitle + " and Mrs. " + p.SpouseName
                                                           : "Mr. and Mrs. " + p.SpouseName))))
                                 + ((p.Suffix == null || p.Suffix == "") ? "" : ", " + p.Suffix)
                      where option != 9 || noaddressok
                      where startswith == null || p.LastName.StartsWith(startswith)
            #if DEBUG2
                      where p.PeopleId == 828612
            #endif

                      where (option == 1 && (p.Amount > MinAmt || p.GiftInKind == true))  // GiftInKind = NonTaxDeductible Fund or Pledge OR GiftInkind
                            || (option == 2 && p.HohFlag == 1 && ((p.Amount + p.SpouseAmount) > MinAmt || p.GiftInKind == true))

                      orderby p.FamilyId, p.PositionInFamilyId, p.HohFlag, p.Age
                      select new ContributorInfo
                      {
                          Name = name,
                          Address1 = p.PrimaryAddress,
                          Address2 = p.PrimaryAddress2,
                          City = p.PrimaryCity,
                          State = p.PrimaryState,
                          Zip = p.PrimaryZip,
                          PeopleId = p.PeopleId,
                          SpouseID = p.SpouseId,
                          DeacesedDate = p.DeceasedDate,
                          FamilyId = p.FamilyId,
                          Age = p.Age,
                          FamilyPositionId = p.PositionInFamilyId,
                          hohInd = p.HohFlag,
                          Joint = option == 2,
                          CampusId = p.CampusId,
                      };

            #if DEBUG
            return q11.Take(30);
            #else
            return q11;
            #endif
        }
예제 #3
0
        public static IEnumerable<ContributorInfo> contributors(CMSDataContext Db,
            DateTime fromDate, DateTime toDate, int PeopleId, int? SpouseId, int FamilyId, bool noaddressok, bool useMinAmt,
            string startswith = null, string sort = null, bool singleStatement = false, int? tagid = null, bool excludeelectronic = false)
        {
            var MinAmt = Db.Setting("MinContributionAmount", "5").ToDecimal();
            if (!useMinAmt)
                MinAmt = 0;

            var endswith = "";
            if (startswith != null && startswith.Contains("-"))
            {
                var a = startswith.SplitStr("-", 2);
                startswith = a[0];
                endswith = a[1];
            }
            var q = from p in Db.Contributors(fromDate, toDate, PeopleId, SpouseId, FamilyId, noaddressok, tagid)
                    select p;

            if (startswith.HasValue() && !endswith.HasValue())
                q = from p in q
                    where p.LastName.StartsWith(startswith)
                    select p;
            else if (startswith.HasValue() && endswith.HasValue())
                q = from p in q
                    // ReSharper disable StringCompareToIsCultureSpecific
                    where (p.LastName.CompareTo(startswith) >= 0 && p.LastName.CompareTo(endswith) < 0) || SqlMethods.Like(p.LastName, endswith + "%")
                    select p;

            if (sort == "zip")
                q = from p in q
                    orderby p.PrimaryZip, p.FamilyId, p.PositionInFamilyId, p.HohFlag, p.Age
                    select p;
            else if (sort == "name")
                q = from p in q
                    orderby p.LastName, p.FamilyId, p.PositionInFamilyId, p.HohFlag, p.Age
                    select p;
            else
                q = from p in q
                    orderby p.FamilyId, p.PositionInFamilyId, p.HohFlag, p.Age
                    select p;

            if (singleStatement)
            {
                var familylist = q.ToList();
                if (familylist.Any(m => m.DeceasedDate != null && m.ContributionOptionsId == 2))
                    return GetInfo(familylist);
            }

            const int NOTSPEC = 0;
            const int NONE = StatementOptionCode.None;
            const int JOINT = StatementOptionCode.Joint;
            const int INDIV = StatementOptionCode.Individual;

            if (MinAmt > 0)
                q = from p in q
                    let option = (p.ContributionOptionsId ?? NOTSPEC) == NOTSPEC
                            ? (p.SpouseId > 0 && (p.SpouseContributionOptionsId ?? NOTSPEC) != INDIV ? JOINT : INDIV)
                            : p.ContributionOptionsId
                    where option != NONE || noaddressok
                    where (option == INDIV && (p.Amount > MinAmt))
                            || (option == JOINT && p.HohFlag == 1 && ((p.Amount + p.SpouseAmount) > MinAmt))
                    where p.ElectronicStatement == false || excludeelectronic == false
                    select p;
            else
                q = from p in q
                    let option =
                        (p.ContributionOptionsId ?? NOTSPEC) == NOTSPEC
                            ? (p.SpouseId > 0 && (p.SpouseContributionOptionsId ?? 0) != INDIV ? JOINT : INDIV)
                            : p.ContributionOptionsId
                    where option != NONE || noaddressok
                    where p.ElectronicStatement == false || excludeelectronic == false
                    where
                        (option == INDIV && (p.Amount > 0 || p.GiftInKind == true))  // GiftInKind = NonTaxDeductible Fund or Pledge OR GiftInkind
                        || (option == JOINT && p.HohFlag == 1 && ((p.Amount + p.SpouseAmount) > 0 || p.GiftInKind == true))
                    select p;

            IEnumerable<ContributorInfo> q2 = null;
            if (Db.Setting("NoTitlesOnStatements", "false").ToBool())
                q2 = from p in q
                     let option = (p.ContributionOptionsId ?? 0) == 0
                         ? (p.SpouseId > 0 && (p.SpouseContributionOptionsId ?? 0) != 1 ? 2 : 1)
                         : p.ContributionOptionsId
                     let name =
                         option == 1
                             ? p.Name
                             : (p.SpouseId == null
                                 ? p.Name
                                 : (p.HohFlag == 1
                                     ? p.CoupleName ?? (p.Name + " and " + p.SpouseName)
                                     : p.CoupleName ?? (p.SpouseName + " and " + p.Name)))
                     select new ContributorInfo
                     {
                         Name = name,
                         MailingAddress = MailingAddress(p),
                         PeopleId = p.PeopleId,
                         SpouseID = p.SpouseId,
                         DeacesedDate = p.DeceasedDate,
                         FamilyId = p.FamilyId,
                         Age = p.Age,
                         FamilyPositionId = p.PositionInFamilyId,
                         hohInd = p.HohFlag,
                         Joint = option == 2,
                         CampusId = p.CampusId,
                     };
            else
                q2 = GetInfo(q);

            return q2;
        }
예제 #4
0
        public static IEnumerable <ContributorInfo> contributors(CMSDataContext Db, DateTime fromDate, DateTime toDate, int PeopleId, int?SpouseId, int FamilyId, bool noaddressok, bool useMinAmt, string startswith = null)
        {
            var MinAmt = Db.Setting("MinContributionAmount", "5").ToDecimal();

            if (!useMinAmt)
            {
                MinAmt = 0;
            }
            var q11 = from p in Db.Contributors(fromDate, toDate, PeopleId, SpouseId, FamilyId, noaddressok)
                      let option =
                (p.ContributionOptionsId ?? 0) == 0
                              ? (p.SpouseId > 0 && (p.SpouseContributionOptionsId ?? 0) != 1 ? 2 : 1)
                              : p.ContributionOptionsId
                let option2 =
                    (p.SpouseContributionOptionsId ?? 0) == 0
                              ? (p.SpouseId > 0 ? 2 : 1)
                              : p.SpouseContributionOptionsId
                    let name = (option == 1
                                      ? (p.Title != null ? p.Title + " " + p.Name : p.Name)
                                      : (p.SpouseId == null
                                             ? (p.Title != null ? p.Title + " " + p.Name : p.Name)
                                             : (p.HohFlag == 1
                                                    ? ((p.Title != null && p.Title != "")
                                                           ? p.Title + " and Mrs. " + p.Name
                                                           : "Mr. and Mrs. " + p.Name)
                                                    : ((p.SpouseTitle != null && p.SpouseTitle != "")
                                                           ? p.SpouseTitle + " and Mrs. " + p.SpouseName
                                                           : "Mr. and Mrs. " + p.SpouseName))))
                               + ((p.Suffix == null || p.Suffix == "") ? "" : ", " + p.Suffix)
                               where option != 9 || noaddressok
                               where startswith == null || p.LastName.StartsWith(startswith)
#if DEBUG2
                               where p.LastName.StartsWith("V")
#endif
                               where (option == 1 && (p.Amount > MinAmt || p.GiftInKind == true)) ||
                               (option == 2 && p.HohFlag == 1 && ((p.Amount + p.SpouseAmount) > MinAmt || p.GiftInKind == true))
                               orderby p.FamilyId, p.PositionInFamilyId, p.HohFlag, p.Age
                select new ContributorInfo
            {
                Name             = name,
                Address1         = p.PrimaryAddress,
                Address2         = p.PrimaryAddress2,
                City             = p.PrimaryCity,
                State            = p.PrimaryState,
                Zip              = p.PrimaryZip,
                PeopleId         = p.PeopleId,
                SpouseID         = p.SpouseId,
                DeacesedDate     = p.DeceasedDate,
                FamilyId         = p.FamilyId,
                Age              = p.Age,
                FamilyPositionId = p.PositionInFamilyId,
                hohInd           = p.HohFlag,
                Joint            = option == 2,
                CampusId         = p.CampusId,
            };

#if DEBUG
            return(q11.Take(30));
#else
            return(q11);
#endif
        }