Reputation: 666
I am trying to write two value to a PDF. I am able to write the first row to Copay Paid1 and total paid1, but i cant write the secound row to Copay Paid2 and total paid2. How am i able to write the second row to Copay Paid2 and total paid2.
sample SQL data
sample of code
void miCopayReceipt_Click(object sender, Telerik.Windows.RadRoutedEventArgs e)
{
DataRow dr;
try
{
DataSet ds = Application.WebService.ExecuteQuery("pat_reprintCoPayReceipt",
new SPParam[] {
new SPParam("@ApptId",currentAppt.ApptId)
});
dr = ds.Tables[0].Rows[0];
cb.BeginText();
string s = "";
s = "Total Paid1:";
cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, s, 75, 595, 0);
cb.EndText();
cb.BeginText();
string textLine = Convert.ToDouble(dr["PaymentAmount"]).ToString("C");
textLine += " Copay Paid1: " + Convert.ToDecimal(dr["CopayAmount"]).ToString("C");
cb.BeginText();
string s = "";
s = "Total Paid 2:";
cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, s, 75, 595, 0);
cb.EndText();
cb.BeginText();
string textLine = Convert.ToDouble(dr["PaymentAmount"]).ToString("C");
textLine += " Copay Paid2: " + Convert.ToDecimal(dr["CopayAmount"]).ToString("C");
Upvotes: 1
Views: 128
Reputation: 995
You are missing one or two EndText()
calls. Apparantly the control you're using demands an EndText()
call to start a new line, or write the text at all.
Also you're storing the first row in dr
. If you want to store a second row, you should declare a second DataRow
or overwrite the dr
with the second row as soon as you're done with the first row.
cb.BeginText();
string textLine = Convert.ToDouble(dr["PaymentAmount"]).ToString("C");
textLine += " Copay Paid1: " + Convert.ToDecimal(dr["CopayAmount"]).ToString("C");
cb.EndText(); // Added this
// Get the second row
if(dr = ds.Tables[0].Rows.Length > 0)
dr = ds.Tables[0].Rows[1];
cb.BeginText();
string s = "";
s = "Total Paid 2:";
cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, s, 75, 595, 0);
cb.EndText();
cb.BeginText();
string textLine = Convert.ToDouble(dr["PaymentAmount"]).ToString("C");
textLine += " Copay Paid2: " + Convert.ToDecimal(dr["CopayAmount"]).ToString("C");
cb.EndText(); // Added this
Upvotes: 1