当前位置: 首页>>代码示例>>C#>>正文


C# CMSDataContext.GetCurrentOnlinePledgeBundle方法代码示例

本文整理汇总了C#中CmsData.CMSDataContext.GetCurrentOnlinePledgeBundle方法的典型用法代码示例。如果您正苦于以下问题:C# CMSDataContext.GetCurrentOnlinePledgeBundle方法的具体用法?C# CMSDataContext.GetCurrentOnlinePledgeBundle怎么用?C# CMSDataContext.GetCurrentOnlinePledgeBundle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CmsData.CMSDataContext的用法示例。


在下文中一共展示了CMSDataContext.GetCurrentOnlinePledgeBundle方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PostUnattendedContribution

        public Contribution PostUnattendedContribution(CMSDataContext db, decimal amt, int? fund, string description, bool pledge = false, int? typecode = null, int? tranid = null)
        {
            if (!typecode.HasValue)
            {
                typecode = BundleTypeCode.Online;
                if (pledge)
                    typecode = BundleTypeCode.OnlinePledge;
            }

            var now = Util.Now;
            var d = now.Date;
            BundleHeader bundle = null;

            var spec = db.Setting("OnlineContributionBundleDayTime", "");
            if (spec.HasValue())
            {
                var a = spec.SplitStr(" ", 2);
                try
                {
                    var next = DateTime.Parse(now.ToShortDateString() + " " + a[1]);
                    var dow = Enum.Parse(typeof(DayOfWeek), a[0], ignoreCase: true);
                    next = next.Sunday().Add(next.TimeOfDay).AddDays(dow.ToInt());
                    if (now > next)
                        next = next.AddDays(7);
                    var prev = next.AddDays(-7);
                    var bid = BundleTypeCode.MissionTrip == typecode
                        ? db.GetCurrentMissionTripBundle(next, prev)
                        : BundleTypeCode.OnlinePledge == typecode
                            ? db.GetCurrentOnlinePledgeBundle(next, prev)
                            : db.GetCurrentOnlineBundle(next, prev);
                    bundle = db.BundleHeaders.SingleOrDefault(bb => bb.BundleHeaderId == bid);
                }
                catch (Exception)
                {
                    spec = "";
                }
            }
            if (!spec.HasValue())
            {
                var nextd = d.AddDays(1);
                var bid = BundleTypeCode.MissionTrip == typecode
                    ? db.GetCurrentMissionTripBundle(nextd, d)
                    : BundleTypeCode.OnlinePledge == typecode
                        ? db.GetCurrentOnlinePledgeBundle(nextd, d)
                        : db.GetCurrentOnlineBundle(nextd, d);
                bundle = db.BundleHeaders.SingleOrDefault(bb => bb.BundleHeaderId == bid);
            }
            if (bundle == null)
            {
                bundle = new BundleHeader
                {
                    BundleHeaderTypeId = typecode.Value,
                    BundleStatusId = BundleStatusCode.Open,
                    CreatedBy = Util.UserId1,
                    ContributionDate = d,
                    CreatedDate = now,
                    FundId = db.Setting("DefaultFundId", "1").ToInt(),
                    RecordStatus = false,
                    TotalCash = 0,
                    TotalChecks = 0,
                    TotalEnvelopes = 0,
                    BundleTotal = 0
                };
                db.BundleHeaders.InsertOnSubmit(bundle);
            }
            if (!fund.HasValue)
                fund = db.Setting("DefaultFundId", "1").ToInt();
            var fundtouse = (from f in db.ContributionFunds
                             where f.FundId == fund
                             select f).SingleOrDefault();

            //failsafe if fund is not found
            if (fundtouse == null)
                fund = (from f in db.ContributionFunds
                        where f.FundStatusId == 1
                        orderby f.FundId
                        select f.FundId).First();

            var financeManagerId = db.Setting("FinanceManagerId", "").ToInt2();
            if (!financeManagerId.HasValue)
            {
                var qu = from u in db.Users
                         where u.UserRoles.Any(ur => ur.Role.RoleName == "Finance")
                         orderby u.Person.LastName
                         select u.UserId;
                financeManagerId = qu.FirstOrDefault();
                if (!financeManagerId.HasValue)
                    financeManagerId = 1;
            }
            var bd = new BundleDetail
            {
                BundleHeaderId = bundle.BundleHeaderId,
                CreatedBy = financeManagerId.Value,
                CreatedDate = now,
            };
            var typid = ContributionTypeCode.CheckCash;
            if (pledge)
                typid = ContributionTypeCode.Pledge;
            bd.Contribution = new Contribution
            {
//.........这里部分代码省略.........
开发者ID:GSBCfamily,项目名称:bvcms,代码行数:101,代码来源:Person.cs


注:本文中的CmsData.CMSDataContext.GetCurrentOnlinePledgeBundle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。