public ActionResult ListMember(int memberID) { int year = DateTime.Now.Year; string bDateString = "1/1/" + year.ToString(); DateTime bDate = Convert.ToDateTime(bDateString).Date; string eDateString = "12/31/" + year.ToString(); DateTime eDate = Convert.ToDateTime(eDateString).Date; decimal AnnualpledgeAmount; ViewBag.RecordCount = 0; IEnumerable <pledge> pledge = PledgeRepository.GetPledgeByMember(memberID, bDate.Year); if (pledge != null) { ViewBag.RecordCount = pledge.Count(); foreach (var i in pledge.Where(e => e.PledgeYear == year).ToList()) { //categoryID = ConstantRepository.GetConstantListByCategory("Member Contribution").FirstOrDefault(e => e.ConstantName == i.FundName).constantID; i.TotalAmountPaid = ContributionRepository.GetContributionByMemberCategoryRange(memberID, i.FundID, bDate, eDate).Sum(e => e.Amount); if (i.Type == "Weekly") { AnnualpledgeAmount = i.Amount * 52; } else if (i.Type == "Monthly") { AnnualpledgeAmount = i.Amount * 12; } else if (i.Type == "Semi-Monthly") { AnnualpledgeAmount = i.Amount * 24; } else if (i.Type == "Quarterly") { AnnualpledgeAmount = i.Amount * 4; } else if (i.Type == "Annually") { AnnualpledgeAmount = i.Amount; } else if (i.Type == "Bi-Annually") { AnnualpledgeAmount = i.Amount * 2; } else { AnnualpledgeAmount = i.Amount; } i.RatioCompleted = (i.TotalAmountPaid / AnnualpledgeAmount); } } return(PartialView(pledge)); }
public void TaxReport(int memberID) { string FileName = string.Format("{0}","ContributionTaxFile.pdf"); // var path = Path.Combine(Server.MapPath("~/public_html/ClientFiles"), FileName); var path = Path.Combine(Server.MapPath("~/App_Data/ClientFiles"), FileName); bool exist = System.IO.File.Exists(string.Format("{0}", path)); if (exist) { System.IO.File.Delete(string.Format("{0}", path)); //System.IO.File.Delete(@"C:\test.txt"); } member member = MemberRepository.GetMemberByID(memberID); Document doc = new Document(iTextSharp.text.PageSize.LETTER, 10, 10, 42, 35); PdfWriter wri = PdfWriter.GetInstance(doc, new FileStream(path, FileMode.Create)); doc.Open(); //image picture icon = PictureRepository.GetLetterHeadImage(); if (icon != null) { iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(icon.ImageData); //image.ScalePercent(50f); //image.SetAbsolutePosition(doc.PageSize.Width - 36f - 72f, doc.PageSize.Height - 36f - 216.6f); image.ScaleToFit(250f, 250f); // image.Border = iTextSharp.text.Rectangle.BOX; // image.BorderColor = iTextSharp.text.BaseColor.GREEN; // image.BorderWidth = 5f; doc.Add(image); } //get contribution data //ministry ministry = string ChurchName = ConstantRepository.GetConstantByName("Church Name").Value1; string ChurchAddress = ConstantRepository.GetConstantByName("Church Address").Value1; string ChurchPhone = ConstantRepository.GetConstantByName("Church Phone").Value1; constant signature1 = ConstantRepository.GetConstantByName("TaxSignature1"); constant signature2 = ConstantRepository.GetConstantByName("TaxSignature2"); Paragraph data; data = new Paragraph(string.Format("{0}\n", ChurchName)); doc.Add(data); data = new Paragraph(string.Format("{0}\n", ChurchAddress)); doc.Add(data); data = new Paragraph(string.Format("{0}\n", ChurchPhone)); doc.Add(data); data = new Paragraph(Environment.NewLine); doc.Add(data); data = new Paragraph("Member Contribution Tax Statement"); doc.Add(data); data = new Paragraph(Environment.NewLine); doc.Add(data); string memberTitle = SpouseRepository.JointTitheTitle(memberID); data = new Paragraph(string.Format("For: {0}", memberTitle)); doc.Add(data); data = new Paragraph(Environment.NewLine); doc.Add(data); int ContributionYear = DateTime.Today.Year; DateTime BeginDate = Convert.ToDateTime("1/1/" + ContributionYear.ToString()); DateTime EndDate = Convert.ToDateTime("12/31/" + ContributionYear.ToString()); int thiteID = ConstantRepository.GetConstantByName("Tithes").constantID; int offeringID = ConstantRepository.GetConstantByName("Offering").constantID; decimal TithesTotal = ContributionRepository.GetContributionByMemberCategoryRange(memberID, thiteID, BeginDate, EndDate).Sum(e => e.Amount); decimal OfferingTotal = ContributionRepository.GetContributionByMemberCategoryRange(memberID, offeringID, BeginDate, EndDate).Sum(e => e.Amount); decimal Totalcontribution = ContributionRepository.GetContributionByMemberDateRange(memberID,BeginDate, EndDate).Sum(e => e.Amount); decimal OthersTotal = Totalcontribution - TithesTotal - OfferingTotal; data = new Paragraph(string.Format("Tithes: {0:c}", TithesTotal)); doc.Add(data); data = new Paragraph(string.Format("Offerings: {0:c}", OfferingTotal)); doc.Add(data); data = new Paragraph(string.Format("Others: {0:c}", OthersTotal)); doc.Add(data); data = new Paragraph(string.Format("-----------------------------------")); doc.Add(data); data = new Paragraph(string.Format("Total: {0:c}", Totalcontribution)); doc.Add(data); data = new Paragraph(Environment.NewLine); doc.Add(data); data = new Paragraph(string.Format("-----------------------------------")); doc.Add(data); if (signature1.Value1 != "") { data = new Paragraph(string.Format("Signed: {0} ({1})", signature1.Value2, signature1.Value1)); doc.Add(data); } data = new Paragraph(Environment.NewLine); doc.Add(data); if (signature2.Value1 != "") { data = new Paragraph(string.Format("-----------------------------------")); doc.Add(data); data = new Paragraph(string.Format("Signed: {0} ({1})", signature2.Value2, signature2.Value1)); doc.Add(data); } doc.Close(); //document doc = DocumentRepository.GetDocumentByID(DocumentID); //string path = AppDomain.CurrentDomain.BaseDirectory + "App_Data/ClientFiles/"; path = AppDomain.CurrentDomain.BaseDirectory + "App_Data/ClientFiles/"; // path = AppDomain.CurrentDomain.BaseDirectory + "public_html/ClientFiles/"; Response.ContentType = "application/pdf"; Response.AddHeader("Content-Disposition", @"filename=""IT Report.xls"""); Response.TransmitFile(@path + FileName); //Response.TransmitFile(FileName); }
public void TaxReport2(int memberID, int Year) { try { string FileName = string.Format("{0}", "ContributionTaxFile.pdf"); // var path = Path.Combine(Server.MapPath("~/public_html/ClientFiles"), FileName); var path = Path.Combine(Server.MapPath("~/App_Data/ClientFiles"), FileName); bool exist = System.IO.File.Exists(string.Format("{0}", path)); if (exist) { System.IO.File.Delete(string.Format("{0}", path)); //System.IO.File.Delete(@"C:\test.txt"); } member member = MemberRepository.GetMemberByID(memberID); Document doc = new Document(iTextSharp.text.PageSize.LETTER, 70, 40, 42, 35); PdfWriter wri = PdfWriter.GetInstance(doc, new FileStream(path, FileMode.Create)); doc.Open(); //image //picture icon = PictureRepository.GetLetterHeadImage(); //if ((icon != null) || (DisplayLog0 == "Yes")) //{ // iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(icon.ImageData); // image.ScaleToFit(250f, 250f); // doc.Add(image); //} //get contribution data //ministry ministry = string ChurchName = ConstantRepository.GetConstantByName("Church Name").Value1; string ChurchAddress = ConstantRepository.GetConstantByName("Church Address").Value1; string ChurchPhone = ConstantRepository.GetConstantByName("Church Phone").Value1; string DisplayLog0 = ConstantRepository.GetConstantByName("Tax ChurchPicture").Value1; string DisplayChurchHeading = ConstantRepository.GetConstantByName("Tax ChurchAddress").Value1; constant signature1 = ConstantRepository.GetConstantByName("TaxSignature1"); constant signature2 = ConstantRepository.GetConstantByName("TaxSignature2"); Font fdefault = FontFactory.GetFont("Arial", 18, Font.NORMAL, BaseColor.BLACK); Paragraph data; //Add space string text = @" "; data = new Paragraph(string.Format("{0}", text)); doc.Add(data); if (DisplayChurchHeading == "Yes") { data = new Paragraph(string.Format("{0}\n", ChurchName), fdefault); doc.Add(data); fdefault = FontFactory.GetFont("Arial", 12, Font.NORMAL, BaseColor.BLACK); data = new Paragraph(string.Format("{0}\n", ChurchAddress), fdefault); doc.Add(data); data = new Paragraph(string.Format("{0}\n", ChurchPhone), fdefault); doc.Add(data); data = new Paragraph(Environment.NewLine); data.SpacingAfter = 15; doc.Add(data); } else { data = new Paragraph(); data.SpacingAfter = 25; doc.Add(data); } fdefault = FontFactory.GetFont("Arial", 18, Font.BOLD, BaseColor.BLACK); data = new Paragraph(Year.ToString() + " Member Contribution Tax Statement", fdefault); data.SpacingBefore = 35; doc.Add(data); data = new Paragraph(Environment.NewLine); data.SpacingAfter = 15; doc.Add(data); string memberTitle = SpouseRepository.JointTitheTitle(memberID); data = new Paragraph(string.Format("Dear {0},", memberTitle)); data.SpacingAfter = 3; doc.Add(data); text = @"Thanks for your financial support to the " + ChurchName + ". The Pastor and leaders of the church truly appreciate your contributions and pray the Lord bless you and keep You. Amen."; fdefault = FontFactory.GetFont("Arial", 14, Font.NORMAL, BaseColor.BLACK); data = new Paragraph(string.Format("{0}", text, fdefault)); data.SpacingAfter = 25; doc.Add(data); data = new Paragraph(Environment.NewLine); doc.Add(data); int ContributionYear = Year; // DateTime.Today.Year; DateTime BeginDate = Convert.ToDateTime("1/1/" + ContributionYear.ToString()); DateTime EndDate = Convert.ToDateTime("12/31/" + ContributionYear.ToString()); int thiteID = ConstantRepository.GetConstantByName("Tithes").constantID; int offeringID = ConstantRepository.GetConstantByName("Offering").constantID; decimal TithesTotal = ContributionRepository.GetContributionByMemberCategoryRange(memberID, thiteID, BeginDate, EndDate).Sum(e => e.Amount); decimal OfferingTotal = ContributionRepository.GetContributionByMemberCategoryRange(memberID, offeringID, BeginDate, EndDate).Sum(e => e.Amount); decimal Totalcontribution = ContributionRepository.GetContributionByMemberDateRange(memberID, BeginDate, EndDate).Sum(e => e.Amount); decimal OthersTotal = Totalcontribution - TithesTotal - OfferingTotal; Font fdefault2 = FontFactory.GetFont("Arial", 18, Font.BOLD, BaseColor.BLACK); data = new Paragraph(string.Format("Tithes: {0:c}", TithesTotal, fdefault2)); doc.Add(data); data = new Paragraph(string.Format("Offerings: {0:c}", OfferingTotal, fdefault2)); doc.Add(data); data = new Paragraph(string.Format("Others: {0:c}", OthersTotal, fdefault2)); doc.Add(data); data = new Paragraph(string.Format("--------------------------------------------")); doc.Add(data); data = new Paragraph(string.Format("Total: {0:c}", Totalcontribution, fdefault2)); doc.Add(data); data = new Paragraph(Environment.NewLine); doc.Add(data); //Add space text = @" "; data = new Paragraph(string.Format("{0}", text)); doc.Add(data); data.SpacingBefore = 25; data = new Paragraph(string.Format("--------------------------------------------")); doc.Add(data); if (signature1.Value1 != "") { fdefault = FontFactory.GetFont("Arial", 10, Font.ITALIC, BaseColor.RED); data = new Paragraph(string.Format("Signed: {0} ({1})", signature1.Value2, signature1.Value1, fdefault2)); doc.Add(data); } data.SpacingBefore = 5; data = new Paragraph(Environment.NewLine); doc.Add(data); //Add space text = @" "; data = new Paragraph(string.Format("{0}", text)); doc.Add(data); if (signature2.Value1 != "") { fdefault = FontFactory.GetFont("Arial", 10, Font.ITALIC, BaseColor.RED); data = new Paragraph(string.Format("--------------------------------------------")); doc.Add(data); data = new Paragraph(string.Format("Signed: {0} ({1})", signature2.Value2, signature2.Value1, fdefault2)); doc.Add(data); } doc.Close(); //document doc = DocumentRepository.GetDocumentByID(DocumentID); //string path = AppDomain.CurrentDomain.BaseDirectory + "App_Data/ClientFiles/"; path = AppDomain.CurrentDomain.BaseDirectory + "App_Data/ClientFiles/"; // path = AppDomain.CurrentDomain.BaseDirectory + "public_html/ClientFiles/"; Response.ContentType = "application/pdf"; Response.AddHeader("Content-Disposition", @"filename=""IT Report.xls"""); Response.TransmitFile(@path + FileName); //Response.TransmitFile(FileName); } catch (Exception ex) { TempData["Message2"] = string.Format("Error printing tax report."); } }