SVN-Revision: r443
This commit is contained in:
tdx
2025-04-03 07:46:31 +00:00
parent 61da6228a6
commit eed569b9e3
2 changed files with 77 additions and 28 deletions
+43 -4
View File
@@ -274,10 +274,31 @@ namespace Lskj.Control
{
DataRow gridRow = view.GetDataRow(e.RowHandle);
// 获取行的最大日期值
DateTime? maxDateForRow = GetMaxDateFromColumnNames(gridRow);
DateTime? maxDateForRow = null;
if (gridRow.Table.Columns.Contains("PrecomputedMaxDate") && gridRow["PrecomputedMaxDate"] != null && gridRow["PrecomputedMaxDate"].ToString() != "")
{
if (DateTime.TryParse(gridRow["PrecomputedMaxDate"].ToString(), out DateTime parsedDate))
{
maxDateForRow = parsedDate;
}
}
//DateTime? maxDateForRow = GetMaxDateFromColumnNames(gridRow);
foreach (DataRow item in this.GridRowColorsTable.Rows)
{
string cond = ReplaceHelper.ReplaceRowParam(gridRow, item["condition"] + "").ReplaceColumnParam(e.Column.Name, e.Column.Caption, e.CellValue + "");
string condition = item["condition"] + "";
string cond = condition;
// 检查是否条件字符串包含 'COLUMN_NAME'
if (condition.Contains("COLUMN_NAME"))
{
// 解析期望的列名
string expectedColumnName = condition.Split('=').Last().Trim('\'');
// 构建直接的列名比较
cond = $"'{e.Column.Name}'='{expectedColumnName}'";
}
else
{
cond = ReplaceHelper.ReplaceRowParam(gridRow, item["condition"] + "").ReplaceColumnParam(e.Column.Name, e.Column.Caption, e.CellValue + "");
}
bool isLaterDatePresent = false;
// 检查当前列是否为日期类型并获取日期
DateTime currentDate;
@@ -1347,6 +1368,24 @@ namespace Lskj.Control
{
try
{
GridView gridView = this.gridControl.MainView as GridView;
DataTable dataTable = this.gridControl.DataSourceTable();
if (dataTable != null&& dataTable.Columns.Contains("PrecomputedMaxDate"))
{
DataRow HandleRow = this.bandedGridView.GetDataRow(e.RowHandle);
DateTime? maxDate = null; // 初始化为 null,表示尚未找到有效日期
if (DateTime.TryParse(e.Column.FieldName, out DateTime tempDate) && DateTime.TryParse(HandleRow["PrecomputedMaxDate"] + "", out DateTime newDate))
{
if (tempDate > maxDate) // 只有在找到更大的日期时才更新
{
HandleRow["PrecomputedMaxDate"] = tempDate;
}
} else if (string.IsNullOrEmpty(HandleRow["PrecomputedMaxDate"]+""))
{
HandleRow["PrecomputedMaxDate"] = tempDate;
}
}
if (e.Column.Tag == null) return;
GridColumnModel model = e.Column.Tag as GridColumnModel;
if (model == null) return;
@@ -1363,9 +1402,9 @@ namespace Lskj.Control
}
}
}
GridView gridView = this.gridControl.MainView as GridView;
int rowHandle = gridView.GetDataSourceRowIndex(e.RowHandle);
DataTable dataTable = this.gridControl.DataSourceTable();
//根据某一列的值自动填充对应值
if (this.AutoPadDataReleColList.Count > 0)
{