0

//工作细节

       PdfPTable tabl2 = new PdfPTable(7);
               // tabl2.TotalWidth = 350f;
                //tabl2.LockedWidth = true;
                //tabl2.HorizontalAlignment = 0;
                tabl2.SpacingBefore = 10f;
                bfTimes = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, false);
                times = new Font(bfTimes, 12f, Font.UNDERLINE);
                para = new Paragraph("Working Details:", times);
                para.Alignment = Element.ALIGN_LEFT;
                doc.Add(para);
                cell.Colspan = 3;
                cell.Rowspan = 2;
                cell.HorizontalAlignment = 0;
                cell.BorderColor = new BaseColor(0, 0, 0);
                //tabl2.AddCell(new Phrase("Sr.No.", FontFactory.GetFont("Arial", 8, Font.BOLD, BaseColor.BLACK)));

                tabl2.AddCell(new Phrase("Working Place", FontFactory.GetFont("Arial", 8, Font.BOLD, BaseColor.BLACK)));
                tabl2.AddCell(new Phrase("Date Of Joining", FontFactory.GetFont("Arial", 8, Font.BOLD, BaseColor.BLACK)));
                tabl2.AddCell(new Phrase("Institute Name", FontFactory.GetFont("Arial", 8, Font.BOLD, BaseColor.BLACK)));
                tabl2.AddCell(new Phrase("Year", FontFactory.GetFont("Arial", 8, Font.BOLD, BaseColor.BLACK)));
                tabl2.AddCell(new Phrase("Duration", FontFactory.GetFont("Arial", 8, Font.BOLD, BaseColor.BLACK)));
                tabl2.AddCell(new Phrase("Post held at last", FontFactory.GetFont("Arial", 8, Font.BOLD, BaseColor.BLACK)));
                tabl2.AddCell(new Phrase("Area of Work", FontFactory.GetFont("Arial", 8, Font.BOLD, BaseColor.BLACK)));
                string connects = @"Data Source=BOPSERVER;Initial Catalog=Project;Integrated Security=True";
                using (SqlConnection cn = new SqlConnection(connects))
                {
                    string query = "select * from Working_det where Fid='" + va+"'";
                    SqlCommand cmd = new SqlCommand(query, cn);
                    try
                    {
                        cn.Open();
                        using (SqlDataReader sdr = cmd.ExecuteReader())
                        {
                            while (sdr.Read())
                            {


                                tabl2.AddCell(new Phrase(sdr[1].ToString(), FontFactory.GetFont("Arial", 8, Font.NORMAL, BaseColor.BLACK)));
                                tabl2.AddCell(new Phrase(Convert.ToDateTime(sdr[2]).ToShortDateString(), FontFactory.GetFont("Arial", 8, Font.NORMAL, BaseColor.BLACK)));
                                tabl2.AddCell(new Phrase(sdr[3].ToString(), FontFactory.GetFont("Arial", 8, Font.NORMAL, BaseColor.BLACK)));
                                tabl2.AddCell(new Phrase(sdr[4].ToString(), FontFactory.GetFont("Arial", 8, Font.NORMAL, BaseColor.BLACK)));
                                tabl2.AddCell(new Phrase(sdr[5].ToString(), FontFactory.GetFont("Arial", 8, Font.NORMAL, BaseColor.BLACK)));
                                tabl2.AddCell(new Phrase(sdr[6].ToString(), FontFactory.GetFont("Arial", 8, Font.NORMAL, BaseColor.BLACK)));
                                tabl2.AddCell(new Phrase(sdr[7].ToString(), FontFactory.GetFont("Arial", 8, Font.NORMAL, BaseColor.BLACK)));
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Response.Write(ex.Message);
                    }
                }

                cell.Rowspan = 2;
                cell.Colspan = 2;
                tabl2.AddCell(cell);
                tabl2.SpacingAfter = 30f;
                doc.Add(tabl2);


                //Membership Details
                PdfPTable tabl3 = new PdfPTable(4);
                tabl3.SpacingBefore = 10f;
                bfTimes = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, false);
                times = new Font(bfTimes, 12f, Font.UNDERLINE);
                para = new Paragraph("Membership Details:", times);
                para.Alignment = Element.ALIGN_LEFT;
                doc.Add(para);
                cell.Colspan = 3;
                cell.Rowspan = 2;
                cell.HorizontalAlignment = 0;
                cell.BorderColor = new BaseColor(0, 0, 0);
                tabl3.AddCell(new Phrase("Membership Number", FontFactory.GetFont("Arial", 8, Font.BOLD, BaseColor.BLACK)));
                tabl3.AddCell(new Phrase("Type of Membership", FontFactory.GetFont("Arial", 8, Font.BOLD, BaseColor.BLACK)));
                tabl3.AddCell(new Phrase("Validity", FontFactory.GetFont("Arial", 8, Font.BOLD, BaseColor.BLACK)));
                tabl3.AddCell(new Phrase("Remarks", FontFactory.GetFont("Arial", 8, Font.BOLD, BaseColor.BLACK)));
                string connect = @"Data Source=BOPSERVER;Initial Catalog=Project;Integrated Security=True";
                using (SqlConnection cn = new SqlConnection(connect))
                {
                    string query = "select * from Membership_det where Fid=='" + va + "'";
                    SqlCommand cmd = new SqlCommand(query, cn);
                    try
                    {
                        cn.Open();
                        using (SqlDataReader sdr = cmd.ExecuteReader())
                        {
                            while (sdr.Read())
                            {

                                tabl3.AddCell(new Phrase(sdr[1].ToString(), FontFactory.GetFont("Arial", 8, Font.NORMAL, BaseColor.BLACK)));
                                tabl3.AddCell(new Phrase(sdr[2].ToString(), FontFactory.GetFont("Arial", 8, Font.NORMAL, BaseColor.BLACK)));
                                tabl3.AddCell(new Phrase(sdr[3].ToString(), FontFactory.GetFont("Arial", 8, Font.NORMAL, BaseColor.BLACK)));
                                tabl3.AddCell(new Phrase(sdr[4].ToString(), FontFactory.GetFont("Arial", 8, Font.NORMAL, BaseColor.BLACK)));
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Response.Write(ex.Message);
                    }
                }
                cell.Rowspan = 2;
                cell.Colspan = 2;
                tabl3.AddCell(cell);
                tabl3.SpacingAfter = 30f;
                doc.Add(tabl3);

上面的代码显示以pdf格式显示数据..我的问题是pdf数据将显示为工作详细信息,但不显示会员详细信息..pdf如下所示。我需要检索会员详细信息的数据已显示在工作详情中

代码没有变化,但没有检索到数据..请为此提供任何帮助..

以下代码的pdf

4

1 回答 1

2

通过快速检查您的代码,您的第二个查询似乎没有得到任何响应。确保您的数据库中包含用于查询的数据,并且您的查询返回您期望的数据。

于 2013-09-16T05:32:20.553 回答