Grid++Report生成送货单

原文: Grid++Report生成送货单



  
  
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using gregn6Lib;
  10. namespace Order
  11. {
  12. public partial class Form1 : Form
  13. {
  14. private GridppReport Report= new GridppReport();
  15. public Form1()
  16. {
  17. InitializeComponent();
  18. Report.LoadFromFile( "danju.grf");
  19. }
  20. private void button1_Click(object sender, EventArgs e)
  21. {
  22. Report.FetchRecord -= new _IGridppReportEvents_FetchRecordEventHandler(InsertTable);
  23. Report.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(InsertTable);
  24. Report.PrintPreview( true);
  25. }
  26. //插入数据
  27. private void InsertTable()
  28. {
  29. // //插入头部数据
  30. Report.ControlByName( "CompanyAddress").AsStaticBox.Text = "广州天河";
  31. Report.ControlByName( "CompanyPhone").AsStaticBox.Text = "020-123456";
  32. Report.ControlByName( "CustomerName").AsStaticBox.Text = "马小云";
  33. Report.ControlByName( "CustomerAddress").AsStaticBox.Text = "杭州";
  34. Report.ControlByName( "CompanyMan").AsStaticBox.Text = "马小腾";
  35. Report.ControlByName( "CustomerPhone").AsStaticBox.Text = "147258369";
  36. Report.ControlByName( "OrderNo").AsBarcode.Text = "123456789";
  37. Report.ControlByName( "ShDate").AsStaticBox.Text = DateTime.Now.ToString( "yyyy-MM-dd");
  38. Report.ControlByName( "Creator").AsStaticBox.Text = "清歌王子";
  39. //插入数据明细
  40. IGRField NO = Report.FieldByName( "NO");
  41. IGRField ProductName = Report.FieldByName( "ProductName");
  42. IGRField Size = Report.FieldByName( "Size");
  43. IGRField Dawei = Report.FieldByName( "Dawei");
  44. IGRField Count = Report.FieldByName( "Count");
  45. IGRField Prince = Report.FieldByName( "Prince");
  46. IGRField Total = Report.FieldByName( "Total");
  47. IGRField Remark = Report.FieldByName( "Remark");
  48. DataTable dt = new DataTable();
  49. dt.Columns.Add( "NO", typeof( string));
  50. dt.Columns.Add( "ProductName", typeof( string));
  51. dt.Columns.Add( "Size", typeof( string));
  52. dt.Columns.Add( "Dawei", typeof( string));
  53. dt.Columns.Add( "Count", typeof( string));
  54. dt.Columns.Add( "Prince", typeof( string));
  55. dt.Columns.Add( "Total", typeof( string));
  56. dt.Columns.Add( "Remark", typeof( string));
  57. dt.Rows.Add( new object[] { "1", "三联复写打印纸", "二等分", "箱", "5", "45.00", "225.00", "备注" });
  58. dt.Rows.Add( new object[] { "2", "联想计算机", "台", "箱", "5", "2000", "10000", "备注" });
  59. dt.Rows.Add( new object[] { "3", "联想计算机", "台", "箱", "5", "2000", "10000", "备注" });
  60. dt.Rows.Add( new object[] { "4", "联想计算机", "台", "箱", "5", "2000", "10000", "备注" });
  61. dt.Rows.Add( new object[] { "5", "联想计算机", "台", "箱", "5", "2000", "10000", "备注" });
  62. dt.Rows.Add( new object[] { "6", "联想计算机", "台", "箱", "5", "2000", "10000", "备注" });
  63. foreach (DataRow dr in dt.Rows)
  64. {
  65. //追加一行
  66. Report.DetailGrid.Recordset.Append();
  67. //给模板设置的每一列插入数据
  68. NO.AsString = dr[ "NO"].ToString();
  69. ProductName.AsString = dr[ "ProductName"].ToString();
  70. Size.AsString = dr[ "Size"].ToString();
  71. Dawei.AsString = dr[ "Dawei"].ToString();
  72. Count.AsString = dr[ "Count"].ToString();
  73. Prince.AsString = dr[ "Prince"].ToString();
  74. Total.AsString = dr[ "Total"].ToString();
  75. Remark.AsString = dr[ "Remark"].ToString();
  76. //插入
  77. Report.DetailGrid.Recordset.Post();
  78. }
  79. //插入尾部数据
  80. Report.ControlByName( "Heji").AsStaticBox.Text = "叁仟伍佰";
  81. Report.ControlByName( "HejiCount").AsStaticBox.Text = "55";
  82. Report.ControlByName( "HejiLower").AsStaticBox.Text = "¥3500";
  83. }
  84. }
  85. }



猜你喜欢

转载自www.cnblogs.com/lonelyxmas/p/12295358.html