From 0f3a3c9c591ffcde74acce5476083e48b549f95a Mon Sep 17 00:00:00 2001
From: yxj <1qaz@123>
Date: 星期四, 08 九月 2022 14:45:29 +0800
Subject: [PATCH] 条码档案列表模块打印、预览报错修改
---
BLL/系统公用CLS/GridppReport.cs | 77 ++++++++++++++++++++++++++++++++++++++
WarM/条码管理/Gy_BarCodeBillList.cs | 2
2 files changed, 78 insertions(+), 1 deletions(-)
diff --git "a/BLL/\347\263\273\347\273\237\345\205\254\347\224\250CLS/GridppReport.cs" "b/BLL/\347\263\273\347\273\237\345\205\254\347\224\250CLS/GridppReport.cs"
index 37cb45e..5c014bd 100644
--- "a/BLL/\347\263\273\347\273\237\345\205\254\347\224\250CLS/GridppReport.cs"
+++ "b/BLL/\347\263\273\347\273\237\345\205\254\347\224\250CLS/GridppReport.cs"
@@ -536,6 +536,83 @@
}
+ // 将 DataGridView 的数据转储到 Grid++Report 的数据集中
+ public static void FillRecordToReport_Sel(IGridppReport Report, System.Windows.Forms.DataGridView grd, DataTable dt, int FindCol)
+ {
+ try
+ {
+ MatchFieldPairType[] MatchFieldPairs = new MatchFieldPairType[Math.Min(Report.DetailGrid.Recordset.Fields.Count, grd.Columns.Count)];
+ //根据字段名称与列名称进行匹配,建立DataReader字段与Grid++Report记录集的字段之间的对应关系
+ int MatchFieldCount = 0;
+ int FixCols = 0;
+ DataRow sRow;
+ DataColumn sCol;
+ //将grd1的数据写入grd2,写入前提,字段名和网格标题 相同,FindCol为判断是否空行
+ int iCol = 0;
+ bool bb = false;
+ for (int j = 0; j < grd.RowCount; j++) //循环网格1,
+ {
+ iCol = 0;
+ if (DBUtility.ClsPub.isStrNull(grd.Rows[j].Cells[FindCol].Value) != "")//是否空行
+ {
+ sRow = dt.NewRow();
+ for (int i = FixCols; i < grd.Columns.Count; ++i)
+ {
+ foreach (IGRField fld in Report.DetailGrid.Recordset.Fields) //从记录集中找到 相同字段名
+ {
+ if (String.Compare(fld.Name, grd.Columns[i].HeaderText, true) == 0)
+ {
+ iCol = iCol + 1;
+ if (bb == false)
+ {
+ sCol = new DataColumn();
+ sCol.ColumnName = fld.Name;
+ dt.Columns.Add(sCol);
+ }
+ if (DBUtility.ClsPub.isStrNull(grd.Rows[j].Cells[i + FixCols].Value) != "")
+ {
+
+ sRow[iCol - 1] = DBUtility.ClsPub.isStrNull(grd.Rows[j].Cells[i + FixCols].Value);
+ }
+ }
+ }
+ }
+ dt.Rows.Add(sRow);
+ bb = true;
+ }
+ }
+ //
+ for (int i = 0; i < dt.Columns.Count; ++i)
+ {
+ foreach (IGRField fld in Report.DetailGrid.Recordset.Fields)
+ {
+ if (String.Compare(fld.Name, dt.Columns[i].ColumnName, true) == 0)
+ {
+ MatchFieldPairs[MatchFieldCount].grField = fld;
+ MatchFieldPairs[MatchFieldCount].MatchColumnIndex = i;
+ ++MatchFieldCount;
+ break;
+ }
+ }
+ }
+ // 将 DataTable 中的每一条记录转储到 Grid++Report 的数据集中去
+ foreach (DataRow dr in dt.Rows)
+ {
+ Report.DetailGrid.Recordset.Append();
+ for (int i = 0; i < MatchFieldCount; ++i)
+ {
+ if (!dr.IsNull(MatchFieldPairs[i].MatchColumnIndex))
+ MatchFieldPairs[i].grField.Value = dr[MatchFieldPairs[i].MatchColumnIndex];
+ }
+ Report.DetailGrid.Recordset.Post();
+ }
+ }
+ catch (Exception e)
+ {
+ MessageBox.Show(e.Message);
+ }
+ }
+
// 将 DataGridView 的数据转储到 Grid++Report 的数据集中
public static void FillRecordToReport(IGridppReport Report, DataTable dt_Old, DataTable dt, int FindCol)
diff --git "a/WarM/\346\235\241\347\240\201\347\256\241\347\220\206/Gy_BarCodeBillList.cs" "b/WarM/\346\235\241\347\240\201\347\256\241\347\220\206/Gy_BarCodeBillList.cs"
index f69e147..3f1fc2a 100644
--- "a/WarM/\346\235\241\347\240\201\347\256\241\347\220\206/Gy_BarCodeBillList.cs"
+++ "b/WarM/\346\235\241\347\240\201\347\256\241\347\220\206/Gy_BarCodeBillList.cs"
@@ -491,7 +491,7 @@
try
{
DataTable ds = new DataTable();
- BLL.Utility.FillRecordToReport(Report, grdMain, ds, Fun_GetCol("閫夋嫨"));
+ BLL.Utility.FillRecordToReport_Sel(Report, grdMain, ds, Fun_GetCol("閫夋嫨"));
}
catch (Exception e)
{
--
Gitblit v1.9.1