2013-09-16 6 views
0

// Рабочая Подробностиотображения данных в формате PDF

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

Приведенный выше код показывает Diplay данные в формате PDF .. моя проблема Данные PDF будут отображаться для обработки деталей, но не для членства в деталях ..Программа показана ниже. Мне нужно получить данные для деталей членства, поскольку они отображаются в рабочих деталях.

Код не изменяется, но данные не извлекаются .. Пожалуйста, предложите любую помощь для это ..

Pdf for the following code

ответ

2

С помощью быстрой проверки вашего кода выясняется, что ваш второй запрос не получил никакого ответа. Убедитесь, что в базе данных есть данные для вашего запроса и что ваш запрос возвращает ожидаемые данные.

+0

У него есть некоторые данные в базе данных –

Смежные вопросы