日期:2014-05-18 浏览次数:21023 次
private ReportDocument reportDocument; private void button13_Click(object sender, EventArgs e) { ReportDocument _rpt1; _rpt1.Load(StartPath + "\\rpt\\HzGBD2.rpt"); DataSet ds = new DataSet(); DataTable ds1 = truckDal.GetSqltb(" select TID as 序号,NoteCode as 流水编号,PlateCode as 车牌号, Goods as 货物名称, guige as 规格, Weight as 皮重,GrossWeight as 毛重,NetWeight as 净重 from Table1 where TID = " + int.Parse(label35.Text.Substring(8, label35.Text.Length - 8)) + ""); DataTable ds2 = truckDal.GetSqltb("select NoteCode as 流水编号,Goods as 货物名称,Guige as 规格,Unit as 单价,Counts as 数量,Price as 金额 from Table2 where NoteCode='" + label35.Text + "'"); ds.Tables.Add(ds1); ds1.TableName = "Table1"; ds.Tables.Add(ds2); ds2.TableName = "Table2"; ds.Relations.Add(new DataRelation("link", ds1.Columns["流水编号"], ds2.Columns["流水编号"])); _rpt1.SetDataSource(ds); crystalReportViewer1.ReportSource = _rpt1; }