1

我正在尝试将两个值写入 PDF。我可以将第一行写入 Copay Paid1 和总支付 1,但我不能将第二行写入 Copay Paid2 和总支付 2。我怎样才能将第二行写入 Copay Paid2 和 totalpaid2。

示例 SQL 数据

在此处输入图像描述

代码示例

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");
4

1 回答 1

1

你错过了一两个EndText()电话。显然,您正在使用的控件需要EndText()调用以开始新行,或根本编写文本。

此外,您将第一行存储在dr. 如果要存储第二行,则应在完成第一行后立即声明第二行DataRow或用第二行覆盖dr

    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
于 2013-08-13T17:49:53.897 回答