private void btnSave_Click(object sender, EventArgs e) { try { if (Course.Text == "") { MessageBox.Show("Please select course", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Course.Focus(); return; } if (Branch.Text == "") { MessageBox.Show("Please select branch", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Branch.Focus(); return; } if (Semester.Text == "") { MessageBox.Show("Please select semester", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Semester.Focus(); return; } if (TutionFees.Text == "") { MessageBox.Show("Please enter tution fees", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); TutionFees.Focus(); return; } if (UDFees.Text == "") { MessageBox.Show("Please enter university development fees", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); UDFees.Focus(); return; } if (LibraryFees.Text == "") { MessageBox.Show("Please enter library fees", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); LibraryFees.Focus(); return; } if (USFees.Text == "") { MessageBox.Show("Please enter university student welfare fees", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); USFees.Focus(); return; } if (OtherFees.Text == "") { MessageBox.Show("Please enter other fees", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); OtherFees.Focus(); return; } if (Semester.Text == "1st") { if (CautionMoney.Text == "") { MessageBox.Show("Please enter caution money", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); CautionMoney.Focus(); return; } } con = new SqlConnection(cs.DBConn); con.Open(); string ct = "select Semester,Course,Branch from FeesDetails where Semester= '" + Semester.Text + "' and Course = '" + Course.Text + "' and branch= '" + Branch.Text + "'"; cmd = new SqlCommand(ct); cmd.Connection = con; rdr = cmd.ExecuteReader(); if (rdr.Read()) { MessageBox.Show("Record Already Exists", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Reset(); if ((rdr != null)) { rdr.Close(); } return; } if (Semester.Text == "1st") { TotalFees.Text = (int.Parse(TutionFees.Text) + int.Parse(LibraryFees.Text) + int.Parse(UDFees.Text) + int.Parse(USFees.Text) + int.Parse(OtherFees.Text) + int.Parse(CautionMoney.Text)).ToString(); } else { TotalFees.Text = (int.Parse(TutionFees.Text) + int.Parse(LibraryFees.Text) + int.Parse(UDFees.Text) + int.Parse(USFees.Text) + int.Parse(OtherFees.Text)).ToString(); } auto(); con = new SqlConnection(cs.DBConn); con.Open(); string ct1 = "select feeid from feesdetails where feeid=@find"; cmd = new SqlCommand(ct1); cmd.Connection = con; cmd.Parameters.Add(new SqlParameter("@find", System.Data.SqlDbType.NChar, 20, "feeid")); cmd.Parameters["@find"].Value = FeeID.Text; rdr = cmd.ExecuteReader(); if (rdr.Read()) { MessageBox.Show("Fee ID Already Exists", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); FeeID.Text = ""; if ((rdr != null)) { rdr.Close(); } return; } con = new SqlConnection(cs.DBConn); con.Open(); string cb = "insert into feesdetails(FeeID,Course,Branch,Semester,TutionFees,LibraryFees,UniversityDevelopmentFees,UniversityStudentWelfareFees,CautionMoney,OtherFees,TotalFees) VALUES (@d1,@d2,@d3,@d4,@d5,@d6,@d7,@d8,@d9,@d10,@d11)"; cmd = new SqlCommand(cb); cmd.Connection = con; cmd.Parameters.Add(new SqlParameter("@d1", System.Data.SqlDbType.NChar, 20, "FeeId")); cmd.Parameters.Add(new SqlParameter("@d2", System.Data.SqlDbType.NChar, 20, "Course")); cmd.Parameters.Add(new SqlParameter("@d3", System.Data.SqlDbType.NChar, 30, "Branch")); cmd.Parameters.Add(new SqlParameter("@d4", System.Data.SqlDbType.NChar, 10, "Semester")); cmd.Parameters.Add(new SqlParameter("@d5", System.Data.SqlDbType.NChar, 10, "TutionFees")); cmd.Parameters.Add(new SqlParameter("@d6", System.Data.SqlDbType.NChar, 10, "LibraryFees")); cmd.Parameters.Add(new SqlParameter("@d7", System.Data.SqlDbType.NChar, 10, "UniversityDevelopmentFees")); cmd.Parameters.Add(new SqlParameter("@d8", System.Data.SqlDbType.NChar, 15, "UniversityStudentWelfareFees")); cmd.Parameters.Add(new SqlParameter("@d9", System.Data.SqlDbType.NChar, 10, "CautionMoney")); cmd.Parameters.Add(new SqlParameter("@d10", System.Data.SqlDbType.NChar, 10, "OtherFees")); cmd.Parameters.Add(new SqlParameter("@d11", System.Data.SqlDbType.NChar, 10, "TotalFees")); cmd.Parameters["@d1"].Value = FeeID.Text.Trim(); cmd.Parameters["@d2"].Value = Course.Text.Trim(); cmd.Parameters["@d3"].Value = Branch.Text.Trim(); cmd.Parameters["@d4"].Value = Semester.Text.Trim(); cmd.Parameters["@d5"].Value = (TutionFees.Text); cmd.Parameters["@d6"].Value = (LibraryFees.Text); cmd.Parameters["@d7"].Value = (UDFees.Text); cmd.Parameters["@d8"].Value = (USFees.Text); if (Semester.Text == "1st") { cmd.Parameters["@d9"].Value = (CautionMoney.Text); } else { cmd.Parameters["@d9"].Value = 0; } cmd.Parameters["@d10"].Value = (OtherFees.Text); cmd.Parameters["@d11"].Value = (TotalFees.Text); cmd.ExecuteNonQuery(); MessageBox.Show("Successfully saved", "Fees Record", MessageBoxButtons.OK, MessageBoxIcon.Information); con.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public bool Print() { try { rptFont = FontFactory.GetFont("Arial", 8, Font.NORMAL); rptFontBold = FontFactory.GetFont("Arial", 8, Font.BOLD); rptFontHeader = FontFactory.GetFont("Arial", 10, Font.BOLD); if (string.IsNullOrWhiteSpace(Context.OutputPath)) { FileLogger.Instance.logMessage(LogLevel.ERROR, this, "Pickup Payment Receipt printing failed since file name is not set"); return(false); } document = new Document(PageSize.HALFLETTER.Rotate()); document.AddTitle("Pickup Payment Receipt"); var writer = PdfWriter.GetInstance(document, new FileStream(Context.OutputPath, FileMode.Create)); const int mainTableColumns = 1; var mainTable = new PdfPTable(mainTableColumns) { WidthPercentage = 100 }; mainTable.AddCell(new PdfPCell(new Paragraph("Pickup Payment Receipt", rptFontHeader)) { Border = Rectangle.BOTTOM_BORDER, HorizontalAlignment = Element.ALIGN_CENTER, Colspan = mainTableColumns }); var topDataTable = new PdfPTable(5) { WidthPercentage = 100 }; var ticket = Context.Ticket; PfiMailerFee = ticket.PfiMailerSent ? new BusinessRulesProcedures(GlobalDataAccessor.Instance.DesktopSession).GetPFIMailerFee( GlobalDataAccessor.Instance.DesktopSession.CurrentSiteId) : 0M; topDataTable.SetWidths(new[] { 1f, 1f, 8f, 1f, 1f }); topDataTable.AddCell(new PdfPCell(new Paragraph("Date:", rptFont)) { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_LEFT }); topDataTable.AddCell(new PdfPCell(new Paragraph(Context.Time.FormatDate(), rptFont)) { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_LEFT }); topDataTable.AddCell(new PdfPCell(new Paragraph(string.Format("{0} # {1}", Context.StoreName, Context.StoreNumber), rptFont)) { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_CENTER, NoWrap = true }); topDataTable.AddCell(new PdfPCell(new Paragraph("Ticket No:", rptFont)) { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_RIGHT }); topDataTable.AddCell(new PdfPCell(new Paragraph(ticket.TicketNumber.ToString(), rptFont)) { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_RIGHT }); topDataTable.AddCell(new PdfPCell(new Paragraph("Time:", rptFont)) { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_LEFT }); topDataTable.AddCell(new PdfPCell(new Paragraph(Context.Time.ToString("t"), rptFont)) { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_LEFT }); topDataTable.AddCell(new PdfPCell(new Paragraph(Context.StoreAddress, rptFont)) { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_CENTER, NoWrap = true }); topDataTable.AddCell(new PdfPCell(new Paragraph("Emp No:", rptFont)) { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_RIGHT }); topDataTable.AddCell(new PdfPCell(new Paragraph(Context.EmployeeNumber, rptFont)) { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_RIGHT }); mainTable.AddCell(new PdfPCell(topDataTable) { Colspan = mainTableColumns, Border = Rectangle.NO_BORDER }); mainTable.AddCell(new PdfPCell(new Phrase()) { Border = Rectangle.NO_BORDER, Colspan = mainTableColumns, FixedHeight = 10 }); // empty row var ticketTable = new PdfPTable(4) { WidthPercentage = 100 }; ticketTable.SetWidths(new[] { 1f, 6f, 2f, 1f }); ticketTable.AddCell(new PdfPCell(new Phrase()) { Border = Rectangle.NO_BORDER }); ticketTable.AddCell(new PdfPCell(new Phrase()) { Border = Rectangle.NO_BORDER }); ticketTable.AddCell(new PdfPCell(new Paragraph("Current Principal Amount:", rptFont)) { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_RIGHT }); ticketTable.AddCell(new PdfPCell(new Paragraph(ticket.CurrentPrincipalAmount.ToString("c"), rptFont)) { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_RIGHT }); ticketTable.AddCell(new PdfPCell(new Phrase()) { Border = Rectangle.NO_BORDER }); ticketTable.AddCell(new PdfPCell(new Phrase()) { Border = Rectangle.NO_BORDER }); ticketTable.AddCell(new PdfPCell(new Paragraph("Interest:", rptFont)) { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_RIGHT }); ticketTable.AddCell(new PdfPCell(new Paragraph(ticket.Interest.ToString("c"), rptFont)) { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_RIGHT }); ticketTable.AddCell(new PdfPCell(new Phrase()) { Border = Rectangle.NO_BORDER }); ticketTable.AddCell(new PdfPCell(new Phrase()) { Border = Rectangle.NO_BORDER }); ticketTable.AddCell(new PdfPCell(new Paragraph("Processing Fee:", rptFont)) { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_RIGHT }); ticketTable.AddCell(new PdfPCell(new Paragraph(ticket.ServiceFee.ToString("c"), rptFont)) { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_RIGHT }); OtherFees = PfiMailerFee + ticket.LateFee + ticket.LostTicketFee; ticketTable.AddCell(new PdfPCell(new Phrase()) { Border = Rectangle.NO_BORDER }); ticketTable.AddCell(new PdfPCell(new Phrase()) { Border = Rectangle.NO_BORDER }); ticketTable.AddCell(new PdfPCell(new Paragraph("Other:", rptFont)) { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_RIGHT }); ticketTable.AddCell(new PdfPCell(new Paragraph(OtherFees.ToString("c"), rptFont)) { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_RIGHT }); TicketTotal = ticket.CurrentPrincipalAmount + ticket.Interest + ticket.ServiceFee + OtherFees; ticketTable.AddCell(new PdfPCell(new Phrase()) { Border = Rectangle.NO_BORDER }); ticketTable.AddCell(new PdfPCell(new Phrase()) { Border = Rectangle.NO_BORDER }); ticketTable.AddCell(new PdfPCell(new Phrase()) { Border = Rectangle.NO_BORDER }); ticketTable.AddCell(new PdfPCell(new Paragraph("------------", rptFont)) { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_RIGHT }); ticketTable.AddCell(new PdfPCell(new Phrase()) { Border = Rectangle.NO_BORDER }); ticketTable.AddCell(new PdfPCell(new Phrase()) { Border = Rectangle.NO_BORDER }); ticketTable.AddCell(new PdfPCell(new Paragraph("Total Payment Amount:", rptFont)) { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_RIGHT }); ticketTable.AddCell(new PdfPCell(new Paragraph(TicketTotal.ToString("c"), rptFont)) { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_RIGHT }); ticketTable.AddCell(new PdfPCell(new Phrase()) { Border = Rectangle.NO_BORDER, Colspan = 4 }); mainTable.AddCell(new PdfPCell(ticketTable) { Colspan = mainTableColumns, Border = Rectangle.NO_BORDER }); mainTable.AddCell(new PdfPCell(new Phrase()) { Border = Rectangle.NO_BORDER, Colspan = mainTableColumns, FixedHeight = 10 }); // empty row var bottomTable = new PdfPTable(3) { WidthPercentage = 100 }; bottomTable.SetWidths(new[] { 7f, 2f, 1f }); bottomTable.AddCell(new PdfPCell(new Paragraph(Context.CustomerName, rptFont)) { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_LEFT }); bottomTable.AddCell(new PdfPCell(new Phrase()) { Border = Rectangle.NO_BORDER }); bottomTable.AddCell(new PdfPCell(new Phrase()) { Border = Rectangle.NO_BORDER }); bottomTable.AddCell(new PdfPCell(new Paragraph(Context.CustomerAddress, rptFont)) { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_LEFT }); bottomTable.AddCell(new PdfPCell(new Phrase()) { Border = Rectangle.NO_BORDER }); bottomTable.AddCell(new PdfPCell(new Phrase()) { Border = Rectangle.NO_BORDER }); bottomTable.AddCell(new PdfPCell(new Paragraph(Context.CustomerCityStateZip, rptFont)) { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_LEFT }); bottomTable.AddCell(new PdfPCell(new Phrase()) { Border = Rectangle.NO_BORDER }); bottomTable.AddCell(new PdfPCell(new Phrase()) { Border = Rectangle.NO_BORDER }); bottomTable.AddCell(new PdfPCell(new Paragraph(Context.CustomerPhone, rptFont)) { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_LEFT }); bottomTable.AddCell(new PdfPCell(new Phrase()) { Border = Rectangle.NO_BORDER }); bottomTable.AddCell(new PdfPCell(new Phrase()) { Border = Rectangle.NO_BORDER }); mainTable.AddCell(new PdfPCell(bottomTable) { Colspan = mainTableColumns, Border = Rectangle.NO_BORDER }); mainTable.AddCell(new PdfPCell(new Phrase()) { Border = Rectangle.NO_BORDER, Colspan = mainTableColumns, FixedHeight = 10 }); // empty row document.Open(); document.Add(mainTable); document.Close(); } catch (Exception de) { FileLogger.Instance.logMessage(LogLevel.ERROR, this, "Pickup Payment Receipt printing" + de.Message); return(false); } return(true); }