| | |
| | | |
| | | } |
| | | |
| | | // å° 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) |