public OrderOfPayment(float amount, int orderOfPaymentNo, string orderOfPaymentDate, string purpose, string payor = null, int StudID = 0, string remarks = null, string bankName = null, string checkNo = null, string checkDate = null, float checkAmount = 0, int paymentType = 0) { amountWords = NumberTextExtensionMethod.ToText("" + amount); amountNumeric = amount; this.StudID = StudID; this.orderOfPaymentNo = hasNoDuplicate(orderOfPaymentNo) ? 0 : orderOfPaymentNo; this.orderOfPaymentDate = orderOfPaymentDate; this.purpose = purpose; this.payorName = payor; this.remarks = (string.IsNullOrEmpty(remarks)) ? null : remarks; this.bankName = bankName; this.checkNo = checkNo; this.checkDate = checkDate; this.checkAmount = checkAmount; this.paymentType = (paymentType == 0) ? "NULL" : "" + paymentType; }
// ***************** OFFICIAL RECEIPT PRINTING ******************* void ePrint_officialReceipt(object sender, PrintPageEventArgs e) { Graphics graphic = e.Graphics; Font font = new Font("Arial", 12); float fontHeight = font.GetHeight(); //string strDestination; string Remarks; int startX = 10; int startY = 175; int offset = 40; int CenterPage = Convert.ToInt16(e.PageBounds.Width / 2 - e.Graphics.MeasureString(printData["ORNumber"], new Font("Arial", 12)).Width) / 4; // First Line graphic.DrawString(printData["ORNumber"], new Font("Arial", 11), new SolidBrush(Color.Black), CenterPage + offset * 2, startY + (offset - 10)); offset += (int)fontHeight + 70; CenterPage = Convert.ToInt16(e.PageBounds.Width / 2 - e.Graphics.MeasureString(printData["collectionDate"], new Font("Arial", 10)).Width) / 4; // Second Line graphic.DrawString(printData["collectionDate"], new Font("Arial", 11), new SolidBrush(Color.Black), CenterPage * 2, (startY + (offset / 2)) - 10); offset += (int)fontHeight - 45; CenterPage = Convert.ToInt16(e.PageBounds.Width / 2 - e.Graphics.MeasureString("Sorsogon State College", new Font("Arial", 10, FontStyle.Bold)).Width / 2) / 4; // Third Line graphic.DrawString("Sorsogon State College", new Font("Arial", 11, FontStyle.Bold), new SolidBrush(Color.Black), CenterPage / 2 + 20, startY + offset - 10); offset = offset + (int)fontHeight + 5; CenterPage = Convert.ToInt16(e.PageBounds.Width / 2 - e.Graphics.MeasureString("", new Font("Arial", 12, FontStyle.Bold)).Width / 2) / 4; // Payor string studentName = printData["LName"] + ", " + printData["FName"] + " " + printData["MName"]; string payor = String.IsNullOrEmpty(printData["Payor"]) ? studentName : printData["Payor"]; // Fourth Line graphic.DrawString(payor, new Font("Arial", 11), new SolidBrush(Color.Black), CenterPage / 2 + 20, startY + offset); offset = offset + (int)fontHeight + 5; // add more offset for particular items offset += (int)fontHeight + 25; int tempDiff = 0; int particularLength = 0; float MscAmount = 0; for (int i = 0; i < particularsAmount.Length; i++) { if (particularLength > 0) { tempDiff = particularLength; } // measure nature of collection name particularLength = Convert.ToInt16(e.Graphics.MeasureString(particularsAmount[i][0], new Font("Arial", 11, FontStyle.Bold)).Width / 2) / 4; if (tempDiff > 0 && tempDiff != particularLength && i != particularsAmount.Length - 1) { tempDiff = tempDiff - particularLength; } int tempFinal = particularLength + tempDiff; if (particularsAmount[i][3] != "1" || isOtherPayment) { graphic.DrawString(particularsAmount[i][0], new Font("Arial", 11, FontStyle.Bold), new SolidBrush(Color.Black), startX + 10, startY + offset); graphic.DrawString(particularsAmount[i][1].PadRight(10), new Font("Arial", 11, FontStyle.Bold), new SolidBrush(Color.Black), startX + 225, startY + offset); graphic.DrawString(particularsAmount[i][2], new Font("Arial", 11, FontStyle.Bold), new SolidBrush(Color.Black), startX + 275, startY + offset); if (particularsAmount.Length > 8) { offset = offset + (int)fontHeight + 2; } else { offset = offset + (int)fontHeight + 5; } } else { MscAmount += float.Parse(particularsAmount[i][2]); } if (MscAmount > 0 && i == particularsAmount.Length - 1) { graphic.DrawString("Miscl. Fee".PadRight(28) + " ".PadRight(10) + MscAmount.ToString().PadRight(tempFinal), new Font("Arial", 13), new SolidBrush(Color.Black), startX + 10, startY + offset); } } // For Total int totalPosY = 550; offset += 60; // if has Check string amount, amountInWords; if (!string.IsNullOrEmpty(printData["CheckNo"]) && !string.IsNullOrEmpty(printData["CheckAmount"])) { amount = printData["CheckAmount"]; amountInWords = NumberTextExtensionMethod.ToText("" + printData["CheckAmount"]); } else { amount = printData["Amount"]; amountInWords = printData["AmtInWords"]; } graphic.DrawString(amount, new Font("Arial", 10), new SolidBrush(Color.Black), CenterPage * 3 - 40, totalPosY); totalPosY = totalPosY + (int)fontHeight + 25; // For Amount in Words graphic.DrawString(amountInWords, new Font("Arial", 10, FontStyle.Bold), new SolidBrush(Color.Black), CenterPage / 4, totalPosY); // if has check or not if (!string.IsNullOrEmpty(printData["CheckNo"]) && !string.IsNullOrEmpty(printData["CheckAmount"])) { // for the x mark graphic.DrawString("X - Check", new Font("Arial", 10), new SolidBrush(Color.Black), 30, totalPosY + 48); // for check details graphic.DrawString(printData["BankName"], new Font("Arial", 10), new SolidBrush(Color.Black), CenterPage / 2 + 100, totalPosY + 45); graphic.DrawString(printData["CheckNo"], new Font("Arial", 10), new SolidBrush(Color.Black), CenterPage / 2 + 150, totalPosY + 45); graphic.DrawString(printData["CheckDate"], new Font("Arial", 10), new SolidBrush(Color.Black), CenterPage / 2 + 230, totalPosY + 45); } else { // for the x mark graphic.DrawString("X - Cash", new Font("Arial", 10), new SolidBrush(Color.Black), 30, totalPosY + 40); } }