SVN-Revision: r431
This commit is contained in:
cyf
2025-04-02 08:39:39 +00:00
parent d69b0a7c1e
commit ad17816f5c
10 changed files with 230 additions and 67 deletions
@@ -785,6 +785,10 @@ namespace Lskj.Control
}
}
}
// 隐藏分组面板
this.bandedGridView.OptionsView.ShowGroupPanel = false;
// 展开所有分组
this.bandedGridView.OptionsBehavior.AutoExpandAllGroups = true;//展开所有分组
}
foreach (BandedGridColumn col in this.bandedGridView.Columns)
{
+1 -1
View File
@@ -85,7 +85,7 @@ namespace Lskj.Control
this.lblFP.Text = "0";
}
this.gcMain.GridControl.DataSource = null;
this.SearchObj.SearchLastGrid();
this.SearchObj.SearchGrid();//为啥取上一次?
if (this.FpOtherRows != null && this.FpOtherRows.Length > 0)
{
DataTable table = this.gcMain.GridControl.DataSource as DataTable;
+33 -38
View File
@@ -109,7 +109,7 @@ namespace Lskj.Control
BandedGridView gridView = bandGridControlEx.GridView as BandedGridView;
BandedGridControlEx NewBandedGridControlEx = new BandedGridControlEx();
BandedGridView gridView2 = NewBandedGridControlEx.GridView as BandedGridView;
gridView2.Columns.Clear();//默认有2个列
List<string> boolList = new List<string>();
List<string> datetimeList = new List<string>();
List<string> visibleList = new List<string>();
@@ -364,7 +364,6 @@ namespace Lskj.Control
{
gridView2.OptionsView.ShowFooter = true;
firstColumn.Summary.AddRange(new DevExpress.XtraGrid.GridSummaryItem[] { new DevExpress.XtraGrid.GridColumnSummaryItem(DevExpress.Data.SummaryItemType.Count, firstColumn.FieldName.ToString(), "合计: {0:#,###}行") });
if (SystemInfo.Instance.GroupSpecialMode)
{
//gridView2.GroupSummary.Add(new DevExpress.XtraGrid.GridGroupSummaryItem(DevExpress.Data.SummaryItemType.Count, firstColumn.FieldName.ToString(), firstColumn, "合计: {0:#,###}行"));
@@ -454,7 +453,8 @@ namespace Lskj.Control
hasBoolean = true;
}
GridColumnModel model = col.Tag as GridColumnModel;
if (model != null && (model.FieldType == ControlType.LabMultiSelectValue || model.FieldType == ControlType.LabTreeLookValue || model.FieldType == ControlType.LabMultiSelectValueParam))
if (model != null && (model.FieldType == ControlType.LabMultiSelectValue || model.FieldType == ControlType.LabTreeLookValue || model.FieldType == ControlType.LabMultiSelectValueParam)|| model.FieldType == ControlType.LabSelectReturnId)
{
StoreValueList.Add(col.FieldName);
}
@@ -515,6 +515,10 @@ namespace Lskj.Control
{
newCol.DataType = typeof(DateTime);
}
if (StoreValueList.Contains(col.ColumnName))
{
newCol.DataType = typeof(String);
}
dtTable.Columns.Add(newCol);
}
}
@@ -610,9 +614,9 @@ namespace Lskj.Control
if (gridColumn.Tag is GridColumnModel)
{
GridColumnModel model = gridColumn.Tag as GridColumnModel;
//|| model.FieldType == ControlType.LabSelectReturnId
if ((model.FieldType == ControlType.LabMultiSelectValue ||
model.FieldType == ControlType.LabMultiSelectValueParam) && row[col.ColumnName].ToString().Contains(","))
model.FieldType == ControlType.LabMultiSelectValueParam ) && row[col.ColumnName].ToString().Contains(","))
{
string[] cellText = row[col.ColumnName].ToString().Split(',');
fieldValue = string.Empty;
@@ -958,6 +962,29 @@ namespace Lskj.Control
ValueGridColumnTable.Add(model, translationDict);
}
}
else if (model.FieldType == ControlType.LabSelectReturnId)
{
string sqlValue = model.SqlSource;
if (model.IsRadio&& !string.IsNullOrWhiteSpace(model.addModuleld))
{
//单选模式数据源为模块sql
DataRow modelRow = Business.Impl.MainImpl.GetSystemdllTab(model.addModuleld);
sqlValue = modelRow["SQL"]+"";
}
DataTable dataTable = Business.Impl.BaseImpl.GetDataTableResult(sqlValue);
Dictionary<string, string> translationDict = new Dictionary<string, string>();
foreach (DataRow item in dataTable.Rows)
{
string key = item[model.ValueMember].ToString();
string value = item[model.TextMember].ToString();
if (!translationDict.ContainsKey(key))
{
translationDict.Add(key, value);
}
}
ValueGridColumnTable.Add(model, translationDict);
}
}
}
@@ -979,36 +1006,4 @@ namespace Lskj.Control
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0.0.3</para>
/// </summary>
/// <param name="control">The control.</param>
/// <returns>DataTable.</returns>
public string GetValueByImportText(GridColumnModel model, string text, bool isBillImport = false)
{
string value = text;
Dictionary<string, string> translationDict = null;
if (ValueGridColumnTable.TryGetValue(model, out translationDict))
{
if (translationDict != null && translationDict.Count > 0)
{
if (translationDict.TryGetValue(text, out string translatedValue))
{
value = translatedValue;
}
else
{
value = text;
}
}
else
{
value = "";
}
}
return value;
}
}
}
/// <para>版
+15 -2
View File
@@ -275,10 +275,21 @@ namespace Lskj.Control
model.FieldType == ControlType.LabAutoCompleteValueParam ||
model.FieldType == ControlType.LabMultiSelectValue ||
model.FieldType == ControlType.LabMultiSelectValueParam ||
model.FieldType == ControlType.LabAutoGridValue
model.FieldType == ControlType.LabAutoGridValue||
model.FieldType == ControlType.LabSelectReturnId
)
{
string sqlValue = model.SqlSource;
if (model.FieldType == ControlType.LabSelectReturnId)
{
if (model.IsRadio && !string.IsNullOrWhiteSpace(model.addModuleld))
{
//单选模式数据源为模块sql
DataRow modelRow = Business.Impl.MainImpl.GetSystemdllTab(model.addModuleld);
sqlValue = modelRow["SQL"] + "";
}
}
if (sqlValue.Contains(" #"))
{
//sqlValue = sqlValue.Replace("#", "");
@@ -457,7 +468,9 @@ namespace Lskj.Control
model.FieldType == ControlType.LabAutoCompleteValueParam ||
model.FieldType == ControlType.LabMultiSelectValue ||
model.FieldType == ControlType.LabMultiSelectValueParam ||
model.FieldType == ControlType.LabAutoGridValue))
model.FieldType == ControlType.LabAutoGridValue||
model.FieldType == ControlType.LabSelectReturnId
))
{
string fieldValue = GetValueByImportText(dr, gc.FieldName, dr[gc.FieldName] + "");
if (!string.IsNullOrEmpty(fieldValue))
+61 -7
View File
@@ -361,6 +361,10 @@ namespace Lskj.Control
/// </summary>
public bool DisableFieldSources;
/// <summary>
/// 表格重新赋值数据源时,更新的列
/// </summary>
public string UpdateColumns;
/// <summary>
/// 聚合多表头控件
/// </summary>
public BandedGridControlEx CustomGroupBandEx;
@@ -1168,12 +1172,13 @@ namespace Lskj.Control
this.mTimer.Dispose();
}
}
private void SetColumnsSource(bool isResfush = false)
private void SetColumnsSource(bool UpdateColumnRefresh = false)
{
foreach (GridColumnModel item in mControlList)
{
if (this.DisableFieldSources && item.isVislble) continue;
if (ControlType.IsNotLoadData(item.FieldType)) continue;
if (UpdateColumnRefresh && !string.IsNullOrWhiteSpace(UpdateColumns) &&!UpdateColumns.Split(',').Contains(item.FieldName)) continue;
if (!string.IsNullOrWhiteSpace(item.SqlSource))
{
DataTable dataTable = new DataTable();
@@ -1669,8 +1674,9 @@ namespace Lskj.Control
}
}
}
this.ClearImage();
this.GridControl.DataSource = table;
this.AdjustIndicatorWidthSmart();
//modifyThePosition.Clear();
this.SetAutoColumns();
if (selectRowHandler)
@@ -1752,8 +1758,10 @@ namespace Lskj.Control
dt.Columns.Add("RightMenuBtnEdit");
}
this.GridControl.DataSource = dt;
this.ClearImage();
this.GridControl.DataSource = dt;
this.AdjustIndicatorWidthSmart();
//modifyThePosition.Clear();
// 动态列处理
this.SetAutoColumns();
@@ -2200,6 +2208,10 @@ namespace Lskj.Control
}
}
}
// 隐藏分组面板
this.gridView.OptionsView.ShowGroupPanel = false;
// 展开所有分组
this.gridView.OptionsBehavior.AutoExpandAllGroups = true;//展开所有分组
}
}
foreach (GridColumn col in this.gridView.Columns)
@@ -4493,6 +4505,29 @@ namespace Lskj.Control
}
}
/// <summary>
/// 设置序号列宽度
/// </summary>
public void AdjustIndicatorWidthSmart()
{
try
{
int rowCount = this.gridView.RowCount;
if (rowCount == 0) return;
// 计算数字部分宽度
int numberWidth = (int)(rowCount.ToString().Length * 7.5) + 16;
// 设置最终宽度(取较大值,并在40-80px之间)
this.gridView.IndicatorWidth = Math.Max(40, Math.Min(80, numberWidth));
}
catch (Exception ex)
{
}
}
/// <summary>
/// <para>说明:拖拽列</para>
/// <para>创建人:龚宇超</para>
@@ -7573,12 +7608,12 @@ namespace Lskj.Control
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
public void RefreshDataSource()
/// <param name="UpdateColumnRefresh">判断是否只刷新UpdateColumn中配置的列的数据源</param>
public void RefreshDataSource(bool UpdateColumnRefresh=false)
{
this.mLoading = false;
SetColumnsSource(true);
mControlSourceDic.Clear();
SetColumnsSource(UpdateColumnRefresh);
}
/// <summary>
@@ -7885,6 +7920,25 @@ namespace Lskj.Control
}
}
/// <summary>
/// 清空url图片列缓存
/// </summary>
private void ClearImage()
{
GridColumnCollection gridColumns = this.GridView.Columns;
foreach (GridColumn col in gridColumns)
{
GridColumnModel model = col.Tag as GridColumnModel;
if (model!=null&&model.FieldType == ControlType.LabPicUrl)
{
model.LabPicUrlImages = new Hashtable();
}
}
}
#region
/// <summary>
/// <para>说明:自身表格的拖拽类</para>
+26 -2
View File
@@ -204,7 +204,7 @@ namespace Lskj.Control.Model
/// </summary>
public const int LabComboxValueParam = 35;
/// <summary>
/// 下拉列表框(带参数) 保存Value值,显示Text值
/// 下拉列表框(带参数) 保存Text值,显示Text值
/// </summary>
public const int LabComboxTextParam = 36;
/// <summary>
@@ -514,4 +514,28 @@ namespace Lskj.Control.Model
}
/// <summary>
/// 不需要根据数据源sql获取数据源的控件
/// </summary>
/// <param name="fieldType"></param>
/// <returns></returns>
public static bool IsNotLoadData(int fieldType)
{
return fieldType == LabText ||
fieldType == LabDate ||
fieldType == LabDateTime ||
fieldType == LabDateTimeShort ||
fieldType == LabTime ||
fieldType == LabShortTime ||
fieldType == LabTextInt ||
fieldType == LabPassWordValue ||
fieldType == LabRemark ||
fieldType == LabMemoEdit ||
fieldType == LabWWW ||
fieldType == LabQQ ||
fieldType == LabPhone ||
fieldType == LabSelectReturnIdNew ||
fieldType == LabSelectReturnTextNew ||
fieldType == LabApiBtuton;
}
}
}
+43 -2
View File
@@ -3064,6 +3064,11 @@ namespace Lskj.Control.Model
{
if (this._mainGridEx != null)
{
if (!string.IsNullOrWhiteSpace(this._mainGridEx.UpdateColumns))
{
this._mainGridEx.RefreshDataSource(true);
}
if (string.IsNullOrWhiteSpace(this._mainGridEx.LastSearchSql))
{
this.SearchGrid();
@@ -3072,12 +3077,15 @@ namespace Lskj.Control.Model
{
// 上一次查询
int oldRowHandle = GetFocusedRowHandle();
//int oldTopRowHandle = GetTopRowHandle();
if (_mainGridEx.IsHandleCreated)
{
{
// 窗口加载完成搜索,采用异步加载
_mainGridEx.Invoke((EventHandler)delegate
{
//this._mainGridEx.GridView.BeginUpdate();
this.GridRowCount = this._mainGridEx.SetGridViewDataSource(MainImpl.GetAdapterResult(this._mainGridEx.LastSearchSql));
//this._mainGridEx.GridView.EndUpdate();
});
}
else
@@ -3092,6 +3100,7 @@ namespace Lskj.Control.Model
}
SetFocusedRowHandle(oldRowHandle);
//SetTopRowHandle(oldTopRowHandle);
}
}
@@ -3104,7 +3113,6 @@ namespace Lskj.Control.Model
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
/// <summary>
/// <para>说明:查询数据</para>
@@ -4461,6 +4469,23 @@ namespace Lskj.Control.Model
}
return oldRowHandle;
}
/// <summary>
/// 获取上一次顶部可见行
/// </summary>
/// <returns></returns>
private int GetTopRowHandle()
{
int oldRowHandle = 0;
if (_gridControl != null)
{
if (_gridControl.MainView is GridView)
{
oldRowHandle = (_gridControl.MainView as GridView).GetVisibleRowHandle((_gridControl.MainView as GridView).TopRowIndex);
}
}
return oldRowHandle;
}
/// <summary>
/// <para>说明:设置选中行</para>
/// <para>创建人:龚宇超</para>
@@ -4489,6 +4514,22 @@ namespace Lskj.Control.Model
}
}
}
/// <summary>
/// 设置顶部行位置(执行上一次sql刷新后,移动滚动条和上一次保持一致)
/// </summary>
/// <param name="rowHandle"></param>
private void SetTopRowHandle(int rowHandle)
{
if (_gridControl != null)
{
if (_gridControl.MainView is GridView)
{
if (rowHandle > 0) (_gridControl.MainView as GridView).TopRowIndex = rowHandle;
}
}
}
/// <summary>
/// <para>说明:设置查询条件</para>
/// <para>创建人:龚宇超</para>
+19 -1
View File
@@ -137,6 +137,8 @@ namespace Lskj.Control
/// 上一次选中的树表格节点
/// </summary>
public TreeListNode treeListNode;
public ModuleEx()
@@ -1524,4 +1526,20 @@ namespace Lskj.Control
using (BinaryReader r = new BinaryReader(fs))
{
byte[] buffer = r.ReadBytes((int)fs.Length);
int Result = BaseModuleImpl.SaveImage(this.SysModel.MenuTable, _labPicName, this.SysModel.ParmaryKey, this._currentRow[this.SysModel.ParmaryK
int Result = BaseModuleImpl.SaveImage(this.SysModel.MenuTable, _labPicName, this.SysModel.ParmaryKey, this._currentRow[this.SysModel.ParmaryKey] + "", buffer);
MessageUtil.Show(Result > 0 ? ResourceKeys.SaveSuccess : ResourceKeys.SaveFault);
}
}
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
/// <summary>
/// 判断是否是selete开头(可以处理sql前方有注释和空格的情况)
+16 -3
View File
@@ -1571,6 +1571,12 @@ namespace Lskj.Control
MessageUtil.Show("请查询后添加!");
return;
}
if (!SysModel.CanEdit)
{
MessageUtil.Show("表格不可编辑,增加失败");
return;
}
if (!(dt.Columns.Contains(ERPInfo.Instance.isAddRows)))
{
dt.Columns.Add(ERPInfo.Instance.isAddRows, typeof(String));
@@ -3266,6 +3272,7 @@ namespace Lskj.Control
this.SysModel = sysModel;
this.Model = model;
this.gcMain.DisableFieldSources = this.SysModel.DisableFieldSources;
this.gcMain.UpdateColumns = this.SysModel.UpdateColumns;
//if (this.Model is DynamicModuleDetailModelInfo)
//{
// DynamicModuleDetailModelInfo dynamic = this.Model as DynamicModuleDetailModelInfo;
@@ -4076,10 +4083,7 @@ namespace Lskj.Control
{
if (this.GridControlObj.CustomGroupBandEx != null)//保存前若存在虚拟多表头则反写修改
{
this.GridControlObj.callbackUpdData();
}
int dataNumber = (this.GridControlObj.GridView.GetGridViewFilteredAndSortedDataToDataTable() as DataTable).Rows.Count;
@@ -4743,6 +4747,15 @@ namespace Lskj.Control
{
this.SearchObj.SearchGrid(sourceTable);
}
if (this.SysModel.RecordRowUponExit)
{
string Handle = IniHelper.Read(string.Format("RecordRowUponExit_{0}", this.Model.ModuleCode));
if (!string.IsNullOrWhiteSpace(Handle) && int.Parse(Handle) > 0)
{
this.gcMain.GridView.SelectRowHandler(int.Parse(Handle));
}
}
}
}
}
+12 -11
View File
@@ -522,7 +522,7 @@ namespace Lskj.Control
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
private void SetUpdateData()
private void SetUpdateData(bool FirstLoading= true)
{
//外面表格搜索条件赋值
if (!string.IsNullOrWhiteSpace(SearchObject) && SavaState)
@@ -535,13 +535,7 @@ namespace Lskj.Control
}
}
if (!string.IsNullOrWhiteSpace(this.ControlSql))
{
DataRow rowItem = BaseImpl.GetDataRowResult(this.ControlSql);
this.ControlObj.CurrentData = rowItem;
this.ControlObj.SetAllControlValue(rowItem);
this.ControlObj.SyncLocalModel();
}
if (!string.IsNullOrWhiteSpace(this.PrimaryValue))
{
// 修改默认赋值
@@ -564,7 +558,14 @@ namespace Lskj.Control
{
this.ControlObj.SetControlValue(UnionKey, UnionValue);
}
//不如不是初始化时进入,就不加载配置数据源sql(添加或者修改后,执行赋值sql会导致保存的数据被覆盖)
if (!string.IsNullOrWhiteSpace(this.ControlSql)&& FirstLoading)
{
DataRow rowItem = BaseImpl.GetDataRowResult(this.ControlSql);
this.ControlObj.CurrentData = rowItem;
this.ControlObj.SetAllControlValue(rowItem);
this.ControlObj.SyncLocalModel();
}
this.ControlObj.CanExecControl = true;
}
/// <summary>
@@ -1244,7 +1245,7 @@ namespace Lskj.Control
}
else
{
SetUpdateData();//重新加载数据
SetUpdateData(false);//重新加载数据
}
return true;
}
@@ -1274,7 +1275,7 @@ namespace Lskj.Control
}
else
{
SetUpdateData();//重新加载数据
SetUpdateData(false);//重新加载数据
btnApply.Enabled = btnCopyNew.Enabled = btnAttach.Enabled = true;
}
return true;