SVN r1138

SVN-Revision: r1138
This commit is contained in:
cyf
2026-03-19 09:47:10 +00:00
parent 2352b79793
commit 814b2a8559
9 changed files with 400 additions and 76 deletions
+84 -24
View File
@@ -372,9 +372,13 @@ namespace Lskj.Control
/// </summary>
private List<GridColumn> ColumnsList = new List<GridColumn>();
/// <summary>
///选中的行在数据源中的索引
///复选模式,表格主键
/// </summary>
private List<int> SelectedDataSource = new List<int>();
public string MultiplePrimary = string.Empty;
/// <summary>
///选中的行在数据源中的主键值
/// </summary>
private List<string> SelectedDataSource = new List<string>();
/// <summary>
/// 禁显列不加载数据源
/// </summary>
@@ -963,9 +967,11 @@ namespace Lskj.Control
Task<DataTable> sourceTask = new Task<DataTable>(() =>
{
DataTable dataTable = new DataTable();
using (SqlConnection sqlConnection = new SqlConnection(SqlHelper._connection.ConnectionString))
using (DbConnection sqlConnection = SqlHelper.dbFactory.CreateConnection())
{
using (SqlCommand cmd = new SqlCommand())
sqlConnection.ConnectionString = SqlHelper._connection.ConnectionString;
using (DbCommand cmd = SqlHelper.dbFactory.CreateCommand())
{
try
{
@@ -979,11 +985,13 @@ namespace Lskj.Control
cmd.CommandTimeout = 0;
cmd.CommandText = sqlValue;
cmd.CommandType = CommandType.Text;
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
DbDataAdapter adapter = SqlHelper.dbFactory.CreateDataAdapter();
adapter.SelectCommand = cmd;
adapter.Fill(dataTable);
}
catch (Exception)
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
finally
{
@@ -1166,6 +1174,7 @@ namespace Lskj.Control
protected virtual void SetColumnFormat(GridColumn gridColumn, GridColumnModel model)
{
if (gridColumn == null || model == null) return;
// 格式化数字
if (!string.IsNullOrEmpty(model.DataFormat))
{
@@ -1304,9 +1313,10 @@ namespace Lskj.Control
}
if (!string.IsNullOrEmpty(model.FontName) || model.FontSize != 0)
{
gridColumn.AppearanceCell.Options.UseFont = true;
//gridColumn.AppearanceCell.Options.UseFont = true;//设置后数值和英文会加粗,2026-3-17 注释
//gridColumn.AppearanceCell.Font = new System.Drawing.Font(model.FontName, gridColumn.AppearanceCell.Font.Size);
gridColumn.AppearanceCell.Font = new System.Drawing.Font(string.IsNullOrEmpty(model.FontName) ? gridColumn.AppearanceCell.Font.Name : model.FontName, model.FontSize == 0 ? gridColumn.AppearanceCell.Font.Size : model.FontSize);
}
this.SetColumnFormat(gridColumn, model);
@@ -1323,7 +1333,11 @@ namespace Lskj.Control
{
PromptMessage.Add(model.FieldName, model.PromptText);
}
if (!string.IsNullOrWhiteSpace(model.ColumnAnnotation))
{
gridColumn.ToolTip = model.ColumnAnnotation;
}
}
//创建右键菜单列
@@ -1604,6 +1618,10 @@ namespace Lskj.Control
{
PromptMessage.Add(model.FieldName, model.PromptText);
}
if (!string.IsNullOrWhiteSpace(model.ColumnAnnotation))
{
gridColumn.ToolTip = model.ColumnAnnotation;
}
}
DataTable customTable = this.gridView.GetCustomColumnByDatabase(this.CustomColumKey);
this.SetCustomColumns(customTable);
@@ -1664,6 +1682,11 @@ namespace Lskj.Control
}
//gridView.OptionsView.AllowCellMerge = gridView.OptionsView.AllowCellMerge;
if (!string.IsNullOrWhiteSpace(model.TitleColor))
{
gridColumn.AppearanceHeader.Options.UseForeColor = true;
gridColumn.AppearanceHeader.ForeColor = ColorTranslator.FromHtml(model.TitleColor);
}
if (EnabledChangeColor)
{
@@ -1691,7 +1714,7 @@ namespace Lskj.Control
//修改字体控制
if (!string.IsNullOrEmpty(model.FontName) || model.FontSize != 0)
{
gridColumn.AppearanceCell.Options.UseFont = true;
//gridColumn.AppearanceCell.Options.UseFont = true;//设置后数值和英文会加粗,2026-3-17 注释
//gridColumn.AppearanceCell.Font = new System.Drawing.Font(model.FontName, gridColumn.AppearanceCell.Font.Size);
gridColumn.AppearanceCell.Font = new System.Drawing.Font(string.IsNullOrEmpty(model.FontName) ? gridColumn.AppearanceCell.Font.Name : model.FontName, model.FontSize == 0 ? gridColumn.AppearanceCell.Font.Size : model.FontSize);
@@ -1735,6 +1758,10 @@ namespace Lskj.Control
{
PromptMessage.Add(model.FieldName, model.PromptText);
}
if (!string.IsNullOrWhiteSpace(model.ColumnAnnotation))
{
gridColumn.ToolTip = model.ColumnAnnotation;
}
}
if (Model != null)
@@ -6242,7 +6269,7 @@ namespace Lskj.Control
/// <exception cref="System.NotImplementedException"></exception>
protected void OnGridViewRowCellStyle(object sender, RowCellStyleEventArgs e)
{
if (e.RowHandle >= 0 && this.GridRowColorsTable != null && this.GridRowColorsTable.Rows.Count > 0 && !string.IsNullOrEmpty(e.CellValue + ""))
if (e.RowHandle >= 0 && this.GridRowColorsTable != null && this.GridRowColorsTable.Rows.Count > 0 && (!string.IsNullOrEmpty(e.CellValue + "")|| SystemInfo.Instance.isBlankCellColor))
{
// 渲染界面数据量过多界面刷新会很慢
//DataTable table = this.gridControl.DataSourceTable();
@@ -6256,14 +6283,21 @@ namespace Lskj.Control
if (!string.IsNullOrWhiteSpace(cond) && ReplaceHelper.EvalCond(cond))
{
GridRowColorModel model = new GridRowColorModel(item);
if (!string.IsNullOrWhiteSpace(model.BackColor))
// 判断单元格是否被选中
bool isCellSelected = gridView.IsCellSelected(e.RowHandle, e.Column);
if (!isCellSelected)
{
e.Appearance.BackColor = ColorTranslator.FromHtml(model.BackColor);
}
if (!string.IsNullOrWhiteSpace(model.ForceColor))
{
e.Appearance.ForeColor = ColorTranslator.FromHtml(model.ForceColor);
if (!string.IsNullOrWhiteSpace(model.BackColor))
{
e.Appearance.BackColor = ColorTranslator.FromHtml(model.BackColor);
}
if (!string.IsNullOrWhiteSpace(model.ForceColor))
{
e.Appearance.ForeColor = ColorTranslator.FromHtml(model.ForceColor);
}
}
FontStyle fontStyle = new FontStyle();
if (model.IsBold) fontStyle = fontStyle | FontStyle.Bold;
@@ -6405,6 +6439,29 @@ namespace Lskj.Control
{
e.Appearance.ForeColor = ColorTranslator.FromHtml(SystemInfo.Instance.SelectRowForeColor);
}
//// 如果当前单元格被选中 → 画虚线
//if (gridView.IsCellSelected(e.RowHandle, e.Column))
//{
// // 先绘制默认内容(文字、背景、行颜色不变)
// e.DefaultDraw();
// // 创建虚线笔
// using (Pen pen = new Pen(Color.Black, 1))
// {
// pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash; // 虚线样式
// // 在单元格内部画一圈虚线边框
// Rectangle rect = e.Bounds;
// rect.Width -= 1;
// rect.Height -= 1;
// e.Graphics.DrawRectangle(pen, rect);
// }
// // 标记已处理,防止被覆盖
// e.Handled = true;
//}
}
//选中行不改变颜色条件设置的颜色
@@ -6695,15 +6752,17 @@ namespace Lskj.Control
this.SelectedRows = this.gridView.GetSelectedRows();
if (gridView.OptionsSelection.MultiSelect == true && gridView.OptionsSelection.MultiSelectMode == GridMultiSelectMode.CheckBoxRowSelect && gridView.OptionsSelection.EnableAppearanceFocusedCell == false) this.gridView.UpdateSummary();
if (SystemInfo.Instance.DisplayCheckboxSelection && gridView.OptionsSelection.MultiSelect == true && gridView.OptionsSelection.MultiSelectMode == GridMultiSelectMode.CheckBoxRowSelect && gridView.OptionsSelection.EnableAppearanceFocusedCell == false)
if (SystemInfo.Instance.DisplayCheckboxSelection &&!string.IsNullOrWhiteSpace(this.MultiplePrimary) && gridView.OptionsSelection.MultiSelect == true && gridView.OptionsSelection.MultiSelectMode == GridMultiSelectMode.CheckBoxRowSelect && gridView.OptionsSelection.EnableAppearanceFocusedCell == false)
{
SelectedDataSource.Clear();
// 遍历勾选的行索引,并获取它们在数据源中的索引
foreach (int rowHandle in SelectedRows)
DataRow[] dataRows = this.GetViewFocusedDataRows();
if (dataRows.Length > 0 && dataRows[0].Table.Columns.Contains(this.MultiplePrimary))
{
// 获取行在数据源中的索引
int dataSourceRowIndex = gridView.GetDataSourceRowIndex(rowHandle);
SelectedDataSource.Add(dataSourceRowIndex);
// 遍历勾选的行索引,并获取它们在数据源中的索引
foreach (DataRow row in GetViewFocusedDataRows())
{
SelectedDataSource.Add(row[this.MultiplePrimary] + "");
}
}
}
}
@@ -9033,9 +9092,10 @@ namespace Lskj.Control
/// <param name="e"></param>
private void GridView_CustomRowFilter(object sender, RowFilterEventArgs e)
{
if (SystemInfo.Instance.DisplayCheckboxSelection && gridView.OptionsSelection.MultiSelect == true && gridView.OptionsSelection.MultiSelectMode == GridMultiSelectMode.CheckBoxRowSelect && gridView.OptionsSelection.EnableAppearanceFocusedCell == false)
if (SystemInfo.Instance.DisplayCheckboxSelection && !string.IsNullOrWhiteSpace(this.MultiplePrimary) && gridView.OptionsSelection.MultiSelect == true && gridView.OptionsSelection.MultiSelectMode == GridMultiSelectMode.CheckBoxRowSelect && gridView.OptionsSelection.EnableAppearanceFocusedCell == false)
{
if (SelectedDataSource.Contains(e.ListSourceRow))
DataRow dataRow = this.gridView.GetDataRow(e.ListSourceRow);
if (dataRow!=null&& dataRow.Table.Columns.Contains(this.MultiplePrimary) && SelectedDataSource.Contains(dataRow[this.MultiplePrimary]+""))
{
e.Handled = true;
e.Visible = true;