本文整理汇总了C#中CmsData.CMSDataContext.GetCurrentOnlineBundle方法的典型用法代码示例。如果您正苦于以下问题:C# CMSDataContext.GetCurrentOnlineBundle方法的具体用法?C# CMSDataContext.GetCurrentOnlineBundle怎么用?C# CMSDataContext.GetCurrentOnlineBundle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CmsData.CMSDataContext
的用法示例。
在下文中一共展示了CMSDataContext.GetCurrentOnlineBundle方法的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 (Util.HasValue(spec))
{
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)
: Db.GetCurrentOnlineBundle(next, prev);
bundle = Db.BundleHeaders.SingleOrDefault(bb => bb.BundleHeaderId == bid);
}
catch (Exception)
{
spec = "";
}
}
if(!Util.HasValue(spec))
{
var nextd = d.AddDays(1);
var bid = BundleTypeCode.MissionTrip == typecode
? Db.GetCurrentMissionTripBundle(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
{
CreatedBy = FinanceManagerId.Value,
CreatedDate = bd.CreatedDate,
FundId = Fund.Value,
PeopleId = PeopleId,
//.........这里部分代码省略.........