SVN r1104

SVN-Revision: r1104
This commit is contained in:
cyf
2026-01-30 07:48:24 +00:00
parent 5ccfe15fee
commit 47cf35aa28
45 changed files with 4096 additions and 449 deletions
+106 -55
View File
@@ -53,6 +53,7 @@ using System.Threading.Tasks;
using System.Collections;
using Newtonsoft.Json;
using System.Net;
using System.Data.Common;
namespace Lskj.Control
{
@@ -239,7 +240,7 @@ namespace Lskj.Control
/// Gets or sets the adapter object.
/// </summary>
/// <value>The adapter object.</value>
public SqlDataAdapter AdapterObj { get; set; }
public DbDataAdapter AdapterObj { get; set; }
/// <summary>
/// Gets the grid view.
/// </summary>
@@ -452,7 +453,14 @@ namespace Lskj.Control
/// 搜索框 手动添加行
/// </summary>
public Dictionary<string, List<DataRow>> ManuallyAddData = new Dictionary<string, List<DataRow>>();
/// <summary>
/// 修改字段
/// </summary>
public string ModifyFields = string.Empty;
/// <summary>
/// 必填字段
/// </summary>
public string RequiredFields = string.Empty;
public GridControlEx()
{
@@ -509,14 +517,11 @@ namespace Lskj.Control
this.gridView.ShowingEditor += GridView_ShowingEditor;
this.gridView.MouseDown += GridView_MouseDown;
//绑定滚轮横向滚动
this.gridView.MouseWheel += GridView_MouseWheel;
}
/// <summary>
/// 保存前反写多表头数据源
/// </summary>
@@ -1783,10 +1788,10 @@ namespace Lskj.Control
public void GetDataCaches(Dictionary<object, Hashtable> cachesDic, string customColumKey = "")
{
Task<DynamicModel> dynamicModelTask = cachesDic.GetTask<DynamicModel>(this, "DynamicModel");
Task<bool> existsSettingTableTask = cachesDic.AddTask(this, "HasExistsSettingTable", new Task<bool>(() =>
{
return BaseImpl.HasExistsTable(ResourceKeys.SettingTableName);
}));
//Task<bool> existsSettingTableTask = cachesDic.AddTask(this, "HasExistsSettingTable", new Task<bool>(() =>
//{
// return BaseImpl.HasExistsTable(ResourceKeys.SettingTableName);
//}));
Task<DataTable> setBaseGridRightMenusTask = cachesDic.AddTask(this, "RightMenuBtn", new Task<DataTable>(() =>
{
DataTable dataTable = null;
@@ -1929,7 +1934,7 @@ namespace Lskj.Control
/// <param name="adapter">The adapter.</param>
/// <param name="selectRowHandler">if set to <c>true</c> [select row handler].</param>
/// <returns>System.Int32.</returns>
public virtual int SetGridViewDataSource(SqlDataAdapter adapter, bool selectRowHandler = true)
public virtual int SetGridViewDataSource(DbDataAdapter adapter, bool selectRowHandler = true)
{
if (adapter == null) return 0;
@@ -1992,7 +1997,8 @@ namespace Lskj.Control
this.gridView.Columns.Clear();
}
}
SqlCommandBuilder cb = new SqlCommandBuilder(this.AdapterObj);
DbCommandBuilder cb = SqlHelper.dbFactory.CreateCommandBuilder();
cb.DataAdapter = this.AdapterObj;
//this.GridControl.DataSource = dataSet.Tables[0];
//解决大小写问题后在赋值
@@ -2447,11 +2453,12 @@ namespace Lskj.Control
protected virtual void SetCustomColumns(DataTable customTable, bool isInit = true)
{
Dictionary<object, Hashtable> dataCaches = Model != null ? Model.DataCaches : null;
if (!dataCaches.GetValue(this, "HasExistsSettingTable", out bool hasExistsSettingTable))
{
hasExistsSettingTable = BaseImpl.HasExistsTable(ResourceKeys.SettingTableName);
}
if (string.IsNullOrEmpty(this.CustomColumKey) || !hasExistsSettingTable)
//if (!dataCaches.GetValue(this, "HasExistsSettingTable", out bool hasExistsSettingTable))
//{
// hasExistsSettingTable = BaseImpl.HasExistsTable(ResourceKeys.SettingTableName);
//}
if (string.IsNullOrEmpty(this.CustomColumKey) || customTable.Columns.Count == 0)//!hasExistsSettingTable
{
return;
}
@@ -2607,6 +2614,7 @@ namespace Lskj.Control
{
gridView.GroupSummary.AddRange(new GridSummaryItem[] { new GridGroupSummaryItem(SummaryItemType.Sum, col.FieldName, null, "{0:" + dataFormat + "}") });
}
}
}
if (colSplit.Length > 3)
@@ -3919,6 +3927,7 @@ namespace Lskj.Control
RepositoryItemLookUpEdit comboxEdit = new RepositoryItemLookUpEdit();
if (model.FontSize > 0) comboxEdit.Appearance.Font = new Font("微软雅黑", model.FontSize);
comboxEdit.SearchMode = SearchMode.AutoFilter;
//comboxEdit.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//允许编辑
comboxEdit.ShowHeader = false;
comboxEdit.ImmediatePopup = false;
comboxEdit.NullText = "";
@@ -4145,14 +4154,16 @@ namespace Lskj.Control
gridColumn.ColumnEdit = searchEdit;
searchEdit.View.Tag = searchEdit;
if (model.SearchBoxAddition) searchEdit.ProcessNewValue += SearchEdit_ProcessNewValue;
if ((ControlType.LabAutoCompleteText == model.FieldType || ControlType.LabAutoGridText == model.FieldType || ControlType.LabAutoGridTextParam == model.FieldType))
{
searchEdit.EditValueChanging += gridLookUpEdit1_EditValueChangingAdd;
}
else
{
searchEdit.EditValueChanging += gridLookUpEdit1_EditValueChanging;
}
searchEdit.EditValueChanging += gridLookUpEdit1_EditValueChanging;
//if ((ControlType.LabAutoCompleteText == model.FieldType || ControlType.LabAutoGridText == model.FieldType || ControlType.LabAutoGridTextParam == model.FieldType))
//{
// searchEdit.EditValueChanging += gridLookUpEdit1_EditValueChangingAdd;
//}
//else
//{
// searchEdit.EditValueChanging += gridLookUpEdit1_EditValueChanging;
//}
searchEdit.View.CustomDrawFilterPanel += OnCustomDrawFilterPanel;
searchEdit.View.Click += new EventHandler(View_Click);
this.mControlList.Add(model);
@@ -4242,7 +4253,7 @@ namespace Lskj.Control
}
}
}
}
catch (Exception ex)
{
@@ -4251,7 +4262,7 @@ namespace Lskj.Control
}
finally
{
}
}
@@ -4331,16 +4342,16 @@ namespace Lskj.Control
{
FilterLookup(sender, e.NewValue + "");
}));
//if (string.IsNullOrWhiteSpace(edit.AutoSearchText) && e.NewValue == "")
//{
// DataRow newRow = dt.NewRow();
// if (dt.Rows.Cast<DataRow>().FirstOrDefault(x => x == newRow) == null)
// {
// dt.Rows.Add(newRow.ItemArray);
// }
//}
if (string.IsNullOrWhiteSpace(edit.AutoSearchText) && e.NewValue == "")
{
DataRow newRow = dt.NewRow();
if (dt.Rows.Cast<DataRow>().FirstOrDefault(x => x == newRow) == null)
{
dt.Rows.Add(newRow.ItemArray);
}
}
}
catch (Exception ex)
{
@@ -4946,6 +4957,7 @@ namespace Lskj.Control
gridColumn.OptionsColumn.ReadOnly = true;
gridColumn.ColumnEdit = btnEdit;
gridColumn.FilterMode = ColumnFilterMode.DisplayText;//筛选行匹配文本值(模块返回ID不像下拉框,不进入弹出框,只能看到文本值。所以把筛选改成按文本筛选)
this.mControlList.Add(model);
}
@@ -6531,7 +6543,7 @@ namespace Lskj.Control
string[] dataReleColNames = selectColumnModel.AutoPadDataReleColName.TrimEnd(',').Split(',');
if (dataReleColNames.Contains(e.Column.FieldName))
{
DataRow[] selectRows = dataTable.Select().Where(n => n[selectColumnModel.FieldName].Equals(value)).ToArray();
DataRow[] selectRows = dataTable.Select().Where(n => (n[selectColumnModel.FieldName]+"").Equals(value)).ToArray();
foreach (DataRow selectRow in selectRows)
{
int dataSourceIndex = dataTable.Rows.IndexOf(selectRow);
@@ -8886,32 +8898,36 @@ namespace Lskj.Control
/// <summary>
/// 重新设置表格的字段属性
/// </summary>
/// <param name="ModifyFields">修改字段</param>
/// <param name="RequiredFields">必填字段</param>
public virtual void SetFieldStatus(string ModifyFields, string RequiredFields, DataTable AuthorityTable = null)
/// <param name="modifyFields">修改字段</param>
/// <param name="requiredFields">必填字段</param>
public virtual void SetFieldStatus(string modifyFields, string requiredFields, DataTable AuthorityTable = null)
{
this.ModifyFields = modifyFields;
this.RequiredFields = requiredFields;
GridColumnCollection gc = this.GridView.Columns;
bool Modify = false;
bool Required = false;
Color RequiredForceColor = string.IsNullOrEmpty(SystemInfo.Instance.ControlRequiredColor) ? Color.Blue : ColorTranslator.FromHtml(SystemInfo.Instance.ControlRequiredColor);
//修改字段
if (!string.IsNullOrEmpty(ModifyFields) && ModifyFields != "-1")
if (!string.IsNullOrEmpty(modifyFields) && modifyFields != "-1")
{
ModifyFields = ModifyFields + ",";
modifyFields = modifyFields + ",";
Modify = true;
modifyFields = modifyFields.ToLower();
}
if (!string.IsNullOrEmpty(RequiredFields) && RequiredFields != "-1")
if (!string.IsNullOrEmpty(requiredFields) && requiredFields != "-1")
{
Required = true;
RequiredFields = RequiredFields + ",";
requiredFields = requiredFields + ",";
requiredFields = requiredFields.ToLower();
}
this.gridView.BeginUpdate();
foreach (GridColumn item in gc)
{
GridColumnModel model = item.Tag as GridColumnModel;
//修改
if (Modify && ModifyFields.IndexOf(item.FieldName + ",", StringComparison.OrdinalIgnoreCase) != -1)
if (Modify && modifyFields.Split(',').Contains(item.FieldName.ToLower()))
{
if (!string.IsNullOrWhiteSpace(model.PrivilegeOper) && AuthorityTable != null)
{
@@ -8931,7 +8947,7 @@ namespace Lskj.Control
}
item.OptionsColumn.AllowEdit = ModifyFields.IndexOf(item.FieldName + ",", StringComparison.OrdinalIgnoreCase) != -1;
item.OptionsColumn.AllowEdit = modifyFields.IndexOf(item.FieldName + ",", StringComparison.OrdinalIgnoreCase) != -1;
item.OptionsColumn.ReadOnly = !item.OptionsColumn.AllowEdit;
if (!item.OptionsColumn.AllowEdit)
@@ -8944,16 +8960,12 @@ namespace Lskj.Control
item.AppearanceHeader.Options.UseForeColor = true;
item.AppearanceHeader.ForeColor = ColorTranslator.FromHtml("#00000");
}
//if (model.CanNull)
//{
// item.AppearanceHeader.Options.UseForeColor = true;
// item.AppearanceHeader.ForeColor = RequiredForceColor;
//}
if (model.FieldType == ControlType.LabMemoEdit) item.OptionsColumn.AllowEdit = true;
}
//必填
if (Required && RequiredFields.IndexOf(item.FieldName + ",", StringComparison.OrdinalIgnoreCase) != -1)
if (Required && requiredFields.Split(',').Contains(item.FieldName.ToLower()))
{
item.AppearanceHeader.Options.UseForeColor = true;
item.AppearanceHeader.ForeColor = RequiredForceColor;
@@ -9932,4 +9944,43 @@ namespace Lskj.Control
return Rectangle.Empty;
// 转换为网格控件内的坐标(关键修正)
Point cellLocation = view.GridControl.PointToClient(
viewInfo.GridControl.PointToScreen(cellInfo.Bounds.Location)
);
return new Rectangle(
cellLocation.X,
cellLocation.Y,
cellInfo.Bounds.Width,
cellInfo.Bounds.Height
);
}
catch
{
return Rectangle.Empty;
}
}
// 计算按钮起始X坐标(支持左右对齐)
private int GetButtonStartX(int cellWidth, int totalButtonsWidth, bool isLeftAligned)
{
if (isLeftAligned)
{
// 靠左对齐:从单元格左侧开始
return 0;
}
else
{
// 靠右对齐:从右侧减去总宽度
return cellWidth - totalButtonsWidth;
}
}
/// <summary>
/// 滚轮滚动事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void GridView_MouseWhee