-
using System;
-
using System.Collections.Generic;
-
using System.ComponentModel;
-
using System.Data;
-
using System.Drawing;
-
using System.Linq;
-
using System.Text;
-
using System.Windows.Forms;
-
using gregn6Lib;
-
namespace
Order
-
{
-
public
partial
class
Form1 :
Form
-
{
-
private GridppReport Report=
new GridppReport();
-
public Form1()
-
{
-
InitializeComponent();
-
Report.LoadFromFile(
"danju.grf");
-
}
-
-
private void button1_Click(object sender, EventArgs e)
-
{
-
-
Report.FetchRecord -=
new _IGridppReportEvents_FetchRecordEventHandler(InsertTable);
-
Report.FetchRecord +=
new _IGridppReportEvents_FetchRecordEventHandler(InsertTable);
-
Report.PrintPreview(
true);
-
}
-
//插入数据
-
private void InsertTable()
-
{
-
// //插入头部数据
-
Report.ControlByName(
"CompanyAddress").AsStaticBox.Text =
"广州天河";
-
Report.ControlByName(
"CompanyPhone").AsStaticBox.Text =
"020-123456";
-
Report.ControlByName(
"CustomerName").AsStaticBox.Text =
"马小云";
-
Report.ControlByName(
"CustomerAddress").AsStaticBox.Text =
"杭州";
-
Report.ControlByName(
"CompanyMan").AsStaticBox.Text =
"马小腾";
-
Report.ControlByName(
"CustomerPhone").AsStaticBox.Text =
"147258369";
-
Report.ControlByName(
"OrderNo").AsBarcode.Text =
"123456789";
-
Report.ControlByName(
"ShDate").AsStaticBox.Text = DateTime.Now.ToString(
"yyyy-MM-dd");
-
Report.ControlByName(
"Creator").AsStaticBox.Text =
"清歌王子";
-
//插入数据明细
-
IGRField NO = Report.FieldByName(
"NO");
-
IGRField ProductName = Report.FieldByName(
"ProductName");
-
IGRField Size = Report.FieldByName(
"Size");
-
IGRField Dawei = Report.FieldByName(
"Dawei");
-
IGRField Count = Report.FieldByName(
"Count");
-
IGRField Prince = Report.FieldByName(
"Prince");
-
IGRField Total = Report.FieldByName(
"Total");
-
IGRField Remark = Report.FieldByName(
"Remark");
-
DataTable dt =
new DataTable();
-
dt.Columns.Add(
"NO",
typeof(
string));
-
dt.Columns.Add(
"ProductName",
typeof(
string));
-
dt.Columns.Add(
"Size",
typeof(
string));
-
dt.Columns.Add(
"Dawei",
typeof(
string));
-
dt.Columns.Add(
"Count",
typeof(
string));
-
dt.Columns.Add(
"Prince",
typeof(
string));
-
dt.Columns.Add(
"Total",
typeof(
string));
-
dt.Columns.Add(
"Remark",
typeof(
string));
-
dt.Rows.Add(
new
object[] {
"1",
"三联复写打印纸",
"二等分",
"箱",
"5",
"45.00",
"225.00",
"备注" });
-
dt.Rows.Add(
new
object[] {
"2",
"联想计算机",
"台",
"箱",
"5",
"2000",
"10000",
"备注" });
-
dt.Rows.Add(
new
object[] {
"3",
"联想计算机",
"台",
"箱",
"5",
"2000",
"10000",
"备注" });
-
dt.Rows.Add(
new
object[] {
"4",
"联想计算机",
"台",
"箱",
"5",
"2000",
"10000",
"备注" });
-
dt.Rows.Add(
new
object[] {
"5",
"联想计算机",
"台",
"箱",
"5",
"2000",
"10000",
"备注" });
-
dt.Rows.Add(
new
object[] {
"6",
"联想计算机",
"台",
"箱",
"5",
"2000",
"10000",
"备注" });
-
foreach (DataRow dr
in dt.Rows)
-
{
-
//追加一行
-
Report.DetailGrid.Recordset.Append();
-
//给模板设置的每一列插入数据
-
NO.AsString = dr[
"NO"].ToString();
-
ProductName.AsString = dr[
"ProductName"].ToString();
-
Size.AsString = dr[
"Size"].ToString();
-
Dawei.AsString = dr[
"Dawei"].ToString();
-
Count.AsString = dr[
"Count"].ToString();
-
Prince.AsString = dr[
"Prince"].ToString();
-
Total.AsString = dr[
"Total"].ToString();
-
Remark.AsString = dr[
"Remark"].ToString();
-
//插入
-
Report.DetailGrid.Recordset.Post();
-
}
-
//插入尾部数据
-
Report.ControlByName(
"Heji").AsStaticBox.Text =
"叁仟伍佰";
-
Report.ControlByName(
"HejiCount").AsStaticBox.Text =
"55";
-
Report.ControlByName(
"HejiLower").AsStaticBox.Text =
"¥3500";
-
}
-
}
-
}