SVN-Revision: r973
This commit is contained in:
cyf
2025-09-09 01:59:56 +00:00
parent e9603c2287
commit c3b8d39f9d
13 changed files with 879 additions and 178 deletions
@@ -117,8 +117,11 @@ namespace Lskj.Control
this.bandedGridView.Appearance.GroupRow.FontSizeDelta = SystemInfo.Instance.GroupRowFontSizeDelta;
}
this.bandedGridView.EndSorting += BandedGridView_EndSorting;//排序后选中第一行
this.bandedGridView.ShowingEditor += GridView_ShowingEditor;
}
/// <summary>
/// <para>说明:单元格合并</para>
/// <para>创建人:王一帆</para>
@@ -3189,4 +3192,29 @@ namespace Lskj.Control
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex, Model.ModuleCode);
MessageUtil.Show(Message, ex.Message);
}
}
/// <summary>
/// 点击标题行排序后,默认选中第一行
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void BandedGridView_EndSorting(object sender, EventArgs e)
{
this.bandedGridView.MoveFirst(); // 将焦点行移动到第一行
this.bandedGridView.FocusedRowHandle = 0;// 确保第一行被聚焦
}
/// <summary>
/// 水平滚动条位置改变
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void OnBandedLeftCoordChanged(object sender, EventArgs e)
{
if (OnLeftCoordCallback != null)
{
+353 -62
View File
@@ -382,6 +382,31 @@ namespace Lskj.Control
/// 聚合多表头控件
/// </summary>
public BandedGridControlEx CustomGroupBandEx;
/// <summary>
/// 聚合多表头控件
/// </summary>
public TreeBandedGridControlEx CustomGroupTreeBandEx;
/// <summary>
/// 聚合多表头控件选中行
/// </summary>
public DataRow CustomGroupSelectedRow
{
get
{
DataRow dataRow = null;
if (CustomGroupBandEx != null)
{
dataRow = CustomGroupBandEx.GetViewFocusedDataRow();
}
else if (CustomGroupTreeBandEx != null)
{
dataRow = CustomGroupTreeBandEx.GetViewFocusedDataRow();
}
return dataRow;
}
}
/// <summary>
/// 导出名不包含日期
/// </summary>
@@ -454,12 +479,14 @@ namespace Lskj.Control
this.gridView.CustomRowFilter += GridView_CustomRowFilter;
}
#region LabPicUrl控件实现事件
this.gridView.CustomUnboundColumnData += OnGridViewCustomUnboundColumnData;
this.gridView.DoubleClick += OnShowImageDoubleClick; ;
//this.gridView.CustomUnboundColumnData += OnGridViewCustomUnboundColumnData;
//this.gridView.DoubleClick += OnShowImageDoubleClick;
LabPicUrlPreview.Attach(this.gridView); // 必须
LabPicUrlPreview.AttachPreview(this.gridView); // 新增(双击预览)
#endregion
if (SystemInfo.Instance.GroupSpecialMode) this.gridView.EndGrouping += GridView_EndGrouping;
this.gridView.ShowingEditor += GridView_ShowingEditor;
}
@@ -467,6 +494,12 @@ namespace Lskj.Control
/// <summary>
/// 保存前反写多表头数据源
/// </summary>
@@ -474,81 +507,165 @@ namespace Lskj.Control
{
try
{
// 获取动态多表头的Grid控件数据源 (假设为DataTable)
DataTable updatedTable = CustomGroupBandEx.gridControl.DataSource as DataTable;
if (updatedTable == null) return;
// 获取原始的GridControl的数据源
DataTable originalDataTable = this.gridControl.DataSource as DataTable;
if (originalDataTable == null) return;
// 获取分组相关的列定义
GridColumnModel GroupPrimary = ColumnList.FirstOrDefault(o => o.IsCustomGroupPrimary);
GridColumnModel GroupFieldprimary = ColumnList.FirstOrDefault(o => o.IsCustomGroupField == 1);
List<GridColumnModel> GroupField = ColumnList.Where(o => o.IsCustomGroupField == 2).ToList();
if (GroupPrimary == null || GroupFieldprimary == null || !GroupField.Any()) return;
// 遍历每一行更新回原始数据表
foreach (DataRow updatedRow in updatedTable.Rows)
if (CustomGroupBandEx != null)
{
string primaryKeyValue = updatedRow[GroupPrimary.FieldName]?.ToString();
// 获取动态多表头的Grid控件数据源 (假设为DataTable)
DataTable updatedTable = CustomGroupBandEx.gridControl.DataSource as DataTable;
if (updatedTable == null) return;
// 根据主键定位原始表中的行集合
var originalRows = originalDataTable.AsEnumerable()
.Where(row => row.Field<string>(GroupPrimary.FieldName) == primaryKeyValue).ToList();
// 获取原始的GridControl的数据源
DataTable originalDataTable = this.gridControl.DataSource as DataTable;
if (originalDataTable == null) return;
if (!originalRows.Any()) continue; // 若没有匹配的行,跳过
// 获取分组相关的列定义
GridColumnModel GroupPrimary = ColumnList.FirstOrDefault(o => o.IsCustomGroupPrimary);
GridColumnModel GroupFieldprimary = ColumnList.FirstOrDefault(o => o.IsCustomGroupField == 1);
List<GridColumnModel> GroupField = ColumnList.Where(o => o.IsCustomGroupField == 2).ToList();
// 遍历动态表头的Band及子列
foreach (GridBand band in CustomGroupBandEx.BandedView.Bands)
if (GroupPrimary == null || GroupFieldprimary == null || !GroupField.Any()) return;
// 遍历每一行更新回原始数据表
foreach (DataRow updatedRow in updatedTable.Rows)
{
if (band.Caption == "基本信息") continue; // 跳过普通列Band
string primaryKeyValue = updatedRow[GroupPrimary.FieldName]?.ToString();
string groupFieldPrimaryValue = band.Caption;
// 根据主键定位原始表中的行集合
var originalRows = originalDataTable.AsEnumerable()
.Where(row => row.Field<string>(GroupPrimary.FieldName) == primaryKeyValue).ToList();
foreach (BandedGridColumn column in band.Columns)
if (!originalRows.Any()) continue; // 若没有匹配的行,跳过
// 遍历动态表头的Band及子列
foreach (GridBand band in CustomGroupBandEx.BandedView.Bands)
{
var subField = column.Tag as GridColumnModel;
if (subField == null) continue;
if (band.Caption == "基本信息") continue; // 跳过普通列Band
string dynamicFieldName = column.FieldName;
object updatedValue = updatedRow[dynamicFieldName];
string groupFieldPrimaryValue = band.Caption;
// 精确匹配原数据源对应的单行
DataRow targetRow = originalRows.FirstOrDefault(r =>
r.Field<string>(GroupFieldprimary.FieldName) == groupFieldPrimaryValue);
// 若找到行,则更新该行对应的字段
if (targetRow != null && originalDataTable.Columns.Contains(subField.FieldName))
foreach (BandedGridColumn column in band.Columns)
{
targetRow[subField.FieldName] = updatedValue;
}
else if (targetRow == null)
{
// 若没找到,说明可能为新增数据行,插入新行(若业务需要)
DataRow newOriginalRow = originalDataTable.NewRow();
newOriginalRow[GroupPrimary.FieldName] = primaryKeyValue;
newOriginalRow[GroupFieldprimary.FieldName] = groupFieldPrimaryValue;
var subField = column.Tag as GridColumnModel;
if (subField == null) continue;
foreach (var col in ColumnList.Where(x => !x.IsCustomGroupField.Equals(1) && !x.IsCustomGroupPrimary))
string dynamicFieldName = column.FieldName;
object updatedValue = updatedRow[dynamicFieldName];
// 精确匹配原数据源对应的单行
DataRow targetRow = originalRows.FirstOrDefault(r =>
r.Field<string>(GroupFieldprimary.FieldName) == groupFieldPrimaryValue);
// 若找到行,则更新该行对应的字段
if (targetRow != null && originalDataTable.Columns.Contains(subField.FieldName))
{
if (updatedTable.Columns.Contains(col.FieldName) && originalDataTable.Columns.Contains(col.FieldName))
targetRow[subField.FieldName] = updatedValue;
}
else if (targetRow == null)
{
// 若没找到,说明可能为新增数据行,插入新行(若业务需要)
DataRow newOriginalRow = originalDataTable.NewRow();
newOriginalRow[GroupPrimary.FieldName] = primaryKeyValue;
newOriginalRow[GroupFieldprimary.FieldName] = groupFieldPrimaryValue;
foreach (var col in ColumnList.Where(x => !x.IsCustomGroupField.Equals(1) && !x.IsCustomGroupPrimary))
{
newOriginalRow[col.FieldName] = updatedRow[col.FieldName];
if (updatedTable.Columns.Contains(col.FieldName) && originalDataTable.Columns.Contains(col.FieldName))
{
newOriginalRow[col.FieldName] = updatedRow[col.FieldName];
}
}
}
if (originalDataTable.Columns.Contains(subField.FieldName))
{
newOriginalRow[subField.FieldName] = updatedValue;
}
if (originalDataTable.Columns.Contains(subField.FieldName))
{
newOriginalRow[subField.FieldName] = updatedValue;
}
originalDataTable.Rows.Add(newOriginalRow);
originalDataTable.Rows.Add(newOriginalRow);
}
}
}
}
}
else if (CustomGroupTreeBandEx != null)
{
// 获取动态多表头的Grid控件数据源 (假设为DataTable)
DataTable updatedTable = CustomGroupTreeBandEx.TreeListObj.DataSource as DataTable;
if (updatedTable == null) return;
// 获取原始的GridControl的数据源
DataTable originalDataTable = this.gridControl.DataSource as DataTable;
if (originalDataTable == null) return;
// 获取分组相关的列定义
GridColumnModel GroupPrimary = ColumnList.FirstOrDefault(o => o.IsCustomGroupPrimary);
GridColumnModel GroupFieldprimary = ColumnList.FirstOrDefault(o => o.IsCustomGroupField == 1);
List<GridColumnModel> GroupField = ColumnList.Where(o => o.IsCustomGroupField == 2).ToList();
if (GroupPrimary == null || GroupFieldprimary == null || !GroupField.Any()) return;
// 遍历每一行更新回原始数据表
foreach (DataRow updatedRow in updatedTable.Rows)
{
string primaryKeyValue = updatedRow[GroupPrimary.FieldName]?.ToString();
// 根据主键定位原始表中的行集合
var originalRows = originalDataTable.AsEnumerable()
.Where(row => row.Field<string>(GroupPrimary.FieldName) == primaryKeyValue).ToList();
if (!originalRows.Any()) continue; // 若没有匹配的行,跳过
// 遍历动态表头的Band及子列
foreach (DevExpress.XtraTreeList.Columns.TreeListBand band in CustomGroupTreeBandEx.TreeListObj.Bands)
{
if (band.Caption == "基本信息") continue; // 跳过普通列Band
string groupFieldPrimaryValue = band.Caption;
foreach (DevExpress.XtraTreeList.Columns.TreeListColumn column in band.Columns)
{
var subField = column.Tag as GridColumnModel;
if (subField == null) continue;
string dynamicFieldName = column.FieldName;
object updatedValue = updatedRow[dynamicFieldName];
// 精确匹配原数据源对应的单行
DataRow targetRow = originalRows.FirstOrDefault(r =>
r.Field<string>(GroupFieldprimary.FieldName) == groupFieldPrimaryValue);
// 若找到行,则更新该行对应的字段
if (targetRow != null && originalDataTable.Columns.Contains(subField.FieldName))
{
targetRow[subField.FieldName] = updatedValue;
}
else if (targetRow == null)
{
// 若没找到,说明可能为新增数据行,插入新行(若业务需要)
DataRow newOriginalRow = originalDataTable.NewRow();
newOriginalRow[GroupPrimary.FieldName] = primaryKeyValue;
newOriginalRow[GroupFieldprimary.FieldName] = groupFieldPrimaryValue;
foreach (var col in ColumnList.Where(x => !x.IsCustomGroupField.Equals(1) && !x.IsCustomGroupPrimary))
{
if (updatedTable.Columns.Contains(col.FieldName) && originalDataTable.Columns.Contains(col.FieldName))
{
newOriginalRow[col.FieldName] = updatedRow[col.FieldName];
}
}
if (originalDataTable.Columns.Contains(subField.FieldName))
{
newOriginalRow[subField.FieldName] = updatedValue;
}
originalDataTable.Rows.Add(newOriginalRow);
}
}
}
}
}
}
catch (Exception ex)
{
@@ -959,7 +1076,9 @@ namespace Lskj.Control
InitPicEdit(column);
break;
case ControlType.LabPicUrl:
InitPicEditUrl(column, model);
//InitPicEditUrl(column, model);
// 用工具类创建图片列(绑定 Tag、Repository、UnboundType
LabPicUrlPreview.InitPicColumn(this.gridControl, column, model);
break;
case ControlType.LabSelectReturnId:
case ControlType.LabSelectReturnText:
@@ -3685,6 +3804,8 @@ namespace Lskj.Control
RepositoryItemProgressBar progressEdit = new RepositoryItemProgressBar();
progressEdit.ShowTitle = true;
//progressEdit.Maximum = 200;
this.ProgressBarColumn.Add(gridColumn.FieldName);
gridControl.RepositoryItems.Add(progressEdit);
gridColumn.ColumnEdit = progressEdit;
@@ -5555,7 +5676,7 @@ namespace Lskj.Control
GridColumnModel model = col.Tag as GridColumnModel;
if (!string.IsNullOrWhiteSpace(model.DisableCond))
{
DataRow FocusedRow = newRow == null? this.gridView.GetFocusedDataRow(): newRow;
DataRow FocusedRow = newRow == null ? this.gridView.GetFocusedDataRow() : newRow;
string UpdateCond = model.DisableCond;
if (this.ParentControl != null) UpdateCond = this.ParentControl.ReplaceParentControlValue(model.DisableCond);
UpdateCond = ReplaceHelper.ReplaceRowParam(FocusedRow, UpdateCond);
@@ -7358,13 +7479,18 @@ namespace Lskj.Control
}
}
// 调用动态构建方法
if (CustomGroupBandEx != null)
if (CustomGroupBandEx != null || CustomGroupTreeBandEx != null)
{
DataTable currentDataSource = gridView.GridControl.DataSource as DataTable;
if (currentDataSource != null)
if (CustomGroupBandEx != null && currentDataSource != null)
{
BuildDynamicGroupedColumns(CustomGroupBandEx, currentDataSource);
}
if (CustomGroupTreeBandEx != null && currentDataSource != null)
{
BuildDynamicGroupedColumns(CustomGroupTreeBandEx, currentDataSource);
}
}
}
/// <summary>
@@ -7500,6 +7626,148 @@ namespace Lskj.Control
}
/// <summary>
/// 构建多表头格式
/// </summary>
/// <param name="bandedGridControlEx"></param>
/// <param name="originalDataSource"></param>
private void BuildDynamicGroupedColumns(TreeBandedGridControlEx TreeBandedGridControlEx, DataTable originalDataSource)
{
TreeBandedGridControlEx.TreeListObj.BeginUpdate();
TreeBandedGridControlEx.TreeListObj.OptionsView.AutoWidth = false;
/* ========= 0. 取列定义 ========= */
GridColumnModel GroupPrimary = ColumnList.FirstOrDefault(o => o.IsCustomGroupPrimary);
GridColumnModel GroupFieldprimary = ColumnList.FirstOrDefault(o => o.IsCustomGroupField == 1);
List<GridColumnModel> GroupField = ColumnList.Where(o => o.IsCustomGroupField == 2 || o.IsCustomGroupField == 4).ToList(); // 4 = 特殊字段
List<GridColumnModel> sumField = ColumnList.Where(o => o.IsCustomGroupField == 3).ToList();
if (GroupPrimary == null || GroupFieldprimary == null || !GroupField.Any()) return;
/* ========= 1. 清空现有列 ========= */
TreeBandedGridControlEx.TreeListObj.Bands.Clear();
TreeBandedGridControlEx.TreeListObj.Columns.Clear();
/* ========= 2. 创建“基本信息”Band ========= */
List<GridColumnModel> normalColumns = ColumnList.Where(o => o.IsCustomGroupField == 0 || o.IsCustomGroupField == 3).ToList();
DevExpress.XtraTreeList.Columns.TreeListBand normalBand = new DevExpress.XtraTreeList.Columns.TreeListBand { Caption = "基本信息", Fixed = DevExpress.XtraTreeList.Columns.FixedStyle.Left };
normalBand.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
normalBand.AppearanceHeader.Options.UseTextOptions = true;
TreeBandedGridControlEx.TreeListObj.Bands.Add(normalBand);
foreach (var normalCol in normalColumns)
{
if (!originalDataSource.Columns.Contains(normalCol.FieldName)) continue;
DevExpress.XtraTreeList.Columns.TreeListColumn col = new DevExpress.XtraTreeList.Columns.TreeListColumn
{
FieldName = normalCol.FieldName,
Caption = normalCol.FieldText,
Width = normalCol.Width,
Visible = normalCol.Visible,
Tag = normalCol,
OptionsColumn = { AllowEdit = normalCol.Edit, FixedWidth = true }
};
if (!normalCol.Edit)
{
col.AppearanceHeader.Options.UseForeColor = true;
col.AppearanceHeader.ForeColor = ColorTranslator.FromHtml(HeaderColor);
}
if (normalCol.CanNull)
{
col.AppearanceHeader.Options.UseForeColor = true;
col.AppearanceHeader.ForeColor = RequiredForceColor;
}
col.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
col.AppearanceHeader.Options.UseTextOptions = true;
TreeBandedGridControlEx.SetColumnFormat(col, normalCol);
normalBand.Columns.Add(col);
TreeBandedGridControlEx.TreeListObj.Columns.Add(col);
}
/* ========= 3. 生成动态表头列表 ========= */
var dynamicHeaders = originalDataSource.AsEnumerable()
.Select(r => r[GroupFieldprimary.FieldName])
.Where(v => v != null && v != DBNull.Value)
.Select(v => v is DateTime dt ? dt.ToString("yyyy-MM-dd") : v.ToString())
.Distinct()
.ToList();
/* ========= 4. 生成动态 Band + 子列 ========= */
foreach (string headerName in dynamicHeaders)
{
DevExpress.XtraTreeList.Columns.TreeListBand dynamicBand = new DevExpress.XtraTreeList.Columns.TreeListBand { Caption = headerName };
dynamicBand.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
dynamicBand.AppearanceHeader.Options.UseTextOptions = true;
TreeBandedGridControlEx.TreeListObj.Bands.Add(dynamicBand);
// 尝试把 headerName 解析成日期,以便下面用星期几
DateTime headerDate;
bool isDateHeader = DateTime.TryParse(headerName, out headerDate);
foreach (var subField in GroupField)
{
string dynamicFieldName = $"{headerName}_{subField.FieldName}";
/* —— 计算子列 Caption —— */
string subCaption = subField.FieldText; // 默认
if (subField.IsCustomGroupField == 4 && isDateHeader)
{
// 将星期几转成中文“日一二三四五六”,根据需要可自行改动
string[] cnWeek = { "日", "一", "二", "三", "四", "五", "六" };
subCaption = cnWeek[(int)headerDate.DayOfWeek]; // 0=Sunday
}
DevExpress.XtraTreeList.Columns.TreeListColumn subColumn = new DevExpress.XtraTreeList.Columns.TreeListColumn
{
FieldName = dynamicFieldName,
Caption = subCaption,
Width = subField.Width,
Visible = subField.Visible,
Tag = subField,
MinWidth = subField.Width,
OptionsColumn = { AllowEdit = subField.Edit, FixedWidth = true }
};
if (!subField.Edit)
{
subColumn.AppearanceHeader.Options.UseForeColor = true;
subColumn.AppearanceHeader.ForeColor = ColorTranslator.FromHtml(HeaderColor);
}
if (subField.CanNull)
{
subColumn.AppearanceHeader.Options.UseForeColor = true;
subColumn.AppearanceHeader.ForeColor = RequiredForceColor;
}
subColumn.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
subColumn.AppearanceHeader.Options.UseTextOptions = true;
TreeBandedGridControlEx.SetColumnFormat(subColumn, subField);
dynamicBand.Columns.Add(subColumn);
TreeBandedGridControlEx.TreeListObj.Columns.Add(subColumn);
}
}
TreeBandedGridControlEx.TreeListObj.EndUpdate();
/* ========= 5. 构建最终数据源并绑定 ========= */
DataTable dynamicDataTable = BuildDynamicDataSource(
originalDataSource,
GroupPrimary,
GroupFieldprimary,
GroupField,
normalColumns,
sumField,
dynamicHeaders);
TreeBandedGridControlEx.TreeListObj.DataSource = dynamicDataTable;
if (OnBuildGroupedColumnCallBack != null)
{
OnBuildGroupedColumnCallBack(TreeBandedGridControlEx.TreeListObj, null);
}
}
/// <summary>
/// 构建数据源
/// </summary>
@@ -9202,4 +9470,27 @@ namespace Lskj.Control
gridView.GroupSummarySortInfo.Clear();
// 遍历多目标汇总列,按优先级添加排序
foreach (GridColumn gridColumn in gridView.Columns)
{
string summaryName = gridColumn.FieldName;
// 查找当前目标列的汇总项(假设汇总类型为Sum,可根据实际修改)
GridGroupSummaryItem summaryItem = gridView.GroupSummary
.FirstOrDefault(item => item.FieldName.Equals(summaryName)
&& item.SummaryType == SummaryItemType.Sum) as GridGroupSummaryItem;
if (summaryItem != null)
{
//根据汇总降序排序
gridView.GroupSummarySortInfo.Add(summaryItem, ColumnSortOrder.Descending);
break;
}
}
}
finally
{
Completed = true;
}
}
+6 -2
View File
@@ -443,12 +443,16 @@ namespace Lskj.Control.Model
public const int LabApiBtuton = 163;
/// <summary>
///超链接
/// </ summary>
/// </summary>
public const int LabHyperlink = 164;
/// <summary>
///关联右键列
/// </ summary>
/// </summary>
public const int LabRightlink = 165;
/// <summary>
///单据来源控件(弹出控件根据下拉框中的单据来源id加载数据)
/// </summary>
public const int LabBillSource = -11;
/// <summary>
/// <para>说明:是否为Value类型</para>
+25 -25
View File
@@ -614,7 +614,7 @@ namespace Lskj.Control.Model
GridColumnModel model = col.Tag as GridColumnModel;
DataRow a = customTable.Rows.Cast<DataRow>().FirstOrDefault(x => col.Name.Equals(x["fieldName"] + "", StringComparison.OrdinalIgnoreCase));
string tempSql = a == null ? string.Format(@"insert into {8}(formkey,fieldname,username,orderid,isvisible,operatorid,operatorName,operatedate,fieldWidth,IfFixColumn,FieldText {11}) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}',getdate(),'{7}','{9}','{10}' {12});",
key, col.FieldName, col.Caption, col.VisibleIndex, Convert.ToInt32(col.Visible), ERPInfo.Instance.UserId, ERPInfo.Instance.UserName, col.Width, ResourceKeys.SettingTableName, col.OwnerBand.Fixed == DevExpress.XtraGrid.Columns.FixedStyle.Left, model.FieldText, saveFieldName, fieldValue) : string.Format(@"update {6} set orderid='{0}',fieldWidth='{1}',isvisible={2},IfFixColumn='{7}' {8} where formkey='{3}' and fieldname='{4}' and operatorid='{5}';",
key, col.FieldName, col.Caption, col.VisibleIndex, Convert.ToInt32(col.Visible), ERPInfo.Instance.UserId, ERPInfo.Instance.UserName, col.Width, ResourceKeys.SettingTableName, col.OwnerBand != null ? col.OwnerBand.Fixed == DevExpress.XtraGrid.Columns.FixedStyle.Left : false, model.FieldText, saveFieldName, fieldValue) : string.Format(@"update {6} set orderid='{0}',fieldWidth='{1}',isvisible={2},IfFixColumn='{7}' {8} where formkey='{3}' and fieldname='{4}' and operatorid='{5}';",
col.VisibleIndex, col.Width, Convert.ToInt32(col.Visible), key, col.FieldName, ERPInfo.Instance.UserId, ResourceKeys.SettingTableName, col.OwnerBand != null ? col.OwnerBand.Fixed == DevExpress.XtraGrid.Columns.FixedStyle.Left : false, updateField);
sBuilder.Append(tempSql);
}
@@ -2183,7 +2183,7 @@ namespace Lskj.Control.Model
model.FieldType == ControlType.LabDateTime ||
model.FieldType == ControlType.LabDateTimeShort ||
model.FieldType == ControlType.LabTime ||
model.FieldType == ControlType.LabShortTime)&& (cell == null&&cell.StringCellValue!=null && cell.CellType == CellType.Blank && string.IsNullOrWhiteSpace(cell+"")))
model.FieldType == ControlType.LabShortTime) && (cell == null && cell.StringCellValue != null && cell.CellType == CellType.Blank && string.IsNullOrWhiteSpace(cell + "")))
{
//日期框如果值是空,就直接跳过。赋空值("")会报错
continue;
@@ -2242,21 +2242,21 @@ namespace Lskj.Control.Model
|| model.FieldType == ControlType.LabAutoGridValue
|| model.FieldType == ControlType.LabAutoGridValueParam
|| model.FieldType == ControlType.LabSelectReturnId
||(model.FieldType == ControlType.LabSelectReturnIdNew && model.ModuleFrameDisplayText)
|| (model.FieldType == ControlType.LabSelectReturnIdNew && model.ModuleFrameDisplayText)
))
{
bool isEmpty = model.CanNull;
string fieldValue = GetValueByImportText(dataRow, col.FieldName, cell + "", isBillImport);
// if ((model.FieldType == ControlType.LabMultiSelectValue || model.FieldType == ControlType.LabMultiSelectValueNew ||
//model.FieldType == ControlType.LabMultiSelectValueParam) && cell.ToString().Contains(","))
// {
// string[] cellText = cell.ToString().Split(',');
// foreach (string cellValue in cellText)
// {
// fieldValue += GetValueByImportText(dataRow, col.FieldName, cellValue, isBillImport) + ',';
// }
// fieldValue = fieldValue.TrimEnd(',');
// }
// if ((model.FieldType == ControlType.LabMultiSelectValue || model.FieldType == ControlType.LabMultiSelectValueNew ||
//model.FieldType == ControlType.LabMultiSelectValueParam) && cell.ToString().Contains(","))
// {
// string[] cellText = cell.ToString().Split(',');
// foreach (string cellValue in cellText)
// {
// fieldValue += GetValueByImportText(dataRow, col.FieldName, cellValue, isBillImport) + ',';
// }
// fieldValue = fieldValue.TrimEnd(',');
// }
if (string.IsNullOrEmpty(fieldValue))
{
if (isEmpty)
@@ -2593,16 +2593,16 @@ namespace Lskj.Control.Model
{
bool isEmpty = model.CanNull;
string fieldValue = GetValueByImportText(dataRow, col.FieldName, cell + "", isBillImport);
// if ((model.FieldType == ControlType.LabMultiSelectValue || model.FieldType == ControlType.LabMultiSelectValueNew ||
//model.FieldType == ControlType.LabMultiSelectValueParam) && cell.ToString().Contains(","))
// {
// string[] cellText = cell.ToString().Split(',');
// foreach (string cellValue in cellText)
// {
// fieldValue += GetValueByImportText(dataRow, col.FieldName, cellValue, isBillImport) + ',';
// }
// fieldValue = fieldValue.TrimEnd(',');
// }
// if ((model.FieldType == ControlType.LabMultiSelectValue || model.FieldType == ControlType.LabMultiSelectValueNew ||
//model.FieldType == ControlType.LabMultiSelectValueParam) && cell.ToString().Contains(","))
// {
// string[] cellText = cell.ToString().Split(',');
// foreach (string cellValue in cellText)
// {
// fieldValue += GetValueByImportText(dataRow, col.FieldName, cellValue, isBillImport) + ',';
// }
// fieldValue = fieldValue.TrimEnd(',');
// }
if (string.IsNullOrEmpty(fieldValue))
{
if (isEmpty)
@@ -3013,7 +3013,7 @@ namespace Lskj.Control.Model
model.FieldType == ControlType.LabMultiSelectValue ||
model.FieldType == ControlType.LabMultiSelectValueParam ||
model.FieldType == ControlType.LabAutoGridValue ||
model.FieldType == ControlType.LabSelectReturnId||
model.FieldType == ControlType.LabSelectReturnId ||
(model.FieldType == ControlType.LabSelectReturnIdNew && model.ModuleFrameDisplayText)
))
{
@@ -3428,7 +3428,7 @@ namespace Lskj.Control.Model
string sqlValue = model.SqlSource;
if (model.FieldType == ControlType.LabSelectReturnId || model.FieldType == ControlType.LabSelectReturnIdNew)
{
if ((model.IsRadio && !string.IsNullOrWhiteSpace(model.addModuleld)) ||model.FieldType == ControlType.LabSelectReturnIdNew)
if ((model.IsRadio && !string.IsNullOrWhiteSpace(model.addModuleld)) || model.FieldType == ControlType.LabSelectReturnIdNew)
{
//单选模式数据源为模块sql 新版模块选中返回id固定位模块sql
DataRow modelRow = Business.Impl.MainImpl.GetSystemdllTab(model.addModuleld);
@@ -298,7 +298,7 @@ namespace Lskj.Control.Model
//{
//}
if (model.ActionType == 0 && execResult)
if (model.ActionType == 0 && execResult && !model.DisableSuccessfulPrompt)
{
MessageUtil.Show(string.IsNullOrEmpty(model.SuccessMsg) ? ResourceKeys.OperSuccess : model.SuccessMsg);
}
@@ -319,6 +319,10 @@ namespace Lskj.Control.Model
/// sql直接执行模式
/// </summary>
public bool SqlDirectExecution;
/// <summary>
/// sql执行成功不提示
/// </summary>
public bool DisableSuccessfulPrompt;
/// <summary>
@@ -441,4 +445,6 @@ namespace Lskj.Control.Model
this._resultSQL = item["ResultSQL"] + "";
if (item.Table.Columns.Contains("ExecuteFirstCode"))
this.ExecuteFirstCode = item["ExecuteFirstCode"] + "";
if (item.Table.Columns.Contains("DuringExecutionMinimize"))
this.DuringExecutionMinimize = string.IsNullOrWhiteSpace(item["DuringExecutionMinimize"] + "") ? false : "1".Equals(item["DuringExecutionMinimize"] + "");
if
+43 -34
View File
@@ -152,6 +152,10 @@ namespace Lskj.Control.Model
/// 是否为审核界面主表
/// </summary>
public bool isAuditMain = false;
/// <summary>
///单据特殊模块id(单据来源控件)
/// </summary>
public string BillSourceControlId = string.Empty;
/// <summary>
@@ -236,6 +240,10 @@ namespace Lskj.Control.Model
/// </summary>
public event KeyEventHandler OnDataFileRefrshCallBack;
/// <summary>
/// 打开来源模块
/// </summary>
public event EventHandler OpenDocumentSource;
/// <summary>
/// 控件Panel对象
/// </summary>
public XtraScrollableControl ParentPanel
@@ -1578,6 +1586,10 @@ namespace Lskj.Control.Model
case ControlType.LabCheckText:
LabelCheckText labelCheckText = ctr as LabelCheckText;
break;
case ControlType.LabBillSource:
LabelBillSourceComboxEdit billSourceComboxEdit = ctr as LabelBillSourceComboxEdit;
billSourceComboxEdit.SetDataSource(table);
break;
default:
break;
}
@@ -1699,7 +1711,7 @@ namespace Lskj.Control.Model
}
else if (model.FieldName.EndsWith("operatedate", StringComparison.OrdinalIgnoreCase))
{
controlValue = DateTime.Now.ToString();
controlValue = SqlHelper.ExecuteScalar("select getdate()")+"";//DateTime.Now.ToString();
}
else
{
@@ -1718,7 +1730,7 @@ namespace Lskj.Control.Model
if (model.FieldName.ToLower().EndsWith("operatorname"))
control.EditText = ERPInfo.Instance.UserName;
if (model.FieldName.ToLower().EndsWith("operatedate"))
control.EditText = DateTime.Now.ToString();
control.EditText = SqlHelper.ExecuteScalar("select getdate()") + "";//DateTime.Now.ToString();
}
}
@@ -2516,7 +2528,7 @@ namespace Lskj.Control.Model
}
else if (model.FieldName.EndsWith("operatedate", StringComparison.OrdinalIgnoreCase))
{
controlValue = DateTime.Now.ToString();
controlValue = SqlHelper.ExecuteScalar("select getdate()") + ""; //DateTime.Now.ToString();
}
else
{
@@ -2563,8 +2575,9 @@ namespace Lskj.Control.Model
}
else if (model.FieldName.EndsWith("operatedate", StringComparison.OrdinalIgnoreCase))
{
control.EditText = DateTime.Now.ToString();
control.Model.Text = DateTime.Now.ToString();
string date = SqlHelper.ExecuteScalar("select getdate()") + "";
control.EditText = date; //DateTime.Now.ToString();
control.Model.Text = date; //DateTime.Now.ToString();
}
else
{
@@ -3704,7 +3717,7 @@ namespace Lskj.Control.Model
if (model.FieldName.ToLower().EndsWith("operatorname"))
SetControlValue(model, ERPInfo.Instance.UserName);
if (model.FieldName.ToLower().EndsWith("operatedate"))
SetControlValue(model, DateTime.Now.ToString());
SetControlValue(model, SqlHelper.ExecuteScalar("select getdate()") + "");//DateTime.Now.ToString()
}
// 没有权限的控件设置为****
@@ -4609,6 +4622,28 @@ namespace Lskj.Control.Model
labApiButtonEdit.OnRefreshDataCallBack += new EventHandler(OnLabApiDataCallBack);
baseControl = labApiButtonEdit;
break;
case ControlType.LabBillSource:
LabelBillSourceComboxEdit billSourceComboxEdit = new LabelBillSourceComboxEdit();
billSourceComboxEdit.Button.Visible = true;
billSourceComboxEdit.OpenDocumentSource += new EventHandler(OpenDocumentSource);
billSourceComboxEdit.clickAfterEmpty = model.clickAfterEmpty;
billSourceComboxEdit.ValueMember =model.ValueMember;
billSourceComboxEdit.ValueField = model.ValueMember;
billSourceComboxEdit.TextField = model.TextMember;
billSourceComboxEdit.FormKey = model.FieldName + "_" + model.FormKey;
//billSourceComboxEdit.SetDataSource(dataSource);
billSourceComboxEdit.TextEdit.SourceSQL = model.SourceSql;
billSourceComboxEdit.TextEdit.SpeciesValue = ParentKey;
billSourceComboxEdit.TextEdit.ControlObj = this;
billSourceComboxEdit.TextEdit.KeyDown += new KeyEventHandler(OnTextEditKeyDown);
//billSourceComboxEdit.TextEdit.TextChanged += new EventHandler(GetAutoSearcher_HandleSQL);
//billSourceComboxEdit.TextEdit.TextChanged += new EventHandler(OnTextEditTextChanged);
billSourceComboxEdit.TextEdit.HiddenValueChange += new EventHandler(OnTextEditTextChanged);
if (!isLoadBorder) billSourceComboxEdit.TextEdit.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
baseControl = billSourceComboxEdit;
break;
case ControlType.LabText:
case ControlType.LabTextInt:
default:
@@ -4941,7 +4976,7 @@ namespace Lskj.Control.Model
else
cond = ReplaceHelper.ReplaceSearchControlCond(cond, fieldValue);
// 带复选框控件构造sql语句时,假如没有值,则不构造查询条件
// 带复选框控件构造sql语句时,假如没有值,则不构造查询条件
if ((fieldTypeId == ControlType.LabCheckAutoSeacherText ||
fieldTypeId == ControlType.LabCheckAutoSeacherValue ||
fieldTypeId == ControlType.LabCheckBox ||
@@ -6059,30 +6094,4 @@ namespace Lskj.Control.Model
LabelDateEdit dateEdit = controlObj as LabelDateEdit;
value = dateEdit.TextEdit.EditValue == null ? dateEdit.EditText : dateEdit.TextEdit.DateTime.ToString("yyyy-MM-dd");
}
else if (controlObj is LabelCheckEdit)
{
LabelCheckEdit checkEdit = controlObj as LabelCheckEdit;
value = checkEdit.EditText;
}
else if (controlObj is LabelComboxEdit)
{
LabelComboxEdit autoEdit = controlObj as LabelComboxEdit;
value = autoEdit.EditValue;
}
else if (controlObj is LabelTextEdit)
{
LabelTextEdit textIntEdit = controlObj as LabelTextEdit;
if (textIntEdit != null) value = string.IsNullOrEmpty(textIntEdit.EditText) ? "0" : textIntEdit.EditText;
}
defaultValue = defaultValue.Replace(item, value);
}
}
}
return defaultValue;
}
}
}
else if
@@ -113,6 +113,23 @@ namespace Lskj.Control.Model
DataRowView dataRowView = this._sourceTreeList.GetDataRecordByNode(treeNode) as DataRowView;
dataRows[i] = dataRowView != null ? dataRowView.Row : null;
}
//设置了复选框这个获取所有选中的节点行
if (this._sourceTreeList.OptionsView.ShowCheckBoxes == true && this._sourceTreeList.OptionsSelection.MultiSelect == true && this._sourceTreeList.OptionsSelection.MultiSelectMode == TreeListMultiSelectMode.RowSelect)
{
List<TreeListNode> TreeListNodeList = this._sourceTreeList.GetAllCheckedNodes();
dataRows = new DataRow[TreeListNodeList.Count];
for (int i = 0; i < TreeListNodeList.Count; i++)
{
TreeListNode treeNode = TreeListNodeList[i];
DataRowView dataRowView = this._sourceTreeList.GetDataRecordByNode(treeNode) as DataRowView;
dataRows[i] = dataRowView != null ? dataRowView.Row : null;
}
}
return dataRows;
}
@@ -199,33 +216,4 @@ namespace Lskj.Control.Model
}
/// <summary>
/// <para>说明:源树表格鼠标按下</para>
/// <para>创建人:</para>
/// <para>创建日期:2023-3-20 </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
private void treeList_MouseDown(object sender, MouseEventArgs e)
{
//this._sourceTreeList.AllowDrop = false;
//this._targetGridView.GridControl.AllowDrop = true;
TreeList treelist = sender as TreeList;
downHitInfo = null;
_hitInfo = null;
TreeListHitInfo hitInfo = treelist.CalcHitInfo(new Point(e.X, e.Y));
// if (Control.ModifierKeys != Keys.None) return;
if (e.Button == MouseButtons.Left && hitInfo != null)
{
StaticControl.SourceDragGridView = null;
this._draging = true;
downHitInfo = hitInfo;
}
}
}
}
/// <para>说明:源树表格鼠
+102 -5
View File
@@ -43,6 +43,7 @@ using DevExpress.XtraGrid.Views.Base;
using System.Threading.Tasks;
using DevExpress.XtraRichEdit;
using DevExpress.XtraRichEdit.API.Native;
using DevExpress.XtraGrid.Views.Grid.ViewInfo;
namespace Lskj.Control
{
@@ -196,6 +197,10 @@ namespace Lskj.Control
/// 是否保存成功(Lskj.PubBillSpecial点击保存后,先执行右上方表格保存)
/// </summary>
public bool isSuccessfullySaved;
/// <summary>
/// 扫码添加行
/// </summary>
public DataRow SweepCodeRow=null;
#endregion
#region public set property
@@ -955,6 +960,19 @@ namespace Lskj.Control
gcMain.CustomGroupBandEx = bandedGridControlEx;
this.panelControl1.Controls.Add(bandedGridControlEx);
bandedGridControlEx.BringToFront();
}
else if (SysModel.IsCustomGroup == 2)
{
TreeBandedGridControlEx treeBandedGridControlEx = new TreeBandedGridControlEx();
treeBandedGridControlEx.moduleModel = this.SysModel;
treeBandedGridControlEx.Model = this.Model;
treeBandedGridControlEx.SysModel = this.SysModel;
treeBandedGridControlEx.Dock = DockStyle.Fill;
// 明确设置禁止自动调整列宽
treeBandedGridControlEx.TreeListObj.OptionsView.AutoWidth = false;
gcMain.CustomGroupTreeBandEx = treeBandedGridControlEx;
this.panelControl1.Controls.Add(treeBandedGridControlEx);
treeBandedGridControlEx.BringToFront();
}
// 报表类型创建只读列
@@ -1808,6 +1826,11 @@ namespace Lskj.Control
string fieldValue = model.DefaultValue;
string replaceKey = "{" + DetailKeyField + "}";
string replaceValue = "{" + ParentKeyField + "}";
if (SweepCodeRow!=null&& SweepCodeRow.Table.Columns.Contains(model.FieldName))
{
//如果有扫码数据,优先以扫码数据为准
fieldValue = ReplaceHelper.ReplaceRowParam(SweepCodeRow, "{"+ model.FieldName + "}");
}
if (!string.IsNullOrEmpty(ParentKeyField) && fieldValue.Contains(replaceKey))
{
fieldValue = fieldValue.Replace(replaceKey, replaceValue);
@@ -2205,6 +2228,12 @@ namespace Lskj.Control
unionValue = !string.IsNullOrEmpty(ParentKeyField) && row.Table.Columns.Contains(ParentKeyField) ? row[ParentKeyField] + "" : row.Table.Columns.Contains(DetailKeyField) ? row[DetailKeyField] + "" : string.Empty;
}
}
if (string.IsNullOrWhiteSpace(maintabFocusedRowJson)&&this.SearchObj.SystemModel.maintabFocusedRow!=null)
{
maintabFocusedRowJson = this.SearchObj.SystemModel.maintabFocusedRow.ToJsonObject();
}
// 上下结构父容器为面板
if (ParentControlEx != null)
{
@@ -3619,11 +3648,17 @@ namespace Lskj.Control
this.SetScanEvent();
this.ValidateButtonState(null, false);
if (SystemInfo.Instance.TabAddLine)
if (SystemInfo.Instance.TabAddLine|| this.SysModel.EnterToNextRow)
{
this.gcMain.GridView.KeyDown += OnGcMain_KeyDown;
}
if (!string.IsNullOrWhiteSpace(this.SysModel.SweepCodeSql))
{
this.pl_SweepCode.Visible = true;
this.txt_SweepCode.KeyDown += Txt_SweepCode_KeyDown;
}
}
//按钮翻译
//this.ButtonTranslation();
@@ -3637,6 +3672,41 @@ namespace Lskj.Control
}
}
private void Txt_SweepCode_KeyDown(object sender, KeyEventArgs e)
{
try
{
if (e.KeyCode == Keys.Enter)
{
this.SweepCodeRow = null;
string text = this.txt_SweepCode.Text;
string Sql = ReplaceHelper.ReplaceParamToValue(ReplaceHelper.ReplaceUserInfo(this.SysModel.SweepCodeSql), "{keyvalue}", text);
DataTable dataTable = SqlHelper.ExecuteDataTable(Sql);
if (dataTable == null || dataTable.Rows.Count == 0) return;
foreach (DataRow item in dataTable.Rows)
{
this.SweepCodeRow = item;
this.AddGridViewRecord();
}
this.txt_SweepCode.Text = "";
if (btnSave.Enabled)
{
this.OnSaveClick(null,null);
}
this.txt_SweepCode.Focus();
}
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
finally
{
this.SweepCodeRow = null;
}
}
/// <summary>
@@ -4244,6 +4314,14 @@ namespace Lskj.Control
{
try
{
GridColumn gridColumn = this.gcMain.GridView.FocusedColumn;
if (gridColumn!=null)
{
//双击的是url图片框就不打开修改界面(会打开图片框)
GridColumnModel columnModel = gridColumn.Tag as GridColumnModel;
if (columnModel.FieldType == ControlType.LabPicUrl) return;
}
if (!string.IsNullOrWhiteSpace(this.SysModel.PreSQL))//如果配置预新增界面则弹出
{
GridDetailModel gridDetailModel = this.GridControlObj.Tag as GridDetailModel;
@@ -4404,7 +4482,7 @@ namespace Lskj.Control
protected void OnSaveClick(object sender, EventArgs e)
{
this.isSuccessfullySaved = false;
if (this.GridControlObj.CustomGroupBandEx != null)//保存前若存在虚拟多表头则反写修改
if (this.GridControlObj.CustomGroupBandEx != null|| this.GridControlObj.CustomGroupTreeBandEx != null)//保存前若存在虚拟多表头则反写修改
{
this.GridControlObj.callbackUpdData();
}
@@ -4455,7 +4533,7 @@ namespace Lskj.Control
{
}
IsApi: if (isExec)
IsApi: if (isExec)
{
this.SaveTreeRecord();
if (OnSaveGridCallBack != null)
@@ -4516,7 +4594,7 @@ namespace Lskj.Control
{
LogUtil.WriteError("基础档案明细保存失败", ex);
}
IsApi: if (isExec)
IsApi: if (isExec)
{
this.SaveGridRecord();
if (OnSaveGridCallBack != null)
@@ -5462,7 +5540,7 @@ namespace Lskj.Control
try
{
//点击Tab键时,如果是最后一行,最后一列,就新增一行
if (e.KeyCode == Keys.Tab)
if (e.KeyCode == Keys.Tab && SystemInfo.Instance.TabAddLine)
{
if (this.btnAdd.Enabled)
{
@@ -5482,6 +5560,25 @@ namespace Lskj.Control
}
if (e.KeyCode == Keys.Enter && this.SysModel.EnterToNextRow)
{
// 获取当前行和列
int currentRow = this.gcMain.GridView.FocusedRowHandle;
int currentColumn = this.gcMain.GridView.FocusedColumn.VisibleIndex;
//移动到下一行
int targetRow = currentRow + 1;
if (targetRow < this.gcMain.GridView.RowCount)
{
this.gcMain.GridView.FocusedRowHandle = targetRow;
this.gcMain.GridView.FocusedColumn = this.gcMain.GridView.VisibleColumns[currentColumn];
//gridView.MakeRowVisible(targetRow);
}
else
{
// 取消默认行为(避免在最后一行点击回车时向右移动)
e.SuppressKeyPress = true;
}
}
}
catch (Exception ex)
{
@@ -31,7 +31,7 @@ using Lskj.Model;
using System.Text.RegularExpressions;
using System.Reflection;
using DevExpress.Data.Filtering;
using DevExpress.XtraGrid.Views.Grid.ViewInfo;
namespace Lskj.Control.MultiGridLookUp
{
@@ -694,6 +694,12 @@ namespace Lskj.Control.MultiGridLookUp
/// <param name="e">The <see cref="DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs"/> instance containing the event data.</param>
private void GridView_RowCellClick(object sender, EventArgs e)
{
Point pt = this.gcMain.GridControl.PointToClient(System.Windows.Forms.Control.MousePosition);
GridHitInfo hitInfo = this.gcMain.CalcHitInfo(pt);
// 判断是否点击在列头(如果是,则不执行双击逻辑)
if (hitInfo.InColumnPanel) return;
DataRow rowItem = this.gcMain.GetFocusedDataRow();
bool isSelect = true;
if (rowItem != null)
@@ -807,6 +813,13 @@ namespace Lskj.Control.MultiGridLookUp
private void GridView_DoubleClick(object sender, EventArgs e)
{
if (this.gcDetail.RowCount == 0) return;
Point pt = this.gcDetail.GridControl.PointToClient(System.Windows.Forms.Control.MousePosition);
GridHitInfo hitInfo = this.gcDetail.CalcHitInfo(pt);
// 判断是否点击在列头(如果是,则不执行双击逻辑)
if (hitInfo.InColumnPanel) return;
DataRow rowItem = this.gcDetail.GetFocusedDataRow();
DataRow[] sourceRowItems = this.DataSource.Select(_id + "=" + rowItem[_id] + "");
if (rowItem != null && sourceRowItems != null && sourceRowItems.Length > 0)
+130 -6
View File
@@ -238,8 +238,10 @@ namespace Lskj.Control
// 行:优先 overrideRow,其次主表当前行
DataRow rowItem = overrideRow ?? leftGrid.GetViewFocusedDataRow();
if (leftGrid.CustomGroupBandEx != null && overrideRow == null)
rowItem = leftGrid.CustomGroupBandEx.GetViewFocusedDataRow();
//if (leftGrid.CustomGroupBandEx != null && overrideRow == null)
// rowItem = leftGrid.CustomGroupBandEx.GetViewFocusedDataRow();
if (leftGrid.CustomGroupSelectedRow != null && overrideRow == null)
rowItem = leftGrid.CustomGroupSelectedRow;
/********* 1. 置空逻辑 ***********************************************/
if (isNull || rowItem == null)
@@ -401,6 +403,12 @@ namespace Lskj.Control
ParentGridEx.CustomGroupBandEx.BandedView.ColumnWidthChanged += OnBandedViewColumnWidthChanged;
ParentGridEx.OnBuildGroupedColumnCallBack += OnBandedViewColumnWidthChanged;
}
if (ParentGridEx != null && ParentGridEx.CustomGroupTreeBandEx != null)
{
ParentGridEx.CustomGroupTreeBandEx.TreeListObj.LeftCoordChanged += OnBandedViewLeftCoordChanged; ;
ParentGridEx.CustomGroupTreeBandEx.TreeListObj.ColumnWidthChanged += OnBandedViewColumnWidthChanged;
ParentGridEx.OnBuildGroupedColumnCallBack += OnBandedViewColumnWidthChanged;
}
this._gridDetail = gridDetail;
if (!isAddPages) this.xtc_container.TabPages.Clear();
@@ -497,6 +505,11 @@ namespace Lskj.Control
}
}
}
/// <summary>
/// <para>说明:绑定选项卡</para>
/// <para>创建人:龚宇超</para>
@@ -1354,6 +1367,10 @@ namespace Lskj.Control
{
gridEx.GridControlObj.CustomGroupBandEx.BandedView.LeftCoordChanged += OnBandedViewLeftCoordChanged;
}
if (gridEx.GridControlObj.CustomGroupTreeBandEx != null)
{
gridEx.GridControlObj.CustomGroupTreeBandEx.TreeListObj.LeftCoordChanged += OnBandedViewLeftCoordChanged;
}
//gridEx.Tag = model;
if (model.IsCheck == 1)
{
@@ -2093,7 +2110,20 @@ namespace Lskj.Control
{
gridControl.GridView.DoubleClick += new EventHandler(OnGridCompleted);
}
tabPage.Text = gridControl.CustomGroupBandEx != null ? model.DetailName + "(" + gridControl.CustomGroupBandEx.DataRowCount() + "条)" : model.DetailName + "(" + dataRowCount + ")";
if (gridControl.CustomGroupBandEx != null)
{
tabPage.Text = model.DetailName + "(" + gridControl.CustomGroupBandEx.DataRowCount() + "条)";
}
else if (gridControl.CustomGroupTreeBandEx != null)
{
tabPage.Text = model.DetailName + "(" + gridControl.CustomGroupTreeBandEx.DataRowCount() + "条)";
}
else
{
tabPage.Text = model.DetailName + "(" + dataRowCount + ")";
}
//tabPage.Text = gridControl.CustomGroupBandEx != null ? model.DetailName + "(" + gridControl.CustomGroupBandEx.DataRowCount() + "条)" : model.DetailName + "(" + dataRowCount + ")";
tabPage.Appearance.Header.ForeColor = dataRowCount > 0 ? Color.Red : Color.FromArgb(0, 0, 0);
}
@@ -2495,6 +2525,7 @@ namespace Lskj.Control
private void OnBandedViewLeftCoordChanged(object sender, EventArgs e)
{
BandedGridControlEx childBandView = null;
TreeBandedGridControlEx childTreeBandView = null;
if (this.TabControlObj.SelectedTabPage != null && this.TabControlObj.SelectedTabPage.Controls.Count > 0)
{
foreach (System.Windows.Forms.Control item in this.TabControlObj.SelectedTabPage.Controls)
@@ -2504,8 +2535,14 @@ namespace Lskj.Control
childBandView = moduleGridEx.GridControlObj.CustomGroupBandEx;
break;
}
if (item is ModuleGridEx moduleGridExNew && moduleGridExNew.GridControlObj.CustomGroupTreeBandEx != null)
{
childTreeBandView = moduleGridExNew.GridControlObj.CustomGroupTreeBandEx;
break;
}
}
}
//父表格是 表格 的情况
if (childBandView != null && ParentGridEx != null && ParentGridEx.CustomGroupBandEx != null)
{
if (sender == ParentGridEx.CustomGroupBandEx.BandedView)
@@ -2517,13 +2554,53 @@ namespace Lskj.Control
ParentGridEx.CustomGroupBandEx.BandedView.LeftCoord = childBandView.BandedView.LeftCoord;
}
}
if (childTreeBandView != null && ParentGridEx != null && ParentGridEx.CustomGroupBandEx != null)
{
if (sender == ParentGridEx.CustomGroupBandEx.BandedView)
{
childTreeBandView.TreeListObj.LeftCoord = ParentGridEx.CustomGroupBandEx.BandedView.LeftCoord;
}
else if (sender == childTreeBandView.TreeListObj)
{
ParentGridEx.CustomGroupBandEx.BandedView.LeftCoord = childTreeBandView.TreeListObj.LeftCoord;
}
}
//父表格是 树表格 的情况
if (childBandView != null && ParentGridEx != null && ParentGridEx.CustomGroupTreeBandEx != null)
{
if (sender == ParentGridEx.CustomGroupTreeBandEx.TreeListObj)
{
childBandView.BandedView.LeftCoord = ParentGridEx.CustomGroupTreeBandEx.TreeListObj.LeftCoord;
}
else if (sender == childBandView.BandedView)
{
ParentGridEx.CustomGroupTreeBandEx.TreeListObj.LeftCoord = childBandView.BandedView.LeftCoord;
}
}
if (childTreeBandView != null && ParentGridEx != null && ParentGridEx.CustomGroupTreeBandEx != null)
{
if (sender == ParentGridEx.CustomGroupTreeBandEx.TreeListObj)
{
childTreeBandView.TreeListObj.LeftCoord = ParentGridEx.CustomGroupTreeBandEx.TreeListObj.LeftCoord;
}
else if (sender == childTreeBandView.TreeListObj)
{
ParentGridEx.CustomGroupTreeBandEx.TreeListObj.LeftCoord = childTreeBandView.TreeListObj.LeftCoord;
}
}
}
/// <summary>
/// 宽度改变事件处理,兼容BandedGridView和TreeList
/// </summary>
public void OnBandedViewColumnWidthChanged(object sender, EventArgs e)
{
BandedGridControlEx childBandView = null;
TreeBandedGridControlEx childTreeBandView = null;
if (this.TabControlObj.SelectedTabPage != null && this.TabControlObj.SelectedTabPage.Controls.Count > 0)
{
foreach (System.Windows.Forms.Control item in this.TabControlObj.SelectedTabPage.Controls)
@@ -2533,13 +2610,19 @@ namespace Lskj.Control
childBandView = moduleGridEx.GridControlObj.CustomGroupBandEx;
break;
}
if (item is ModuleGridEx moduleGridExNew && moduleGridExNew.GridControlObj.CustomGroupTreeBandEx != null)
{
childTreeBandView = moduleGridExNew.GridControlObj.CustomGroupTreeBandEx;
break;
}
}
}
if (childBandView != null && ParentGridEx != null && ParentGridEx.CustomGroupBandEx != null)
if ((childBandView != null || childTreeBandView != null) && ParentGridEx != null && (ParentGridEx.CustomGroupBandEx != null || ParentGridEx.CustomGroupTreeBandEx != null))
{
int allWidth = 0;
// 如果sender为原有的BandedView类型
if (sender == ParentGridEx.CustomGroupBandEx.BandedView)
if (ParentGridEx.CustomGroupBandEx != null && sender == ParentGridEx.CustomGroupBandEx.BandedView)
{
foreach (GridBand gridBand in ParentGridEx.CustomGroupBandEx.BandedView.Bands)
{
@@ -2550,6 +2633,47 @@ namespace Lskj.Control
}
}
}
else if (ParentGridEx.CustomGroupTreeBandEx != null && sender == ParentGridEx.CustomGroupTreeBandEx.TreeListObj)
{
//父表格为树表格
foreach (DevExpress.XtraTreeList.Columns.TreeListBand gridBand in ParentGridEx.CustomGroupTreeBandEx.TreeListObj.Bands)
{
if (gridBand.Caption.Equals("基本信息"))
{
allWidth += gridBand.VisibleWidth;
break;
}
}
}
else
{
return; // 非
return; // 非预期sender类型时直接退出
}
if (childBandView != null)
{
// 调整底部bandGcBottom的列宽(始终为BandedGridView类型)
List<BandedGridColumn> bottomColumnList = new List<BandedGridColumn>();
foreach (GridBand gridBand in childBandView.BandedView.Bands)
{
if (gridBand.Caption.Equals("基本信息"))
{
bottomColumnList.AddRange(gridBand.Columns.Cast<BandedGridColumn>());
break;
}
}
// 按计算好的宽度均分调整
if (bottomColumnList.Count > 0)
{
int perWidth = allWidth / bottomColumnList.Count;
foreach (BandedGridColumn bandedGridColumn in bottomColumnList)
{
bandedGridColumn.Width = perWidth;
}
}
}
//选中页签为树表格
if (childTreeBandView != null)
{
// 调整底部bandGcBottom的列宽(始终为BandedGridView类型)
List<DevExpress.XtraTreeList.Columns.TreeListColumn> bottomColumnList = new List<DevExpress.
@@ -337,7 +337,7 @@ namespace Lskj.Control
{
if (table == null) return;
this.CustomColumKey = customColumKey;
//设置列头自动高度
this.gcMain.OptionsView.ColumnHeaderAutoHeight = DefaultBoolean.True;
@@ -1189,7 +1189,11 @@ namespace Lskj.Control
btnEdit.DisplayMember = model.TextMember;
btnEdit.SeparatorChar = ',';
btnEdit.ValueMember = model.FieldType == ControlType.LabSelectReturnIdNew ? model.ValueMember : model.TextMember;
btnEdit.DataSource = MainImpl.GetDataTableResult(model.SqlSource);
if (model.ModuleFrameDisplayText)
{
DataTable dataTable = MainImpl.GetDataTableResult(modelLookUp.SysModel.MenuSql);
btnEdit.DataSource = dataTable;
}
btnEdit.Buttons[0].Visible = false; // 不能移除,移除后事件不起作用.
btnEdit.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] { new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Ellipsis) });
@@ -1703,7 +1707,7 @@ namespace Lskj.Control
/// </summary>
/// <param name="gridColumn">The grid column.</param>
/// <param name="model">The model.</param>
private void SetColumnFormat(TreeListColumn gridColumn, GridColumnModel model)
protected virtual void SetColumnFormat(TreeListColumn gridColumn, GridColumnModel model)
{
if (gridColumn == null || model == null) return;
+146 -9
View File
@@ -77,7 +77,10 @@ namespace Lskj.Control
/// 日期类型控件名称
/// </summary>
private List<string> DateColumnNames = new List<string>();
/// <summary>
/// 聚合多表头控件
/// </summary>
//public TreeBandedGridControlEx CustomGroupTreeBandEx;
/// <summary>
/// 下拉框数据源绑定完成后执行
@@ -95,6 +98,7 @@ namespace Lskj.Control
this.gcMain.NodesReloaded += OnNodesReloaded;
this.gcMain.ColumnFilterChanged += TreeList1_ColumnFilterChanged;
this.gcMain.CustomDrawFooterCell += GcMain_CustomDrawFooterCell;
if (LicenseManager.UsageMode != LicenseUsageMode.Designtime)
{
@@ -111,6 +115,46 @@ namespace Lskj.Control
//this.gcMain.OptionsFind.AlwaysVisible = true;
}
private void GcMain_CustomDrawFooterCell(object sender, CustomDrawFooterCellEventArgs e)
{
TreeListColumn listColumn = e.Column;
GridColumnModel columnModel = listColumn.Tag as GridColumnModel;
if (!string.IsNullOrWhiteSpace(columnModel.SumCond))
{
decimal sum = CalculateConditionalSum(columnModel);
e.Text = sum + "";
}
}
/// <summary>
/// 计算符合条件的合计值
/// </summary>
private decimal CalculateConditionalSum(GridColumnModel columnModel)
{
decimal total = 0;
List<TreeListNode> listNodes = this.GetAllNodesOnTheInterface();
// 遍历所有节点(包含子节点)
foreach (TreeListNode node in listNodes)
{
// 跳过空节点
if (node == null) continue;
DataRowView dataRowView = this.gcMain.GetDataRecordByNode(node) as DataRowView;
DataRow gridRow = dataRowView != null ? dataRowView.Row : null;
if ("true".Equals(EvalHelper.Eval(ReplaceHelper.ReplaceEvalCond(ReplaceHelper.ReplaceRowParam(gridRow, columnModel.SumCond))) + "", StringComparison.OrdinalIgnoreCase))
{
if (decimal.TryParse(node.GetDisplayText(columnModel.FieldName), out decimal value))
{
total += value;
}
}
}
return total;
}
/// <summary>
/// 修改筛选框筛选日期类型列的条件(日期=xxx 替换wei 日期>=xxx && 日期<xxx+1
@@ -391,7 +435,7 @@ namespace Lskj.Control
if (table == null) return;
Dictionary<object, Hashtable> dataCaches = Model != null ? Model.DataCaches : null;
this.CustomColumKey = customColumKey;
for (int i = 0; i < table.Rows.Count; i++)
{
DataRow item = table.Rows[i];
@@ -1258,11 +1302,11 @@ namespace Lskj.Control
itemBsChartShowClick.Visible = ERPInfo.Instance.UserName == "管理员" && Model != null;
itemFixLeft.Tag = itemFixLeftAll.Tag = itemUnFix.Tag = hitInfo.Column;
itemSaveColumn.Tag = itemResetColumn.Tag = itemExportColumn.Tag = itemPrintColumn.Tag = itemSortColumn.Tag= itemBsChartShowClick.Tag = hitInfo.Column;
itemSaveColumn.Tag = itemResetColumn.Tag = itemExportColumn.Tag = itemPrintColumn.Tag = itemSortColumn.Tag = itemBsChartShowClick.Tag = hitInfo.Column;
columnMenu.Items.AddRange(new DXMenuItem[] { itemFixLeft, itemFixLeftAll, itemUnFix });
if (!string.IsNullOrEmpty(CustomColumKey)) columnMenu.Items.AddRange(new DXMenuItem[] { itemSaveColumn, itemResetColumn });
columnMenu.Items.AddRange(new DXMenuItem[] { itemExportColumn, itemPrintColumn, itemSortColumn,itemBsChartShowClick });
columnMenu.Items.AddRange(new DXMenuItem[] { itemExportColumn, itemPrintColumn, itemSortColumn, itemBsChartShowClick });
}
}
catch (Exception ex)
@@ -1810,7 +1854,7 @@ namespace Lskj.Control
/// </summary>
/// <param name="gridColumn">The grid column.</param>
/// <param name="model">The model.</param>
private void SetColumnFormat(TreeListColumn gridColumn, GridColumnModel model)
public virtual void SetColumnFormat(TreeListColumn gridColumn, GridColumnModel model)
{
if (gridColumn == null || model == null) return;
@@ -1862,7 +1906,7 @@ namespace Lskj.Control
{
gcMain.OptionsView.ShowSummaryFooter = true;
gridColumn.AllNodesSummary = true;
gridColumn.SummaryFooter = DevExpress.XtraTreeList.SummaryItemType.Sum;
gridColumn.SummaryFooter = !string.IsNullOrEmpty(model.SumCond) ? DevExpress.XtraTreeList.SummaryItemType.Custom : DevExpress.XtraTreeList.SummaryItemType.Sum;
gridColumn.SummaryFooterStrFormat = "{0:" + model.DataFormat + "}";
}
}
@@ -2273,7 +2317,7 @@ namespace Lskj.Control
}
//设置了复选框这个获取所有选中的节点行
if (this.gcMain.OptionsView.ShowCheckBoxes == true&& this.gcMain.OptionsSelection.MultiSelect == true && this.gcMain.OptionsSelection.MultiSelectMode == TreeListMultiSelectMode.RowSelect)
if (this.gcMain.OptionsView.ShowCheckBoxes == true && this.gcMain.OptionsSelection.MultiSelect == true && this.gcMain.OptionsSelection.MultiSelectMode == TreeListMultiSelectMode.RowSelect)
{
List<TreeListNode> TreeListNodeList = this.TreeListObj.GetAllCheckedNodes();
dataRows = new DataRow[TreeListNodeList.Count];
@@ -2283,7 +2327,7 @@ namespace Lskj.Control
DataRowView dataRowView = this.gcMain.GetDataRecordByNode(treeNode) as DataRowView;
dataRows[i] = dataRowView != null ? dataRowView.Row : null;
}
}
return dataRows;
@@ -3414,15 +3458,18 @@ namespace Lskj.Control
{
//判断选中行是否满足条件,满足就删除
DataRow[] dataRows = this.GetViewFocusedDataRows();
DataTable dataSource = this.GetGridViewDataSource();
List<DataRow> deleteRows = new List<DataRow>();//可以删除的行
List<string> DeleteFailedRows = new List<string>();//不满足条件,删除失败的行的行号
//选中行判断条件
//选中行判断条件
foreach (DataRow rowItem in dataRows)
{
string deleteCond2 = ReplaceHelper.ReplaceRowParam(rowItem, deleteCond);
if (ReplaceHelper.EvalCond(deleteCond2))
{
deleteRows.Add(rowItem);
// 递归添加所有子节点
this.AddAllChildRows(rowItem, dataSource, deleteRows);
}
else
{
@@ -4283,6 +4330,96 @@ namespace Lskj.Control
/// <summary>
/// 获取界面上所有的节点(获取ctrl+f后的数据,包含折叠的子节点)
/// </summary>
/// <returns></returns>
public List<TreeListNode> GetAllNodesOnTheInterface()
{
List<TreeListNode> orderedList = new List<TreeListNode>();
// 遍历所有的TreeList节点
foreach (TreeListNode node in TreeListObj.Nodes)
{
// 递归地添加节点
if (node.Visible)
{
AddNodeAndChildrenInterface(node, orderedList);
}
}
return orderedList;
}
/// <summary>
/// 记录当前节点和对应子节点
/// </summary>
/// <param name="node"></param>
/// <param name="list"></param>
public void AddNodeAndChildrenInterface(TreeListNode node, List<TreeListNode> list)
{
// 添加当前节点的数据
list.Add(node);
// 递归添加子节点
foreach (TreeListNode childNode in node.Nodes)
{
if (childNode.Visible)
{
AddNodeAndChildrenInterface(childNode, list);
}
}
}
/// <summary>
/// 递归获取所有子节点并添加到删除集合中(删除选中节点数据和对应的子节点数据)
/// </summary>
/// <param name="parentRow">选中节点的数据</param>
/// <param name="table">表格数据</param>
/// <param name="deleteRows">删除数据集合</param>
private void AddAllChildRows(DataRow parentRow, DataTable table, List<DataRow> deleteRows)
{
if (parentRow == null || table == null) return;
// 获取TreeList的父子关系字段
string keyField = this.TreeListObj.KeyFieldName;
string parentField = this.TreeListObj.ParentFieldName;
// 获取当前父节点的键值
object parentKeyValue = parentRow[keyField];
if (parentKeyValue == DBNull.Value) return;
// 查找所有直接子节点
DataRow[] childRows = table.Select($"{parentField} = '{parentKeyValue}'");
foreach (DataRow childRow in childRows)
{
if (!deleteRows.Contains(childRow))
{
deleteRows.Add(childRow);
// 递归查找子节点的子节点
AddAllChildRows(childRow, table, deleteRows);
}
}
}
/// <summary>
/// <para>说明:获取Grid列,判断是否是必填列</para>
/// <para>创建人:王一帆</para>