Wednesday, November 24, 2010

GET Fetch Data USing Adaperter with input parameter.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ABCpdf = WebSupergoo.ABCpdf7;
using WebSupergoo.ABCpdf7;
using System.Net;
using System.IO;
using System.Text;
using System.Configuration;
using System.Collections;
using System.Data;
using System.Data.SqlClient;

public partial class Headerfooter : System.Web.UI.Page
{

Pdfgenration ObjPdf = new Pdfgenration();

protected void Page_Load(object sender, EventArgs e)
{

if (!IsPostBack)
{


string HtmlString = string.Empty;
string strfileName = string.Empty;
StringBuilder strHtml = new StringBuilder();
string dbstring = ConfigurationManager.AppSettings["DB_WEBGRID_CON_STRING"].ToString();
SqlConnection sqlcon = new SqlConnection(dbstring);
sqlcon.Open();

if (sqlcon.State.ToString() == "Open")
{
SqlCommand command = new SqlCommand("Sproc_POL_INSTALLMENT_BOLETO", sqlcon);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add("@Boleto_ID", SqlDbType.Int).Value = 821;
SqlDataAdapter adapter = new SqlDataAdapter(command);
DataSet ds = new DataSet();
adapter.Fill(ds);
HtmlString = ds.Tables[0].Rows[0]["BOLETO_HTML"].ToString();
string Customer_ID = ds.Tables[0].Rows[0]["CUSTOMER_ID"].ToString();
string Policy_ID = ds.Tables[0].Rows[0]["POLICY_ID"].ToString();
string Installement_ID = ds.Tables[0].Rows[0]["INSTALLEMT_ID"].ToString();
string Boleto_ID = ds.Tables[0].Rows[0]["BOLETO_ID"].ToString();
strfileName = Customer_ID + "_" + Policy_ID + "_" + Installement_ID + "_" + Boleto_ID+".pdf";


}

string strPath = "../HTMLToPDF"+ConfigurationManager.AppSettings["PDFDocumentsPath"].ToString();

//string path = System.Web.HttpContext.Current.Request.PhysicalApplicationPath + Filename;

string strLocation = Server.MapPath(strPath) + strfileName;
if (!Directory.Exists(Server.MapPath(strPath)))
Directory.CreateDirectory(Server.MapPath(strPath));
ObjPdf.GeneratePdf(HtmlString, strfileName, strLocation);

//if (!File.Exists(strPath))
//{
// File.Create(strPath);
// ObjPdf.GeneratePdf(HtmlString, strfile, strPath);
//}
//else
//{
// File.Delete(strPath);
// ObjPdf.GeneratePdf(HtmlString, strfile, strPath);
//}
}


}


}

No comments:

Post a Comment