From 8f7939ec9cc2f47733c6b9d3a2fd3da5d7cf0268 Mon Sep 17 00:00:00 2001 From: wyf Date: Tue, 8 Apr 2025 03:42:27 +0000 Subject: [PATCH] SVN r458 SVN-Revision: r458 --- 插件库/Lskj.Control/BandedGridControlEx.cs | 85 ++++++++++------------ 1 file changed, 40 insertions(+), 45 deletions(-) diff --git a/插件库/Lskj.Control/BandedGridControlEx.cs b/插件库/Lskj.Control/BandedGridControlEx.cs index 565c445..a51c7aa 100644 --- a/插件库/Lskj.Control/BandedGridControlEx.cs +++ b/插件库/Lskj.Control/BandedGridControlEx.cs @@ -42,14 +42,14 @@ using DevExpress.XtraEditors.Controls; namespace Lskj.Control { - + /// /// 多表头表格 /// public partial class BandedGridControlEx : GridControlEx { // 创建Dictionary存储行号为Key,有效日期格式列名数组为Value - public Dictionary> rowDateValues = new Dictionary>(); + public Dictionary> rowDateValues = new Dictionary>(); /// /// 获取模块配置 /// @@ -280,18 +280,18 @@ namespace Lskj.Control DateTime? maxDateForRow = null; if (gridRow.Table.Columns.Contains("PrecomputedMaxDate")) { - bool isFieldDate= DateTime.TryParse(e.Column.FieldName, out DateTime FieldDate); + bool isFieldDate = DateTime.TryParse(e.Column.FieldName, out DateTime FieldDate); bool isMaxDate = DateTime.TryParse(gridRow["PrecomputedMaxDate"].ToString(), out DateTime parsedDate); if (isMaxDate && isFieldDate) { maxDateForRow = parsedDate; - - if (FieldDate< parsedDate) + + if (FieldDate < parsedDate) { isLaterDatePresent = true; } } - else if(isFieldDate) + else if (isFieldDate) { return; // 如果当前是日期框模式且没有定义最大值则直接跳过 } @@ -315,7 +315,7 @@ namespace Lskj.Control } try { - if (!string.IsNullOrWhiteSpace(cond) && ReplaceHelper.EvalCond(cond) && (!string.IsNullOrEmpty(e.CellValue + "")|| isLaterDatePresent)) + if (!string.IsNullOrWhiteSpace(cond) && ReplaceHelper.EvalCond(cond) && (!string.IsNullOrEmpty(e.CellValue + "") || isLaterDatePresent)) { GridRowColorModel model = new GridRowColorModel(item); if (!string.IsNullOrWhiteSpace(model.BackColor)) @@ -370,7 +370,7 @@ namespace Lskj.Control { if (!maxDate.HasValue || date > maxDate.Value) { - if (!string.IsNullOrEmpty(row[column.ColumnName]+"")) + if (!string.IsNullOrEmpty(row[column.ColumnName] + "")) { maxDate = date; } @@ -1378,41 +1378,8 @@ 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,表示尚未找到有效日期 - bool isdatefile= DateTime.TryParse(e.Column.FieldName, out DateTime tempDate);//获取改变当前列日期 - bool isMaxDatefile = rowDateValues.TryGetValue(e.RowHandle, out List currentRowDateColumns);//获取记录日期 - if (isdatefile) - { - if (isMaxDatefile&& currentRowDateColumns.Count>0) - { - List validDateColumns= rowDateValues[e.RowHandle]; - if (tempDate > currentRowDateColumns.Max()) // 只有在找到更大的日期时才更新 - { - validDateColumns.Add(tempDate); - HandleRow["PrecomputedMaxDate"] = tempDate.ToString("yyyy-MM-dd"); - } - else if (tempDate == currentRowDateColumns.Max() && string.IsNullOrEmpty(e.Value + "")) - { - rowDateValues[e.RowHandle].Remove(tempDate); - HandleRow["PrecomputedMaxDate"] = currentRowDateColumns.Max().ToString("yyyy-MM-dd"); - } - else - { - if(!validDateColumns.Contains(tempDate)) validDateColumns.Add(tempDate); - } - } - else { - rowDateValues[e.RowHandle].Add(tempDate); - HandleRow["PrecomputedMaxDate"] = tempDate.ToString("yyyy-MM-dd"); - } - } - } if (e.Column.Tag == null) return; GridColumnModel model = e.Column.Tag as GridColumnModel; if (model == null) return; @@ -1429,9 +1396,9 @@ namespace Lskj.Control } } } - + int rowHandle = gridView.GetDataSourceRowIndex(e.RowHandle); - + //根据某一列的值自动填充对应值 if (this.AutoPadDataReleColList.Count > 0) { @@ -1724,7 +1691,7 @@ namespace Lskj.Control { GridColumn col = GridView.VisibleColumns[_colNumber]; GridColumnModel model = col.Tag as GridColumnModel; - if (DateTime.TryParse(col.FieldName,out _)||(model.CanCopy || ((GridView.OptionsBehavior.Editable) && (GridView.VisibleColumns[_colNumber].OptionsColumn.AllowEdit)))) + if (DateTime.TryParse(col.FieldName, out _) || (model.CanCopy || ((GridView.OptionsBehavior.Editable) && (GridView.VisibleColumns[_colNumber].OptionsColumn.AllowEdit)))) { // 返回ID类型特殊处理 string cellValue = _arrayStr2[j]; @@ -3168,4 +3135,32 @@ namespace Lskj.Control } } - string tempSql = string.Format(@"insert i \ No newline at end of file + string tempSql = string.Format(@"insert into {3}(GroupName,GroupAmount,OperAtorId) values('{0}','{1}','{2}');", editValue, groupText, ERPInfo.Instance.UserId, ResourceKeys.SettingGrouprptab); + SqlHelper.ExecuteNonQuery(tempSql); + } + } + } + } + + } + catch (Exception ex) + { + string Message = ErrorMessage.PromptErrorMessage(ex, Model.ModuleCode); + MessageUtil.Show(Message, ex.Message); + } + } + + + /// + /// 点击标题行排序后,默认选中第一行 + /// + /// + /// + private void BandedGridView_EndSorting(object sender, EventArgs e) + { + this.bandedGridView.MoveFirst(); // 将焦点行移动到第一行 + this.bandedGridView.FocusedRowHandle = 0;// 确保第一行被聚焦 + } + + } +}