// returns one aggregate value private static object FillGridAggrFRowProcent(DataRow row, AvrViewColumn aggrColumn) { object ret = DBNull.Value; if (!bv.common.Core.Utils.IsEmpty(aggrColumn.SourceViewColumn) && row.Table.Columns.Contains(aggrColumn.SourceViewColumn)) { double sum = 0; double dCol; var view = aggrColumn.GetView(); object cur = row[aggrColumn.SourceViewColumn]; if (!bv.common.Core.Utils.IsEmpty(cur) && double.TryParse(cur.ToString(), out dCol)) { // get Sum of rowIndex row inside parent band aggrColumn.Owner.GetAllColumns().ToList().FindAll(col => !col.IsToDelete && !col.IsAggregate && col.IsVisible && col.FieldType.IsNumeric() && !col.OriginalName.EndsWith(view.GrandTotalSuffix) && !col.OriginalName.EndsWith(view.TotalSuffix)).ForEach(c => { double dCur; cur = row[c.UniquePath]; if (!bv.common.Core.Utils.IsEmpty(cur) && double.TryParse(cur.ToString(), out dCur)) { sum += dCur; } }); if (sum != 0) { ret = dCol / sum; } } } return(ret); }
// returns one aggregate value private static object FillGridAggrFColProcent(DataTable data, int rowIndex, AvrViewColumn aggrColumn, ref Dictionary <int, object> dict) { object ret = DBNull.Value; if (!bv.common.Core.Utils.IsEmpty(aggrColumn.SourceViewColumn) && data.Columns.Contains(aggrColumn.SourceViewColumn)) { double dCur; object cur = data.Rows[rowIndex][aggrColumn.SourceViewColumn]; if (!bv.common.Core.Utils.IsEmpty(cur) && double.TryParse(cur.ToString(), out dCur)) { var view = aggrColumn.GetView(); var rowCols = view.GetVisibleRowAdminColumns(true, null, false); // get Sum of refColumn double sumFull = AvrViewHelper.GetColumnSum(data, rowCols.Count, view.GrandTotalSuffix, view.TotalSuffix, aggrColumn.SourceViewColumn, ref dict); if (sumFull != 0) { ret = dCur / sumFull; } } } return(ret); }
// fill aggregate values into data column private static void FillGridAggrFCumProcent(DataTable data, AvrViewColumn aggrColumn, string sort) { if (!bv.common.Core.Utils.IsEmpty(aggrColumn.SourceViewColumn) && data.Columns.Contains(aggrColumn.SourceViewColumn)) { var view = aggrColumn.GetView(); var rowCols = view.GetVisibleRowAdminColumns(true, null, false); // get Sum of refColumn double sumFull = AvrViewHelper.GetColumnSum(data, rowCols.Count, view.GrandTotalSuffix, view.TotalSuffix, aggrColumn.SourceViewColumn); if (sumFull != 0) { double sum = 0; DataView dv = new DataView(data); dv.Sort = sort; foreach (DataRowView row in dv) { if (!AvrViewHelper.GetRowTotalStatus(row.Row, rowCols.Count, view.GrandTotalSuffix, view.TotalSuffix)) //if regular value (not total) { object cur = row[aggrColumn.SourceViewColumn]; if (bv.common.Core.Utils.IsEmpty(cur)) { continue; } double dCur; if (double.TryParse(cur.ToString(), out dCur)) { sum += dCur; row[aggrColumn.UniquePath] = sum / sumFull; } } } } } }
// returns one aggregate value private static object FillGridAggrFMinMax(DataRow row, bool max, AvrViewColumn aggrColumn) { object ret = DBNull.Value; var view = aggrColumn.GetView(); DateTime?mmDt = null; double? mmN = null; foreach (var col in aggrColumn.Owner.GetAllColumns()) { if (col.IsToDelete || col.IsAggregate || !col.IsVisible || !col.FieldType.IsNumeric() || col.OriginalName.EndsWith(view.GrandTotalSuffix) || col.OriginalName.EndsWith(view.TotalSuffix)) { continue; } object cur = row[col.UniquePath]; if (bv.common.Core.Utils.IsEmpty(cur)) { continue; } double c; DateTime cd; if (double.TryParse(cur.ToString(), out c)) { if (mmN == null || (max && mmN < c) || (!max && mmN > c)) { mmN = c; } } else if (DateTime.TryParse(cur.ToString(), out cd)) { if (mmDt == null || (max && mmDt < cd) || (!max && mmDt > cd)) { mmDt = cd; } } else { } } if (mmDt != null && mmN == null) { ret = mmDt; } else if (mmN != null && mmDt == null) { ret = mmN; } return(ret); }
// fill aggregate values into data column private static void FillGridAggrFColProcent(DataTable data, AvrViewColumn aggrColumn) { if (!bv.common.Core.Utils.IsEmpty(aggrColumn.SourceViewColumn) && data.Columns.Contains(aggrColumn.SourceViewColumn)) { var view = aggrColumn.GetView(); var rowCols = view.GetVisibleRowAdminColumns(true, null, false); // get Sum of refColumn double sumFull = AvrViewHelper.GetColumnSum(data, rowCols.Count, view.GrandTotalSuffix, view.TotalSuffix, aggrColumn.SourceViewColumn); if (sumFull != 0) { double dCur; foreach (DataRow row in data.Rows) { object cur = row[aggrColumn.SourceViewColumn]; if (!bv.common.Core.Utils.IsEmpty(cur) && double.TryParse(cur.ToString(), out dCur)) { row[aggrColumn.UniquePath] = dCur / sumFull; } } } } }
// returns one aggregate value private static object FillGridAggrFCumProcent(DataTable data, int rowIndex, AvrViewColumn aggrColumn, ref Dictionary <int, object> dict) { object ret = DBNull.Value; if (!bv.common.Core.Utils.IsEmpty(aggrColumn.SourceViewColumn) && data.Columns.Contains(aggrColumn.SourceViewColumn)) { var view = aggrColumn.GetView(); var rowCols = view.GetVisibleRowAdminColumns(true, null, false); double sum = 0; for (int i = 0; i <= rowIndex; i++) { if (!AvrViewHelper.GetRowTotalStatus(data.Rows[i], rowCols.Count, view.GrandTotalSuffix, view.TotalSuffix)) //if regular value (not total) { object cur = data.Rows[i][aggrColumn.SourceViewColumn]; if (bv.common.Core.Utils.IsEmpty(cur)) { continue; } double dCur; if (double.TryParse(cur.ToString(), out dCur)) { sum += dCur; } } } // get Sum of refColumn double sumFull = AvrViewHelper.GetColumnSum(data, rowCols.Count, view.GrandTotalSuffix, view.TotalSuffix, aggrColumn.SourceViewColumn, ref dict); if (sumFull != 0) { ret = sum / sumFull; } } return(ret); }