Dynamically create a table and add data to the table for reporting.

Source: Internet
Author: User

Using system;
Using system. collections;
Using system. configuration;
Using system. Data;
Using system. LINQ;
Using system. Web;
Using system. Web. Security;
Using system. Web. UI;
Using system. Web. UI. htmlcontrols;
Using system. Web. UI. webcontrols;
Using system. Web. UI. webcontrols. webparts;
Using system. xml. LINQ;
Using bnbcrm. models;
Using bnbcrm. BLL;
Using Microsoft. Reporting. webforms;
Using system. Collections. Generic;
Public partial class commanreport_finacereport: system. Web. UI. Page
{
Int project_id = 0;
Protected void page_load (Object sender, eventargs E)
{
Project_id = convert. toint32 (request. querystring ["project_id"]);
If (! Ispostback)
{
This.txt createdt. value = datetime. Now. tostring ("yyyy-mm-dd ");
This.txt createdto. value = datetime. Now. tostring ("yyyy-mm-dd ");
}
Reportviewer1.localreport. Refresh ();

}
Protected void btnsearch_click (Object sender, eventargs E)
{

Datetime cretd = convert.todatetime(this.txt createdt. value );
Datetime endtd = convert.todatetime(this.txt createdto. value );

Datatable dt = new datatable ();
DT. Columns. Add ("DT", typeof (datetime ));
DT. Columns. Add ("basic_orderid", typeof (string ));
DT. Columns. Add ("ID", typeof (INT ));
DT. Columns. Add ("fee_pay_mode", typeof (string ));
DT. Columns. Add ("fee_sum", typeof (decimal ));
DT. Columns. Add ("fee_fact_all", typeof (decimal ));
DT. Columns. Add ("remark", typeof (string ));
DT. Columns. Add ("quantity", typeof (INT ));
DT. Columns. Add ("pay_dt", typeof (string ));
DT. Columns. Add ("pay_sum", typeof (decimal ));
DT. Columns. Add ("Ar", typeof (decimal ));

Ilist <tborder> orderlist = tbordermanager. getorderbyproject_idandshipping_dt (project_id, cretd, endtd );

For (INT I = 0; I <orderlist. Count; I ++)
{
Datarow ROW = DT. newrow ();

Row ["DT"] = orderlist [I]. shipping_dt;
String basic_orderid = orderlist [I]. basic_orderid.tostring (). Trim ();
Int id = convert. toint32 (orderlist [I]. ID );


Tborderdetail Todd = tborderdetailmanager. gettborderdetailbyorder_id (ID );
Row ["quantity"] = Todd. quantity;

Row ["ID"] = ID;
Row ["basic_orderid"] = basic_orderid;
If (basic_orderid.length> 0 & basic_orderid! = "")
{
Tbfincomparetaobao TB = tbfincomparetaobaomanager. getsomebytaobaoid (basic_orderid );

If (Tb. pay_dt = convert. todatetime ("0001-1-1 0:00:00 "))
{
Row ["pay_dt"] = "";
}
Else
{
Row ["pay_dt"] = Tb. pay_dt.tostring ("yyyy/mm/DD", system. Globalization. datetimeformatinfo. invariantinfo );
}

Row ["pay_sum"] = Tb. fee_sum;

}
Else
{
Tbfincomparecod cc = tbfincomparecodmanager. getsomebytaobaoid (ID );



If (CC. pay_dt = convert. todatetime ("0001-1-1 0:00:00 "))
{
Row ["pay_dt"] = "";
}
Else
{
Row ["pay_dt"] = cc. pay_dt.tostring ("yyyy/mm/DD", system. Globalization. datetimeformatinfo. invariantinfo );
}

Row ["pay_sum"] = cc. fee_sum;

}

Row ["fee_pay_mode"] = orderlist [I]. fee_pay_mode;
Row ["fee_sum"] = orderlist [I]. fee_sum;
Row ["fee_fact_all"] = orderlist [I]. fee_fact_all;
Row ["remark"] = orderlist [I]. remark;

DT. Rows. Add (ROW );


Reportviewer1.localreport. reportpath = @ "commanreport/finacereport. rdlc ";

Reportviewer1.localreport. CES. Clear ();
Reportviewer1.localreport. CES. Add (New reportdatasource ("commandateset_tborder", DT ));
Reportviewer1.localreport. Refresh ();


}


}

 


}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.