1. C#之 VS 自带 RDLC 报表学习,可参考学习
http://blog.csdn.net/hk_5788/article/details/49846905
2.代码片段
///
/// 打印
///
///
///
private void btnPrint_Click(object sender, EventArgs e)
{
try
{
string ticket = "";
string grossDatatime = "";
string str = "SELECT ticketno,grossdatetime from trade where cardno =
@cardno and datastatus in (1,5) ORDER BY grossdatetime desc LIMIT 0,1";
MySqlDataReader reader = dbHelper.ExecuteReader(str,
new MySqlParameter("@cardno",
this.txtCardNo.Text.Trim().ToString()));
if (reader.Read())
{
}
ticket = reader["ticketno"].ToString();
grossDatatime = reader["grossdatetime"].ToString();
reader.Close();
System.Data.DataTable table = new System.Data.DataTable();
table.Columns.Add("ticketNo", typeof(string));
table.Columns.Add("carNo", typeof(string));
table.Columns.Add("grossTime", typeof(string));
table.Columns.Add("grossWeight", typeof(string));
table.Columns.Add("tareWeight", typeof(string));
table.Columns.Add("netWeight", typeof(string));
table.Rows.Add(ticket,
this.cboNo.Text.ToString(),
grossDatatime,
this.txtGrossWeight.Text.ToString(),
this.txtTareWeight.Text.ToString(),
this.txtNetWeight.Text.ToString());
FrmPound frm = new FrmPound(table);
frm.StartPosition = FormStartPosition.CenterScreen;
frm.Show();
}
catch (Exception ex)
this.txtError.Text = ex.ToString();
VortexLog.WriteLog(VortexLog.LogLevel.Fatal, "打印错误 " + ex);
{
}
}
public FrmPound(DataTable dt)
{
}
InitializeComponent();
table = dt;
private void FrmPound_Load(object sender, EventArgs e)
{
//添加数据源
ReportDataSource rds = new ReportDataSource();
rds.Name = "DataSet1";
rds.Value = table;
//向报表绑定数据源
this.reportPound.LocalReport.DataSources.Add(rds);
//向报表查看器指定显示的报表
this.reportPound.LocalReport.ReportPath =
@"D:\DownLoad\VortexDBXT\AdminPower\AdminPower\Report\ReportPound.rdlc";
this.reportPound.RefreshReport();
}
自制 rsdl 报表:
3.必须先懂第一点的基础上,再进行代码的编写。