private DataTable op_jinedie_2023(DataTable dataTable, int startIndex) { var length = dataTable.Rows.Count; if (startIndex >= length) return dataTable; int a = -1, b = -1; for (var i = startIndex; i < length; i++) { var dataRow = dataTable.get_row_by_index(i); if (dataRow.get_cell_val("FEXPLANATION").StartsWith("来账") || dataRow.get_cell_val("FEXPLANATION").StartsWith("往账")) if (a == -1) a = i; else b = i; if (a != -1 && b != -1) break; if (i == length - 1) b = length; } if (a == -1 || b == -1) return dataTable; decimal co = 0, cp = 0; for (var i = a; i < b; i++) { co += dataTable.get_row_by_index(i).get_cell_val("FDEBIT").to_decimal(); cp += dataTable.get_row_by_index(i).get_cell_val("FCREDIT").to_decimal(); } if (co == cp) { dataTable.Rows[b]["FAMOUNTFOR"] = "0"; dataTable.Rows[b]["FDEBIT"] = "0"; return op_jinedie_2023(dataTable, b); } b--; dataTable.Rows[b]["FAMOUNTFOR"] = Math.Abs(Math.Abs(co) - Math.Abs(cp)); dataTable.Rows[b]["FDEBIT"] = dataTable.Rows[b]["FAMOUNTFOR"]; return op_jinedie_2023(dataTable, b + 1); }
标签:Rows,co,汇兑,get,金蝶,length,2023,dataTable From: https://www.cnblogs.com/IBPM/p/17021243.html