Public class expdf
{
Static string sqlstr = "select member_value from mdb_archive_member where member_id in () order by member_id ";
Int DTC;
Document document = new document ();
Static basefont bfhei = basefont. createfont (@ configurationmanager. appsettings ["WINDIR"]. replace ("System32", "fonts") + @ "\ simhei. TTF ", basefont. identity_h, basefont. not_embedded );
Static Font font = new font (bfhei, 12 );
Dataset Ds;
Datatable DT;
Public expdf ()
{
}
Public void makepdf (string entityid, string FN)
{
DS = sqlhelper. executedataset (sqlhelper. toeposconnstring, commandtype. Text, sqlstr );
Sqlparameter SPA = new sqlparameter ("@ varentityid", entityid );
Dataset DST = sqlhelper. executedataset (sqlhelper. toeposconnstring, commandtype. storedprocedure, "dsc_sp_exportauthedshop", SPA );
Invalid writer. getinstance (document, new filestream (httpcontext. current. request. physicalapplicationpath + "/" + system. configuration. configurationsettings. deleetask[ "uploadfilepath"]. tostring () + "/" + FN + ". PDF ", filemode. create ));
Document. open ();
For (int ii = 0; II <DST. Tables. Count; II ++)
{
Dt = DST. Tables [II];
DTC = DT. Rows. count;
If (DTC> 0)
{
Int P = int. parse (system. Math. Floor (double) (DTC/10). tostring ());
Int Pc = DTC % 10;
If (P = 0)
{
For (INT I = 0; I <1; I ++)
{
Pdfrot (I * 10, (I + 1) * 10 );
}
}
If (Pc = 0 & P> 0)
{
For (INT I = 0; I <p; I ++)
{
Pdfrot (I * 10, (I + 1) * 10 );
If (I + 1 <p)
{
Document. Newpage ();
}
}
}
If (Pc> 0 & P> 0)
{
For (INT I = 0; I <p + 1; I ++)
{
Pdfrot (I * 10, (I + 1) * 10 );
If (I + 1 <p + 1)
{
Document. Newpage ();
}
}
}
}
If (II + 1 <DST. Tables. Count)
{
Document. Newpage ();
}
}
Document. Close ();
}
Public void pdfrot (INT start, int end)
{
Image Ln = image. getinstance (httpcontext. Current. Request. physicalapplicationpath + "/EXCEL/ln.jpg ");
Ln. Alignment = image. right_align;
Ln. scalepercent (25 );
Document. Add (LN );
String text = @ "" ***** "***** contract (No.:" + (Dt. Rows. Count> 0? DT. Rows [0] ["dealer_no"]. tostring (): "") + @ ") Attachment
"*****" ******** table
";
string text_ B = "this shop list form is an attachment to" ***** "******" of both parties, and clarifies the name and address of the shop opened by Party B, it has the same legal force as "*****" ****** and is valid from "+ dt. rows [0] [DT. columns. count-1]. tostring (). substring (0, 4) + "year" + dt. rows [0] [DT. columns. count-1]. tostring (). substring (4, 2) + "month" + dt. rows [0] [DT. columns. count-1]. tostring (). substring (6, 2) + "day" + "to" + datetime. today. addyears (1 ). tostring ("YYYY") + "year" + int. Parse (Ds. Tables [0]. Rows [1] ["member_value"]. tostring (). tostring ("00-00") +. (Within the validity period ). ";
document. Add (new paragraph (text, font);
document. Add (new paragraph (text_ B, font);
Table atable = new table (7, 2 );
Atable. cellpadding = 2;
Atable. withpercentage = 100;
Atable. addcell (new paragraph ("** ID", font ));
Cell C = new cell (new paragraph ("** name", font ));
C. colspan = 3;
Atable. addcell (C );
C = new cell (new paragraph ("** address", font ));
C. colspan = 3;
Atable. addcell (C );
For (INT I = start; I <end; I ++)
{
If (I <DTC)
{
Atable. addcell (new paragraph (Dt. Rows [I] [0]. tostring (), font ));
C = new cell (new paragraph (Dt. Rows [I] [2]. tostring (), font ));
C. colspan = 3;
Atable. addcell (C );
C = new cell (new paragraph (Dt. Rows [I] [3]. tostring (), font ));
C. colspan = 3;
Atable. addcell (C );
// Atable. addcell (new paragraph (Dt. Rows [I] [2]. tostring (), font ));
// Atable. addcell (new paragraph (Dt. Rows [I] [3]. tostring (), font ));
}
}
Document. Add (atable );
String vtext = @ "I *** Party B's above ***" *** "products.
* ** Limited Company
"+ dt. rows [0] [DT. columns. count-1]. tostring (). substring (0, 4) + "year" + dt. rows [0] [DT. columns. count-1]. tostring (). substring (4, 2) + "month" + dt. rows [0] [DT. columns. count-1]. tostring (). substring (6, 2) + "day";
document. add (new paragraph (vtext, font);
}< BR >}