Example #1
0
        public object PostContribution(PostBundleController ctl)
        {
            try
            {
                var bd = new BundleDetail
                {
                    BundleHeaderId = id,
                    CreatedBy = Util.UserId,
                    CreatedDate = DateTime.Now
                };
                int type;
                switch (PLNT)
                {
                    case "PL":
                        type = ContributionTypeCode.Pledge;
                        break;
                    case "NT":
                        type = ContributionTypeCode.NonTaxDed;
                        break;
                    case "GK":
                        type = ContributionTypeCode.GiftInKind;
                        break;
                    case "SK":
                        type = ContributionTypeCode.Stock;
                        break;
                    default:
                        type = ContributionTypeCode.CheckCash;
                        break;
                }

                decimal? othersplitamt = null;
                if (splitfrom > 0)
                {
                    var q = from c in DbUtil.Db.Contributions
                            where c.ContributionId == splitfrom
                            select new
                            {
                                c,
                                bd = c.BundleDetails.First()
                            };
                    var i = q.Single();
                    othersplitamt = i.c.ContributionAmount - amt;
                    i.c.ContributionAmount = othersplitamt;
                    DbUtil.Db.SubmitChanges();
                    bd.BundleSort1 = i.bd.BundleDetailId;
                }

                bd.Contribution = new Contribution
                {
                    CreatedBy = Util.UserId,
                    CreatedDate = bd.CreatedDate,
                    FundId = fund,
                    PeopleId = pid.ToInt2(),
                    ContributionDate = contributiondate ?? bundle.ContributionDate,
                    ContributionAmount = amt,
                    ContributionStatusId = 0,
                    ContributionTypeId = type,
                    ContributionDesc = notes,
                    CheckNo = (checkno ?? "").Trim().Truncate(20)
                };
                bundle.BundleDetails.Add(bd);
                DbUtil.Db.SubmitChanges();
                return ContributionRowData(ctl, bd.ContributionId, othersplitamt);
            }
            catch (Exception ex)
            {
                return new {error = ex.Message};
            }
        }
Example #2
0
        public object UpdateContribution(PostBundleController ctl)
        {
            var c = DbUtil.Db.Contributions.SingleOrDefault(cc => cc.ContributionId == editid);
            if (c == null)
                return null;

            var type = c.ContributionTypeId;
            switch (PLNT)
            {
                case "PL":
                    type = ContributionTypeCode.Pledge;
                    break;
                case "NT":
                    type = ContributionTypeCode.NonTaxDed;
                    break;
                case "GK":
                    type = ContributionTypeCode.GiftInKind;
                    break;
                case "SK":
                    type = ContributionTypeCode.Stock;
                    break;
                default:
                    type = ContributionTypeCode.CheckCash;
                    break;
            }
            c.FundId = fund;
            c.PeopleId = pid.ToInt2();
            c.ContributionAmount = amt;
            c.ContributionTypeId = type;
            c.ContributionDesc = notes;
            c.ContributionDate = contributiondate;
            c.CheckNo = checkno;
            DbUtil.Db.SubmitChanges();
            return ContributionRowData(ctl, c.ContributionId);
        }
Example #3
0
 public object ContributionRowData(PostBundleController ctl, int cid, decimal? othersplitamt = null)
 {
     var cinfo = FetchContributions(cid).Single();
     var body = ViewExtensions2.RenderPartialViewToString(ctl, "Row", cinfo);
     var q = from c in DbUtil.Db.Contributions
             let bh = c.BundleDetails.First().BundleHeader
             where c.ContributionId == cid
             select new
             {
                 row = body,
                 amt = c.ContributionAmount.ToString2("N2"),
                 cid,
                 totalitems = bh.BundleDetails.Sum(d =>
                     d.Contribution.ContributionAmount).ToString2("C2"),
                 diff = ((bh.TotalCash.GetValueOrDefault() + bh.TotalChecks.GetValueOrDefault() + bh.TotalEnvelopes.GetValueOrDefault()) - bh.BundleDetails.Sum(d => d.Contribution.ContributionAmount.GetValueOrDefault())),
                 difference = ((bh.TotalCash.GetValueOrDefault() + bh.TotalChecks.GetValueOrDefault() + bh.TotalEnvelopes.GetValueOrDefault()) - bh.BundleDetails.Sum(d => d.Contribution.ContributionAmount)).ToString2("C2"),
                 itemcount = bh.BundleDetails.Count(),
                 othersplitamt = othersplitamt.ToString2("N2")
             };
     return q.First();
 }