提交当前本机最新程序
This commit is contained in:
@@ -2913,7 +2913,7 @@ namespace Lskj.Control
|
||||
int[] rows = this.bandedGridView.GetSelectedRows();
|
||||
|
||||
// 只判断单元格数目,允许同行多单元格选中
|
||||
this.pl_buttom.Visible = cells.Length > 1;
|
||||
this.pl_buttom.Visible = cells.Length > 1 && rows.Length > 1;
|
||||
|
||||
if (this.pl_buttom.Visible)
|
||||
{
|
||||
|
||||
@@ -192,6 +192,30 @@ namespace Lskj.Control
|
||||
/// </summary>
|
||||
public Dictionary<GridColumnModel, Task<DataTable>> mControlSourceDic = new Dictionary<GridColumnModel, Task<DataTable>>();
|
||||
/// <summary>
|
||||
/// 字典搜索框数据源缓存,只用于弹出下拉框时临时绑定,避免表格滚动时控件持有大数据源。
|
||||
/// </summary>
|
||||
private Dictionary<string, DataTable> mSpecialReturnSourceDic = new Dictionary<string, DataTable>();
|
||||
/// <summary>
|
||||
/// 字典搜索框后台加载任务缓存。
|
||||
/// </summary>
|
||||
private Dictionary<string, Task<DataTable>> mSpecialReturnSourceTaskDic = new Dictionary<string, Task<DataTable>>();
|
||||
/// <summary>
|
||||
/// 字典搜索框显示文本缓存,表格显示时按单元格值快速转换为显示文本。
|
||||
/// </summary>
|
||||
private Dictionary<string, Dictionary<string, string>> mSpecialReturnDisplayDic = new Dictionary<string, Dictionary<string, string>>();
|
||||
/// <summary>
|
||||
/// 字典搜索框编辑器缓存,进入编辑状态时再替换为搜索框控件。
|
||||
/// </summary>
|
||||
private Dictionary<string, RepositoryItemGridLookUpEdit> mSpecialReturnEditDic = new Dictionary<string, RepositoryItemGridLookUpEdit>();
|
||||
/// <summary>
|
||||
/// 字典搜索框显示文本事件是否已绑定。
|
||||
/// </summary>
|
||||
private bool mSpecialReturnDisplayEventAttached = false;
|
||||
/// <summary>
|
||||
/// 字典搜索框编辑器替换事件是否已绑定。
|
||||
/// </summary>
|
||||
private bool mSpecialReturnEditEventAttached = false;
|
||||
/// <summary>
|
||||
/// 计算值
|
||||
/// </summary>
|
||||
public decimal customSum;
|
||||
@@ -995,7 +1019,7 @@ namespace Lskj.Control
|
||||
return;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(model.SqlSource) && !ControlType.IsNotLoadData(model.FieldType))
|
||||
if (!string.IsNullOrEmpty(model.SqlSource) && !ControlType.IsNotLoadData(model.FieldType) && !IsSpecialReturnBox(model.FieldType))
|
||||
{
|
||||
Task<DataTable> sourceTask = new Task<DataTable>(() =>
|
||||
{
|
||||
@@ -1191,6 +1215,12 @@ namespace Lskj.Control
|
||||
case ControlType.LabModuleAddRowsText:
|
||||
InitModuleReturnLine(column, model);
|
||||
break;
|
||||
case ControlType.DictionarySearchBoxToId:
|
||||
case ControlType.DictionarySearchBoxToText:
|
||||
case ControlType.DictionarySearchBoxToIdParam:
|
||||
case ControlType.DictionarySearchBoxToTextParam:
|
||||
InitSpecialReturn(column, model);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -1201,6 +1231,567 @@ namespace Lskj.Control
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 初始化字典搜索框。表格显示阶段使用文本编辑器,进入编辑状态时再切换为搜索框。
|
||||
/// </summary>
|
||||
private void InitSpecialReturn(GridColumn column, GridColumnModel model)
|
||||
{
|
||||
RepositoryItemGridLookUpEdit searchEdit = CreateSpecialReturnSearchEdit(model);
|
||||
RepositoryItemTextEdit textEdit = new RepositoryItemTextEdit();
|
||||
|
||||
gridControl.RepositoryItems.Add(textEdit);
|
||||
gridControl.RepositoryItems.Add(searchEdit);
|
||||
column.ColumnEdit = textEdit;
|
||||
|
||||
mSpecialReturnEditDic[model.FieldName] = searchEdit;
|
||||
this.mControlList.Add(model);
|
||||
StartSpecialReturnSourceTask(model);
|
||||
|
||||
if (!mSpecialReturnDisplayEventAttached)
|
||||
{
|
||||
this.gridView.CustomColumnDisplayText += GridView_CustomColumnDisplayText_SpecialReturn;
|
||||
mSpecialReturnDisplayEventAttached = true;
|
||||
}
|
||||
if (!mSpecialReturnEditEventAttached)
|
||||
{
|
||||
this.gridView.CustomRowCellEditForEditing += GridView_CustomRowCellEditForEditing_SpecialReturn;
|
||||
mSpecialReturnEditEventAttached = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断是否为字典搜索框类型。
|
||||
/// </summary>
|
||||
private static bool IsSpecialReturnBox(int fieldType)
|
||||
{
|
||||
return fieldType == ControlType.DictionarySearchBoxToId
|
||||
|| fieldType == ControlType.DictionarySearchBoxToText
|
||||
|| fieldType == ControlType.DictionarySearchBoxToIdParam
|
||||
|| fieldType == ControlType.DictionarySearchBoxToTextParam;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断字典搜索框是否保存显示文本。
|
||||
/// </summary>
|
||||
private static bool IsSpecialReturnTextBox(int fieldType)
|
||||
{
|
||||
return fieldType == ControlType.DictionarySearchBoxToText
|
||||
|| fieldType == ControlType.DictionarySearchBoxToTextParam;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断字典搜索框是否为带参数类型。
|
||||
/// </summary>
|
||||
private static bool IsSpecialReturnParamBox(int fieldType)
|
||||
{
|
||||
return fieldType == ControlType.DictionarySearchBoxToIdParam
|
||||
|| fieldType == ControlType.DictionarySearchBoxToTextParam;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建字典搜索框编辑器。
|
||||
/// </summary>
|
||||
private RepositoryItemGridLookUpEdit CreateSpecialReturnSearchEdit(GridColumnModel model)
|
||||
{
|
||||
RepositoryItemGridLookUpEdit searchEdit = new RepositoryItemGridLookUpEdit();
|
||||
if (model.FontSize > 0) searchEdit.View.Appearance.Row.Font = new Font("微软雅黑", model.FontSize);
|
||||
searchEdit.View.OptionsView.ShowIndicator = false;
|
||||
searchEdit.View.OptionsView.ColumnAutoWidth = false;
|
||||
searchEdit.PopupSizeable = true;
|
||||
searchEdit.PopupResizeMode = ResizeMode.Default;
|
||||
searchEdit.AllowFocused = true;
|
||||
searchEdit.ImmediatePopup = true;
|
||||
searchEdit.ShowFooter = false;
|
||||
searchEdit.NullText = "";
|
||||
searchEdit.TextEditStyle = TextEditStyles.Standard;
|
||||
searchEdit.PopupBorderStyle = PopupBorderStyles.Flat;
|
||||
searchEdit.AllowNullInput = DefaultBoolean.False;
|
||||
searchEdit.ShowPopupShadow = true;
|
||||
searchEdit.DisplayMember = model.TextMember;
|
||||
searchEdit.ValueMember = IsSpecialReturnTextBox(model.FieldType) ? model.TextMember : model.ValueMember;
|
||||
searchEdit.Tag = model;
|
||||
searchEdit.View.Tag = searchEdit;
|
||||
searchEdit.View.Appearance.HeaderPanel.TextOptions.HAlignment = HorzAlignment.Center;
|
||||
searchEdit.View.PopupMenuShowing += new PopupMenuShowingEventHandler(OnAutoSearchEditPopupMenuShowing);
|
||||
searchEdit.KeyDown += OnsearchEditKeyDown;
|
||||
searchEdit.QueryPopUp += SpecialReturnEdit_QueryPopUp;
|
||||
searchEdit.CloseUp += SpecialReturnEdit_CloseUp;
|
||||
searchEdit.Closed += SpecialReturnEdit_Closed;
|
||||
searchEdit.CustomDisplayText += SpecialReturnEdit_CustomDisplayText;
|
||||
searchEdit.EditValueChanging += gridLookUpEdit1_EditValueChanging;
|
||||
searchEdit.View.CustomDrawFilterPanel += OnCustomDrawFilterPanel;
|
||||
|
||||
GridColumn valueColumn = new GridColumn();
|
||||
valueColumn.Name = valueColumn.FieldName = model.ValueMember;
|
||||
valueColumn.Caption = "编码";
|
||||
valueColumn.Visible = model.ValueMember.Substring(0, 1) != "_";
|
||||
|
||||
GridColumn textColumn = new GridColumn();
|
||||
textColumn.Name = textColumn.FieldName = model.TextMember;
|
||||
textColumn.Caption = "名称";
|
||||
textColumn.Visible = model.TextMember.Substring(0, 1) != "_";
|
||||
|
||||
searchEdit.View.Columns.AddRange(new GridColumn[] { valueColumn, textColumn });
|
||||
return searchEdit;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 字典搜索框显示文本事件,表格滚动显示时只查字典,不绑定下拉框大数据源。
|
||||
/// </summary>
|
||||
private void GridView_CustomColumnDisplayText_SpecialReturn(object sender, CustomColumnDisplayTextEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
GridColumnModel model = e.Column.Tag as GridColumnModel;
|
||||
if (model == null || !IsSpecialReturnBox(model.FieldType)) return;
|
||||
|
||||
string value = e.Value + "";
|
||||
if (string.IsNullOrWhiteSpace(value)) return;
|
||||
|
||||
string displayText = string.Empty;
|
||||
bool sourceReady = EnsureSpecialReturnSourceReady(model);
|
||||
if (TryGetSpecialReturnDisplayText(model, value, out displayText))
|
||||
{
|
||||
e.DisplayText = displayText;
|
||||
}
|
||||
else if (sourceReady)
|
||||
{
|
||||
e.DisplayText = string.Empty;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 字典搜索框编辑器替换事件,只有进入编辑状态时才使用搜索框控件。
|
||||
/// </summary>
|
||||
private void GridView_CustomRowCellEditForEditing_SpecialReturn(object sender, CustomRowCellEditEventArgs e)
|
||||
{
|
||||
GridColumnModel model = e.Column.Tag as GridColumnModel;
|
||||
if (model == null || !IsSpecialReturnBox(model.FieldType)) return;
|
||||
if (mSpecialReturnEditDic.ContainsKey(model.FieldName))
|
||||
{
|
||||
RepositoryItemGridLookUpEdit searchEdit = mSpecialReturnEditDic[model.FieldName];
|
||||
BindSpecialReturnCurrentValue(searchEdit, model, this.gridView.GetRowCellValue(e.RowHandle, e.Column));
|
||||
e.RepositoryItem = searchEdit;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 字典搜索框编辑态显示文本事件,避免编辑器未绑定数据源时当前值显示为空。
|
||||
/// </summary>
|
||||
private void SpecialReturnEdit_CustomDisplayText(object sender, CustomDisplayTextEventArgs e)
|
||||
{
|
||||
RepositoryItemGridLookUpEdit edit = sender as RepositoryItemGridLookUpEdit;
|
||||
if (edit == null || e.Value == null) return;
|
||||
|
||||
GridColumnModel model = edit.Tag as GridColumnModel;
|
||||
if (model == null || !IsSpecialReturnBox(model.FieldType)) return;
|
||||
|
||||
string value = e.Value + "";
|
||||
if (string.IsNullOrWhiteSpace(value)) return;
|
||||
|
||||
string displayText = string.Empty;
|
||||
bool sourceReady = EnsureSpecialReturnSourceReady(model);
|
||||
if (TryGetSpecialReturnDisplayText(model, value, out displayText))
|
||||
{
|
||||
e.DisplayText = displayText;
|
||||
}
|
||||
else if (sourceReady)
|
||||
{
|
||||
e.DisplayText = string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 字典搜索框弹出事件。普通类型使用缓存数据源,带参数类型按当前行条件重新查询。
|
||||
/// </summary>
|
||||
private void SpecialReturnEdit_QueryPopUp(object sender, CancelEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
GridLookUpEdit edit = sender as GridLookUpEdit;
|
||||
if (edit == null) return;
|
||||
GridColumnModel model = edit.Properties.Tag as GridColumnModel;
|
||||
if (model == null) return;
|
||||
|
||||
CurrentOperColumnKey = Model.ModuleCode + "_" + model.FieldName;
|
||||
CurrentOperModel = model;
|
||||
|
||||
DataTable table = IsSpecialReturnParamBox(model.FieldType) ? GetSpecialReturnParamSourceTable(model) : GetSpecialReturnSourceTable(model);
|
||||
if (IsSpecialReturnParamBox(model.FieldType))
|
||||
{
|
||||
AddSpecialReturnManualData(model, table);
|
||||
}
|
||||
edit.Properties.DataSource = table;
|
||||
AddSpecialReturnViewColumns(edit.Properties, table, model);
|
||||
SetSpecialReturnPopupWidth(edit.Properties, table, model);
|
||||
CacheSpecialReturnDisplayValues(model, table);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
string Message = ErrorMessage.PromptErrorMessage(ex, Model.ModuleCode);
|
||||
MessageUtil.Show(Message, ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 字典搜索框关闭选择事件,把本次选择结果补入显示字典。
|
||||
/// </summary>
|
||||
private void SpecialReturnEdit_CloseUp(object sender, CloseUpEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
GridLookUpEdit edit = sender as GridLookUpEdit;
|
||||
if (edit == null) return;
|
||||
GridColumnModel model = edit.Properties.Tag as GridColumnModel;
|
||||
if (model == null || e.Value == null) return;
|
||||
|
||||
DataTable table = edit.Properties.DataSource as DataTable;
|
||||
if (table == null) return;
|
||||
|
||||
string value = e.Value + "";
|
||||
string valueMember = IsSpecialReturnTextBox(model.FieldType) ? model.TextMember : model.ValueMember;
|
||||
if (!table.Columns.Contains(valueMember) || !table.Columns.Contains(model.TextMember)) return;
|
||||
|
||||
DataRow row = table.Rows.Cast<DataRow>().FirstOrDefault(item => (item[valueMember] + "").Equals(value));
|
||||
if (row != null)
|
||||
{
|
||||
GetSpecialReturnDisplayDic(model)[value] = row[model.TextMember] + "";
|
||||
}
|
||||
|
||||
edit.EditValue = e.Value;
|
||||
GridColumn column = this.gridView.Columns[model.FieldName];
|
||||
if (column != null)
|
||||
{
|
||||
this.gridView.SetFocusedRowCellValue(column, e.Value);
|
||||
}
|
||||
this.gridView.PostEditor();
|
||||
this.gridView.UpdateCurrentRow();
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 字典搜索框关闭后清空临时数据源,避免编辑器长期持有大量数据。
|
||||
/// </summary>
|
||||
private void SpecialReturnEdit_Closed(object sender, ClosedEventArgs e)
|
||||
{
|
||||
GridLookUpEdit edit = sender as GridLookUpEdit;
|
||||
if (edit != null)
|
||||
{
|
||||
edit.Properties.DataSource = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取字典搜索框初始化数据源,用于普通弹出和显示字典缓存。
|
||||
/// </summary>
|
||||
private DataTable GetSpecialReturnSourceTable(GridColumnModel model)
|
||||
{
|
||||
string key = model.FieldName;
|
||||
if (mSpecialReturnSourceDic.ContainsKey(key))
|
||||
{
|
||||
return mSpecialReturnSourceDic[key];
|
||||
}
|
||||
if (mSpecialReturnSourceTaskDic.ContainsKey(key))
|
||||
{
|
||||
DataTable taskTable = mSpecialReturnSourceTaskDic[key].Result;
|
||||
mSpecialReturnSourceDic[key] = taskTable;
|
||||
CacheSpecialReturnDisplayValues(model, taskTable);
|
||||
return taskTable;
|
||||
}
|
||||
|
||||
DataTable table = BaseImpl.GetDataTableResult(model.SqlSource);
|
||||
mSpecialReturnSourceDic[key] = table;
|
||||
CacheSpecialReturnDisplayValues(model, table);
|
||||
return table;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取带参数字典搜索框弹出数据源,逻辑与原带参数搜索框弹出查询保持一致。
|
||||
/// </summary>
|
||||
private DataTable GetSpecialReturnParamSourceTable(GridColumnModel model)
|
||||
{
|
||||
DataRow[] dataRows = this.GetViewFocusedDataRows();
|
||||
DataRow rowItem = dataRows.Count() > 0 ? dataRows[0] : this.gridView.GetFocusedDataRow();
|
||||
if (rowItem == null && this.ParentControl == null)
|
||||
{
|
||||
return GetSpecialReturnSourceTable(model);
|
||||
}
|
||||
|
||||
string sqlValue = model.SqlSource;
|
||||
if (this.ParentControl != null)
|
||||
sqlValue = this.ParentControl.ReplaceParentControlValue(sqlValue);
|
||||
|
||||
sqlValue = sqlValue.Replace("#", "");
|
||||
|
||||
if (rowItem != null)
|
||||
{
|
||||
sqlValue = ReplaceHelper.ReplaceRowParam(rowItem, sqlValue);
|
||||
}
|
||||
|
||||
return MainImpl.GetDataTableResult(sqlValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 带参数字典搜索框保存文本时,把手动新增的数据追加到本次弹出数据源。
|
||||
/// </summary>
|
||||
private void AddSpecialReturnManualData(GridColumnModel model, DataTable table)
|
||||
{
|
||||
if (model == null || table == null || !model.SearchBoxAddition || !IsSpecialReturnTextBox(model.FieldType)) return;
|
||||
if (!this.ManuallyAddData.ContainsKey(model.FieldName)) return;
|
||||
|
||||
List<DataRow> dataRows = this.ManuallyAddData[model.FieldName];
|
||||
foreach (DataRow row in dataRows)
|
||||
{
|
||||
DataRow newrow = table.NewRow();
|
||||
newrow.ItemArray = row.ItemArray;
|
||||
table.Rows.Add(newrow);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 后台加载字典搜索框数据源并建立显示字典。
|
||||
/// </summary>
|
||||
private void StartSpecialReturnSourceTask(GridColumnModel model)
|
||||
{
|
||||
if (model == null || string.IsNullOrWhiteSpace(model.SqlSource) || mSpecialReturnSourceTaskDic.ContainsKey(model.FieldName)) return;
|
||||
|
||||
Task<DataTable> sourceTask = new Task<DataTable>(() =>
|
||||
{
|
||||
return BaseImpl.GetDataTableResult(model.SqlSource);
|
||||
});
|
||||
sourceTask.ContinueWith(task =>
|
||||
{
|
||||
if (task.Status != TaskStatus.RanToCompletion || task.Result == null) return;
|
||||
if (this.IsDisposed || !this.IsHandleCreated) return;
|
||||
this.BeginInvoke(new MethodInvoker(delegate ()
|
||||
{
|
||||
if (this.IsDisposed) return;
|
||||
mSpecialReturnSourceDic[model.FieldName] = task.Result;
|
||||
CacheSpecialReturnDisplayValues(model, task.Result);
|
||||
gridView.Invalidate();
|
||||
}));
|
||||
});
|
||||
mSpecialReturnSourceTaskDic.Add(model.FieldName, sourceTask);
|
||||
sourceTask.Start(DataTableExtend.SchedulerUtil);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取字段对应的显示文本字典。
|
||||
/// </summary>
|
||||
private Dictionary<string, string> GetSpecialReturnDisplayDic(GridColumnModel model)
|
||||
{
|
||||
if (!mSpecialReturnDisplayDic.ContainsKey(model.FieldName))
|
||||
{
|
||||
mSpecialReturnDisplayDic[model.FieldName] = new Dictionary<string, string>();
|
||||
}
|
||||
return mSpecialReturnDisplayDic[model.FieldName];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 确认字典搜索框数据源是否已加载;后台任务已完成但回调未执行时,在这里补建显示字典。
|
||||
/// </summary>
|
||||
private bool EnsureSpecialReturnSourceReady(GridColumnModel model)
|
||||
{
|
||||
if (model == null) return false;
|
||||
if (mSpecialReturnSourceDic.ContainsKey(model.FieldName)) return true;
|
||||
|
||||
Task<DataTable> sourceTask = null;
|
||||
if (!mSpecialReturnSourceTaskDic.TryGetValue(model.FieldName, out sourceTask)) return false;
|
||||
if (!sourceTask.IsCompleted) return false;
|
||||
|
||||
if (sourceTask.Status == TaskStatus.RanToCompletion && sourceTask.Result != null)
|
||||
{
|
||||
mSpecialReturnSourceDic[model.FieldName] = sourceTask.Result;
|
||||
CacheSpecialReturnDisplayValues(model, sourceTask.Result);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 把数据源中的值和显示文本缓存到字典中。
|
||||
/// </summary>
|
||||
private void CacheSpecialReturnDisplayValues(GridColumnModel model, DataTable table)
|
||||
{
|
||||
if (table == null || !table.Columns.Contains(model.ValueMember) || !table.Columns.Contains(model.TextMember)) return;
|
||||
|
||||
Dictionary<string, string> displayDic = GetSpecialReturnDisplayDic(model);
|
||||
foreach (DataRow row in table.Rows)
|
||||
{
|
||||
string value = IsSpecialReturnTextBox(model.FieldType) ? row[model.TextMember] + "" : row[model.ValueMember] + "";
|
||||
if (!string.IsNullOrWhiteSpace(value) && !displayDic.ContainsKey(value))
|
||||
{
|
||||
displayDic.Add(value, row[model.TextMember] + "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据单元格保存值获取显示文本。
|
||||
/// </summary>
|
||||
private string GetSpecialReturnDisplayText(GridColumnModel model, string value)
|
||||
{
|
||||
Dictionary<string, string> displayDic = GetSpecialReturnDisplayDic(model);
|
||||
string[] values = value.Trim(',').Split(',');
|
||||
StringBuilder result = new StringBuilder();
|
||||
foreach (string item in values)
|
||||
{
|
||||
string key = (item + "").Trim();
|
||||
if (string.IsNullOrWhiteSpace(key)) continue;
|
||||
|
||||
string displayText = string.Empty;
|
||||
result.Append(displayDic.TryGetValue(key, out displayText) ? displayText : key);
|
||||
result.Append(",");
|
||||
}
|
||||
return result.ToString().TrimEnd(',');
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 严格按字典获取显示文本,字典中不存在时返回false。
|
||||
/// </summary>
|
||||
private bool TryGetSpecialReturnDisplayText(GridColumnModel model, string value, out string displayText)
|
||||
{
|
||||
displayText = string.Empty;
|
||||
Dictionary<string, string> displayDic = GetSpecialReturnDisplayDic(model);
|
||||
string[] values = value.Trim(',').Split(',');
|
||||
StringBuilder result = new StringBuilder();
|
||||
foreach (string item in values)
|
||||
{
|
||||
string key = (item + "").Trim();
|
||||
if (string.IsNullOrWhiteSpace(key)) continue;
|
||||
|
||||
string itemText = string.Empty;
|
||||
if (!displayDic.TryGetValue(key, out itemText)) return false;
|
||||
|
||||
result.Append(itemText);
|
||||
result.Append(",");
|
||||
}
|
||||
|
||||
displayText = result.ToString().TrimEnd(',');
|
||||
return !string.IsNullOrWhiteSpace(displayText);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 进入编辑态时只给当前有效值绑定一行临时数据,避免未弹出下拉框时显示为空。
|
||||
/// </summary>
|
||||
private void BindSpecialReturnCurrentValue(RepositoryItemGridLookUpEdit searchEdit, GridColumnModel model, object cellValue)
|
||||
{
|
||||
if (searchEdit == null || model == null || cellValue == null) return;
|
||||
|
||||
string value = cellValue + "";
|
||||
if (string.IsNullOrWhiteSpace(value)) return;
|
||||
|
||||
string displayText = string.Empty;
|
||||
bool sourceReady = EnsureSpecialReturnSourceReady(model);
|
||||
if (!TryGetSpecialReturnDisplayText(model, value, out displayText))
|
||||
{
|
||||
if (sourceReady)
|
||||
{
|
||||
searchEdit.DataSource = null;
|
||||
return;
|
||||
}
|
||||
displayText = value;
|
||||
}
|
||||
|
||||
DataTable table = new DataTable();
|
||||
if (!table.Columns.Contains(model.ValueMember)) table.Columns.Add(model.ValueMember);
|
||||
if (!table.Columns.Contains(model.TextMember)) table.Columns.Add(model.TextMember);
|
||||
|
||||
DataRow row = table.NewRow();
|
||||
row[model.ValueMember] = IsSpecialReturnTextBox(model.FieldType) ? displayText : value;
|
||||
row[model.TextMember] = displayText;
|
||||
table.Rows.Add(row);
|
||||
|
||||
searchEdit.DataSource = table;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据弹出数据源补充搜索框显示列。
|
||||
/// </summary>
|
||||
private void AddSpecialReturnViewColumns(RepositoryItemGridLookUpEdit searchEdit, DataTable table, GridColumnModel model)
|
||||
{
|
||||
if (searchEdit == null || table == null) return;
|
||||
|
||||
foreach (DataColumn dcol in table.Columns)
|
||||
{
|
||||
if (string.IsNullOrEmpty(dcol.ColumnName) || dcol.ColumnName.Substring(0, 1) == "_") continue;
|
||||
if (searchEdit.View.Columns.FirstOrDefault(item => item.FieldName == dcol.ColumnName) != null) continue;
|
||||
|
||||
GridColumn otherColumn = new GridColumn();
|
||||
otherColumn.Name = otherColumn.FieldName = otherColumn.Caption = dcol.ColumnName;
|
||||
otherColumn.Visible = true;
|
||||
searchEdit.View.Columns.Add(otherColumn);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置字典搜索框弹出宽度,规则与普通自动搜索框保持一致。
|
||||
/// </summary>
|
||||
private void SetSpecialReturnPopupWidth(RepositoryItemGridLookUpEdit searchEdit, DataTable table, GridColumnModel model)
|
||||
{
|
||||
if (searchEdit == null || table == null || model == null) return;
|
||||
|
||||
int popWidth = 0;
|
||||
string[] columnsWidth = !string.IsNullOrWhiteSpace(model.LookUpFieldsWidth) ? model.LookUpFieldsWidth.Trim().TrimEnd(',').Split(',') : null;
|
||||
if (columnsWidth != null && columnsWidth.Length > 0)
|
||||
{
|
||||
int columnWidthIndex = 0;
|
||||
foreach (DataColumn dcol in table.Columns)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(dcol.ColumnName) && dcol.ColumnName.Substring(0, 1) != "_")
|
||||
{
|
||||
GridColumn gCol = searchEdit.View.Columns.FirstOrDefault(x => x.FieldName == dcol.ColumnName);
|
||||
if (gCol != null)
|
||||
{
|
||||
int width = 0;
|
||||
if (columnWidthIndex < columnsWidth.Length)
|
||||
{
|
||||
string widthStr = columnsWidth[columnWidthIndex];
|
||||
width = int.TryParse(widthStr, out width) ? width : GraphicsText.GetTextWidth(gCol.Caption);
|
||||
}
|
||||
else
|
||||
{
|
||||
width = GraphicsText.GetTextWidth(gCol.Caption);
|
||||
int maxWidth = CalcMaxColumnWidth(table, gCol.Name);
|
||||
width = width > maxWidth ? width : maxWidth;
|
||||
}
|
||||
gCol.Width = width;
|
||||
popWidth += gCol.Width;
|
||||
}
|
||||
}
|
||||
columnWidthIndex++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (DataColumn dcol in table.Columns)
|
||||
{
|
||||
if (string.IsNullOrEmpty(dcol.ColumnName) || dcol.ColumnName.Substring(0, 1) == "_") continue;
|
||||
GridColumn gCol = searchEdit.View.Columns.FirstOrDefault(x => x.FieldName == dcol.ColumnName);
|
||||
if (gCol != null)
|
||||
{
|
||||
int columnWidth = GraphicsText.GetTextWidth(gCol.Caption);
|
||||
gCol.Width = CalcMaxColumnWidth(table, gCol.Name);
|
||||
gCol.Width = columnWidth > gCol.Width ? columnWidth : gCol.Width;
|
||||
popWidth += gCol.Width;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (model.LookUpWidth > 0)
|
||||
{
|
||||
popWidth = model.LookUpWidth + 5;
|
||||
}
|
||||
searchEdit.PopupFormSize = new Size(popWidth, searchEdit.PopupFormSize.Height);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -1457,6 +2048,7 @@ namespace Lskj.Control
|
||||
{
|
||||
if (this.DisableFieldSources && item.isVislble) continue;
|
||||
if (ControlType.IsNotLoadData(item.FieldType)) continue;
|
||||
if (IsSpecialReturnBox(item.FieldType)) continue;
|
||||
if (UpdateColumnRefresh && !string.IsNullOrWhiteSpace(UpdateColumns) && !UpdateColumns.Split(',').Contains(item.FieldName)) continue;
|
||||
if (!string.IsNullOrWhiteSpace(item.SqlSource))
|
||||
{
|
||||
@@ -4573,6 +5165,11 @@ namespace Lskj.Control
|
||||
if (SystemInfo.Instance.DisableCellAutoFiltering && edit.Properties != null) edit.Properties.AutoComplete = false;//设置是否启用自动完成功能
|
||||
RepositoryItemGridLookUpEdit searchEdit = edit.Properties;
|
||||
DataTable dt = (searchEdit.DataSource as DataTable);
|
||||
GridColumnModel model = searchEdit.Tag as GridColumnModel;
|
||||
if (dt == null && model != null && IsSpecialReturnBox(model.FieldType))
|
||||
{
|
||||
return;
|
||||
}
|
||||
BeginInvoke(new MethodInvoker(delegate ()
|
||||
{
|
||||
FilterLookup(sender, e.NewValue + "");
|
||||
@@ -8165,6 +8762,8 @@ namespace Lskj.Control
|
||||
Tag = normalCol,
|
||||
OptionsColumn = { AllowEdit = normalCol.Edit, FixedWidth = true }
|
||||
};
|
||||
col.OptionsFilter.AutoFilterCondition = AutoFilterCondition.Contains;
|
||||
col.OptionsFilter.FilterPopupMode = FilterPopupMode.CheckedList;
|
||||
if (!normalCol.Edit)
|
||||
{
|
||||
col.AppearanceHeader.Options.UseForeColor = true;
|
||||
@@ -8213,6 +8812,7 @@ namespace Lskj.Control
|
||||
|
||||
BandedGridColumn subColumn = new BandedGridColumn
|
||||
{
|
||||
Name = dynamicFieldName,
|
||||
FieldName = dynamicFieldName,
|
||||
Caption = subCaption,
|
||||
Width = subField.Width,
|
||||
@@ -8222,6 +8822,8 @@ namespace Lskj.Control
|
||||
MaxWidth = subField.Width,
|
||||
OptionsColumn = { AllowEdit = subField.Edit, FixedWidth = true }
|
||||
};
|
||||
subColumn.OptionsFilter.AutoFilterCondition = AutoFilterCondition.Contains;
|
||||
subColumn.OptionsFilter.FilterPopupMode = FilterPopupMode.CheckedList;
|
||||
if (!subField.Edit)
|
||||
{
|
||||
subColumn.AppearanceHeader.Options.UseForeColor = true;
|
||||
@@ -8302,6 +8904,8 @@ namespace Lskj.Control
|
||||
Tag = normalCol,
|
||||
OptionsColumn = { AllowEdit = normalCol.Edit, FixedWidth = true }
|
||||
};
|
||||
col.OptionsFilter.AutoFilterCondition = DevExpress.XtraTreeList.Columns.AutoFilterCondition.Contains;
|
||||
col.OptionsFilter.FilterPopupMode = DevExpress.XtraTreeList.FilterPopupMode.CheckedList;
|
||||
if (!normalCol.Edit)
|
||||
{
|
||||
col.AppearanceHeader.Options.UseForeColor = true;
|
||||
@@ -8355,6 +8959,7 @@ namespace Lskj.Control
|
||||
|
||||
DevExpress.XtraTreeList.Columns.TreeListColumn subColumn = new DevExpress.XtraTreeList.Columns.TreeListColumn
|
||||
{
|
||||
Name = dynamicFieldName,
|
||||
FieldName = dynamicFieldName,
|
||||
Caption = subCaption,
|
||||
Width = subField.Width,
|
||||
@@ -8363,6 +8968,8 @@ namespace Lskj.Control
|
||||
MinWidth = subField.Width,
|
||||
OptionsColumn = { AllowEdit = subField.Edit, FixedWidth = true }
|
||||
};
|
||||
subColumn.OptionsFilter.AutoFilterCondition = DevExpress.XtraTreeList.Columns.AutoFilterCondition.Contains;
|
||||
subColumn.OptionsFilter.FilterPopupMode = DevExpress.XtraTreeList.FilterPopupMode.CheckedList;
|
||||
if (!subField.Edit)
|
||||
{
|
||||
subColumn.AppearanceHeader.Options.UseForeColor = true;
|
||||
@@ -9252,6 +9859,16 @@ namespace Lskj.Control
|
||||
{
|
||||
this.mLoading = false;
|
||||
mControlSourceDic.Clear();
|
||||
mSpecialReturnSourceDic.Clear();
|
||||
mSpecialReturnSourceTaskDic.Clear();
|
||||
mSpecialReturnDisplayDic.Clear();
|
||||
foreach (GridColumnModel model in mControlList)
|
||||
{
|
||||
if (IsSpecialReturnBox(model.FieldType))
|
||||
{
|
||||
StartSpecialReturnSourceTask(model);
|
||||
}
|
||||
}
|
||||
SetColumnsSource(UpdateColumnRefresh);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ using System.Windows.Forms;
|
||||
using DevExpress.XtraEditors;
|
||||
using DevExpress.XtraEditors.Controls;
|
||||
using Lskj.Control.Model;
|
||||
using Lskj.Business.Impl;
|
||||
|
||||
namespace Lskj.Control
|
||||
{
|
||||
@@ -51,12 +52,48 @@ namespace Lskj.Control
|
||||
/// </summary>
|
||||
/// <value>The label.</value>
|
||||
public Label Label { get { return lblText; } }
|
||||
/// <summary>
|
||||
/// The contro object
|
||||
/// </summary>
|
||||
public MyControl ControlObj;
|
||||
/// <summary>
|
||||
/// 数据源
|
||||
/// </summary>
|
||||
public string SourceSQL = string.Empty;
|
||||
/// <summary>
|
||||
/// 是否带参数
|
||||
/// </summary>
|
||||
public bool Isparameters = false;
|
||||
|
||||
|
||||
public LabelComboxEdit()
|
||||
{
|
||||
InitializeComponent();
|
||||
// 绑定事件
|
||||
txtEdit.QueryPopUp += TxtEdit_QueryPopUp;
|
||||
|
||||
}
|
||||
|
||||
private void TxtEdit_QueryPopUp(object sender, CancelEventArgs e)
|
||||
{
|
||||
this.RefreshData();
|
||||
}
|
||||
|
||||
public void RefreshData()
|
||||
{
|
||||
if (Isparameters && !string.IsNullOrWhiteSpace(this.SourceSQL) && this.ControlObj != null)
|
||||
{
|
||||
string oldValue = this.EditValue;
|
||||
|
||||
string sqlValue = this.ControlObj.ReplaceControlValue(this.SourceSQL);
|
||||
sqlValue = sqlValue.Replace("#", "");
|
||||
DataTable table = BaseImpl.GetDataTableResult(sqlValue);
|
||||
this.SetDataSource(table, true);
|
||||
this.EditText = oldValue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// <para>说明:设置控件显示文本</para>
|
||||
@@ -261,9 +298,25 @@ namespace Lskj.Control
|
||||
/// </summary>
|
||||
/// <param name="dataSource">数据源</param>
|
||||
public void SetDataSource(DataTable dataSource)
|
||||
{
|
||||
SetDataSource(dataSource, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>说明:设置数据源</para>
|
||||
/// </summary>
|
||||
/// <param name="dataSource">数据源</param>
|
||||
/// <param name="clearBeforeBind">绑定前是否清空原数据源</param>
|
||||
public void SetDataSource(DataTable dataSource, bool clearBeforeBind)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (clearBeforeBind)
|
||||
{
|
||||
ClearDataSource();
|
||||
}
|
||||
if (dataSource == null) return;
|
||||
|
||||
foreach (DataRow item in dataSource.Rows)
|
||||
{
|
||||
ComboBoxModel model = new ComboBoxModel
|
||||
@@ -282,6 +335,17 @@ namespace Lskj.Control
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清空下拉数据源和已选项,避免带参数下拉每次弹出重复追加。
|
||||
/// </summary>
|
||||
private void ClearDataSource()
|
||||
{
|
||||
this._sources.Clear();
|
||||
this.txtEdit.SelectedItem = null;
|
||||
this.txtEdit.EditValue = null;
|
||||
this.txtEdit.Properties.Items.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 背景颜色
|
||||
/// </summary>
|
||||
@@ -347,4 +411,4 @@ namespace Lskj.Control
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,9 +203,29 @@ namespace Lskj.Control
|
||||
}
|
||||
set
|
||||
{
|
||||
this.txtEdit.Text = value;
|
||||
//this.txtEdit.Text = value;
|
||||
this.txtEdit.Text = NormalizeMemoText(value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 处理换行 (\n的换行不会生效,必须要\r\n才行。这里会把\n转成\r\n)
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
private static string NormalizeMemoText(string value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value)) return value;
|
||||
|
||||
return value
|
||||
.Replace("\r\n", "\n") // 先把 CRLF 压成 LF
|
||||
.Replace("\r", "\n") // 再把单独 CR 压成 LF
|
||||
.Replace("\n", Environment.NewLine); // 最后统一成 Windows CRLF
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// <para>说明:设置控件提示文本</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
|
||||
@@ -493,13 +493,21 @@ namespace Lskj.Control.Model
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 测试特殊搜索框返回id
|
||||
/// 快速搜索框返回id(字典模式)
|
||||
/// </summary>
|
||||
public const int SpecialSearchBoxToId = 181;
|
||||
public const int DictionarySearchBoxToId = 181;
|
||||
/// <summary>
|
||||
/// 测试特殊搜索框返回text
|
||||
/// 快速搜索框返回text(字典模式)
|
||||
/// </summary>
|
||||
public const int SpecialSearchBoxToText = 182;
|
||||
public const int DictionarySearchBoxToText = 182;
|
||||
/// <summary>
|
||||
/// 快速搜索框返回id 带参数(字典模式)
|
||||
/// </summary>
|
||||
public const int DictionarySearchBoxToIdParam = 183;
|
||||
/// <summary>
|
||||
/// 快速搜索框返回text 带参数(字典模式)
|
||||
/// </summary>
|
||||
public const int DictionarySearchBoxToTextParam = 184;
|
||||
|
||||
/// <summary>
|
||||
/// <para>说明:是否为Value类型</para>
|
||||
|
||||
@@ -423,7 +423,10 @@ namespace Lskj.Control.Model
|
||||
this._bandTitle = item.Table.Columns.Contains("bandTitle") ? item["bandTitle"] + "" : string.Empty;
|
||||
this._bandFields = item.Table.Columns.Contains("bandFields") ? item["bandFields"] + "" : string.Empty;
|
||||
this._fieldtype = item.Table.Columns.Contains("fieldsqltag") && !string.IsNullOrWhiteSpace(item["fieldsqltag"] + "") ? Convert.ToInt32(item["fieldsqltag"] + "") : 0;
|
||||
|
||||
//if (this._fieldtype == 5 || this._fieldtype == 15)
|
||||
//{
|
||||
// _fieldtype = 181;
|
||||
//}
|
||||
this._sqlSource = item.Table.Columns.Contains("fieldsql") && !string.IsNullOrWhiteSpace(item["fieldsql"] + "") ? item["fieldsql"] + "" : string.Empty;
|
||||
this._valueMember = item.Table.Columns.Contains("fieldsqlid") && !string.IsNullOrWhiteSpace(item["fieldsqlid"] + "") ? item["fieldsqlid"] + "" : "dm";
|
||||
this._textMember = item.Table.Columns.Contains("fieldsqlname") && !string.IsNullOrWhiteSpace(item["fieldsqlname"] + "") ? item["fieldsqlname"] + "" : "mc";
|
||||
|
||||
@@ -3048,7 +3048,18 @@ namespace Lskj.Control.Model
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 快速导入
|
||||
/// </summary>
|
||||
/// <param name="gridView"></param>
|
||||
/// <param name="SysModel"></param>
|
||||
/// <param name="parmaryKey"></param>
|
||||
/// <param name="leftField"></param>
|
||||
/// <param name="leftValue"></param>
|
||||
/// <param name="ImportReturnName"></param>
|
||||
/// <param name="ImportReturnValue"></param>
|
||||
/// <param name="ParentGridEx"></param>
|
||||
/// <returns></returns>
|
||||
public static bool QuickImport(this GridView gridView, ModuleModel SysModel, string parmaryKey, string leftField, string leftValue, List<string> ImportReturnName, List<string> ImportReturnValue, GridControlEx ParentGridEx = null)
|
||||
{
|
||||
OpenFileDialog dialog = new OpenFileDialog();
|
||||
|
||||
@@ -485,6 +485,12 @@ namespace Lskj.Control.Model
|
||||
{
|
||||
tipOnlyOne = false;
|
||||
string prompt = ReplaceHelper.ReplaceRowParam(rowData, model.BeforeMsg);
|
||||
if (model.Mergeexec)
|
||||
{
|
||||
//替换[],替换的是多选行中的数据
|
||||
prompt = ReplaceHelper.ReplaceRowParam(rows, prompt.Replace("[", "{").Replace("]", "}"), "", "");
|
||||
}
|
||||
|
||||
if (prompt.StartsWith("@") || prompt.StartsWith("!"))
|
||||
{
|
||||
prompt = BaseImpl.GetDefaultValue(prompt);
|
||||
|
||||
@@ -42,6 +42,14 @@ namespace Lskj.Control.Model
|
||||
{
|
||||
int[] mSelectRows = this._gridView.GetSelectedRows();
|
||||
if (mSelectRows == null || mSelectRows.Length == 0) return;
|
||||
|
||||
DataRow[] dataRows = new DataRow[mSelectRows.Length];
|
||||
for (int i = 0; i < mSelectRows.Length; i++)
|
||||
{
|
||||
dataRows[i] = this._gridView.GetDataRow(mSelectRows[i]);
|
||||
}
|
||||
|
||||
|
||||
DataRow mSelectRow = this._gridView.GetDataRow(mSelectRows[0]);
|
||||
this._gridView.UpdateCurrentRow();
|
||||
this._gridView.ShowEditor();
|
||||
@@ -127,6 +135,13 @@ namespace Lskj.Control.Model
|
||||
cond = _control.ReplaceParentControlValue(model.MenuCond);
|
||||
}
|
||||
cond = ReplaceHelper.ReplaceRowParam(selectRow, model.MenuCond);
|
||||
|
||||
if (model.Mergeexec&& cond.StartsWith("@"))
|
||||
{
|
||||
//替换[],替换的是多选行中的数据
|
||||
cond = ReplaceHelper.ReplaceRowParam(dataRows, cond.Replace("[", "{").Replace("]", "}"), "", "");
|
||||
}
|
||||
|
||||
if (this._gridView != null)
|
||||
{
|
||||
if (cells != null && cells.Length > 0 && cond.Contains("{COLUMN_"))
|
||||
|
||||
@@ -134,37 +134,69 @@ namespace Lskj.Control.Model.MenuStrip
|
||||
{
|
||||
try
|
||||
{
|
||||
string cond = string.Empty;
|
||||
if (this._control != null)
|
||||
cond = _control.ReplaceParentControlValue(model.MenuCond);
|
||||
cond = ReplaceHelper.ReplaceRowParam(mSelectRow, model.MenuCond);
|
||||
if (this._treeView != null)
|
||||
bool condResult = false;
|
||||
StringBuilder condBuilder = new StringBuilder();
|
||||
StringBuilder sqlCondBuilder = new StringBuilder();
|
||||
List<TreeListCell> cells = this._treeView != null ? this._treeView.GetSelectedCells() : null;
|
||||
DataRow focusedRow = this.TreeGridControlObj.GetViewFocusedDataRow();
|
||||
foreach (DataRow selectRow in mSelectRows)
|
||||
{
|
||||
List<TreeListCell> cells = this._treeView.GetSelectedCells();
|
||||
if (selectRow == null) continue;
|
||||
|
||||
string cond = string.Empty;
|
||||
if (this._control != null)
|
||||
cond = _control.ReplaceParentControlValue(model.MenuCond);
|
||||
cond = ReplaceHelper.ReplaceRowParam(selectRow, model.MenuCond);
|
||||
|
||||
if (model.Mergeexec && cond.StartsWith("@"))
|
||||
{
|
||||
//替换[],替换的是多选行中的数据
|
||||
cond = ReplaceHelper.ReplaceRowParam(mSelectRows, cond.Replace("[", "{").Replace("]", "}"), "", "");
|
||||
}
|
||||
|
||||
if (cells != null && cells.Count > 0 && cond.Contains("{COLUMN_"))
|
||||
{
|
||||
TreeListCell cell = cells[0];
|
||||
DataRow focusedRow = this.BaseGridView.GetFocusedDataRow();
|
||||
string colValue = focusedRow == null || !focusedRow.Table.Columns.Contains(cell.Column.Name) ? "" : focusedRow[cell.Column.Name] + "";
|
||||
cond = cond.ReplaceColumnParam(cell.Column.Name, cell.Column.Caption, colValue);
|
||||
}
|
||||
}
|
||||
if (ControlObj != null)
|
||||
cond = ControlObj.ReplaceParentControlValue(cond);
|
||||
//cms.Enabled = ReplaceHelper.EvalCond(cond);
|
||||
|
||||
if (ControlObj != null)
|
||||
cond = ControlObj.ReplaceParentControlValue(cond);
|
||||
|
||||
if (cond.StartsWith("@"))
|
||||
{
|
||||
sqlCondBuilder.Append($"({cond.TrimStart('@')}) = '1' and ");
|
||||
}
|
||||
else
|
||||
{
|
||||
condBuilder.Append($"({cond}) and ");
|
||||
}
|
||||
}
|
||||
string condStr = "";
|
||||
if (model.MenuCond.StartsWith("@"))
|
||||
{
|
||||
condStr = $"@if({sqlCondBuilder.ToString().TrimEnd().TrimEnd('d', 'n', 'a')}) begin select '1' end else begin select '0' end";
|
||||
}
|
||||
else
|
||||
{
|
||||
condStr = condBuilder.ToString().TrimEnd().TrimEnd('d', 'n', 'a');
|
||||
}
|
||||
condResult = ValidateCond(condStr, null);
|
||||
//cms.Enabled = ReplaceHelper.EvalCond(cond);
|
||||
if (model.ForbiddenDisplay)
|
||||
{
|
||||
cms.Visible = ValidateCond(cond, null);
|
||||
cms.Visible = condResult;
|
||||
}
|
||||
|
||||
cms.Enabled = ValidateCond(cond, null); ;
|
||||
cms.Enabled = condResult;
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
string Message = ErrorMessage.PromptErrorMessage(ex);
|
||||
MessageUtil.Show(ResourceKeys.SetRightMenuCondFault + "\r\n" + Message);
|
||||
e.Cancel = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,10 @@ namespace Lskj.Control
|
||||
/// </summary>
|
||||
public sealed class MessageUtil
|
||||
{
|
||||
|
||||
public static string Prompt = string.IsNullOrWhiteSpace(SystemInfo.Instance.DeadlockPrompt) ? "网络连接超时,请稍候再试!" : SystemInfo.Instance.DeadlockPrompt;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// <para>说明:弹出Ok对话框</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
@@ -51,7 +55,7 @@ namespace Lskj.Control
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(msg) && msg.Contains("与另一个进程被死锁在")&& !SystemInfo.Instance.PromptDeadlock)
|
||||
msg = "网络连接超时,请稍候再试!";
|
||||
msg = Prompt;
|
||||
if (Business.Impl.LanguageTranslation.Translatable)
|
||||
{
|
||||
msg = Business.Impl.LanguageTranslation.GetTranslatedText(msg);
|
||||
@@ -87,7 +91,7 @@ namespace Lskj.Control
|
||||
|
||||
if (!string.IsNullOrEmpty(errorMessage) && errorMessage.Contains("与另一个进程被死锁在") && !SystemInfo.Instance.PromptDeadlock)
|
||||
{
|
||||
errorMessage = "网络连接超时,请稍候再试!";
|
||||
errorMessage = Prompt;
|
||||
if (Business.Impl.LanguageTranslation.Translatable)
|
||||
{
|
||||
errorMessage = Business.Impl.LanguageTranslation.GetTranslatedText(errorMessage);
|
||||
@@ -162,7 +166,7 @@ namespace Lskj.Control
|
||||
{
|
||||
string msg = ex == null ? ResourceKeys.UnKownErrorTip : ex.StackTrace;
|
||||
if (!string.IsNullOrEmpty(msg) && msg.Contains("与另一个进程被死锁在") && !SystemInfo.Instance.PromptDeadlock)
|
||||
msg = "网络连接超时,请稍候再试!";
|
||||
msg = Prompt;
|
||||
if (Business.Impl.LanguageTranslation.Translatable)
|
||||
{
|
||||
msg = Business.Impl.LanguageTranslation.GetTranslatedText(msg);
|
||||
@@ -173,7 +177,7 @@ namespace Lskj.Control
|
||||
{
|
||||
string msg = ex == null ? ResourceKeys.UnKownErrorTip : ex.Message; //ResourceKeys.SystemErrorTip + "\r\n" + ex.Message + "\r\n" + ex.StackTrace;
|
||||
if (!string.IsNullOrEmpty(msg) && msg.Contains("与另一个进程被死锁在") && !SystemInfo.Instance.PromptDeadlock)
|
||||
msg = "网络连接超时,请稍候再试!";
|
||||
msg = Prompt;
|
||||
if (Business.Impl.LanguageTranslation.Translatable)
|
||||
{
|
||||
msg = Business.Impl.LanguageTranslation.GetTranslatedText(msg);
|
||||
|
||||
@@ -1503,7 +1503,31 @@ namespace Lskj.Control.Model
|
||||
// 下拉框
|
||||
LabelComboxEdit comboxEdit = ctr as LabelComboxEdit;
|
||||
comboxEdit.SetDataSource(table);
|
||||
comboxEdit.TextEdit.SelectedIndex = 0;
|
||||
|
||||
if (comboxEdit.Isparameters)
|
||||
{
|
||||
List<string> condition = ReplaceHelper.GetParamFields(model.SourceSql);
|
||||
foreach (string item in condition)
|
||||
{
|
||||
string filename = item.Trim('{', '}');
|
||||
if (ParaContrlsDic.ContainsKey(filename))
|
||||
{
|
||||
if (!ParaContrlsDic[filename].Contains(model.FieldName))
|
||||
{
|
||||
ParaContrlsDic[filename].Add(model.FieldName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ParaContrlsDic[filename] = new List<string>() { model.FieldName };
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//默认选中第一个,如果设置了带参数,就不默认选中
|
||||
comboxEdit.TextEdit.SelectedIndex = 0;
|
||||
}
|
||||
break;
|
||||
case ControlType.LabAutoCompleteValue:
|
||||
case ControlType.LabAutoCompleteText:
|
||||
@@ -3829,6 +3853,7 @@ namespace Lskj.Control.Model
|
||||
if (rowItem == null) return;
|
||||
foreach (ControlModel model in this.ControlModels)
|
||||
{
|
||||
|
||||
selectModel = model;
|
||||
|
||||
if (rowItem.Table.Columns.Contains(model.FieldName))
|
||||
@@ -3859,6 +3884,8 @@ namespace Lskj.Control.Model
|
||||
{
|
||||
SetControlValue(model, "****");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -4212,6 +4239,27 @@ namespace Lskj.Control.Model
|
||||
model.FieldType = 161;
|
||||
model.IsRadio = true;
|
||||
}
|
||||
//快速搜索框在控件中转成普通搜索框
|
||||
if (model.FieldType == 181 || model.FieldType == 182 || model.FieldType == 183 || model.FieldType == 184)
|
||||
{
|
||||
switch (model.FieldType)
|
||||
{
|
||||
case ControlType.DictionarySearchBoxToId:
|
||||
model.FieldType = 5;
|
||||
break;
|
||||
case ControlType.DictionarySearchBoxToText:
|
||||
model.FieldType = 6;
|
||||
break;
|
||||
case ControlType.DictionarySearchBoxToIdParam:
|
||||
model.FieldType = 15;
|
||||
break;
|
||||
case ControlType.DictionarySearchBoxToTextParam:
|
||||
model.FieldType = 16;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return model;
|
||||
}
|
||||
@@ -4340,6 +4388,13 @@ namespace Lskj.Control.Model
|
||||
comboxEdit.ValueMember = ControlType.LabComboxValue == model.FieldType || ControlType.LabComboxValueParam == model.FieldType ? model.ValueMember : model.TextMember;
|
||||
comboxEdit.ValueField = model.ValueMember;
|
||||
comboxEdit.TextField = model.TextMember;
|
||||
if (ControlType.LabComboxValueParam == model.FieldType || ControlType.LabComboxTextParam == model.FieldType)
|
||||
{
|
||||
comboxEdit.ControlObj = this;
|
||||
comboxEdit.SourceSQL = model.SourceSql;
|
||||
comboxEdit.Isparameters = true;
|
||||
}
|
||||
|
||||
//comboxEdit.SetDataSource(dataSource);
|
||||
// 假如为报表模式并且没有默认值,默认选择第一条记录
|
||||
if (model.IsSearchControl && string.IsNullOrEmpty(model.DefaultValue))
|
||||
@@ -5426,6 +5481,10 @@ namespace Lskj.Control.Model
|
||||
{
|
||||
labelAutoGridLook.HandPopupSqlValue(labelAutoGridLook.SourceSQL);
|
||||
}
|
||||
if (baseUserControl is LabelComboxEdit labelComboxEdit)
|
||||
{
|
||||
labelComboxEdit.RefreshData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6415,10 +6474,10 @@ namespace Lskj.Control.Model
|
||||
if (rowItem == null) return;
|
||||
foreach (ControlModel model in this.ControlModels)
|
||||
{
|
||||
if (rowItem.Table.Columns.Contains(model.FieldName)&&!string.IsNullOrWhiteSpace(model.DefaultValue))
|
||||
if (rowItem.Table.Columns.Contains(model.FieldName) && !string.IsNullOrWhiteSpace(model.DefaultValue))
|
||||
{
|
||||
string DefaultValue = ReplaceHelper.ReplaceUserInfo(model.DefaultValue);
|
||||
if (!DefaultValue.Equals(rowItem[model.FieldName] + ""))
|
||||
if (!DefaultValue.Equals(rowItem[model.FieldName] + ""))
|
||||
{
|
||||
BaseUserControl baseControl = FindControl(model.FieldName);
|
||||
if (baseControl == null) continue;
|
||||
@@ -6432,7 +6491,7 @@ namespace Lskj.Control.Model
|
||||
// baseControl.ForeColor = ColorTranslator.FromHtml("#000000");
|
||||
// baseControl.ContentBold = false;
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,12 +124,19 @@ namespace Lskj.Control.Model
|
||||
form.IsMdiContainer = true;
|
||||
form.WindowState = System.Windows.Forms.FormWindowState.Maximized;
|
||||
|
||||
design.ReportObj.Prepare();
|
||||
design.ReportObj.Design(form);
|
||||
design.ReportObj.Designer.BorderStyle = BorderStyle.None;
|
||||
design.ReportObj.Designer.cmdPreview.CustomAction += OnCustomAction;
|
||||
try
|
||||
{
|
||||
design.ReportObj.Prepare();
|
||||
design.ReportObj.Design(form);
|
||||
design.ReportObj.Designer.BorderStyle = BorderStyle.None;
|
||||
design.ReportObj.Designer.cmdPreview.CustomAction += OnCustomAction;
|
||||
|
||||
form.ShowDialog();
|
||||
form.ShowDialog();
|
||||
}
|
||||
finally
|
||||
{
|
||||
ReleaseFastReportDesignerResource(design);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -156,13 +163,50 @@ namespace Lskj.Control.Model
|
||||
//MessageUtil.Show(ex);
|
||||
string Message = ErrorMessage.PromptErrorMessage(ex);
|
||||
MessageUtil.Show(Message, ex.Message);
|
||||
design.ReportObj.Design();
|
||||
if (design != null && design.ReportObj != null)
|
||||
{
|
||||
design.ReportObj.Design();
|
||||
}
|
||||
WaitForm.HideForm();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static void ReleaseFastReportDesignerResource(FrmFastReportDesign design)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (design != null && design.ReportObj != null && design.ReportObj.Designer != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
design.ReportObj.Designer.StopAutoSave();
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
design.ReportObj.Designer.cmdPreview.CustomAction -= OnCustomAction;
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
if (design != null && design.ReportObj != null)
|
||||
{
|
||||
design.ReportObj.Dispose();
|
||||
design.ReportObj = null;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private static void OnCustomAction(object sender, EventArgs e)
|
||||
{
|
||||
FastReport.Design.StandardDesigner.DesignerControl design = sender as FastReport.Design.StandardDesigner.DesignerControl;
|
||||
|
||||
@@ -1882,7 +1882,7 @@ namespace Lskj.Control
|
||||
/// </summary>
|
||||
public void InitializeTab()
|
||||
{
|
||||
DataTable table = BaseModuleImpl.GetBaseAttach(this.Model.ModuleCode);//查看是否有附加模块
|
||||
DataTable table = BaseModuleImpl.GetBaseAttachKey(this.SysModel.FormKey);//查看是否有附加模块
|
||||
if (table.Rows.Count > 0)
|
||||
{
|
||||
XtraTabPage MainTableTab = new XtraTabPage();
|
||||
|
||||
+5
-4
@@ -28,14 +28,15 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.pm_print = new DevExpress.XtraBars.PopupMenu();
|
||||
this.barManager1 = new DevExpress.XtraBars.BarManager();
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.pm_print = new DevExpress.XtraBars.PopupMenu(this.components);
|
||||
this.barManager1 = new DevExpress.XtraBars.BarManager(this.components);
|
||||
this.barDockControlTop = new DevExpress.XtraBars.BarDockControl();
|
||||
this.barDockControlBottom = new DevExpress.XtraBars.BarDockControl();
|
||||
this.barDockControlLeft = new DevExpress.XtraBars.BarDockControl();
|
||||
this.barDockControlRight = new DevExpress.XtraBars.BarDockControl();
|
||||
this.pm_oper = new DevExpress.XtraBars.PopupMenu();
|
||||
this.pm_common = new DevExpress.XtraBars.PopupMenu();
|
||||
this.pm_oper = new DevExpress.XtraBars.PopupMenu(this.components);
|
||||
this.pm_common = new DevExpress.XtraBars.PopupMenu(this.components);
|
||||
this.grouptip = new System.Windows.Forms.GroupBox();
|
||||
this.TipsPanel = new System.Windows.Forms.Panel();
|
||||
this.scc_container = new DevExpress.XtraEditors.SplitContainerControl();
|
||||
|
||||
Reference in New Issue
Block a user