Grid++Report生成送货单

Posted lonelyxmas

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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. }



以上是关于Grid++Report生成送货单的主要内容,如果未能解决你的问题,请参考以下文章

送货单号怎么设置

Grid++Report

Grid++Report 数据填充教程

UniGui中使用Grid++Report报表控件子报表获取数据的方法

Grid++Report设置显示固定行数

VC2015调用Grid++report报表控件