2db4a0fadf
SVN-Revision: r654
5872 lines
287 KiB
C#
5872 lines
287 KiB
C#
using DevExpress.XtraBars;
|
|
using DevExpress.XtraEditors;
|
|
using DevExpress.XtraGrid;
|
|
using DevExpress.XtraGrid.Views.Grid;
|
|
using DevExpress.XtraGrid.Views.Layout;
|
|
using DevExpress.XtraTab;
|
|
using Lskj.Business;
|
|
using Lskj.Business.Impl;
|
|
using Lskj.Core;
|
|
using Lskj.Data;
|
|
using Lskj.Model;
|
|
using Lskj.Util;
|
|
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Drawing;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Text.RegularExpressions;
|
|
using System.Threading.Tasks;
|
|
using System.Web;
|
|
using System.Windows.Forms;
|
|
|
|
namespace Lskj.Control.Model
|
|
{
|
|
/// <summary>
|
|
/// 查询控件、添加修改界面控件管理类
|
|
/// </summary>
|
|
public class MyControl
|
|
{
|
|
private string _searchSql;
|
|
private DataTable _controls;
|
|
private DataTable _schemes;
|
|
private System.Windows.Forms.ComboBox _fixField;
|
|
private System.Windows.Forms.TextBox _fixKey;
|
|
private XtraScrollableControl _parentPanel;
|
|
private SimpleButton _button, _fixButton, _refreshButton;
|
|
private GridControl _gridControl;
|
|
private GridControlEx _mainGridEx;
|
|
private GridControlEx _gridLeft;
|
|
private TreeViewEx _tvLeft;
|
|
private MyControl _leftSearch;
|
|
private DropDownButton _dropDown = new DropDownButton();
|
|
private PopupMenu _popupMenu = new PopupMenu();
|
|
/// <summary>
|
|
/// 计算字段
|
|
/// </summary>
|
|
private List<ControlModel> _calcControls = new List<ControlModel>();
|
|
public List<ControlModel> _models = new List<ControlModel>();
|
|
/// <summary>
|
|
/// 缓存本次数据源
|
|
/// </summary>
|
|
protected Dictionary<string, DataTable> mCacheDictionary = new Dictionary<string, DataTable>();
|
|
/// <summary>
|
|
/// 菜单ID
|
|
/// </summary>
|
|
public int ModuleId;
|
|
/// <summary>
|
|
/// 表格数据行
|
|
/// </summary>
|
|
public int GridRowCount;
|
|
/// <summary>
|
|
/// 记住上一次选中行
|
|
/// </summary>
|
|
public bool RememberRow = true;
|
|
/// <summary>
|
|
/// 是否允许控件关联值、计算值
|
|
/// </summary>
|
|
public bool CanExecControl = true;
|
|
/// <summary>
|
|
/// 左侧树结构、表格主键
|
|
/// </summary>
|
|
public string ParentKeyField;
|
|
/// <summary>
|
|
/// 主表查询时,左侧树表格是否为精确查询(like改成=)
|
|
/// </summary>
|
|
public bool TreeExactQuery = false;
|
|
/// <summary>
|
|
/// 左侧树结构、表格主键关联右侧数据字段
|
|
/// </summary>
|
|
public string ParentUnionField;
|
|
/// <summary>
|
|
/// 树结构隐藏值
|
|
/// </summary>
|
|
public string ParentKey;
|
|
/// <summary>
|
|
/// 树结构显示值
|
|
/// </summary>
|
|
public string ParentValue;
|
|
/// <summary>
|
|
/// 主键值
|
|
/// </summary>
|
|
public string PrimaryValue;
|
|
/// <summary>
|
|
/// 特殊查询条件
|
|
/// </summary>
|
|
public string WhereCond;
|
|
/// <summary>
|
|
/// 需要关联的刷新控件名称
|
|
/// </summary>
|
|
public string RefreshControl;
|
|
protected bool mLoading = false;
|
|
protected Timer mTimer = new Timer();
|
|
/// <summary>
|
|
/// 查询按钮
|
|
/// </summary>
|
|
/// <value>The button object.</value>
|
|
public SimpleButton ButtonObj { get { return _button; } }
|
|
/// <summary>
|
|
/// 条件数据源刷新按钮
|
|
/// </summary>
|
|
/// <value>The button object.</value>
|
|
public SimpleButton RefreshButtonObj { get { return _refreshButton; } }
|
|
/// <summary>
|
|
/// 是否为特殊搜索框
|
|
/// </summary>
|
|
public bool isRevTextEdit = false;
|
|
/// <summary>
|
|
/// 查询主表公共模块
|
|
/// </summary>
|
|
/// <value>The button object.</value>
|
|
public GridControlEx MainGridEx { get { return _mainGridEx; } }
|
|
/// <summary>
|
|
/// 条件参数
|
|
/// </summary>
|
|
public string[] OtherParams;
|
|
public DataRow CurrentData;
|
|
public ModuleModel SystemModel;
|
|
/// <summary>
|
|
/// 下拉框、搜索框控件对象
|
|
/// </summary>
|
|
public List<ControlModel> mControlList = new List<ControlModel>();
|
|
/// <summary>
|
|
/// 数据源任务对象
|
|
/// </summary>
|
|
public Dictionary<ControlModel, Task<DataTable>> mControlSourceDic = new Dictionary<ControlModel, Task<DataTable>>();
|
|
/// <summary>
|
|
/// 获取控件model数据
|
|
/// </summary>
|
|
/// <value>The control models.</value>
|
|
public List<ControlModel> ControlModels { get { return this._models; } }
|
|
/// <summary>
|
|
/// 明细里复选框选中的数据(主表和明细都是复选模式才记录) <页签名, <主表选中行,明细选中行主键(,拼接)>>
|
|
/// 如果主表刷新后还要选中之前的明细,就要存主表主键值(目前没用传进来)
|
|
/// </summary>
|
|
public Dictionary<string, Dictionary<DataRow, string>> DetailSelection = new Dictionary<string, Dictionary<DataRow, string>>();
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 执行查询之前验证
|
|
/// </summary>
|
|
public event PreSearchVerification preSearchVerification;
|
|
/// <summary>
|
|
/// 执行查询之前
|
|
/// </summary>
|
|
public event SearchEventHandler OnSearchBeforeCallBack;
|
|
/// <summary>
|
|
/// 执行查询之后
|
|
/// </summary>
|
|
public event EventHandler OnSearchAfterCallBack;
|
|
/// <summary>
|
|
/// 执行新增控件框之后
|
|
/// </summary>
|
|
public event EventHandler OnAddCallBack;
|
|
/// <summary>
|
|
///改变的智能搜索框
|
|
/// </summary>
|
|
private Dictionary<string, object> changeLabelAutoGridLooks = new Dictionary<string, object>();
|
|
/// <summary>
|
|
/// 主表点击搜索按钮,查询内容为0行时,清空明细
|
|
/// </summary>
|
|
public event EventHandler ClearDetails;
|
|
/// <summary>
|
|
/// 执行最后次查询后触发
|
|
/// </summary>
|
|
public event EventHandler OnLastQueryTriggered;
|
|
|
|
/// <summary>
|
|
/// <para>说明:键盘按下时触发</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-12-21 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
public event KeyEventHandler OnSourceRefrshCallBack;
|
|
/// <summary>
|
|
/// 数据源绑定完成触发
|
|
/// </summary>
|
|
public event EventHandler OnDataSourceBindCallBack;
|
|
/// <summary>
|
|
/// mrp固定传输接口
|
|
/// </summary>
|
|
public DynamicModel mrpDyncModel;
|
|
//public event RefreshThePage refreshThePage;
|
|
//public delegate void RefreshThePage(string text);
|
|
/// <summary>
|
|
/// mrp按钮对象
|
|
/// </summary>
|
|
public Dictionary<GridRightMenuModel, SimpleButton> mrpBtnDic = new Dictionary<GridRightMenuModel, SimpleButton>();
|
|
/// <summary>
|
|
/// 重新设置控件值时是否刷新下拉框数据源
|
|
/// </summary>
|
|
public bool refGridLookUpData;
|
|
/// <summary>
|
|
/// 条件搜索按钮
|
|
/// </summary>
|
|
public SimpleButton btnCondSearch;
|
|
/// <summary>
|
|
/// 默认传递参数
|
|
/// </summary>
|
|
public DynamicModel Model;
|
|
/// <summary>
|
|
/// 弹出框默认传递参数
|
|
/// </summary>
|
|
public DynamicModel popUpDyncModel;
|
|
/// <summary>
|
|
/// 弹出框右键
|
|
/// </summary>
|
|
public BarItemLinkCollection rightItemLinks;
|
|
/// <summary>
|
|
/// 模块选择框 选中后返回关联的字典
|
|
/// </summary>
|
|
public Dictionary<string, string> ModuleResultDic = new Dictionary<string, string>();
|
|
/// <summary>
|
|
/// 控件值改变动态刷新表格列
|
|
/// </summary>
|
|
public event KeyEventHandler OnDataFileRefrshCallBack;
|
|
/// <summary>
|
|
/// 控件Panel对象
|
|
/// </summary>
|
|
public XtraScrollableControl ParentPanel
|
|
{
|
|
get
|
|
{
|
|
return this._parentPanel;
|
|
}
|
|
set
|
|
{
|
|
this._parentPanel = value;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="MyControl"/> class.
|
|
/// </summary>
|
|
public MyControl()
|
|
{
|
|
|
|
}
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="MyControl"/> class.
|
|
/// </summary>
|
|
/// <param name="searchSql">查询条件sql</param>
|
|
/// <param name="condition">查询条件</param>
|
|
/// <param name="gridControl">The grid control.</param>
|
|
/// <param name="treeView">The tree view.</param>
|
|
public MyControl(string searchSql, GridControlEx mainGridEx, TreeViewEx treeView = null, GridControlEx gridLeft = null, MyControl leftSearch = null)
|
|
{
|
|
this._searchSql = searchSql;
|
|
this._mainGridEx = mainGridEx;
|
|
if (this._mainGridEx != null) this._gridControl = _mainGridEx.GridControl;
|
|
this._tvLeft = treeView;
|
|
this._gridLeft = gridLeft;
|
|
this._leftSearch = leftSearch;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:设置GridControlEx</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2019-05-21 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="mainGridEx">The main grid ex.</param>
|
|
public void SetGridControlEx(GridControlEx mainGridEx)
|
|
{
|
|
this._mainGridEx = mainGridEx;
|
|
if (this._mainGridEx != null) this._gridControl = _mainGridEx.GridControl;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:设置GridLeft</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2019-05-21 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="mainGridEx">The main grid ex.</param>
|
|
public void SetGridLeft(GridControlEx gridLeft)
|
|
{
|
|
this._gridLeft = gridLeft;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:创建添加修改界面控件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-09-01 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="table">The table.</param>
|
|
/// <param name="parent">The parent.</param>
|
|
|
|
public int InitControl(DataTable controls, XtraScrollableControl parent, bool isSweepCode = true)
|
|
{
|
|
return this.InitControl(controls, parent, null, isSweepCode);
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:创建分页控件</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2021-04-23 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="table">The table.</param>
|
|
/// <param name="parent">The parent.</param>
|
|
|
|
public int InitPageControl(DataTable controls, DataTable groups, int PageCount)
|
|
{
|
|
List<int> startLocktion = new List<int>();
|
|
List<int> OverLocktion = new List<int>();
|
|
Dictionary<int, XtraTabPage> pageKey = new Dictionary<int, XtraTabPage>();
|
|
int width = 0, height = 0, x = 0, y = 0;
|
|
XtraTabControl tabpage = new XtraTabControl();
|
|
tabpage.Dock = DockStyle.Fill;
|
|
tabpage.Parent = _parentPanel;
|
|
this._parentPanel.Controls.Add(tabpage);
|
|
|
|
for (int i = 1; i <= PageCount; i++)
|
|
{
|
|
DataTable SelectGroups = groups.Select("PageOrder=" + i).CopyToDataTable();
|
|
DataRow rtGroup = SelectGroups.Rows[SelectGroups.Rows.Count - 1];
|
|
if (SelectGroups == null) continue;
|
|
XtraTabPage page = new XtraTabPage();
|
|
page.Text = rtGroup["pageName"] + "";
|
|
startLocktion.Add(Convert.ToInt32(SelectGroups.Rows[0]["controlTop"]));
|
|
OverLocktion.Add(Convert.ToInt32(rtGroup["controlTop"]) + Convert.ToInt32(rtGroup["controlHeight"]));
|
|
pageKey.Add(i, page);
|
|
foreach (DataRow groupdr in SelectGroups.Rows)
|
|
{
|
|
GroupBox group = new GroupBox();
|
|
group.Text = groupdr["groupName"] + "";
|
|
group.Width = Convert.ToInt32(groupdr["controlWidth"]);
|
|
group.Left = Convert.ToInt32(groupdr["controlLeft"]);
|
|
group.Top = i > 1 ? Convert.ToInt32(groupdr["controlTop"]) - OverLocktion[i - 2] : Convert.ToInt32(groupdr["controlTop"]);
|
|
group.Height = Convert.ToInt32(groupdr["controlHeight"]);
|
|
page.Controls.Add(group);
|
|
}
|
|
|
|
//if (xtr != null)
|
|
//{
|
|
// if (i == 1)
|
|
// {
|
|
// xtr.TabPages[0].Text = page.Text;
|
|
// }
|
|
// else
|
|
// {
|
|
// dummyPage.Text = page.Text;
|
|
// xtr.TabPages.Add(dummyPage);
|
|
// dummyPage.Tag = i;
|
|
// }
|
|
//}
|
|
tabpage.TabPages.Add(page);
|
|
}
|
|
foreach (DataRow item in controls.Rows)
|
|
{
|
|
ControlModel model = GetControlModel(item);
|
|
model.IsSearchControl = false;
|
|
System.Windows.Forms.Control control = InitControl(model);
|
|
if (control != null)
|
|
{
|
|
BaseUserControl baseControl = control as BaseUserControl;
|
|
System.Threading.SynchronizationContext.Current.Post(SetProperty, null);
|
|
void SetProperty(object state)
|
|
{
|
|
//放到外面避免线程问题
|
|
baseControl.Model = model;
|
|
baseControl.FontSize = model.FontSize;
|
|
baseControl.Name = "txt_" + model.FieldName;
|
|
baseControl.LabelText = model.LabelText;
|
|
baseControl.NullText = model.NullText;
|
|
//baseControl.EditText = model.DefaultValue;
|
|
baseControl.Location = model.Location;
|
|
baseControl.Size = model.Size;
|
|
if (!model.ReadOnly && !string.IsNullOrWhiteSpace(model.ControlTitleColor))
|
|
{
|
|
baseControl.ModifyDefaultColors(ColorTranslator.FromHtml(model.ControlTitleColor));
|
|
}
|
|
baseControl.ReadOnly = model.ReadOnly;
|
|
baseControl.Required = model.IsEmpty;
|
|
baseControl.Tag = model;
|
|
baseControl.TabIndex = model.TabOrder;
|
|
}
|
|
|
|
for (int i = 0; i < startLocktion.Count; i++)
|
|
{
|
|
if (startLocktion[i] < control.Top && control.Top < OverLocktion[i])
|
|
{
|
|
if (i > 0) control.Top -= OverLocktion[i - 1];
|
|
XtraTabPage page = pageKey[i + 1];
|
|
control.Parent = page;
|
|
int hgt = control.Top + control.Height;
|
|
|
|
if (hgt > height) height = hgt;
|
|
if (y == 0 || model.Location.Y < y) y = model.Location.Y;
|
|
if (model.Location.X >= x && model.Location.Y == y)
|
|
{
|
|
x = model.Location.X;
|
|
width = model.Location.X + model.Size.Width;
|
|
}
|
|
// 树结构类型直接隐藏,不根据配置显示.
|
|
if (model.FieldType == ControlType.LabTreeType)
|
|
control.Visible = false;
|
|
control.BringToFront();
|
|
}
|
|
}
|
|
}
|
|
this._models.Add(model);
|
|
}
|
|
this._parentPanel.Tag = tabpage;
|
|
return height;
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:构造控件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-03-20 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="controls">The controls.</param>
|
|
/// <param name="parent">The parent.</param>
|
|
/// <param name="groups">The groups.</param>
|
|
public int InitControl(DataTable controls, XtraScrollableControl parent, DataTable groups, bool isSweepCode = true)
|
|
{
|
|
if (controls == null) return 0;
|
|
this._parentPanel = parent;
|
|
this._controls = controls;
|
|
parent.SuspendLayout();
|
|
bool isExecute = true;
|
|
int width = 0, height = 0, x = 0, y = 0;
|
|
Console.WriteLine("构造控件:" + DateTime.Now);
|
|
if (groups != null && groups.Rows.Count > 0 && groups.Columns.Contains("pageOrder"))
|
|
{
|
|
string maxOrder = groups.Compute("max(pageOrder)", "") + "";
|
|
if (!string.IsNullOrEmpty(maxOrder))
|
|
{
|
|
isExecute = false;
|
|
height = InitPageControl(controls, groups, Convert.ToInt32(maxOrder));
|
|
}
|
|
}
|
|
if (isExecute)
|
|
{
|
|
Dictionary<object, Hashtable> dataCaches = Model != null ? Model.DataCaches : null;
|
|
dataCaches.GetValue(this, "Controls", out bool _);
|
|
foreach (DataRow item in controls.Rows)
|
|
{
|
|
if (!dataCaches.GetValue(item, "ControlModel", out ControlModel model))
|
|
{
|
|
model = GetControlModel(item);//获取控件对象
|
|
}
|
|
model.IsSearchControl = false;
|
|
//if (!dataCaches.GetValue(item, "Control", out System.Windows.Forms.Control control))
|
|
//{
|
|
// control = InitControl(model, isSweepCode);
|
|
//}
|
|
System.Windows.Forms.Control control = InitControl(model, isSweepCode);
|
|
if (control != null)
|
|
{
|
|
//放到外面避免线程问题
|
|
BaseUserControl baseControl = control as BaseUserControl;
|
|
baseControl.Model = model;
|
|
baseControl.FontSize = model.FontSize;
|
|
baseControl.Name = "txt_" + model.FieldName;
|
|
baseControl.LabelText = model.LabelText;
|
|
|
|
baseControl.NullText = model.NullText;
|
|
//baseControl.EditText = model.DefaultValue;
|
|
baseControl.Location = model.Location;
|
|
baseControl.Size = model.Size;
|
|
|
|
if (!model.ReadOnly && !string.IsNullOrWhiteSpace(model.ControlTitleColor))
|
|
{
|
|
baseControl.ModifyDefaultColors(ColorTranslator.FromHtml(model.ControlTitleColor));
|
|
}
|
|
|
|
baseControl.ReadOnly = model.ReadOnly;
|
|
baseControl.Required = model.IsEmpty;
|
|
baseControl.Tag = model;
|
|
baseControl.TabIndex = model.TabOrder;
|
|
|
|
control.Parent = parent;
|
|
int hgt = control.Top + control.Height;//5+21
|
|
|
|
if (hgt > height) height = hgt;//f
|
|
if (y == 0 || model.Location.Y < y) y = model.Location.Y;//f
|
|
if (model.Location.X >= x && model.Location.Y == y)
|
|
{
|
|
x = model.Location.X;
|
|
width = model.Location.X + model.Size.Width;
|
|
}
|
|
// 树结构类型直接隐藏,不根据配置显示.
|
|
if (model.FieldType == ControlType.LabTreeType)
|
|
control.Visible = false;
|
|
|
|
}
|
|
//if(model.Visible&& "1".Equals(model.DisableType)) control.Visible = false;
|
|
|
|
//配置了显示权限,并且不包含当前人员,控件设置的隐藏
|
|
if (!string.IsNullOrWhiteSpace(model.DisplayPermissions) && !model.DisplayPermissions.Split(',').Contains(ERPInfo.Instance.UserName))
|
|
{
|
|
control.Visible = false;
|
|
}
|
|
this._models.Add(model);
|
|
}
|
|
parent.Width = width;
|
|
parent.Height = height + 10;
|
|
if (groups != null && groups.Rows.Count > 0)
|
|
{
|
|
// 创建分组框
|
|
foreach (DataRow item in groups.Rows)
|
|
{
|
|
//GroupBox group = new GroupBox();
|
|
//group.Text = item["groupName"] + "";
|
|
//group.Width = Convert.ToInt32(item["controlWidth"]);
|
|
//group.Left = Convert.ToInt32(item["controlLeft"]);
|
|
//group.Top = Convert.ToInt32(item["controlTop"]);
|
|
//group.Height = Convert.ToInt32(item["controlHeight"]);
|
|
|
|
LabelGroupBox group = new LabelGroupBox();
|
|
group.Click += new EventHandler(OnGroupClick);
|
|
group.Text = item["groupName"] + "";
|
|
group.Font = new System.Drawing.Font(group.Font, System.Drawing.FontStyle.Bold);
|
|
group.Width = Convert.ToInt32(item["controlWidth"]);
|
|
group.Left = Convert.ToInt32(item["controlLeft"]);
|
|
group.Top = Convert.ToInt32(item["controlTop"]);
|
|
group.Height = Convert.ToInt32(item["controlHeight"]);
|
|
if (groups.Columns.Contains("titlePosition") && !string.IsNullOrWhiteSpace(item["titlePosition"] + "")) group.TitlePosition = Convert.ToInt32(item["titlePosition"]);
|
|
if (groups.Columns.Contains("borderColor") && !string.IsNullOrWhiteSpace(item["borderColor"] + "")) group.BorderColor = ColorTranslator.FromHtml(item["borderColor"] + "");
|
|
parent.Controls.Add(group);
|
|
group.SendToBack();
|
|
}
|
|
}
|
|
}
|
|
//this.SetAllControlValueByUnEmpty(this._models);
|
|
this._calcControls = this._models.FindAll(z => !string.IsNullOrEmpty(z.CalcExpr));
|
|
//关联值
|
|
//this.FindControl();
|
|
parent.ResumeLayout(false);
|
|
parent.PerformLayout();
|
|
Console.WriteLine("构造控件完成:" + DateTime.Now);
|
|
// 延迟加载数据源
|
|
this.mTimer.Tick += new EventHandler(mTimerTick);
|
|
this.mTimer.Start();
|
|
return height + 10;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:构造控件(添加分割线)</para>
|
|
/// <para>创建人:曹屹峰</para>
|
|
/// <para>创建日期:2022-02-14 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="controls">The controls.</param>
|
|
/// <param name="parent">The parent.</param>
|
|
/// <param name="groups">The groups.</param>
|
|
public int InitControl(DataTable controls, XtraScrollableControl parent, DataTable groups, bool isSweepCode, DataTable divider = null)
|
|
{
|
|
if (controls == null) return 0;
|
|
this._parentPanel = parent;
|
|
this._controls = controls;
|
|
parent.SuspendLayout();
|
|
bool isExecute = true;
|
|
int width = 0, height = 0, x = 0, y = 0;
|
|
Console.WriteLine("构造控件:" + DateTime.Now);
|
|
if (groups != null && groups.Rows.Count > 0 && groups.Columns.Contains("pageOrder"))
|
|
{
|
|
string maxOrder = groups.Compute("max(pageOrder)", "") + "";
|
|
if (!string.IsNullOrEmpty(maxOrder))
|
|
{
|
|
isExecute = false;
|
|
height = InitPageControl(controls, groups, Convert.ToInt32(maxOrder));
|
|
}
|
|
}
|
|
if (isExecute)
|
|
{
|
|
Dictionary<object, Hashtable> dataCaches = Model != null ? Model.DataCaches : null;
|
|
dataCaches.GetValue(this, "Controls", out bool _);
|
|
foreach (DataRow item in controls.Rows)
|
|
{
|
|
if (!dataCaches.GetValue(item, "ControlModel", out ControlModel model))
|
|
{
|
|
model = GetControlModel(item);//获取控件对象
|
|
}
|
|
model.IsSearchControl = false;
|
|
//if (!dataCaches.GetValue(item, "Control", out System.Windows.Forms.Control control))
|
|
//{
|
|
// control = InitControl(model, isSweepCode);
|
|
//}
|
|
System.Windows.Forms.Control control = InitControl(model, isSweepCode);
|
|
if (control != null)
|
|
{
|
|
//放到外面避免线程问题
|
|
BaseUserControl baseControl = control as BaseUserControl;
|
|
baseControl.Model = model;
|
|
baseControl.FontSize = model.FontSize;
|
|
baseControl.Name = "txt_" + model.FieldName;
|
|
baseControl.LabelText = model.LabelText;
|
|
baseControl.NullText = model.NullText;
|
|
//baseControl.EditText = model.DefaultValue;
|
|
baseControl.Location = model.Location;
|
|
baseControl.Size = model.Size;
|
|
if (!model.ReadOnly && !string.IsNullOrWhiteSpace(model.ControlTitleColor))
|
|
{
|
|
baseControl.ModifyDefaultColors(ColorTranslator.FromHtml(model.ControlTitleColor));
|
|
}
|
|
baseControl.ReadOnly = model.ReadOnly;
|
|
baseControl.Required = model.IsEmpty;
|
|
baseControl.Tag = model;
|
|
baseControl.TabIndex = model.TabOrder;
|
|
control.Parent = parent;
|
|
int hgt = control.Top + control.Height;
|
|
if (hgt > height) height = hgt;
|
|
if (y == 0 || model.Location.Y < y) y = model.Location.Y;
|
|
if (model.Location.X >= x && model.Location.Y == y)
|
|
{
|
|
x = model.Location.X;
|
|
width = model.Location.X + model.Size.Width;
|
|
}
|
|
// 树结构类型直接隐藏,不根据配置显示.
|
|
if (model.FieldType == ControlType.LabTreeType)
|
|
{
|
|
control.Visible = false;
|
|
}
|
|
}
|
|
this._models.Add(model);
|
|
}
|
|
foreach (DataRow dr in divider.Rows)
|
|
{
|
|
Label label = new Label();
|
|
label.AutoSize = false;
|
|
label.BorderStyle = BorderStyle.Fixed3D;
|
|
label.Top = int.Parse(dr["controlTop"] + "");
|
|
label.Left = int.Parse(dr["controlLeft"] + "");
|
|
label.Height = 2;
|
|
label.Width = int.Parse(dr["controlWidth"] + "");
|
|
parent.Controls.Add(label);
|
|
}
|
|
parent.Width = width;
|
|
parent.Height = height + 10;
|
|
if (groups != null && groups.Rows.Count > 0)
|
|
{
|
|
// 创建分组框
|
|
foreach (DataRow item in groups.Rows)
|
|
{
|
|
LabelGroupBox group = new LabelGroupBox();
|
|
group.Text = item["groupName"] + "";
|
|
group.Width = Convert.ToInt32(item["controlWidth"]);
|
|
group.Left = Convert.ToInt32(item["controlLeft"]);
|
|
group.Top = Convert.ToInt32(item["controlTop"]);
|
|
group.Height = Convert.ToInt32(item["controlHeight"]);
|
|
if (groups.Columns.Contains("titlePosition") && !string.IsNullOrWhiteSpace(item["titlePosition"] + "")) group.TitlePosition = Convert.ToInt32(item["titlePosition"]);
|
|
if (groups.Columns.Contains("borderColor") && !string.IsNullOrWhiteSpace(item["borderColor"] + "")) group.BorderColor = ColorTranslator.FromHtml(item["borderColor"] + "");
|
|
// group.BackColor= ColorTranslator.FromHtml("255,240, 240,240");
|
|
//group.BackColor = Color.White;
|
|
//group.Parent = parent;
|
|
parent.Controls.Add(group);
|
|
group.SendToBack();
|
|
}
|
|
}
|
|
}
|
|
//this.SetAllControlValueByUnEmpty(this._models);
|
|
this._calcControls = this._models.FindAll(z => !string.IsNullOrEmpty(z.CalcExpr));
|
|
//关联值
|
|
//this.FindControl();
|
|
parent.ResumeLayout(false);
|
|
parent.PerformLayout();
|
|
Console.WriteLine("构造控件完成:" + DateTime.Now);
|
|
// 延迟加载数据源
|
|
this.mTimer.Tick += new EventHandler(mTimerTick);
|
|
this.mTimer.Start();
|
|
return height + 10;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 构造控件,父控件大小自适应
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public void InitControl(DataTable controls, XtraScrollableControl parent, DataTable groups, out int parentHeight, out int parentWidth, bool isSweepCode = true)
|
|
{
|
|
parentHeight = 0;
|
|
parentWidth = 0;
|
|
if (controls == null) return;
|
|
this._parentPanel = parent;
|
|
this._controls = controls;
|
|
parent.SuspendLayout();
|
|
bool isExecute = true;
|
|
int x = 0, y = 0;
|
|
Console.WriteLine("构造控件:" + DateTime.Now);
|
|
if (groups != null && groups.Rows.Count > 0 && groups.Columns.Contains("pageOrder"))
|
|
{
|
|
string maxOrder = groups.Compute("max(pageOrder)", "") + "";
|
|
if (!string.IsNullOrEmpty(maxOrder))
|
|
{
|
|
isExecute = false;
|
|
parentHeight = InitPageControl(controls, groups, Convert.ToInt32(maxOrder));
|
|
}
|
|
}
|
|
if (isExecute)
|
|
{
|
|
Dictionary<object, Hashtable> dataCaches = Model != null ? Model.DataCaches : null;
|
|
dataCaches.GetValue(this, "Controls", out bool _);
|
|
foreach (DataRow item in controls.Rows)
|
|
{
|
|
if (!dataCaches.GetValue(item, "ControlModel", out ControlModel model))
|
|
{
|
|
model = GetControlModel(item);//获取控件对象
|
|
}
|
|
model.IsSearchControl = false;
|
|
//if (!dataCaches.GetValue(item, "Control", out System.Windows.Forms.Control control))
|
|
//{
|
|
// control = InitControl(model, isSweepCode);
|
|
//}
|
|
System.Windows.Forms.Control control = InitControl(model, isSweepCode);
|
|
if (control != null)
|
|
{
|
|
//放到外面避免线程问题
|
|
BaseUserControl baseControl = control as BaseUserControl;
|
|
baseControl.Model = model;
|
|
baseControl.FontSize = model.FontSize;
|
|
baseControl.Name = "txt_" + model.FieldName;
|
|
baseControl.LabelText = model.LabelText;
|
|
|
|
baseControl.NullText = model.NullText;
|
|
//baseControl.EditText = model.DefaultValue;
|
|
baseControl.Location = model.Location;
|
|
baseControl.Size = model.Size;
|
|
|
|
if (!model.ReadOnly && !string.IsNullOrWhiteSpace(model.ControlTitleColor))
|
|
{
|
|
baseControl.ModifyDefaultColors(ColorTranslator.FromHtml(model.ControlTitleColor));
|
|
}
|
|
|
|
baseControl.ReadOnly = model.ReadOnly;
|
|
baseControl.Required = model.IsEmpty;
|
|
baseControl.Tag = model;
|
|
baseControl.TabIndex = model.TabOrder;
|
|
|
|
control.Parent = parent;
|
|
int hgt = control.Top + control.Height;//5+21
|
|
|
|
if (hgt > parentHeight) parentHeight = hgt;//f
|
|
if (y == 0 || model.Location.Y < y) y = model.Location.Y;//f
|
|
if (model.Location.X >= x && model.Location.Y == y)
|
|
{
|
|
x = model.Location.X;
|
|
parentWidth = model.Location.X + model.Size.Width;
|
|
}
|
|
// 树结构类型直接隐藏,不根据配置显示.
|
|
if (model.FieldType == ControlType.LabTreeType)
|
|
control.Visible = false;
|
|
}
|
|
this._models.Add(model);
|
|
}
|
|
parent.Width = parentWidth;
|
|
parent.Height = parentWidth + 10;
|
|
if (groups != null && groups.Rows.Count > 0)
|
|
{
|
|
// 创建分组框
|
|
foreach (DataRow item in groups.Rows)
|
|
{
|
|
//GroupBox group = new GroupBox();
|
|
//group.Text = item["groupName"] + "";
|
|
//group.Width = Convert.ToInt32(item["controlWidth"]);
|
|
//group.Left = Convert.ToInt32(item["controlLeft"]);
|
|
//group.Top = Convert.ToInt32(item["controlTop"]);
|
|
//group.Height = Convert.ToInt32(item["controlHeight"]);
|
|
LabelGroupBox group = new LabelGroupBox();
|
|
group.Text = item["groupName"] + "";
|
|
group.Width = Convert.ToInt32(item["controlWidth"]);
|
|
group.Left = Convert.ToInt32(item["controlLeft"]);
|
|
group.Top = Convert.ToInt32(item["controlTop"]);
|
|
group.Height = Convert.ToInt32(item["controlHeight"]);
|
|
if (groups.Columns.Contains("titlePosition") && !string.IsNullOrWhiteSpace(item["titlePosition"] + "")) group.TitlePosition = Convert.ToInt32(item["titlePosition"]);
|
|
if (groups.Columns.Contains("borderColor") && !string.IsNullOrWhiteSpace(item["borderColor"] + "")) group.BorderColor = ColorTranslator.FromHtml(item["borderColor"] + "");
|
|
parent.Controls.Add(group);
|
|
group.SendToBack();
|
|
}
|
|
}
|
|
}
|
|
//this.SetAllControlValueByUnEmpty(this._models);
|
|
this._calcControls = this._models.FindAll(z => !string.IsNullOrEmpty(z.CalcExpr));
|
|
//关联值
|
|
//this.FindControl();
|
|
parent.ResumeLayout(false);
|
|
parent.PerformLayout();
|
|
Console.WriteLine("构造控件完成:" + DateTime.Now);
|
|
// 延迟加载数据源
|
|
this.mTimer.Tick += new EventHandler(mTimerTick);
|
|
this.mTimer.Start();
|
|
return;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取数据源缓存
|
|
/// </summary>
|
|
/// <param name="cachesDic"></param>
|
|
/// <param name="isSweepCode"></param>
|
|
public void GetControlDataCaches(Dictionary<object, Hashtable> cachesDic, bool isSweepCode = true)
|
|
{
|
|
//获取通用数据
|
|
Task<DynamicModel> dynamicModelTask = cachesDic.GetTask<DynamicModel>(this, "DynamicModel");
|
|
Task<DataTable> controlsTableTask = cachesDic.GetTask<DataTable>(this, "ControlsTable");
|
|
Task<bool> InitSearchTask = cachesDic.AddTask(this, "Controls", new Task<bool>(() =>
|
|
{
|
|
DynamicModel dynamicModel = dynamicModelTask.Result;
|
|
DataTable controls = controlsTableTask.Result;
|
|
foreach (DataRow item in controls.Rows)
|
|
{
|
|
Task<string> defaultValueTask = cachesDic.AddTask(item, "DefaultValue", new Task<string>(() =>
|
|
{
|
|
return BaseImpl.GetDefaultValue(item["defaultValue"] + "", ParentKey, OtherParams);
|
|
}));
|
|
Task<ControlModel> controlModelTask = cachesDic.AddTask(item, "ControlModel", new Task<ControlModel>(() =>
|
|
{
|
|
ControlModel controlModel = GetControlModel(item);//获取控件对象
|
|
controlModel.IsSearchControl = true;
|
|
//Task<System.Windows.Forms.Control> controlTask = cachesDic.AddTask(item, "Control", new Task<System.Windows.Forms.Control>(() =>
|
|
//{
|
|
// return InitControl(controlModel, isSweepCode);//创建控件
|
|
//}));
|
|
return controlModel;
|
|
}));
|
|
}
|
|
Task<DataTable> rightDtGridRightMenusTask = cachesDic.AddTask(this, "RightDtGridRightMenus", new Task<DataTable>(() =>
|
|
{
|
|
return BaseModuleImpl.GetBaseGridRightMenus(dynamicModel.ModuleCode, ModuleType.MrpClickBtn);
|
|
}));
|
|
return true;
|
|
}));
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:创建查询条件控件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-09-04 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="controls">查询条件数据源</param>
|
|
/// <param name="parent">父容器面板</param>
|
|
/// <param name="schemes">筛选模版</param>
|
|
public int InitSearchControl(DataTable controls, PanelControl parent, DataTable schemes = null, DynamicModel dynamicModel = null, bool ConditionRefresh = false)
|
|
{
|
|
this._parentPanel = parent;
|
|
this._controls = controls;
|
|
this._schemes = schemes;
|
|
int MaxSize = 0;
|
|
int width = 0, height = 0, x = 0, y = 0;
|
|
Dictionary<object, Hashtable> dataCaches = Model != null ? Model.DataCaches : null;
|
|
dataCaches.GetValue(this, "SearchControls", out bool _);
|
|
foreach (DataRow item in controls.Rows)
|
|
{
|
|
if (!dataCaches.GetValue(item, "ControlModel", out ControlModel model))
|
|
{
|
|
model = GetControlModel(item);//获取控件对象
|
|
}
|
|
model.IsSearchControl = true;
|
|
//if (!dataCaches.GetValue(item, "Control", out System.Windows.Forms.Control control))
|
|
//{
|
|
// control = InitControl(model);//创建控件
|
|
//}
|
|
System.Windows.Forms.Control control = InitControl(model);//创建控件
|
|
if (control != null)
|
|
{
|
|
//放到外面避免线程问题
|
|
BaseUserControl baseControl = control as BaseUserControl;
|
|
|
|
baseControl.Model = model;
|
|
baseControl.FontSize = model.FontSize;
|
|
baseControl.Name = "txt_" + model.FieldName;
|
|
baseControl.LabelText = model.LabelText;
|
|
baseControl.NullText = model.NullText;
|
|
//baseControl.EditText = model.DefaultValue;
|
|
baseControl.Location = model.Location;
|
|
baseControl.Size = model.Size;
|
|
if (!model.ReadOnly && !string.IsNullOrWhiteSpace(model.ControlTitleColor))
|
|
{
|
|
baseControl.ModifyDefaultColors(ColorTranslator.FromHtml(model.ControlTitleColor));
|
|
}
|
|
baseControl.ReadOnly = model.ReadOnly;
|
|
baseControl.Required = model.IsEmpty;
|
|
baseControl.Tag = model;
|
|
baseControl.TabIndex = model.TabOrder;
|
|
control.Parent = parent;
|
|
|
|
MaxSize = model.FontSize > MaxSize ? model.FontSize : MaxSize;
|
|
int hgt = control.Top + control.Height;
|
|
if (hgt > height) height = hgt;
|
|
if (y == 0 || model.Location.Y < y) y = model.Location.Y;
|
|
if (model.Location.X >= x && model.Location.Y == y)
|
|
{
|
|
x = model.Location.X;
|
|
width = model.Location.X + model.Size.Width;
|
|
}
|
|
}
|
|
_models.Add(model);
|
|
}
|
|
//this.SetAllControlValueByUnEmpty(this._models);
|
|
// 创建搜索按钮
|
|
_button = new SimpleButton();
|
|
_button.Text = "搜索(&Q)";
|
|
_button.Name = "btnCondSearch";
|
|
_button.Parent = parent;
|
|
_button.Tag = this;
|
|
if (MaxSize > 0)
|
|
{
|
|
_button.AutoSize = true;
|
|
_button.Font = new Font(this._button.Font.FontFamily, MaxSize);
|
|
}
|
|
else
|
|
{
|
|
_button.Height = 24;
|
|
_button.Width = 75;
|
|
}
|
|
_button.Location = new Point(width + 5, y - 2);
|
|
_button.Click += new EventHandler(OnSimpleButtonClick);
|
|
|
|
width = _button.Location.X + _button.Width;
|
|
|
|
if (ConditionRefresh)
|
|
{
|
|
_refreshButton = new SimpleButton();
|
|
_refreshButton.Text = "刷新";
|
|
_refreshButton.Name = "dataRefresh";
|
|
_refreshButton.Parent = parent;
|
|
_refreshButton.Tag = this;
|
|
if (MaxSize > 0)
|
|
{
|
|
_refreshButton.AutoSize = true;
|
|
_refreshButton.Font = new Font(this._refreshButton.Font.FontFamily, MaxSize);
|
|
}
|
|
else
|
|
{
|
|
_refreshButton.Height = 24;
|
|
_refreshButton.Width = 75;
|
|
}
|
|
_refreshButton.Location = new Point(width + 5, y - 2);
|
|
_refreshButton.Click += new EventHandler(OnRefreshButtonClick);
|
|
|
|
width = _refreshButton.Location.X + _refreshButton.Width;
|
|
}
|
|
|
|
|
|
// 创建模版搜索
|
|
if (_schemes != null && ModuleId > 0 && _schemes.Rows.Count > 0)
|
|
{
|
|
_dropDown = new DropDownButton();
|
|
_dropDown.DropDownArrowStyle = DropDownArrowStyle.Show;
|
|
_dropDown.DropDownControl = this._popupMenu;
|
|
_dropDown.Parent = parent;
|
|
_dropDown.Height = 24;
|
|
_dropDown.Width = 75;
|
|
_dropDown.Location = new Point(width + 85, y - 2);
|
|
_dropDown.Text = "模版搜索";
|
|
_dropDown.Leave += new EventHandler(OnDropDownLeave);
|
|
|
|
width = _dropDown.Location.X + _dropDown.Width;
|
|
BarManager barManager1 = new BarManager();
|
|
_popupMenu.Manager = barManager1;
|
|
_popupMenu.Name = "pm_search";
|
|
CreateSearchScheme();
|
|
}
|
|
if (dynamicModel != null && !string.IsNullOrEmpty(dynamicModel.ModuleCode))
|
|
{
|
|
if (!dataCaches.GetValue(parent, "SysModel", out ModuleModel moduleModel))
|
|
{
|
|
moduleModel = new ModuleModel(MainImpl.GetSystemdllTab(dynamicModel.ModuleCode));
|
|
}
|
|
if (!string.IsNullOrEmpty(moduleModel.SearchCondFormModuleCode) && StaticControl.ConditionsPanelDic.ContainsKey(moduleModel.ModeCode))
|
|
{
|
|
btnCondSearch = new SimpleButton();
|
|
btnCondSearch.Text = "更多";
|
|
btnCondSearch.Name = "btnCondSearchForm";
|
|
btnCondSearch.Parent = parent;
|
|
btnCondSearch.Height = 24;
|
|
btnCondSearch.Width = 75;
|
|
btnCondSearch.Location = new Point(width + 5, y - 2);
|
|
ModuleConditionsPanelEx mcpex = StaticControl.ConditionsPanelDic[moduleModel.ModeCode];
|
|
btnCondSearch.Tag = mcpex;
|
|
btnCondSearch.Click += new EventHandler(OnBtnCondSearchClick);
|
|
}
|
|
}
|
|
DataTable rightDt = null;
|
|
if (dynamicModel != null)
|
|
{
|
|
if (!dataCaches.GetValue(parent, "RightDtGridRightMenus", out rightDt))
|
|
{
|
|
rightDt = BaseModuleImpl.GetBaseGridRightMenus(dynamicModel.ModuleCode, ModuleType.MrpClickBtn);
|
|
}
|
|
}
|
|
if (rightDt != null && rightDt.Rows.Count > 0)
|
|
{
|
|
this.mrpDyncModel = dynamicModel;
|
|
foreach (DataRow dataRow in rightDt.Rows)
|
|
{
|
|
GridRightMenuModel menuModel = new GridRightMenuModel(dataRow);
|
|
SimpleButton mrpBtn = new SimpleButton();
|
|
mrpBtnDic.Add(menuModel, mrpBtn);
|
|
mrpBtn.Name = menuModel.MenuId + "";
|
|
mrpBtn.Text = menuModel.MenuName;
|
|
|
|
mrpBtn.Parent = parent;
|
|
if (MaxSize > 0)
|
|
{
|
|
mrpBtn.AutoSize = true;
|
|
mrpBtn.Font = new Font(this._button.Font.FontFamily, MaxSize);
|
|
}
|
|
else
|
|
{
|
|
mrpBtn.Height = 24;
|
|
mrpBtn.Width = 75;
|
|
}
|
|
mrpBtn.Location = new Point(width + 5, y - 2);
|
|
width = mrpBtn.Location.X + mrpBtn.Width;
|
|
mrpBtn.Click += new EventHandler(OnModuleClick);
|
|
mrpBtn.Tag = menuModel;
|
|
}
|
|
parent.Visible = true;
|
|
}
|
|
// 延迟加载数据源
|
|
this.mTimer.Tick += new EventHandler(mTimerTick);
|
|
this.mTimer.Start();
|
|
return height == 0 ? 0 : height + 5;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:创建查询条件控件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-09-04 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:是否取消搜索按钮模式</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="controls">查询条件数据源</param>
|
|
/// <param name="parent">父容器面板</param>
|
|
/// <param name="schemes">筛选模版</param>
|
|
public int InitSearchControl(DataTable controls, PanelControl parent, bool isShowSearchBtn, DataTable schemes = null, DynamicModel dynamicModel = null)
|
|
{
|
|
this._parentPanel = parent;
|
|
this._controls = controls;
|
|
this._schemes = schemes;
|
|
int MaxSize = 0;
|
|
int width = 0, height = 0, x = 0, y = 0;
|
|
Dictionary<object, Hashtable> dataCaches = Model != null ? Model.DataCaches : null;
|
|
dataCaches.GetValue(this, "SearchControls", out bool _);
|
|
foreach (DataRow item in controls.Rows)
|
|
{
|
|
if (!dataCaches.GetValue(item, "ControlModel", out ControlModel model))
|
|
{
|
|
model = GetControlModel(item);//获取控件对象
|
|
}
|
|
model.IsSearchControl = true;
|
|
//if (!dataCaches.GetValue(item, "Control", out System.Windows.Forms.Control control))
|
|
//{
|
|
// control = InitControl(model);//创建控件
|
|
//}
|
|
System.Windows.Forms.Control control = InitControl(model);//创建控件
|
|
if (control != null)
|
|
{
|
|
//放到外面避免线程问题
|
|
BaseUserControl baseControl = control as BaseUserControl;
|
|
baseControl.Model = model;
|
|
baseControl.FontSize = model.FontSize;
|
|
baseControl.Name = "txt_" + model.FieldName;
|
|
baseControl.LabelText = model.LabelText;
|
|
|
|
baseControl.NullText = model.NullText;
|
|
//baseControl.EditText = model.DefaultValue;
|
|
baseControl.Location = model.Location;
|
|
baseControl.Size = model.Size;
|
|
|
|
if (!model.ReadOnly && !string.IsNullOrWhiteSpace(model.ControlTitleColor))
|
|
{
|
|
baseControl.ModifyDefaultColors(ColorTranslator.FromHtml(model.ControlTitleColor));
|
|
}
|
|
|
|
baseControl.ReadOnly = model.ReadOnly;
|
|
baseControl.Required = model.IsEmpty;
|
|
baseControl.Tag = model;
|
|
baseControl.TabIndex = model.TabOrder;
|
|
|
|
control.Parent = parent;
|
|
MaxSize = model.FontSize > MaxSize ? model.FontSize : MaxSize;
|
|
int hgt = control.Top + control.Height;
|
|
|
|
if (hgt > height) height = hgt;
|
|
if (y == 0 || model.Location.Y < y) y = model.Location.Y;
|
|
if (model.Location.X >= x && model.Location.Y == y)
|
|
{
|
|
x = model.Location.X;
|
|
width = model.Location.X + model.Size.Width;
|
|
}
|
|
}
|
|
_models.Add(model);
|
|
}
|
|
|
|
//this.SetAllControlValueByUnEmpty(this._models);
|
|
// 创建搜索按钮
|
|
_button = new SimpleButton();
|
|
_button.Text = "搜索(&Q)";
|
|
_button.Name = "btnCondSearch";
|
|
_button.Parent = parent;
|
|
_button.Tag = this;
|
|
if (MaxSize > 0)
|
|
{
|
|
_button.AutoSize = true;
|
|
_button.Font = new Font(this._button.Font.FontFamily, MaxSize);
|
|
}
|
|
else
|
|
{
|
|
_button.Height = 24;
|
|
_button.Width = 75;
|
|
}
|
|
_button.Location = new Point(width + 5, y - 2);
|
|
_button.Click += new EventHandler(OnSimpleButtonClick);
|
|
|
|
width = _button.Location.X + _button.Width;
|
|
|
|
if (!isShowSearchBtn)
|
|
{
|
|
_button.Visible = false;
|
|
width = width - _button.Width - 5;
|
|
}
|
|
// 创建模版搜索
|
|
if (_schemes != null && ModuleId > 0 && _schemes.Rows.Count > 0)
|
|
{
|
|
_dropDown = new DropDownButton();
|
|
_dropDown.DropDownArrowStyle = DropDownArrowStyle.Show;
|
|
_dropDown.DropDownControl = this._popupMenu;
|
|
_dropDown.Parent = parent;
|
|
_dropDown.Height = 24;
|
|
_dropDown.Width = 75;
|
|
_dropDown.Location = new Point(width + 85, y - 2);
|
|
_dropDown.Text = "模版搜索";
|
|
_dropDown.Leave += new EventHandler(OnDropDownLeave);
|
|
|
|
width = _dropDown.Location.X + _dropDown.Width;
|
|
BarManager barManager1 = new BarManager();
|
|
_popupMenu.Manager = barManager1;
|
|
_popupMenu.Name = "pm_search";
|
|
CreateSearchScheme();
|
|
}
|
|
DataTable rightDt = null;
|
|
if (dynamicModel != null)
|
|
{
|
|
if (!dynamicModel.DataCaches.GetValue(parent, "RightDtGridRightMenus", out rightDt))
|
|
{
|
|
rightDt = BaseModuleImpl.GetBaseGridRightMenus(dynamicModel.ModuleCode, ModuleType.MrpClickBtn);
|
|
}
|
|
}
|
|
if (rightDt != null && rightDt.Rows.Count > 0)
|
|
{
|
|
this.mrpDyncModel = dynamicModel;
|
|
foreach (DataRow dataRow in rightDt.Rows)
|
|
{
|
|
GridRightMenuModel menuModel = new GridRightMenuModel(dataRow);
|
|
SimpleButton mrpBtn = new SimpleButton();
|
|
mrpBtnDic.Add(menuModel, mrpBtn);
|
|
mrpBtn.Name = menuModel.MenuId + "";
|
|
mrpBtn.Text = menuModel.MenuName;
|
|
|
|
mrpBtn.Parent = parent;
|
|
if (MaxSize > 0)
|
|
{
|
|
mrpBtn.AutoSize = true;
|
|
mrpBtn.Font = new Font(this._button.Font.FontFamily, MaxSize);
|
|
}
|
|
else
|
|
{
|
|
mrpBtn.Height = 24;
|
|
mrpBtn.Width = 75;
|
|
}
|
|
mrpBtn.Location = new Point(width + 5, y - 2);
|
|
width = mrpBtn.Location.X + mrpBtn.Width;
|
|
mrpBtn.Click += new EventHandler(OnModuleClick);
|
|
mrpBtn.Tag = menuModel;
|
|
}
|
|
parent.Visible = true;
|
|
}
|
|
// 延迟加载数据源
|
|
this.mTimer.Tick += new EventHandler(mTimerTick);
|
|
this.mTimer.Start();
|
|
|
|
return height == 0 ? 0 : height + 5;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 获取数据源缓存
|
|
/// </summary>
|
|
/// <param name="cachesDic"></param>
|
|
public void GetSearchDataCaches(Dictionary<object, Hashtable> cachesDic)
|
|
{
|
|
//获取通用数据
|
|
Task<DynamicModel> dynamicModelTask = cachesDic.GetTask<DynamicModel>(this, "DynamicModel");
|
|
Task<DataTable> controlsTableTask = cachesDic.GetTask<DataTable>(this, "ControlsTable");
|
|
Task<bool> InitSearchTask = cachesDic.AddTask(this, "SearchControls", new Task<bool>(() =>
|
|
{
|
|
DynamicModel dynamicModel = dynamicModelTask.Result;
|
|
DataTable controls = controlsTableTask.Result;
|
|
foreach (DataRow item in controls.Rows)
|
|
{
|
|
Task<string> defaultValueTask = cachesDic.AddTask(item, "DefaultValue", new Task<string>(() =>
|
|
{
|
|
return BaseImpl.GetDefaultValue(item["defaultValue"] + "", ParentKey, OtherParams);
|
|
}));
|
|
Task<ControlModel> controlModelTask = cachesDic.AddTask(item, "ControlModel", new Task<ControlModel>(() =>
|
|
{
|
|
ControlModel controlModel = GetControlModel(item);//获取控件对象
|
|
controlModel.IsSearchControl = true;
|
|
//Task<System.Windows.Forms.Control> controlTask = cachesDic.AddTask(item, "Control", new Task<System.Windows.Forms.Control>(() =>
|
|
//{
|
|
// return InitControl(controlModel);//创建控件
|
|
//}));
|
|
return controlModel;
|
|
}));
|
|
}
|
|
Task<DataTable> rightDtGridRightMenusTask = cachesDic.AddTask(this, "RightDtGridRightMenus", new Task<DataTable>(() =>
|
|
{
|
|
return BaseModuleImpl.GetBaseGridRightMenus(dynamicModel.ModuleCode, ModuleType.MrpClickBtn);
|
|
}));
|
|
return true;
|
|
}));
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region
|
|
/// <summary>
|
|
/// <para>说明:模块点击</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-11-12 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <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>
|
|
private void OnModuleClick(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
try
|
|
{
|
|
WaitForm.ShowForm();
|
|
SimpleButton button = sender as SimpleButton;
|
|
if (button != null)
|
|
{
|
|
if (button.Tag is GridRightMenuModel)
|
|
{
|
|
GridRightMenuModel model = button.Tag as GridRightMenuModel;
|
|
|
|
ToolStripMenuItem toolStripMenuItem = this.MainGridEx.gridViewRightMenu.RightMenuMrpBtnEdits.ContainsKey(model.Id) ? this.MainGridEx.gridViewRightMenu.RightMenuMrpBtnEdits[model.Id] : null;
|
|
toolStripMenuItem.PerformClick();
|
|
//BaseRightMenu menu = new BaseRightMenu();
|
|
//menu.Model = this.mrpDyncModel;
|
|
//menu.ControlObj = this;
|
|
//if (menu.ExecRightMenu(model, new DataRow[] { null }) && model.Refresh)
|
|
//{
|
|
// this.SearchLastGrid();
|
|
//}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//MessageUtil.Show(ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
WaitForm.HideForm();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
#endregion
|
|
/// <summary>
|
|
/// <para>说明:创建默认查询条件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-16 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="controls">The controls.</param>
|
|
/// <param name="parent">The parent.</param>
|
|
public void InitDefaultSearchControl(DataTable controls, PanelControl parent)
|
|
{
|
|
this._controls = controls;
|
|
this._parentPanel = parent;
|
|
|
|
System.Windows.Forms.Control.ControlCollection childs = parent.Controls;//Control(控制) 对象的集合。
|
|
if (childs != null && childs.Count > 0)
|
|
{
|
|
try
|
|
{
|
|
this._fixField = childs.Find("cbField", true)[0] as System.Windows.Forms.ComboBox;
|
|
this._fixKey = childs.Find("txtFixKey", true)[0] as System.Windows.Forms.TextBox;
|
|
this._fixButton = childs.Find("btnFixSearch", true)[0] as SimpleButton;
|
|
this._fixButton.Click += new EventHandler(OnFixButtonClick);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//MessageUtil.Show("创建默认查询条件出错!" + ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:创建默认查询条件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-16 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="controls">The controls.</param>
|
|
/// <param name="parent">The parent.</param>
|
|
public void InitDefaultSearchControl(DataTable controls, PanelControl parent, bool isShowSearchBtn)
|
|
{
|
|
this._controls = controls;
|
|
this._parentPanel = parent;
|
|
|
|
System.Windows.Forms.Control.ControlCollection childs = parent.Controls;//Control(控制) 对象的集合。
|
|
if (childs != null && childs.Count > 0)
|
|
{
|
|
try
|
|
{
|
|
this._fixField = childs.Find("cbField", true)[0] as System.Windows.Forms.ComboBox;
|
|
this._fixKey = childs.Find("txtFixKey", true)[0] as System.Windows.Forms.TextBox;
|
|
this._fixButton = childs.Find("btnFixSearch", true)[0] as SimpleButton;
|
|
this._fixButton.Click += new EventHandler(OnFixButtonClick);
|
|
if (!isShowSearchBtn)
|
|
{
|
|
this._fixButton.Visible = false;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//MessageUtil.Show("创建默认查询条件出错!" + ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
}
|
|
public void InitDefaultSearchControl(DataTable controls, PanelControl parent, string _cbField, string _txtFixKey, string _btnFixSearch)
|
|
{
|
|
this._controls = controls;
|
|
this._parentPanel = parent;
|
|
|
|
System.Windows.Forms.Control.ControlCollection childs = parent.Controls;//Control(控制) 对象的集合。
|
|
if (childs != null && childs.Count > 0)
|
|
{
|
|
try
|
|
{
|
|
this._fixField = childs.Find(_cbField, true)[0] as System.Windows.Forms.ComboBox;
|
|
this._fixKey = childs.Find(_txtFixKey, true)[0] as System.Windows.Forms.TextBox;
|
|
this._fixButton = childs.Find(_btnFixSearch, true)[0] as SimpleButton;
|
|
this._fixButton.Click += new EventHandler(OnFixButtonClick);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//MessageUtil.Show("创建默认查询条件出错!" + ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:延迟加载数据源</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期: </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <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>
|
|
protected void mTimerTick(object sender, EventArgs e)
|
|
{
|
|
if (!mLoading)
|
|
{
|
|
mLoading = true;
|
|
try
|
|
{
|
|
WaitForm.ShowForm();
|
|
foreach (ControlModel model in mControlList)
|
|
{
|
|
try
|
|
{
|
|
if (!string.IsNullOrEmpty(model.SourceSql))
|
|
{
|
|
System.Windows.Forms.Control ctr = FindControl(model.FieldName);
|
|
if (model.FieldType == ControlType.LabAutoSelectControl)
|
|
{
|
|
model.SourceSql += "and 1<>1";
|
|
}
|
|
DataTable table = new DataTable();
|
|
if (!ControlType.IsNotLoadData(model.FieldType) && model.FieldType != ControlType.LabTreeType)
|
|
{
|
|
if (mControlSourceDic.ContainsKey(model))
|
|
{
|
|
table = mControlSourceDic[model].Result;
|
|
}
|
|
else
|
|
{
|
|
table = BaseImpl.GetDataTableResult(model.SourceSql);
|
|
}
|
|
}
|
|
//if (model.FieldType != ControlType.LabAutoCompleteValueParam && model.FieldType != ControlType.LabAutoCompleteTextParam && model.FieldType != ControlType.LabAutoCompleteValue && model.FieldType != ControlType.LabAutoCompleteText)
|
|
// table = MainImpl.GetDataTableResult(model.SourceSql);
|
|
//else
|
|
// table = MainImpl.GetDataTableResultGetTableStructure(model.SourceSql);
|
|
switch (model.FieldType)
|
|
{
|
|
case ControlType.LabComboxValue:
|
|
case ControlType.LabComboxText:
|
|
case ControlType.LabComboxValueParam:
|
|
case ControlType.LabComboxTextParam:
|
|
// 下拉框
|
|
LabelComboxEdit comboxEdit = ctr as LabelComboxEdit;
|
|
comboxEdit.SetDataSource(table);
|
|
comboxEdit.TextEdit.SelectedIndex = 0;
|
|
break;
|
|
case ControlType.LabAutoCompleteValue:
|
|
case ControlType.LabAutoCompleteText:
|
|
case ControlType.LabAutoCompleteValueParam:
|
|
case ControlType.LabAutoCompleteTextParam:
|
|
// 自动搜索框
|
|
if (!isRevTextEdit)
|
|
{
|
|
LabelAutoTextEdit autoTextEdit = ctr as LabelAutoTextEdit;
|
|
autoTextEdit.SetDataSource(table);
|
|
}
|
|
else
|
|
{
|
|
LabelAutoTextRevEdit autoTextEdit = ctr as LabelAutoTextRevEdit;
|
|
autoTextEdit.SetDataSource(table);
|
|
}
|
|
break;
|
|
case ControlType.LabMulitTreeValue:
|
|
case ControlType.LabMulitTreeText:
|
|
case ControlType.LabMulitTreeValueParam:
|
|
case ControlType.LabMulitTreeTextParam:
|
|
case ControlType.LabTreeLookValue:
|
|
case ControlType.LabTreeLookText:
|
|
case ControlType.LabCheckTreeLookValue:
|
|
case ControlType.LabCheckTreeLookText:
|
|
case ControlType.LabTreeLastlevelValue:
|
|
case ControlType.LabTreeLastlevelText:
|
|
case ControlType.LabCheckTreeLastlevelValue:
|
|
case ControlType.LabCheckTreeLastlevelText:
|
|
case ControlType.LabMultiComTreeboxValue:
|
|
case ControlType.LabMultiComTreeboxText:
|
|
case ControlType.LabMultiComTreeboxValueParam:
|
|
case ControlType.LabMultiComTreeboxTextParam:
|
|
// 表格树自动搜索框
|
|
LabelAutoTreeEdit autTreeEdit = ctr as LabelAutoTreeEdit;
|
|
autTreeEdit.SetDataSource(table);
|
|
break;
|
|
case ControlType.LabAutoGridValue:
|
|
case ControlType.LabAutoGridText:
|
|
case ControlType.LabAutoGridValueParam:
|
|
case ControlType.LabAutoGridTextParam:
|
|
// 智能搜索框
|
|
LabelAutoGridLook autoiGridEdit = ctr as LabelAutoGridLook;
|
|
autoiGridEdit.SetDataSource(table);
|
|
break;
|
|
case ControlType.LabMultiSelectText:
|
|
case ControlType.LabMultiSelectTextNew:
|
|
case ControlType.LabMultiSelectValue:
|
|
case ControlType.LabMultiSelectValueNew:
|
|
case ControlType.LabMultiSelectValueParam:
|
|
case ControlType.LabMultiSelectTextParam:
|
|
// 多选控件
|
|
LabelMultiAutoTextEdit multiAutiTextEdit = ctr as LabelMultiAutoTextEdit;
|
|
multiAutiTextEdit.SetDataSource(table);
|
|
break;
|
|
case ControlType.LabAutoSelectControl:
|
|
// 多选控件
|
|
LabelAutoTextSearch autoLookUpEdit = ctr as LabelAutoTextSearch;
|
|
autoLookUpEdit.SetDataSource(table);
|
|
break;
|
|
case ControlType.LabCheckMultiSelectValue:
|
|
case ControlType.LabCheckMultiSelectText:
|
|
case ControlType.LabCheckMultiSelectValueParam:
|
|
case ControlType.LabCheckMultiSelectTextParam:
|
|
// 带复选框多选控件
|
|
LabelCheckMultiAutoTextEdit checkMultiAutoTextEdit = ctr as LabelCheckMultiAutoTextEdit;
|
|
checkMultiAutoTextEdit.MultiAutoEdit.SetDataSource(table);
|
|
break;
|
|
|
|
case ControlType.LabCheckComboxText:
|
|
case ControlType.LabCheckComboxValue:
|
|
// 带复选框下拉框
|
|
LabelCheckComboxEdit checkComboxEdit = ctr as LabelCheckComboxEdit;
|
|
checkComboxEdit.ComboxEdit.SetDataSource(table);
|
|
break;
|
|
case ControlType.LabCheckAutoSeacherValue:
|
|
case ControlType.LabCheckAutoSeacherText:
|
|
// 带复选框自动搜索框
|
|
LabelCheckAutoTextEdit checkAutoTextEdit = ctr as LabelCheckAutoTextEdit;
|
|
checkAutoTextEdit.AutoTextEdit.SetDataSource(table);
|
|
break;
|
|
case ControlType.LabSelectReturnId:
|
|
case ControlType.LabSelectReturnText:
|
|
LabelMultiAutoTextEdit2 moduleReturnsId = ctr as LabelMultiAutoTextEdit2;
|
|
moduleReturnsId.SetDataSource(table);
|
|
break;
|
|
case ControlType.DynamicallyGeneratedSql:
|
|
LabelMultiAutoTextEdit3 moduleSqlGenerated = ctr as LabelMultiAutoTextEdit3;
|
|
//moduleSqlGenerated.SetDataSource(table);
|
|
break;
|
|
case ControlType.HighShotMeter:
|
|
HighShotMeterTextEdit highShotMeterTextEdit = ctr as HighShotMeterTextEdit;
|
|
//moduleSqlGenerated.SetDataSource(table);
|
|
break;
|
|
case ControlType.LabCheckText:
|
|
LabelCheckText labelCheckText = ctr as LabelCheckText;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
}
|
|
changeLabelAutoGridLooks.Clear();
|
|
// 设置值和关联值
|
|
foreach (ControlModel model in mControlList)
|
|
{
|
|
|
|
if (model.FieldType == ControlType.LabTreeType)
|
|
{
|
|
SetControlValue(model, this.ParentKey);
|
|
}
|
|
else if (!string.IsNullOrEmpty(model.DefaultValue))
|
|
{
|
|
string defaultValue = this.SystemModel != null ? ReplaceHelper.ReplaceRowParam(this.SystemModel.maintabFocusedRow, model.DefaultValue) : model.DefaultValue;
|
|
SetControlValue(model, defaultValue);
|
|
}
|
|
}
|
|
//智能搜索框第一次加载时手动触发
|
|
if (changeLabelAutoGridLooks.Count > 0)
|
|
{
|
|
foreach (string controlName in changeLabelAutoGridLooks.Keys)
|
|
{
|
|
BaseUserControl baseControl = FindControl(controlName);
|
|
// 手动触发关联,有可能单据打开后直接点击新增按钮此时文本框值未改变,不会触发关联和计算
|
|
this.SetUnionAncCalcControl(baseControl);
|
|
}
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
}
|
|
finally
|
|
{
|
|
WaitForm.HideForm();
|
|
mControlSourceDic.Clear();
|
|
if (this.OnDataSourceBindCallBack != null) this.OnDataSourceBindCallBack(this, null);
|
|
this.mTimer.Stop();
|
|
this.mTimer.Dispose();
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:拷贝控件值</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-12-12 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="rowItem">The row item.</param>
|
|
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
|
public void CopyControlValue(bool refreshSearchSource = false)
|
|
{
|
|
try
|
|
{
|
|
foreach (ControlModel model in this.ControlModels)
|
|
{
|
|
BaseUserControl control = FindControl(model);
|
|
if (control != null)
|
|
{
|
|
if (!model.CanCopy)
|
|
{
|
|
// 不允许复制控件,情况数据
|
|
this.SetControlValue(model, BaseImpl.GetDefaultValue(model.Default, ParentKey));
|
|
}
|
|
else
|
|
{
|
|
//// 允许复制控件,需检查是否有关联字段,有关联字段需要赋值
|
|
//if (!string.IsNullOrEmpty(model.UnionFields) && !string.IsNullOrEmpty(model.UnionValues))
|
|
//{
|
|
// this.SetUnionAncCalcControl(control);
|
|
//}
|
|
// 允许复制,假如为空则看是否有默认值
|
|
if (!string.IsNullOrEmpty(model.Default) && string.IsNullOrEmpty(GetControlValue(model)))
|
|
{
|
|
this.SetControlValue(model, BaseImpl.GetDefaultValue(model.Default, ParentKey));
|
|
}
|
|
}
|
|
|
|
//下拉框赋数据源
|
|
if (control.Model.FieldType == ControlType.LabAutoCompleteValueParam || control.Model.FieldType == ControlType.LabAutoCompleteTextParam || control.Model.FieldType == ControlType.LabAutoCompleteValue || control.Model.FieldType == ControlType.LabAutoCompleteText)//如果为搜索框带参数类型控件,需要在赋值前刷新数据源
|
|
{
|
|
string controlValue = string.Empty;
|
|
//自动搜索框如果有默认值,就在设置默认值时赋数据源。否则在点击时加载数据源
|
|
if (model.FieldName.EndsWith("operatorid", StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
controlValue = ERPInfo.Instance.UserId;
|
|
}
|
|
else if (model.FieldName.EndsWith("operatorname", StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
controlValue = ERPInfo.Instance.UserName;
|
|
}
|
|
else if (model.FieldName.EndsWith("operatedate", StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
controlValue = DateTime.Now.ToString();
|
|
}
|
|
else
|
|
{
|
|
controlValue = BaseImpl.GetDefaultValue(model.Default, ParentKey, OtherParams); ;
|
|
}
|
|
if (refreshSearchSource)
|
|
{
|
|
SerSearchBoxDataSource(control, controlValue + "");
|
|
}
|
|
}
|
|
// 特殊处理:
|
|
// 1. 登录ID、登录名称、操作时间3个字段重置设置为当前人员和时间.
|
|
// 2. 允许复制的字段才赋值,否则无视.
|
|
if (model.FieldName.ToLower().EndsWith("operatorid"))
|
|
control.EditText = ERPInfo.Instance.UserId;
|
|
if (model.FieldName.ToLower().EndsWith("operatorname"))
|
|
control.EditText = ERPInfo.Instance.UserName;
|
|
if (model.FieldName.ToLower().EndsWith("operatedate"))
|
|
control.EditText = DateTime.Now.ToString();
|
|
}
|
|
}
|
|
|
|
foreach (ControlModel model in this.ControlModels)
|
|
{
|
|
BaseUserControl control = FindControl(model);
|
|
// 树结构节点不清空数据
|
|
if (control != null && model.FieldType != ControlType.LabTreeType)
|
|
{
|
|
this.SetUnionAncCalcControl(control);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//MessageUtil.Show("拷贝控件值出错!" + ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 查找下一个跳转控件
|
|
/// </summary>
|
|
/// <param name="baseControl"></param>
|
|
/// <returns></returns>
|
|
public BaseUserControl FindNextControl(BaseUserControl baseControl, out bool isSaveSkip)
|
|
{
|
|
isSaveSkip = false;
|
|
BaseUserControl control = null;
|
|
if (baseControl == null)
|
|
return control;
|
|
try
|
|
{
|
|
DataTable columnsInfo = SqlHelper.ExecuteDataTable(string.Format("select * from P_SYSTEMWORDBOOKTAB where formkey='{0}' and fieldname='{1}'", baseControl.Model.FormKey, baseControl.Model.FieldName));
|
|
if (columnsInfo != null && columnsInfo.Rows.Count > 0)
|
|
{
|
|
string nextOrder = columnsInfo.Rows[0].Table.Columns.Contains("nextOrder") ? columnsInfo.Rows[0]["nextOrder"] + "" : "";
|
|
if (!string.IsNullOrEmpty(nextOrder))
|
|
{
|
|
nextOrder = nextOrder.TrimStart('@');
|
|
nextOrder = this.ReplaceParentControlValue(nextOrder);
|
|
nextOrder = this.ReplaceControlValue(nextOrder);
|
|
string returnStr = SqlHelper.ExecuteScalar(nextOrder.TrimStart('@')) + "";
|
|
if (!string.IsNullOrEmpty(returnStr))
|
|
{
|
|
if (returnStr.StartsWith("@"))
|
|
{
|
|
isSaveSkip = true;
|
|
returnStr = returnStr.TrimStart('@');
|
|
}
|
|
string fieldName = SqlHelper.ExecuteScalar(string.Format("select fieldname from P_SYSTEMWORDBOOKTAB where formkey='{0}' and id='{1}'", baseControl.Model.FormKey, returnStr)) + "";
|
|
if (!string.IsNullOrEmpty(fieldName))
|
|
{
|
|
control = FindControl(fieldName);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
return control;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:查找控件(无需要传入txt_)</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-08 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="controlName">Name of the control.</param>
|
|
/// <returns>BaseUserControl.</returns>
|
|
public BaseUserControl FindControl(string controlName)
|
|
{
|
|
if (_parentPanel == null) return null;
|
|
System.Windows.Forms.Control controlObj = new System.Windows.Forms.Control();
|
|
if (_parentPanel.Tag is XtraTabControl)
|
|
{
|
|
XtraTabControl tabcontrol = _parentPanel.Tag as XtraTabControl;
|
|
foreach (XtraTabPage page in tabcontrol.TabPages)
|
|
{
|
|
if (page.Tag is GridDetailModel)
|
|
{
|
|
continue;
|
|
}
|
|
controlObj = page.Controls
|
|
.Cast<System.Windows.Forms.Control>()
|
|
.FirstOrDefault(x => x.Name.Equals("txt_" + controlName, StringComparison.OrdinalIgnoreCase));
|
|
if (controlObj != null && controlObj is BaseUserControl)
|
|
{
|
|
return controlObj as BaseUserControl;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
controlObj = _parentPanel.Controls
|
|
.Cast<System.Windows.Forms.Control>()
|
|
.FirstOrDefault(x => x.Name.Equals("txt_" + controlName, StringComparison.OrdinalIgnoreCase));
|
|
|
|
}
|
|
if (controlObj != null && controlObj is BaseUserControl)
|
|
{
|
|
return controlObj as BaseUserControl;
|
|
}
|
|
return null;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:查找控件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-08 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="model">The model.</param>
|
|
/// <returns>BaseUserControl.</returns>
|
|
public BaseUserControl FindControl(ControlModel model)
|
|
{
|
|
if (model == null) return null;
|
|
|
|
return this.FindControl(model.FieldName);
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-05-30 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="cardType">Type of the card.</param>
|
|
/// <returns>BaseUserControl.</returns>
|
|
public BaseUserControl FindControl(IDCardType cardType)
|
|
{
|
|
if (this._models != null)
|
|
{
|
|
ControlModel model = this._models.FirstOrDefault(x => x.Sign == (int)cardType);
|
|
return FindControl(model);
|
|
}
|
|
return null;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:根据类型查询控件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-04-03 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="controlType">Type of the control.</param>
|
|
/// <returns>BaseUserControl.</returns>
|
|
public BaseUserControl[] FindControls(int controlType)
|
|
{
|
|
ControlModel[] models = this.ControlModels.Where(x => x.FieldType == controlType).ToArray();
|
|
if (models != null && models.Length > 0)
|
|
{
|
|
BaseUserControl[] controls = new BaseUserControl[models.Length];
|
|
|
|
for (int i = 0; i < controls.Length; i++)
|
|
{
|
|
controls[i] = FindControl(models[i]);
|
|
}
|
|
return controls;
|
|
}
|
|
return new BaseUserControl[] { };
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:获取字段为空时,保存存值处理</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-05-28 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="model">The model.</param>
|
|
/// <returns>System.String.</returns>
|
|
public string GetNullValue(ControlModel model)
|
|
{
|
|
string empty = string.Empty;
|
|
switch (model.FieldType)
|
|
{
|
|
case ControlType.LabDate:
|
|
case ControlType.LabDateTime:
|
|
case ControlType.LabDateTimeShort:
|
|
case ControlType.LabTime:
|
|
case ControlType.LabShortTime:
|
|
case ControlType.LabShortDate:
|
|
|
|
empty = "NULL,";
|
|
break;
|
|
default:
|
|
empty = "'',";
|
|
break;
|
|
}
|
|
return empty;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:获取控件值</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-09-04 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="controlName">Name of the control.</param>
|
|
/// <returns>System.String.</returns>
|
|
public string GetControlValue(string controlName, bool isCondReplace = false)
|
|
{
|
|
string value = string.Empty;
|
|
var ctrs = _parentPanel.Controls.Find("txt_" + controlName, true);
|
|
if (ctrs != null && ctrs.Length > 0)
|
|
{
|
|
var ctr = ctrs[0];
|
|
BaseUserControl uControl = ctr as BaseUserControl;
|
|
if (uControl == null || uControl.Model == null) return ctr.Text;
|
|
|
|
ControlModel model = uControl.Model;
|
|
switch (model.FieldType)
|
|
{
|
|
case ControlType.LabDate:
|
|
case ControlType.LabDateTime:
|
|
case ControlType.LabDateTimeShort:
|
|
case ControlType.LabTime:
|
|
case ControlType.LabShortTime:
|
|
// 日期控件
|
|
LabelDateEdit dateEdit = ctr as LabelDateEdit;
|
|
if (string.IsNullOrWhiteSpace(dateEdit.FormatType))
|
|
{
|
|
value = dateEdit.EditText;
|
|
}
|
|
else
|
|
{
|
|
value = dateEdit.TextEdit.EditValue == null ? dateEdit.EditText : dateEdit.TextEdit.EditValue.ToString();
|
|
}
|
|
//value = dateEdit.TextEdit.EditValue == null ? dateEdit.EditText : dateEdit.TextEdit.EditValue.ToString();
|
|
break;
|
|
case ControlType.LabShortDate:
|
|
//为保存和表格保存格式相同。默认取EditValue值
|
|
LabelDateEdit dateEditNew = ctr as LabelDateEdit;
|
|
value = dateEditNew.TextEdit.EditValue == null ? dateEditNew.EditText : dateEditNew.TextEdit.EditValue.ToString();
|
|
break;
|
|
case ControlType.LabComboxValue:
|
|
case ControlType.LabComboxText:
|
|
case ControlType.LabComboxValueParam:
|
|
case ControlType.LabComboxTextParam:
|
|
// 下拉框
|
|
LabelComboxEdit comboxEdit = ctr as LabelComboxEdit;
|
|
value = ControlType.LabComboxValue == model.FieldType || ControlType.LabComboxValueParam == model.FieldType ? comboxEdit.EditValue : comboxEdit.EditText;
|
|
break;
|
|
case ControlType.LabAutoCompleteValue:
|
|
case ControlType.LabAutoCompleteText:
|
|
case ControlType.LabAutoCompleteValueParam:
|
|
case ControlType.LabAutoCompleteTextParam:
|
|
// 自动搜索框
|
|
if (!isRevTextEdit)
|
|
{
|
|
LabelAutoTextEdit autoEdit = ctr as LabelAutoTextEdit;
|
|
value = ControlType.LabAutoCompleteValue == model.FieldType || ControlType.LabAutoCompleteValueParam == model.FieldType ? autoEdit.EditValue : autoEdit.EditText;
|
|
}
|
|
else
|
|
{
|
|
LabelAutoTextRevEdit autoEdit = ctr as LabelAutoTextRevEdit;
|
|
value = ControlType.LabAutoCompleteValue == model.FieldType || ControlType.LabAutoCompleteValueParam == model.FieldType ? autoEdit.EditValue : autoEdit.EditText;
|
|
}
|
|
break;
|
|
case ControlType.LabAutoGridValue:
|
|
case ControlType.LabAutoGridText:
|
|
case ControlType.LabAutoGridValueParam:
|
|
case ControlType.LabAutoGridTextParam:
|
|
// 智能搜索框
|
|
LabelAutoGridLook autoGridEdit = ctr as LabelAutoGridLook;
|
|
value = ControlType.LabAutoGridValue == model.FieldType || ControlType.LabAutoGridValueParam == model.FieldType ? autoGridEdit.EditValue : autoGridEdit.EditText;
|
|
break;
|
|
case ControlType.LabRemark:
|
|
// 备注框
|
|
LabelRemarkEdit remarkEdit = ctr as LabelRemarkEdit;
|
|
value = remarkEdit.EditText;
|
|
break;
|
|
case ControlType.LabMemoEdit:
|
|
// 备注框A
|
|
LabelMemoEdit memoEdit = ctr as LabelMemoEdit;
|
|
value = memoEdit.EditText;
|
|
break;
|
|
case ControlType.LabMemoSpaceEdit:
|
|
// 备注框A
|
|
LabelMemoSpaceEdit memoSpaceEdit = ctr as LabelMemoSpaceEdit;
|
|
value = memoSpaceEdit.EditText;
|
|
break;
|
|
case ControlType.LabCheckDateEx:
|
|
case ControlType.LabCheckDateTimeEx:
|
|
case ControlType.LabCheckDateTimeShort:
|
|
case ControlType.LabCheckTime:
|
|
case ControlType.LabCheckShortTime:
|
|
// 带复选框日期控件
|
|
LabelCheckDateEdit checkDateEdit = ctr as LabelCheckDateEdit;
|
|
value = (checkDateEdit.CheckEdit.Checked) ? checkDateEdit.TextEdit.EditValue + "" : "";
|
|
break;
|
|
case ControlType.LabMultiSelectText:
|
|
case ControlType.LabMultiSelectTextNew:
|
|
case ControlType.LabMultiSelectValue:
|
|
case ControlType.LabMultiSelectValueNew:
|
|
case ControlType.LabMultiSelectValueParam:
|
|
case ControlType.LabMultiSelectTextParam:
|
|
|
|
// 多选控件
|
|
LabelMultiAutoTextEdit multiAutoEdit = ctr as LabelMultiAutoTextEdit;
|
|
value = (ControlType.LabMultiSelectValue == model.FieldType || model.FieldType == ControlType.LabMultiSelectValueNew || ControlType.LabMultiSelectValueParam == model.FieldType) ? multiAutoEdit.EditValue : multiAutoEdit.EditText;
|
|
break;
|
|
case ControlType.LabTreeLookValue:
|
|
case ControlType.LabTreeLookText:
|
|
case ControlType.LabCheckTreeLookValue:
|
|
case ControlType.LabCheckTreeLookText:
|
|
case ControlType.LabTreeLastlevelValue:
|
|
case ControlType.LabTreeLastlevelText:
|
|
case ControlType.LabCheckTreeLastlevelValue:
|
|
case ControlType.LabCheckTreeLastlevelText:
|
|
case ControlType.LabMulitTreeValue:
|
|
case ControlType.LabMulitTreeValueParam:
|
|
case ControlType.LabMulitTreeText:
|
|
case ControlType.LabMulitTreeTextParam:
|
|
case ControlType.LabMultiComTreeboxValue:
|
|
case ControlType.LabMultiComTreeboxText:
|
|
case ControlType.LabMultiComTreeboxValueParam:
|
|
case ControlType.LabMultiComTreeboxTextParam:
|
|
// 多选控件
|
|
LabelAutoTreeEdit autoTreeEdit = ctr as LabelAutoTreeEdit;
|
|
value = (ControlType.LabMultiComTreeboxValueParam == model.FieldType || ControlType.LabMultiComTreeboxValue == model.FieldType || ControlType.LabMulitTreeValue == model.FieldType || ControlType.LabMulitTreeValueParam == model.FieldType || ControlType.LabTreeLookValue == model.FieldType || ControlType.LabCheckTreeLookValue == model.FieldType || ControlType.LabTreeLastlevelValue == model.FieldType || ControlType.LabCheckTreeLastlevelValue == model.FieldType) ? autoTreeEdit.EditValue : autoTreeEdit.EditText;
|
|
break;
|
|
case ControlType.LabCheckMultiSelectValue:
|
|
case ControlType.LabCheckMultiSelectText:
|
|
case ControlType.LabCheckMultiSelectValueParam:
|
|
case ControlType.LabCheckMultiSelectTextParam:
|
|
// 带复选框多选控件
|
|
LabelCheckMultiAutoTextEdit checkmultiAutoEdit = ctr as LabelCheckMultiAutoTextEdit;
|
|
if (checkmultiAutoEdit.CheckEdit.Checked)
|
|
{
|
|
value = (ControlType.LabCheckMultiSelectValue == model.FieldType || ControlType.LabCheckMultiSelectValueParam == model.FieldType) ? checkmultiAutoEdit.MultiAutoEdit.EditValue : checkmultiAutoEdit.MultiAutoEdit.EditText;
|
|
|
|
}
|
|
break;
|
|
case ControlType.LabCheckComboxText:
|
|
case ControlType.LabCheckComboxValue:
|
|
// 带复选框下拉框
|
|
LabelCheckComboxEdit checkComboxEdit = ctr as LabelCheckComboxEdit;
|
|
if (checkComboxEdit.CheckEdit.Checked)
|
|
{
|
|
if (isCondReplace && checkComboxEdit.ComboxEdit.TextEdit.Properties.Items.Count > 0 && string.IsNullOrEmpty(checkComboxEdit.ComboxEdit.EditText + ""))
|
|
{
|
|
checkComboxEdit.ComboxEdit.TextEdit.SelectedIndex = 0;
|
|
}
|
|
value = (ControlType.LabCheckComboxValue == model.FieldType) ? checkComboxEdit.ComboxEdit.EditValue : checkComboxEdit.ComboxEdit.EditText;
|
|
}
|
|
break;
|
|
case ControlType.LabCheckAutoSeacherValue:
|
|
case ControlType.LabCheckAutoSeacherText:
|
|
// 带复选框自动搜索框
|
|
LabelCheckAutoTextEdit checkAutoTextEdit = ctr as LabelCheckAutoTextEdit;
|
|
if (checkAutoTextEdit.CheckEdit.Checked)
|
|
{
|
|
value = (ControlType.LabCheckAutoSeacherValue == model.FieldType) ? checkAutoTextEdit.AutoTextEdit.EditValue : checkAutoTextEdit.AutoTextEdit.EditText;
|
|
}
|
|
break;
|
|
case ControlType.LabWWW:
|
|
// 网址框
|
|
LabelBrowserEdit browserEdit = ctr as LabelBrowserEdit;
|
|
value = browserEdit.EditText;
|
|
break;
|
|
case ControlType.LabQQ:
|
|
// QQ框
|
|
LabelQQEdit qqEdit = ctr as LabelQQEdit;
|
|
value = qqEdit.EditText;
|
|
break;
|
|
case ControlType.LabCalcText:
|
|
// 计算器
|
|
LabelCalcEdit calcEdit = ctr as LabelCalcEdit;
|
|
value = calcEdit.EditText;
|
|
break;
|
|
case ControlType.LabRichEdit:
|
|
// 富文本编辑框
|
|
LabelRichEdit richEdit = ctr as LabelRichEdit;
|
|
value = richEdit.EditText;
|
|
break;
|
|
case ControlType.LabCheckBox:
|
|
// 复选框
|
|
LabelCheckEdit checkEdit = ctr as LabelCheckEdit;
|
|
value = checkEdit.EditText;
|
|
break;
|
|
//数字编辑框
|
|
case ControlType.LabTextInt:
|
|
LabelTextEdit textIntEdit = ctr as LabelTextEdit;
|
|
if (textIntEdit != null) value = string.IsNullOrEmpty(textIntEdit.EditText) ? "0" : textIntEdit.EditText;
|
|
break;
|
|
case ControlType.LabComboxPopupValue:
|
|
case ControlType.LabComboxPopupText:
|
|
// 弹出下拉列表框
|
|
LabelComboxPopupEdit comboxPopupEdit = ctr as LabelComboxPopupEdit;
|
|
value = ControlType.LabComboxPopupValue == model.FieldType ? comboxPopupEdit.EditValue : comboxPopupEdit.EditText;
|
|
break;
|
|
case ControlType.LabComboxPopupMutilValue:
|
|
case ControlType.LabComboxPopupMutilText:
|
|
// 弹出多选列表框
|
|
LabelComboxMutilPopupEdit comboxMutilPopupEdit = ctr as LabelComboxMutilPopupEdit;
|
|
value = ControlType.LabComboxPopupMutilValue == model.FieldType ? comboxMutilPopupEdit.EditValue : comboxMutilPopupEdit.EditText;
|
|
break;
|
|
case ControlType.LabRadioGroupValue:
|
|
case ControlType.LabRadioGroupText:
|
|
// 单选按钮组
|
|
LabelRadioButtonGroupEdit radioButtonGroupEdit = ctr as LabelRadioButtonGroupEdit;
|
|
value = radioButtonGroupEdit.EditText;
|
|
break;
|
|
case ControlType.LabIntExtend:
|
|
// 数字扩展
|
|
LabelIntExtendEdit intExtendEdit = ctr as LabelIntExtendEdit;
|
|
value = intExtendEdit.EditText;
|
|
break;
|
|
case ControlType.LabGridPopupValue:
|
|
case ControlType.LabGridPopupText:
|
|
case ControlType.LabGridPopupMutilValue:
|
|
case ControlType.LabGridPopupMutilText:
|
|
LabelGridSelectEdit gridSelectEdit = ctr as LabelGridSelectEdit;
|
|
value = ControlType.LabGridPopupValue == model.FieldType || ControlType.LabGridPopupMutilValue == model.FieldType ? gridSelectEdit.EditValue : gridSelectEdit.EditText;
|
|
break;
|
|
case ControlType.LabSelectReturnId:
|
|
case ControlType.LabSelectReturnText:
|
|
LabelMultiAutoTextEdit2 moduleReturnsId = ctr as LabelMultiAutoTextEdit2;
|
|
value = ControlType.LabSelectReturnId == model.FieldType ? moduleReturnsId.EditValue : moduleReturnsId.EditText;
|
|
break;
|
|
case ControlType.LabSelectReturnIdNew:
|
|
case ControlType.LabSelectReturnTextNew:
|
|
LabelMultiAutoTextEdit4 moduleReturnsIdNew = ctr as LabelMultiAutoTextEdit4;
|
|
value = ControlType.LabSelectReturnIdNew == model.FieldType ? moduleReturnsIdNew.EditValue : moduleReturnsIdNew.EditText;
|
|
break;
|
|
case ControlType.DynamicallyGeneratedSql:
|
|
LabelMultiAutoTextEdit3 moduleSqlGenerated = ctr as LabelMultiAutoTextEdit3;
|
|
value = moduleSqlGenerated.EditText;
|
|
break;
|
|
case ControlType.HighShotMeter:
|
|
HighShotMeterTextEdit highShotMeterTextEdit = ctr as HighShotMeterTextEdit;
|
|
value = highShotMeterTextEdit.EditText;
|
|
break;
|
|
case ControlType.LabCheckText:
|
|
LabelCheckText labelCheckText = ctr as LabelCheckText;
|
|
if (labelCheckText.CheckEdit.Checked)
|
|
{
|
|
value = labelCheckText.LabelTextEdit.EditText;
|
|
}
|
|
break;
|
|
case ControlType.Weigh:
|
|
LabelWeigh labelWeigh = ctr as LabelWeigh;
|
|
if (labelWeigh != null) value = labelWeigh.EditText;
|
|
break;
|
|
case ControlType.LabText:
|
|
default:
|
|
// 文本控件
|
|
LabelTextEdit textEdit = ctr as LabelTextEdit;
|
|
if (textEdit != null) value = textEdit.EditText;
|
|
break;
|
|
}
|
|
}
|
|
return value;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:获取控件值</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-09-04 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="model">The model.</param>
|
|
/// <returns>System.String.</returns>
|
|
public string GetControlValue(ControlModel model)
|
|
{
|
|
if (model == null) return string.Empty;
|
|
return GetControlValue(model.FieldName);
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:获取所有控件值</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-09-04 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns>System.String.</returns>
|
|
public string GetAllControlValue()
|
|
{
|
|
string values = string.Empty;
|
|
|
|
foreach (ControlModel model in _models)
|
|
{
|
|
values += model.FieldName + "=" + GetControlValue(model.FieldName) + "|";
|
|
}
|
|
|
|
return values.TrimEnd('|');
|
|
}
|
|
/// <summary>
|
|
/// 获取所有控件值,转换为DataRow行数据
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public DataRow GetAllControlValueRow()
|
|
{
|
|
DataTable dataTable = new DataTable();
|
|
foreach (ControlModel model in _models)
|
|
{
|
|
dataTable.Columns.Add(model.FieldName);
|
|
}
|
|
DataRow dataRow = dataTable.NewRow();
|
|
foreach (ControlModel model in _models)
|
|
{
|
|
dataRow[model.FieldName] = GetControlValue(model.FieldName);
|
|
}
|
|
dataTable.Rows.Add(dataRow);
|
|
return dataRow;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:从当前面板查找控件替换{xxx}值</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-12-06 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="defaultValue">The default value.</param>
|
|
public string ReplaceControlValue(string defaultValue)
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(defaultValue))
|
|
{
|
|
defaultValue = ReplaceHelper.ReplaceUserInfo(defaultValue);
|
|
var paramList = ReplaceHelper.GetParamFields(defaultValue);
|
|
foreach (string item in paramList)
|
|
{
|
|
string field = item.Replace("{", "").Replace("}", "");
|
|
if (FindControl(field) != null)
|
|
{
|
|
string value = GetControlValue(field);
|
|
defaultValue = defaultValue.Replace(item, value);
|
|
}
|
|
//else {
|
|
// defaultValue = defaultValue.Replace(item, "");
|
|
//}
|
|
}
|
|
}
|
|
return defaultValue;
|
|
}
|
|
public string ReplaceControlPmsValue(string defaultValue, BaseUserControl baseControl)
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(defaultValue))
|
|
{
|
|
string pmsStr = "";
|
|
if (Lskj.Util.ReplaceHelper.SubstringCount(defaultValue, "#") > 1)
|
|
{
|
|
try
|
|
{
|
|
pmsStr = defaultValue.Substring(defaultValue.IndexOf('#'), defaultValue.LastIndexOf('#') + 1 - defaultValue.IndexOf('#'));
|
|
if (!string.IsNullOrEmpty(pmsStr))//存在##参数
|
|
{
|
|
//defaultValue = defaultValue.Replace("#", "");
|
|
defaultValue = ReplaceHelper.ReplaceUserInfo(defaultValue);
|
|
var paramList = ReplaceHelper.GetParamFields(pmsStr);
|
|
|
|
if (paramList.Count == 0) defaultValue = defaultValue.Replace(defaultValue.Substring(defaultValue.IndexOf('#'), defaultValue.LastIndexOf('#') + 1 - defaultValue.IndexOf('#')), "1=1");
|
|
|
|
foreach (string item in paramList)
|
|
{
|
|
string field = item.Replace("{", "").Replace("}", "");
|
|
BaseUserControl conditionalControl = FindControl(field);
|
|
decimal OederId = 0;
|
|
decimal newOederId = 0;
|
|
decimal.TryParse(baseControl.Model.OrderId, out OederId);
|
|
decimal.TryParse(conditionalControl.Model.OrderId, out newOederId);
|
|
if (conditionalControl != null && newOederId < OederId)
|
|
{
|
|
string value = GetControlValue(field);
|
|
defaultValue = defaultValue.Replace(item, value);
|
|
}
|
|
else
|
|
{
|
|
defaultValue = defaultValue.Replace(defaultValue.Substring(defaultValue.IndexOf('#'), defaultValue.LastIndexOf('#') + 1 - defaultValue.IndexOf('#')), "1=1");
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
defaultValue = defaultValue.Replace("#", "");
|
|
}
|
|
catch (Exception)
|
|
{
|
|
defaultValue = defaultValue.Replace(defaultValue.Substring(defaultValue.IndexOf('#'), defaultValue.LastIndexOf('#') + 1 - defaultValue.IndexOf('#')), "1=1");
|
|
}
|
|
}
|
|
}
|
|
return defaultValue;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 不弹出搜索窗口模式下设置字符串和值
|
|
/// </summary>
|
|
/// <param name="strText"></param>
|
|
/// <param name="strValue"></param>
|
|
public void SetValueSilent(ControlModel model, string sValue, string sText)
|
|
{
|
|
string conditions = string.Empty;
|
|
string conditionValue = string.Empty;
|
|
|
|
if (string.IsNullOrWhiteSpace(sValue.Trim()) && !string.IsNullOrWhiteSpace(sText.Trim()))
|
|
{
|
|
conditions = model.TextMember;
|
|
conditionValue = sText;
|
|
|
|
}
|
|
else if (!string.IsNullOrWhiteSpace(sValue.Trim()))
|
|
{
|
|
conditions = model.ValueMember;
|
|
conditionValue = sValue.Trim();
|
|
}
|
|
try
|
|
{
|
|
string strSql = model.SourceSql;
|
|
if (string.IsNullOrEmpty(model.SourceSql)) return;
|
|
strSql = Lskj.Business.Impl.BaseImpl.GetDefaultValue(strSql);
|
|
strSql = ReplaceHelper.ReplaceParam(strSql);
|
|
if (!string.IsNullOrEmpty(strSql))
|
|
{
|
|
//if (strSql.IndexOf("order by", StringComparison.OrdinalIgnoreCase) != -1)
|
|
//{
|
|
// int indexOrder = strSql.IndexOf("order by", StringComparison.OrdinalIgnoreCase);
|
|
// string sOrder = string.Empty;
|
|
// if (indexOrder != -1)
|
|
// {
|
|
// sOrder = strSql.Substring(indexOrder, strSql.Length - indexOrder);
|
|
// strSql = "select * from (" + strSql.Substring(0, indexOrder - 1) + ") as t where " + conditions + "='" + conditionValue + "' " + sOrder;
|
|
// }
|
|
//}
|
|
//else
|
|
//{
|
|
// strSql = "select * from (" + strSql + ") as t where " + conditions + "='" + conditionValue + "'";
|
|
//}
|
|
|
|
strSql = "select * from (" + strSql + ") as t where " + conditions + "='" + conditionValue + "'";
|
|
}
|
|
DataTable dt = SqlHelper.ExecuteDataSet(strSql).Tables[0];
|
|
if ((dt != null) && (dt.Rows.Count > 0))
|
|
{
|
|
System.Windows.Forms.Control ctr = FindControl(model.FieldName);
|
|
LabelAutoTextEdit autoTextEdit = ctr as LabelAutoTextEdit;
|
|
autoTextEdit.TextEdit._popup.GridControlObj.DataSource = dt;
|
|
autoTextEdit.TextEdit._popup.Model = autoTextEdit.TextEdit.Model;
|
|
autoTextEdit.TextEdit.SetGridViewColumns(dt as DataTable);
|
|
//autoTextEdit.TextEdit.DataSourceTable = dt.Copy();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
DataTable dt = MainImpl.GetDataTableResult(model.SourceSql);
|
|
System.Windows.Forms.Control ctr = FindControl(model.FieldName);
|
|
LabelAutoTextEdit autoTextEdit = ctr as LabelAutoTextEdit;
|
|
autoTextEdit.TextEdit._popup.GridControlObj.DataSource = dt;
|
|
autoTextEdit.TextEdit._popup.Model = autoTextEdit.TextEdit.Model;
|
|
autoTextEdit.TextEdit.SetGridViewColumns(dt as DataTable);
|
|
//autoTextEdit.TextEdit.DataSourceTable = dt.Copy();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 把控件值带入控件sql中精准修改sql
|
|
/// </summary>
|
|
public string SetValueSilentSql(ControlModel model, string sql, string sValue, string sText)
|
|
{
|
|
string conditions = string.Empty;
|
|
string conditionValue = string.Empty;
|
|
|
|
if (string.IsNullOrWhiteSpace(sValue.Trim()) && !string.IsNullOrWhiteSpace(sText.Trim()))
|
|
{
|
|
conditions = model.TextMember;
|
|
conditionValue = sText;
|
|
|
|
}
|
|
else if (!string.IsNullOrWhiteSpace(sValue.Trim()))
|
|
{
|
|
conditions = model.ValueMember;
|
|
conditionValue = sValue.Trim();
|
|
}
|
|
try
|
|
{
|
|
string strSql = sql;
|
|
strSql = Lskj.Business.Impl.BaseImpl.GetDefaultValue(strSql);
|
|
strSql = ReplaceHelper.ReplaceParam(strSql);
|
|
if (!string.IsNullOrEmpty(strSql))
|
|
{
|
|
//if (strSql.IndexOf("order by", StringComparison.OrdinalIgnoreCase) != -1)
|
|
//{
|
|
// int indexOrder = strSql.IndexOf("order by", StringComparison.OrdinalIgnoreCase);
|
|
// string sOrder = string.Empty;
|
|
// if (indexOrder != -1)
|
|
// {
|
|
// sOrder = strSql.Substring(indexOrder, strSql.Length - indexOrder);
|
|
// strSql = "select * from (" + strSql.Substring(0, indexOrder - 1) + ") as t where " + conditions + "='" + conditionValue + "' " + sOrder;
|
|
// }
|
|
//}
|
|
//else
|
|
//{
|
|
// strSql = "select * from (" + strSql + ") as t where " + conditions + "='" + conditionValue + "'";
|
|
//}
|
|
strSql = "select * from (" + strSql + ") as t where " + conditions + "='" + conditionValue + "'";
|
|
}
|
|
|
|
return strSql;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return sql;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <para>说明:从当前面板查找控件替换{#xxx}值</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-04-20 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="defaultValue">The default value.</param>
|
|
/// <returns>System.String.</returns>
|
|
public string ReplaceParentControlValue(string defaultValue)
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(defaultValue))
|
|
{
|
|
var paramList = ReplaceHelper.GetParamFields(defaultValue);
|
|
foreach (string item in paramList)
|
|
{
|
|
string field = item.Replace("{#", "").Replace("}", "").Replace("{", "");
|
|
if (item.Contains("{#"))
|
|
{
|
|
|
|
string value = GetControlValue(field);
|
|
defaultValue = defaultValue.Replace(item, value);
|
|
}
|
|
else
|
|
if (FindControl(field) != null)
|
|
{
|
|
string value = GetControlValue(field);
|
|
defaultValue = defaultValue.Replace(item, value);
|
|
}
|
|
}
|
|
}
|
|
return defaultValue;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:重置控件值</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-12-12 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
|
public bool ResetControlValue(bool ManuallyTriggerCorrelation = false, bool refreshSearchSource = false)
|
|
{
|
|
foreach (ControlModel model in this.ControlModels)
|
|
{
|
|
BaseUserControl control = FindControl(model);
|
|
if (model.IsFixedValue) continue;//清空时该控件是否忽略
|
|
|
|
if (control.Model.FieldType == ControlType.LabAutoCompleteValueParam || control.Model.FieldType == ControlType.LabAutoCompleteTextParam || control.Model.FieldType == ControlType.LabAutoCompleteValue || control.Model.FieldType == ControlType.LabAutoCompleteText || control.Model.FieldType == ControlType.LabAutoGridText || control.Model.FieldType == ControlType.LabAutoGridValue || control.Model.FieldType == ControlType.LabAutoGridTextParam || control.Model.FieldType == ControlType.LabAutoGridValueParam)//如果为搜索框带参数类型控件,需要在赋值前刷新数据源
|
|
{
|
|
string controlValue = string.Empty;
|
|
//自动搜索框如果有默认值,就在设置默认值时赋数据源。否则在点击时加载数据源
|
|
if (model.FieldName.EndsWith("operatorid", StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
controlValue = ERPInfo.Instance.UserId;
|
|
}
|
|
else if (model.FieldName.EndsWith("operatorname", StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
controlValue = ERPInfo.Instance.UserName;
|
|
}
|
|
else if (model.FieldName.EndsWith("operatedate", StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
controlValue = DateTime.Now.ToString();
|
|
}
|
|
else
|
|
{
|
|
controlValue = BaseImpl.GetDefaultValue(model.Default, ParentKey, OtherParams);
|
|
}
|
|
if (refreshSearchSource)
|
|
{
|
|
SerSearchBoxDataSource(control, controlValue + "");
|
|
}
|
|
}
|
|
// 树结构节点不清空数据
|
|
if (control != null && model.FieldType != ControlType.LabTreeType)
|
|
{
|
|
if (model.FieldType == ControlType.LabPic)
|
|
{
|
|
LabelPictureEdit picEdit = control as LabelPictureEdit;
|
|
picEdit.TextEdit.Image = null;
|
|
}
|
|
else if (model.FieldType == ControlType.LabPicEx)
|
|
{
|
|
LabelImageEdit imageEdit = control as LabelImageEdit;
|
|
imageEdit.TextEdit.Image = null;
|
|
}
|
|
//清空多选选中值
|
|
else if (model.FieldType == ControlType.LabMultiSelectValue || model.FieldType == ControlType.LabMultiSelectValueNew)
|
|
{
|
|
LabelMultiAutoTextEdit multiEdit = control as LabelMultiAutoTextEdit;
|
|
multiEdit.ClearSelectForm();
|
|
multiEdit.EditText = "";
|
|
}
|
|
else
|
|
{
|
|
try
|
|
{
|
|
if (model.FieldName.EndsWith("operatorid", StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
control.Model.Text = control.EditText = ERPInfo.Instance.UserId;
|
|
}
|
|
else if (model.FieldName.EndsWith("operatorname", StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
control.Model.Text = control.EditText = ERPInfo.Instance.UserName;
|
|
}
|
|
else if (model.FieldName.EndsWith("operatedate", StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
control.EditText = DateTime.Now.ToString();
|
|
control.Model.Text = DateTime.Now.ToString();
|
|
}
|
|
else
|
|
{
|
|
model.DefaultValue = BaseImpl.GetDefaultValue(model.Default, ParentKey, OtherParams);
|
|
control.EditText = model.DefaultValue;
|
|
control.Model.Text = model.DefaultValue;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Instance.WriteError(ex);
|
|
LogUtil.WriteError("", ex);
|
|
MessageUtil.Show(ex.Message);
|
|
}
|
|
}
|
|
// 手动触发关联,有可能单据打开后直接点击新增按钮此时文本框值未改变,不会触发关联和计算
|
|
if (ManuallyTriggerCorrelation) this.SetUnionAncCalcControl(control);
|
|
|
|
}
|
|
}
|
|
foreach (ControlModel model in this.ControlModels)
|
|
{
|
|
BaseUserControl control = FindControl(model);
|
|
if (model.IsFixedValue) continue;//清空时该控件是否忽略
|
|
// 树结构节点不清空数据
|
|
if (control != null && model.FieldType != ControlType.LabTreeType)
|
|
{
|
|
this.SetUnionAncCalcControl(control);
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:验证数据合法性</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-06 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
|
public bool VerifyNull()
|
|
{
|
|
foreach (System.Windows.Forms.Control item in _parentPanel.Controls)
|
|
{
|
|
if (item is XtraTabControl)
|
|
{
|
|
return VerifyRecurNull(item);
|
|
}
|
|
if (item is BaseUserControl)
|
|
{
|
|
var baseControl = item as BaseUserControl;
|
|
if (baseControl.IsEmpty())
|
|
{
|
|
baseControl.Focus();
|
|
MessageUtil.Show(string.Format(baseControl.Model.TipMsg, baseControl.LabelText));
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:当处于数据通过page分割时递归验证是否是必填</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2022-02-22 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
|
public bool VerifyRecurNull(System.Windows.Forms.Control ControlObj)
|
|
{
|
|
foreach (System.Windows.Forms.Control item in ControlObj.Controls)
|
|
{
|
|
if (item is BaseUserControl)
|
|
{
|
|
var baseControl = item as BaseUserControl;
|
|
if (baseControl.IsEmpty())
|
|
{
|
|
baseControl.Focus();
|
|
MessageUtil.Show(string.Format(baseControl.Model.TipMsg, baseControl.LabelText));
|
|
return false;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return VerifyRecurNull(item);
|
|
}
|
|
}
|
|
return true;
|
|
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:判断是否是必填列</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2020-12-17 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="columns">The columns.</param>
|
|
public bool isRequiredFields(string requiredFields)
|
|
{
|
|
bool install = true;
|
|
string[] Fields = requiredFields.Split(',');
|
|
foreach (System.Windows.Forms.Control item in _parentPanel.Controls)
|
|
{
|
|
//if (item is BaseUserControl)
|
|
//{
|
|
// BaseUserControl baseControl = item as BaseUserControl;
|
|
// if (Fields.Cast<string>().FirstOrDefault(x => "txt_" + x == baseControl.Name) != null && string.IsNullOrWhiteSpace(baseControl.EditText))
|
|
// {
|
|
// baseControl.Focus();
|
|
// MessageUtil.Show(string.Format(baseControl.Model.TipMsg, baseControl.LabelText));
|
|
// install = false;
|
|
// }
|
|
//}
|
|
install = isRequiredFieldsNew(install, item, requiredFields);
|
|
}
|
|
return install;
|
|
}
|
|
|
|
public bool isRequiredFieldsNew(bool install, System.Windows.Forms.Control control, string requiredFields)
|
|
{
|
|
string[] Fields = requiredFields.Split(',');
|
|
|
|
if (control is BaseUserControl)
|
|
{
|
|
BaseUserControl baseControl = control as BaseUserControl;
|
|
if (Fields.Cast<string>().FirstOrDefault(x => "txt_" + x == baseControl.Name) != null && string.IsNullOrWhiteSpace(baseControl.EditText))
|
|
{
|
|
baseControl.Focus();
|
|
MessageUtil.Show(string.Format(baseControl.Model.TipMsg, baseControl.LabelText));
|
|
install = false;
|
|
}
|
|
}
|
|
if (control is XtraTabControl || control is XtraTabPage)
|
|
{
|
|
foreach (System.Windows.Forms.Control item in control.Controls)
|
|
{
|
|
install = isRequiredFieldsNew(install, item, requiredFields);
|
|
}
|
|
}
|
|
return install;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <para>说明:验证数据是否改过过</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-06 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
|
public bool VerifyUpdated()
|
|
{
|
|
bool results = false;
|
|
|
|
foreach (System.Windows.Forms.Control item in _parentPanel.Controls)
|
|
{
|
|
//if (item is BaseUserControl)
|
|
//{
|
|
// var baseControl = item as BaseUserControl;
|
|
// // 日期控件后面处理
|
|
// if (baseControl.IsUpdate())
|
|
// {
|
|
// return true;
|
|
// }
|
|
//}
|
|
results = VerifyUpdatedNew(item);
|
|
if (results) return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public bool VerifyUpdatedNew(System.Windows.Forms.Control control)
|
|
{
|
|
if (control is BaseUserControl)
|
|
{
|
|
var baseControl = control as BaseUserControl;
|
|
// 日期控件后面处理
|
|
if (baseControl.IsUpdate())
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
if (control is XtraTabControl || control is XtraTabPage)
|
|
{
|
|
foreach (System.Windows.Forms.Control item in control.Controls)
|
|
{
|
|
if (VerifyUpdatedNew(item)) return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 获取导入返回控件的名称
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public List<string> getImportReturnValueControl()
|
|
{
|
|
List<string> names = new List<string>();
|
|
|
|
foreach (System.Windows.Forms.Control item in _parentPanel.Controls)
|
|
{
|
|
if (item is BaseUserControl)
|
|
{
|
|
var baseControl = item as BaseUserControl;
|
|
if (baseControl.Model.ImportReturnValue || baseControl.Model.ImportCurrentValue)
|
|
{
|
|
names.Add(baseControl.Model.FieldName);
|
|
}
|
|
}
|
|
|
|
}
|
|
return names;
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <para>说明:同步本地数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-08 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
public void SyncLocalModel()
|
|
{
|
|
foreach (ControlModel model in this._models)
|
|
{
|
|
if (model.FieldType == ControlType.LabPicEx ||
|
|
model.FieldType == ControlType.LabPic)
|
|
continue;
|
|
|
|
model.Text = this.GetControlValue(model);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:保存面板数据到数据库中.适用于(基础档案、基础档案审核面板数据保存)</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-12-21 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="menuCode">模块编号</param>
|
|
/// <param name="tableName">需要保存的表</param>
|
|
/// <param name="primaryKey">模块主键</param>
|
|
/// <param name="primaryValue">模块主键值</param>
|
|
/// <param name="isAdd">添加保存(true)、修改保存(false)默认为添加</param>
|
|
/// <param name="leftField">需要保存关联左侧树、表格时传递左侧主字段</param>
|
|
/// <returns>返回保存成功于否</returns>
|
|
public bool SaveBaseModuleData(string menuCode, string tableName, string primaryKey, ref string primaryValue, bool isAdd = true, string leftField = "", bool isTip = true, int newVer = 0)
|
|
{
|
|
string execSql = string.Empty;
|
|
if (string.IsNullOrWhiteSpace(tableName))
|
|
{
|
|
MessageUtil.Show(ResourceKeys.NotSettingTableName);
|
|
return false;
|
|
}
|
|
string Autogrowcolumn = BaseImpl.GetResult(string.Format("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.columns WHERE TABLE_NAME='{0}' AND COLUMNPROPERTY(OBJECT_ID('{0}'),COLUMN_NAME,'IsIdentity')=1", tableName)) + "";
|
|
DataTable DatabasePropertySheet = BaseImpl.GetDataTableResult(string.Format("select COLUMN_NAME,DATA_TYPE,CHARACTER_MAXIMUM_LENGTH from information_schema.columns where table_name = '{0}'", tableName));//数据库属性表
|
|
string SaveErrorMessage = string.Empty;
|
|
StringBuilder fieldBuilder = new StringBuilder();
|
|
StringBuilder valueBuilder = new StringBuilder();
|
|
StringBuilder updateBuilder = new StringBuilder();
|
|
DataTable tableColumns = BaseImpl.GetTableColumns(tableName);
|
|
if (isAdd)
|
|
{
|
|
if (newVer == 0)
|
|
{
|
|
// 老版本进行编号验证
|
|
ControlModel model = this.ControlModels.FirstOrDefault(x => x.FieldName == primaryKey);
|
|
if (model != null && !model.Default.Contains("FIXED"))
|
|
{
|
|
string newBillNo = BaseImpl.GetDefaultValue(model.Default, ParentKey);
|
|
if (!primaryValue.Equals(newBillNo) && !string.IsNullOrEmpty(newBillNo))
|
|
{
|
|
if (this.SystemModel.hideSaveFaultMsg)//是否隐藏提示信息
|
|
{
|
|
SetControlValue(primaryKey, newBillNo);
|
|
primaryValue = newBillNo;
|
|
}
|
|
else
|
|
{
|
|
if (MessageUtil.Show(ResourceKeys.CurrentRecordRepeat, MessageBoxButtons.YesNo) == DialogResult.Yes)
|
|
{
|
|
SetControlValue(primaryKey, newBillNo);
|
|
primaryValue = newBillNo;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// 添加记录
|
|
foreach (ControlModel model in this.ControlModels)
|
|
{
|
|
if (!model.IsSave ||
|
|
leftField.Equals(model.FieldName) ||
|
|
"ID".Equals(model.FieldName, StringComparison.CurrentCultureIgnoreCase) ||
|
|
model.FieldType == ControlType.LabPic ||
|
|
model.FieldType == ControlType.LabPicEx || !tableColumns.Columns.Contains(model.FieldName) ||
|
|
Autogrowcolumn.ToLower() == model.FieldName.ToLower())
|
|
continue;
|
|
string fieldValue = this.GetControlValue(model);
|
|
if (fieldValue == "****") continue;
|
|
if (model.FieldType == 7)
|
|
{
|
|
if (fieldValue.Contains('%')) fieldValue = (double.Parse(fieldValue.Replace("%", "")) * 0.01).ToString();
|
|
if (fieldValue.Contains(',')) fieldValue = fieldValue.Replace(",", "");
|
|
}
|
|
fieldBuilder.Append(model.FieldName + ",");
|
|
SaveErrorMessage = SaveErrorMessage + DatabaseFormatJudgment.SaveOrModifyBalidation(DatabasePropertySheet, model, fieldValue);
|
|
if (string.IsNullOrEmpty(fieldValue) && model.Isintordecimal) fieldValue = "0";//数值保存时为空的话默认保存为0;
|
|
valueBuilder.Append(string.IsNullOrEmpty(fieldValue) ? GetNullValue(model) : string.Format("N'{0}',", fieldValue.Replace("'", "''")));
|
|
}
|
|
|
|
// 设置父节点
|
|
if (!string.IsNullOrWhiteSpace(leftField))
|
|
{
|
|
fieldBuilder.Append(leftField + ",");
|
|
valueBuilder.AppendFormat("N'{0}',", ParentKey);
|
|
}
|
|
|
|
if (ModuleResultDic != null && ModuleResultDic.Count > 0)
|
|
{
|
|
foreach (string resultKey in ModuleResultDic.Keys)
|
|
{
|
|
fieldBuilder.Append(resultKey + ",");
|
|
valueBuilder.AppendFormat("N'{0}',", ModuleResultDic[resultKey].Replace("'", "''"));
|
|
}
|
|
}
|
|
execSql = string.Format("insert into {0}({1}) values ({2})", tableName, fieldBuilder.ToString().TrimEnd(','), valueBuilder.ToString().TrimEnd(','));
|
|
}
|
|
else
|
|
{
|
|
// 修改记录
|
|
foreach (ControlModel model in this.ControlModels)
|
|
{
|
|
if (!model.IsSave ||
|
|
leftField.Equals(model.FieldName) ||
|
|
"ID".Equals(model.FieldName, StringComparison.CurrentCultureIgnoreCase) ||
|
|
model.FieldType == ControlType.LabPic ||
|
|
model.FieldType == ControlType.LabPicEx || !tableColumns.Columns.Contains(model.FieldName) ||
|
|
Autogrowcolumn.ToLower() == model.FieldName.ToLower())
|
|
continue;
|
|
BaseUserControl userControl = this.FindControl(model);
|
|
// userControl.IsUpdate() 保存所有数据
|
|
if (userControl != null)
|
|
{
|
|
string fieldValue = this.GetControlValue(model);
|
|
if (fieldValue == "****") continue;
|
|
if (model.FieldType == 7)
|
|
{
|
|
if (fieldValue.Contains('%')) fieldValue = (double.Parse(fieldValue.Replace("%", "")) * 0.01).ToString();
|
|
if (fieldValue.Contains(',')) fieldValue = fieldValue.Replace(",", "");
|
|
}
|
|
SaveErrorMessage = SaveErrorMessage + DatabaseFormatJudgment.SaveOrModifyBalidation(DatabasePropertySheet, model, fieldValue);
|
|
if (string.IsNullOrEmpty(fieldValue) && model.Isintordecimal) fieldValue = "0";//数值保存时为空的话默认保存为0;
|
|
updateBuilder.Append(string.IsNullOrEmpty(fieldValue) ? string.Format("{0}={1}", model.FieldName, GetNullValue(model)) : string.Format("{0}=N'{1}',", model.FieldName, fieldValue.Replace("'", "''")));
|
|
}
|
|
}
|
|
if (ModuleResultDic != null && ModuleResultDic.Count > 0)
|
|
{
|
|
foreach (string resultKey in ModuleResultDic.Keys)
|
|
{
|
|
updateBuilder.Append(string.Format("{0}=N'{1}',", resultKey, ModuleResultDic[resultKey].Replace("'", "''")));
|
|
}
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(updateBuilder.ToString()))
|
|
{
|
|
execSql = string.Format("update {0} set {1} where {2}='{3}'", tableName, updateBuilder.ToString().TrimEnd(','), primaryKey, primaryValue);
|
|
}
|
|
}
|
|
|
|
int result = 1;
|
|
BaseSaveModel saveModel = null;
|
|
|
|
if (!string.IsNullOrWhiteSpace(execSql))
|
|
{
|
|
saveModel = new BaseSaveModel
|
|
{
|
|
BaseSaveType = isAdd ? SaveType.Add : SaveType.Update,
|
|
BaseSql = execSql,
|
|
KeyField = primaryKey,
|
|
FieldValue = primaryValue,
|
|
MenuCode = menuCode,
|
|
TableName = tableName,
|
|
NewVer = newVer
|
|
};
|
|
try
|
|
{
|
|
result = BaseModuleImpl.SaveBasePanelData(saveModel);
|
|
SystemInfo.Instance.Reload = string.Empty;
|
|
SystemInfo.Instance.Reloadcond = string.Empty;
|
|
|
|
switch (result)
|
|
{
|
|
case 1:
|
|
//保存成功
|
|
if (newVer == 1 && saveModel.BaseSaveType == SaveType.Add)
|
|
saveModel.FieldValue = primaryValue = saveModel.FaultMsg;
|
|
this.PrimaryValue = primaryValue;
|
|
#region 修改保存成功后调用API
|
|
if (ApiHelper.IsExecEventApi(Interface.Api.OperateEvent.AfterModuleDataChange, saveModel.MenuCode, 0))
|
|
{
|
|
ApiHelper apiHelper = new ApiHelper(saveModel.MenuCode, saveModel.FieldValue, saveModel.KeyField, saveModel.TableName, 0);
|
|
switch (saveModel.BaseSaveType)
|
|
{
|
|
case SaveType.Add:
|
|
apiHelper.OnEvent(Interface.Api.OperateEvent.AfterModuleDataChange, Interface.Api.ActionType.Add);//添加
|
|
break;
|
|
case SaveType.Update:
|
|
apiHelper.OnEvent(Interface.Api.OperateEvent.AfterModuleDataChange, Interface.Api.ActionType.Update);//更新
|
|
break;
|
|
}
|
|
if (!string.IsNullOrEmpty(apiHelper.apiResutMsg))
|
|
MessageUtil.Show(apiHelper.apiResutMsg);
|
|
}
|
|
if (isTip) MessageUtil.Show(ResourceKeys.SaveSuccess);
|
|
#endregion
|
|
#region 保存成功后上传附件
|
|
string idValue = primaryValue;
|
|
if (SystemModel != null && !string.IsNullOrWhiteSpace(SystemModel.AttachmentAssociated))
|
|
{
|
|
idValue = GetControlValue(SystemModel.AttachmentAssociated);
|
|
}
|
|
List<ControlModel> uploadModels = ControlModels.Where(n => n.FileUploadControl).ToList();
|
|
foreach (ControlModel uploadModel in uploadModels)
|
|
{
|
|
BaseUserControl uploadControl = FindControl(uploadModel);
|
|
if (uploadControl != null && uploadControl is LabelRemarkEdit labelRemarkEdit && !string.IsNullOrEmpty(labelRemarkEdit.filepath) && File.Exists(labelRemarkEdit.filepath))
|
|
{
|
|
string filePath = labelRemarkEdit.filepath;
|
|
string token = UploadFileUtil.Login(SystemInfo.Instance.OAUrl);
|
|
if (!string.IsNullOrEmpty(token))
|
|
{
|
|
string speciesno = "010106";
|
|
byte[] fileBytes = UploadFileUtil.ConvertFileToBytes(filePath);
|
|
string fileStream = Convert.ToBase64String(fileBytes);
|
|
string selectSql = $"select * from P_fm_FileTab where parentid in (select dirid from P_fm_DirectoryTab where pid = '{idValue}' and dllcoid = '{Model.ModuleCode}') and speciesno = '{speciesno}' and sname = '{Path.GetFileName(filePath).Replace(" ", "")}'";
|
|
DataTable deleteTable = BaseImpl.GetDataTableResult(selectSql);
|
|
if (deleteTable != null && deleteTable.Rows.Count > 0)
|
|
{
|
|
foreach (DataRow deleteRow in deleteTable.Rows)
|
|
{
|
|
string field = HttpUtility.UrlEncode(deleteRow["fileId"] + "");
|
|
string webpath = HttpUtility.UrlEncode(deleteRow["webpath"] + "");
|
|
//删除文件
|
|
string deleteUrl = "{0}Api/FileUploadApi.ashx?fileId={1}&filename={2}&method={3}";
|
|
deleteUrl = string.Format(deleteUrl, SystemInfo.Instance.OAUrl, field, webpath, "DoDelete");
|
|
HttpHelper.Setting("application/x-www-form-urlencoded", null, null);
|
|
Dictionary<string, string> deleteHeaderDic = new Dictionary<string, string>();
|
|
deleteHeaderDic.Add("Authorization", $"Bearer {token}");
|
|
HttpHelper.Post(deleteUrl, fileStream, null, deleteHeaderDic, out string deleteResult);
|
|
}
|
|
}
|
|
string postUrl = "{0}Api/FileUploadApi.ashx?moduleId={1}&idValue={2}&speciesno={8}&folder={3}&totsize={4}&position={5}&filename={6}&method={7}";
|
|
postUrl = string.Format(postUrl, SystemInfo.Instance.OAUrl, Model.ModuleCode, HttpUtility.UrlEncode(idValue), "file", fileBytes.Length, 0, HttpUtility.UrlEncode(Path.GetFileName(filePath)), "DoWebUpload", speciesno);
|
|
bool isUpload = UploadFileUtil.UploadFile(token, postUrl, fileStream, out string fileId, out string rtnMsg);
|
|
if (!isUpload)
|
|
{
|
|
MessageUtil.Show($"自动上传失败\r\n{rtnMsg}");
|
|
}
|
|
else
|
|
{
|
|
string updateSql = $"update {SystemModel.MenuTable} set fileId = '{fileId}' where {SystemModel.ParmaryKey} = '{primaryValue}'";
|
|
BaseImpl.ExecSqlValue(updateSql);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
MessageUtil.Show($"登录失败,自动上传失败");
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
#region 保存后执行某个右键
|
|
if (SystemModel != null && !string.IsNullOrEmpty(SystemModel.AfterSaveExec))
|
|
{
|
|
DataRow menuRow = BaseModuleImpl.GetBaseGridRightMenuById(SystemModel.AfterSaveExec);
|
|
if (menuRow != null)
|
|
{
|
|
CommonMenu menu = new CommonMenu(Model, this, MainGridEx);
|
|
//menu.ApplyBefore += new CommonToolApplyEventHandler(OnMenuApplyBefore);
|
|
//menu.DynamicLinkAfter += new CommonToolAfterDynamicLinkEventHandler(OnDynamicLinkAfter);
|
|
//StaticControl.RightMenuGridView = MainGridEx.GridView;
|
|
StaticControl.RightMenuMyControl = this;
|
|
menu.Apply(menuRow);
|
|
if (!menu.issuccess)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
//if (Autogrowcolumn.Equals(primaryKey, StringComparison.CurrentCultureIgnoreCase))
|
|
//{
|
|
// primaryValue = "LskjIdebtity" + SqlHelper.ExecuteScalar(string.Format("SELECT {0} FROM P_EmployeePostTab WHERE {0} = @@IDENTITY", Autogrowcolumn)) + "";
|
|
//}
|
|
// 保存成功后,判断是否需要打印
|
|
string[] resultMsgs = saveModel.FaultMsg.Split('&');
|
|
for (int i = 0; i < resultMsgs.Length; i++)
|
|
{
|
|
bool isPrint = resultMsgs.Contains("autoprint=1");
|
|
//刷新
|
|
if (resultMsgs[i].Contains("speciesno="))
|
|
{
|
|
//string[] specs = resultMsgs[i].Split('=');
|
|
//if (specs.Length == 2)
|
|
//{
|
|
// _tvLeft.RefreshLeftTree(specs[1]);
|
|
//}
|
|
}
|
|
//打印
|
|
if (resultMsgs[i].Contains("print=1"))
|
|
{
|
|
this.Print(primaryValue, this.SystemModel.PrintFile);
|
|
}
|
|
|
|
//打印文件
|
|
if (resultMsgs[i].Contains("printfile="))
|
|
{
|
|
string[] files = resultMsgs[i].Split('=');
|
|
string parameter = string.Empty;
|
|
if (resultMsgs[i].Contains("^"))
|
|
{
|
|
//printfile=成品入库标签.rmf|xxxx.rmf^参数1=参数1值|参数2=参数2值
|
|
//多个打印模块用|分割
|
|
//替换参数用 ^ 隔开,多个用|分割
|
|
string[] parameters = resultMsgs[i].Split('^');
|
|
files = parameters[0].Split('=');
|
|
parameter = parameters[1];
|
|
}
|
|
|
|
|
|
|
|
if (files.Length == 2 && !string.IsNullOrEmpty(files[1]))
|
|
{
|
|
string[] printFiles = files[1].Split('|');
|
|
for (int n = 0; n < printFiles.Length; n++)
|
|
{
|
|
if (!string.IsNullOrEmpty(printFiles[n]))
|
|
{
|
|
this.Print(primaryValue, printFiles[n], parameter);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// 模块
|
|
if (resultMsgs[i].Contains("module="))
|
|
{
|
|
this.CallLibrary(resultMsgs[i]);
|
|
this.CallDelphi(resultMsgs[i]);
|
|
}
|
|
//判断是否重新加载
|
|
if (resultMsgs[i].Contains("reload="))
|
|
{
|
|
string text = resultMsgs[i];
|
|
text = text.Substring(text.IndexOf('=') + 1);
|
|
//if (refreshThePage != null) refreshThePage(text);
|
|
SystemInfo.Instance.Reload = text;
|
|
}
|
|
if (resultMsgs[i].Contains("reloadcond="))
|
|
{
|
|
string text = resultMsgs[i];
|
|
text = text.Substring(text.IndexOf('=') + 1);
|
|
//if (refreshThePage != null) refreshThePage(text);
|
|
SystemInfo.Instance.Reloadcond = text;
|
|
}
|
|
}
|
|
break;
|
|
case 9:
|
|
// 继续执行保存
|
|
if (MessageUtil.Show(saveModel.FaultMsg, MessageBoxButtons.YesNo) == DialogResult.Yes)
|
|
{
|
|
saveModel.ComfirmFlag = 1;
|
|
result = BaseModuleImpl.SaveBasePanelData(saveModel);
|
|
}
|
|
break;
|
|
default:
|
|
// 保存失败
|
|
MessageUtil.Show(ResourceKeys.SaveFault + "\r\n" + saveModel.FaultMsg + "\r\n" + SaveErrorMessage);
|
|
|
|
|
|
if (saveModel.FaultMsg.StartsWith("@") && false)
|
|
{
|
|
//根据tipMsg中数据找到pMenu中对应的右键
|
|
foreach (BarItemLink itemLink in rightItemLinks)
|
|
{
|
|
if (false)
|
|
{
|
|
ErrorRestriction errorRestriction = new ErrorRestriction(SaveErrorMessage, this.popUpDyncModel, this, itemLink);
|
|
DialogResult drr = errorRestriction.ShowDialog();
|
|
errorRestriction.Dispose();
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
break;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//MessageUtil.Show("保存面板数据到数据库出错" + ex.Message);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
if (result == 1)
|
|
{
|
|
// 保存BMP图片
|
|
this.SavePictureToStore(tableName, primaryKey, primaryValue);
|
|
}
|
|
return result == 1;
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <para>说明:执行最后一次查询</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-10-23 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
public void SearchLastGrid()
|
|
{
|
|
try
|
|
{
|
|
if (this._mainGridEx != null)
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(this._mainGridEx.UpdateColumns))
|
|
{
|
|
this._mainGridEx.RefreshDataSource(true);
|
|
}
|
|
this.DetailSelection.Clear();
|
|
if (string.IsNullOrWhiteSpace(this._mainGridEx.LastSearchSql))
|
|
{
|
|
this.SearchGrid();
|
|
}
|
|
else
|
|
{
|
|
// 上一次查询
|
|
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
|
|
{
|
|
if (_mainGridEx != null) this.GridRowCount = this._mainGridEx.SetGridViewDataSource(MainImpl.GetAdapterResult(this._mainGridEx.LastSearchSql));
|
|
}
|
|
if (RememberRow)
|
|
{
|
|
if (this.GridRowCount <= oldRowHandle && SystemInfo.Instance.DeleteSelectedEndOf)
|
|
{
|
|
oldRowHandle = this.GridRowCount - 1;
|
|
}
|
|
|
|
SetFocusedRowHandle(oldRowHandle);
|
|
//SetTopRowHandle(oldTopRowHandle);
|
|
}
|
|
//执行删除或者右键后,主表没有数据时清空明细表格数据
|
|
if (this.GridRowCount == 0 && OnLastQueryTriggered != null) OnLastQueryTriggered(null, null);
|
|
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogUtil.WriteError("执行最后一次查询出错!", ex);
|
|
//MessageUtil.Show("执行最后一次查询出错!" + ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:查询数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-09-13 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
public void SearchGrid(bool state = true)
|
|
{
|
|
// 执行查询
|
|
this.SearchGrid(this._searchSql, true, state);
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:通过sql语句查询数据,例如左侧树点击查询、左侧表格点击查询</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-10-26 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sqlValue">The SQL value.</param>
|
|
/// <param name="hasReplaceCond">是否追加查询条件</param>
|
|
public void SearchGrid(string sql, bool hasReplaceCond = true, bool state = true)
|
|
{
|
|
WaitForm.ShowForm();
|
|
try
|
|
{
|
|
string sqlValue = sql + "";
|
|
if (!string.IsNullOrWhiteSpace(sqlValue))
|
|
{
|
|
if (this._mainGridEx != null)
|
|
{
|
|
this.DetailSelection.Clear();
|
|
if (this.SystemModel != null) RememberRow = (this.SystemModel.AccordingNameSelected == 0);
|
|
int oldRowHandle = GetFocusedRowHandle();//获取上一次选中行
|
|
sqlValue = ReplaceHelper.ReplaceUserInfo(sqlValue);
|
|
sqlValue = ReplaceHelper.ReplaceWhereCond(sqlValue);
|
|
sqlValue = SetSearchSqlValue(sqlValue, hasReplaceCond, state);
|
|
sqlValue = MainImpl.GetDefaultValue(sqlValue, ParentKey, OtherParams);
|
|
// 处理图片
|
|
if (this._mainGridEx != null && this._mainGridEx.ImageList != null && this._mainGridEx.ImageList.Count > 0)
|
|
{
|
|
foreach (string item in this._mainGridEx.ImageList)
|
|
{
|
|
sqlValue = sqlValue.Replace(string.Format(",{0}", item), "").Replace(string.Format("{0},", item), "");
|
|
}
|
|
}
|
|
|
|
this._mainGridEx.LastSearchSql = sqlValue;
|
|
this._mainGridEx.LastSearchButtonhSql = sqlValue;
|
|
//while (!_mainGridEx.IsHandleCreated)
|
|
//{
|
|
// System.Threading.Thread.Sleep(100);
|
|
//}
|
|
if (_mainGridEx.IsHandleCreated)
|
|
{
|
|
// 窗口加载完成搜索,采用异步加载
|
|
_mainGridEx.Invoke((EventHandler)delegate
|
|
{
|
|
this.GridRowCount = this._mainGridEx.SetGridViewDataSource(MainImpl.GetAdapterResult(sqlValue));
|
|
//this._mainGridEx.GridView.BestFitColumns();
|
|
});
|
|
}
|
|
else
|
|
{
|
|
if (_mainGridEx != null) this.GridRowCount = this._mainGridEx.SetGridViewDataSource(MainImpl.GetAdapterResult(sqlValue));
|
|
}
|
|
if (RememberRow)
|
|
{
|
|
if (this.GridRowCount <= oldRowHandle && SystemInfo.Instance.DeleteSelectedEndOf)
|
|
{
|
|
oldRowHandle = this.GridRowCount - 1;
|
|
}
|
|
SetFocusedRowHandle(oldRowHandle);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
MessageUtil.Show(ResourceKeys.UnSetSearchSql);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogUtil.WriteError("查询出错!", ex);
|
|
MessageUtil.Show("查询出错!" + ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
//MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
WaitForm.HideForm();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 查询数据
|
|
/// </summary>
|
|
/// <param name="sourceTable"></param>
|
|
public void SearchGrid(DataTable sourceTable)
|
|
{
|
|
WaitForm.ShowForm();
|
|
try
|
|
{
|
|
if (sourceTable != null)
|
|
{
|
|
this.GridRowCount = sourceTable.Rows.Count;
|
|
if (this._mainGridEx != null)
|
|
{
|
|
this.DetailSelection.Clear();
|
|
int oldRowHandle = GetFocusedRowHandle();//获取上一次选中行
|
|
if (_mainGridEx.IsHandleCreated)
|
|
{
|
|
// 窗口加载完成搜索,采用异步加载
|
|
_mainGridEx.Invoke((EventHandler)delegate
|
|
{
|
|
this._mainGridEx.SetGridViewDataSource(sourceTable);
|
|
});
|
|
}
|
|
else if (_mainGridEx != null)
|
|
{
|
|
this._mainGridEx.SetGridViewDataSource(sourceTable);
|
|
}
|
|
if (RememberRow)
|
|
{
|
|
if (this.GridRowCount <= oldRowHandle && SystemInfo.Instance.DeleteSelectedEndOf)
|
|
{
|
|
oldRowHandle = this.GridRowCount - 1;
|
|
}
|
|
SetFocusedRowHandle(oldRowHandle);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
MessageUtil.Show(ResourceKeys.UnSetSearchSql);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogUtil.WriteError("查询出错!", ex);
|
|
MessageUtil.Show("查询出错!" + ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
//MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
WaitForm.HideForm();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:设置控件值(无需传入txt_ 内部已经追加)</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-09 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="controlName">Name of the control.</param>
|
|
public void SetControlValue(string controlName, object controlValue, bool refreshSearchSource = false)
|
|
{
|
|
BaseUserControl baseControl = FindControl(controlName);
|
|
|
|
if (baseControl == null) return;
|
|
|
|
if (baseControl.Model.FieldType == ControlType.LabAutoCompleteValueParam || baseControl.Model.FieldType == ControlType.LabAutoCompleteTextParam || baseControl.Model.FieldType == ControlType.LabAutoCompleteValue || baseControl.Model.FieldType == ControlType.LabAutoCompleteText || baseControl.Model.FieldType == ControlType.LabAutoGridText || baseControl.Model.FieldType == ControlType.LabAutoGridValue || baseControl.Model.FieldType == ControlType.LabAutoGridTextParam || baseControl.Model.FieldType == ControlType.LabAutoGridValueParam)//如果为搜索框带参数类型控件,需要在赋值前刷新数据源
|
|
{
|
|
if (refreshSearchSource)
|
|
{
|
|
SerSearchBoxDataSource(baseControl, controlValue + "");
|
|
}
|
|
}
|
|
|
|
if (baseControl is LabelImageEdit)
|
|
{
|
|
LabelImageEdit imageEdit = baseControl as LabelImageEdit;
|
|
imageEdit.LoadImage(controlValue + "");
|
|
}
|
|
else if (baseControl is LabelRemarkEdit && baseControl.Model.FileUploadControl && string.IsNullOrEmpty(PrimaryValue))
|
|
{
|
|
LabelRemarkEdit labelRemarkEdit = baseControl as LabelRemarkEdit;
|
|
labelRemarkEdit.lasttext = controlValue + "";
|
|
}
|
|
else if (baseControl is LabelPictureEdit)
|
|
{
|
|
Image image = null;
|
|
LabelPictureEdit pictureEdit = baseControl as LabelPictureEdit;
|
|
if (controlValue is byte[])
|
|
{
|
|
image = ImageHelper.ReadImage(controlValue as byte[]);
|
|
}
|
|
else if (controlValue is Image)
|
|
{
|
|
image = controlValue as Image;
|
|
}
|
|
if (pictureEdit.IsInitSetting)
|
|
{
|
|
pictureEdit.IsInitSetting = false;
|
|
pictureEdit.SourceImage = image;
|
|
}
|
|
pictureEdit.TextEdit.Image = image;
|
|
}
|
|
else if (baseControl.Model.FieldType == 7 && !"****".Equals(controlValue))
|
|
{
|
|
string dfmt = baseControl.Model.DataFormat;
|
|
if (string.IsNullOrEmpty(controlValue + ""))
|
|
{
|
|
baseControl.EditText = 0 + "";
|
|
baseControl.Model.Text = 0 + "";
|
|
}
|
|
else
|
|
if ((controlValue + "").Contains('%'))
|
|
{
|
|
baseControl.EditText = controlValue + "";
|
|
baseControl.Model.Text = controlValue + "";
|
|
}
|
|
else
|
|
if (controlValue != DBNull.Value)
|
|
{
|
|
//dfmt = dfmt == "#.##" ? "0.##" : dfmt;
|
|
baseControl.EditText = string.Format("{0:" + dfmt + "}", Convert.ToDecimal(controlValue));
|
|
baseControl.Model.Text = string.Format("{0:" + dfmt + "}", Convert.ToDecimal(controlValue));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//if (baseControl is LabelAutoGridLook)
|
|
//{
|
|
// baseControl.Focus();
|
|
//}
|
|
|
|
|
|
baseControl.EditText = controlValue + "";
|
|
baseControl.Model.Text = controlValue + "";
|
|
if (baseControl is LabelAutoGridLook)
|
|
{
|
|
if (!changeLabelAutoGridLooks.Keys.Contains(controlName)) changeLabelAutoGridLooks.Add(controlName, controlValue);
|
|
//baseControl.Focus();
|
|
//SendKeys.Send("{Tab}");
|
|
//baseControl.Parent.Focus();
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:设置搜索框数据源</para>
|
|
/// <para>创建人:曹屹峰</para>
|
|
/// <para>创建日期:2022-11-29 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
public void SerSearchBoxDataSource(BaseUserControl baseControl, string controlValue)
|
|
{
|
|
try
|
|
{
|
|
//if (!this.refGridLookUpData) return;//2023-3-31 默认取消限制
|
|
if (baseControl.Model.FieldType == ControlType.LabAutoCompleteValueParam || baseControl.Model.FieldType == ControlType.LabAutoCompleteTextParam || baseControl.Model.FieldType == ControlType.LabAutoCompleteText || baseControl.Model.FieldType == ControlType.LabAutoCompleteValue)//如果为搜索框,满足条件是需要刷新数据源copy值
|
|
{
|
|
ControlModel controlModel = baseControl.Model;
|
|
if (string.IsNullOrEmpty(controlModel.SourceSql)) return;
|
|
DataTable sourceTab = MainImpl.GetDataTableResult(controlModel.SourceSql);
|
|
LabelAutoTextEdit autoTextEdit = baseControl as LabelAutoTextEdit;
|
|
if (sourceTab != null)
|
|
{
|
|
//autoTextEdit.TextEdit._popup.GridControlObj.DataSource = sourceTab;
|
|
//autoTextEdit.TextEdit._popup.Model = autoTextEdit.TextEdit.Model;
|
|
//autoTextEdit.TextEdit.SetGridViewColumns(sourceTab as DataTable);
|
|
autoTextEdit.TextEdit._popup.GridControlObj.DataSource = sourceTab;
|
|
autoTextEdit.TextEdit.DataSourceTable = sourceTab.Copy();
|
|
}
|
|
}
|
|
else if (baseControl.Model.FieldType == ControlType.LabAutoGridText || baseControl.Model.FieldType == ControlType.LabAutoGridValue || baseControl.Model.FieldType == ControlType.LabAutoGridTextParam || baseControl.Model.FieldType == ControlType.LabAutoGridValueParam)//智能搜索框
|
|
{
|
|
ControlModel controlModel = baseControl.Model;
|
|
if (string.IsNullOrEmpty(controlModel.SourceSql)) return;
|
|
DataTable sourceTab = MainImpl.GetDataTableResult(controlModel.SourceSql);
|
|
LabelAutoGridLook autoGridLook = baseControl as LabelAutoGridLook;
|
|
if (sourceTab != null)
|
|
{
|
|
//autoGridLook.SetDataSource(sourceTab);
|
|
DataRow dr = sourceTab.NewRow();
|
|
sourceTab.Rows.Add(dr);
|
|
autoGridLook.TextEdit.Properties.DataSource = sourceTab;
|
|
autoGridLook.DataSourceTable = sourceTab.Copy();
|
|
}
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:设置控件值</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-09 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="model">The model.</param>
|
|
public void SetControlValue(ControlModel model, object controlValue)
|
|
{
|
|
if (model != null)
|
|
this.SetControlValue(model.FieldName, controlValue);
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:设置控件值</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-05-30 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="cardType">Type of the card.</param>
|
|
/// <param name="controlValue">The control value.</param>
|
|
public void SetControlValue(IDCardType cardType, object controlValue)
|
|
{
|
|
if (this._models != null)
|
|
{
|
|
ControlModel model = this._models.FirstOrDefault(x => x.Sign == (int)cardType);
|
|
SetControlValue(model, controlValue);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:设置所有控件值</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-09 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="rowItem">The row item.</param>
|
|
public void SetAllControlValue(DataRow rowItem, bool canReplaceFixed = false)
|
|
{
|
|
ControlModel selectModel = new ControlModel();//设置当前选中列
|
|
try
|
|
{
|
|
if (rowItem == null) return;
|
|
foreach (ControlModel model in this.ControlModels)
|
|
{
|
|
selectModel = model;
|
|
|
|
if (rowItem.Table.Columns.Contains(model.FieldName))
|
|
{
|
|
SetControlValue(model, rowItem[model.FieldName]);
|
|
}
|
|
if (model.FieldName.Contains("_Ls"))
|
|
{
|
|
string[] unioFielName = model.FieldName.Split('_');
|
|
string UnioValue = unioFielName[unioFielName.Length - 1];
|
|
DataColumn grid = rowItem.Table.Columns.Cast<DataColumn>().FirstOrDefault(x => x.ColumnName.Split('_')[x.ColumnName.Split('_').Length - 1].Equals(UnioValue));
|
|
if (grid != null) SetControlValue(model, rowItem[grid.ColumnName]);
|
|
}
|
|
if (canReplaceFixed)
|
|
{
|
|
// 特殊处理:
|
|
// 1. 登录ID、登录名称、操作时间3个字段重置设置为当前人员和时间.
|
|
if (model.FieldName.ToLower().EndsWith("operatorid"))
|
|
SetControlValue(model, ERPInfo.Instance.UserId);
|
|
if (model.FieldName.ToLower().EndsWith("operatorname"))
|
|
SetControlValue(model, ERPInfo.Instance.UserName);
|
|
if (model.FieldName.ToLower().EndsWith("operatedate"))
|
|
SetControlValue(model, DateTime.Now.ToString());
|
|
}
|
|
|
|
// 没有权限的控件设置为****
|
|
if (model.Visible)
|
|
{
|
|
SetControlValue(model, "****");
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogUtil.WriteError(selectModel.FieldName + "设置控件值出错!", ex);
|
|
//MessageUtil.Show(selectModel.FieldName + "设置控件值出错!" + ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(selectModel.FieldName + "设置控件值出错!" + ex);
|
|
//MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:设置所有控件值</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-05-30 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="cards">The cards.</param>
|
|
public void SetAllControlValue(Dictionary<IDCardType, object> cards)
|
|
{
|
|
if (cards != null)
|
|
{
|
|
foreach (var item in cards)
|
|
{
|
|
this.SetControlValue(item.Key, item.Value);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:清除全部必填</para>
|
|
/// <para>创建人:曹屹峰</para>
|
|
/// <para>创建日期:2024-04-12 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
|
|
public void ClearMandatoryFields()
|
|
{
|
|
//目前设置后不会改变颜色
|
|
foreach (ControlModel item in _models)
|
|
{
|
|
if (item.IsEmpty)
|
|
{
|
|
BaseUserControl control = this.FindControl(item.FieldName);
|
|
if (control != null)
|
|
{
|
|
control.Required = false;
|
|
item.IsEmpty = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <para>说明:设置控件是否必填</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-05-22 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="controlName">Name of the control.</param>
|
|
/// <param name="required">if set to <c>true</c>必填</param>
|
|
/// <param name="setting">if set to <c>true</c>是否读取配置是否只读</param>
|
|
public void SetRequiredControl(string controlName, bool required = true, bool setting = true)
|
|
{
|
|
BaseUserControl control = this.FindControl(controlName);
|
|
if (control != null && (!control.Model.IsEmpty || !setting))
|
|
{
|
|
control.Required = required;
|
|
control.Model.IsEmpty = required;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:设置控件是否只读</para>
|
|
/// <Is Emptypara>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-05-22 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="controlName">Name of the control.</param>
|
|
/// <param name="readOnly">if set to <c>true</c> [read only].</param>
|
|
/// <param name="setting">if set to <c>true</c>是否读取配置是否只读</param>
|
|
public void SetReadOnlyControl(string controlName, bool readOnly = true, bool setting = true)
|
|
{
|
|
BaseUserControl control = this.FindControl(controlName);
|
|
if (control != null && (!control.Model.ReadOnly || !setting))
|
|
{
|
|
control.ReadOnly = readOnly;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:设置控件是否只读</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-12-04 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="model">The model.</param>
|
|
/// <param name="readOnly">if set to <c>true</c> [read only].</param>
|
|
/// <param name="setting">if set to <c>true</c>是否读取配置是否只读</param>
|
|
public void SetReadOnlyControl(ControlModel model, bool readOnly = true, bool setting = true)
|
|
{
|
|
this.SetReadOnlyControl(model.FieldName, readOnly, setting);
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:设置所有控件是否只读</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-12-04 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="readOnly">if set to <c>true</c> [read only].</param>
|
|
/// <param name="setting">if set to <c>true</c>是否读取配置是否只读</param>
|
|
public void SetReadOnlyAllControl(bool readOnly = true, bool setting = true)
|
|
{
|
|
foreach (ControlModel model in this.ControlModels)
|
|
{
|
|
SetReadOnlyControl(model, readOnly, setting);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:保存图片到数据库(为了兼容老版本,以后调整舍弃)</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-25 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
|
private bool SavePictureToStore(string tableName, string primaryKey, string primaryValue)
|
|
{
|
|
if (this.ControlModels != null)
|
|
{
|
|
ControlModel[] models = this.ControlModels.Where(x => x.FieldType == ControlType.LabPic).ToArray();
|
|
foreach (ControlModel model in models)
|
|
{
|
|
LabelPictureEdit picEdit = FindControl(model) as LabelPictureEdit;
|
|
if (picEdit != null && picEdit.IsUpdate())
|
|
{
|
|
int result = BaseModuleImpl.SaveImage(tableName, model.FieldName, primaryKey, primaryValue, ImageHelper.ConvertImage(picEdit.TextEdit.Image));
|
|
if (result > 0)
|
|
{
|
|
picEdit.SourceImage = picEdit.TextEdit.Image;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:创建模版搜索</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-09-04 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void CreateSearchScheme()
|
|
{
|
|
if (_popupMenu == null) return;
|
|
_popupMenu.ItemLinks.Clear();
|
|
|
|
foreach (DataRow item in _schemes.Rows)
|
|
{
|
|
BarButtonItem bbi_item = new BarButtonItem();
|
|
bbi_item.Caption = item["ProjectName"] + "";
|
|
bbi_item.Tag = item["SearchValue"] + "";
|
|
bbi_item.ItemClick += new ItemClickEventHandler(OnPopupItemClick);
|
|
|
|
_popupMenu.AddItem(bbi_item);
|
|
}
|
|
|
|
BarButtonItem bbi_save = new BarButtonItem();
|
|
bbi_save.Caption = "保存方案";
|
|
bbi_save.ItemClick += new ItemClickEventHandler(OnPopupSaveItemClick);
|
|
|
|
BarButtonItem bbi_manager = new BarButtonItem();
|
|
bbi_manager.Caption = "方案管理";
|
|
bbi_manager.ItemClick += new ItemClickEventHandler(OnPopupManagerItemClick);
|
|
|
|
_popupMenu.AddItem(bbi_save);
|
|
_popupMenu.AddItem(bbi_manager);
|
|
|
|
_popupMenu.ItemLinks[_schemes.Rows.Count].BeginGroup = true;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:获取控件对象</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-09-01 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="item">The item.</param>
|
|
/// <returns>ControlModel.</returns>
|
|
private ControlModel GetControlModel(DataRow item)
|
|
{
|
|
Dictionary<object, Hashtable> dataCaches = Model != null ? Model.DataCaches : null;
|
|
int left = !string.IsNullOrEmpty(item["controlLeft"] + "") ? Convert.ToInt32(item["controlLeft"] + "") : 0;
|
|
int top = !string.IsNullOrEmpty(item["controlTop"] + "") ? Convert.ToInt32(item["controlTop"] + "") : 0;
|
|
int width = !string.IsNullOrEmpty(item["controlWidth"] + "") ? Convert.ToInt32(item["controlWidth"] + "") : 0;
|
|
int height = string.IsNullOrEmpty(item["controlHeight"] + "") || Convert.ToInt32(item["controlHeight"] + "") == 0 ? 21 : Convert.ToInt32(item["controlHeight"] + "");
|
|
|
|
ControlModel model = new ControlModel();
|
|
model.id = item["id"] + "";
|
|
model.CanClear = (item["edited"] + "" != "1");
|
|
model.CanCopy = item.Table.Columns.Contains("canCopy") ? "1".Equals(item["canCopy"] + "") : true;
|
|
model.IsEmpty = !string.IsNullOrEmpty(item["nullable"] + "") ? Convert.ToBoolean(item["nullable"]) : false;
|
|
model.ReadOnly = ("1".Equals(item["edited"] + ""));
|
|
model.IsSave = true;
|
|
model.Visible = item.Table.Columns.Contains("visible") ? "1".Equals(item["visible"] + "") : false;
|
|
model.FieldType = string.IsNullOrEmpty(item["fieldTypeId"] + "") ? 0 : Convert.ToInt32(item["fieldTypeId"] + "");
|
|
if (model.FieldType == 42)
|
|
{
|
|
model.FieldType = 160;
|
|
}
|
|
if (model.FieldType == 43)
|
|
{
|
|
model.FieldType = 161;
|
|
}
|
|
|
|
|
|
model.FieldName = item["fieldName"] + "";
|
|
model.Name = "txt_" + item["fieldName"] + "";
|
|
model.LabelText = item["userName"] + "";
|
|
|
|
if (Business.Impl.LanguageTranslation.Translatable)
|
|
{
|
|
model.LabelText = Business.Impl.LanguageTranslation.GetTranslatedText(model.LabelText);
|
|
}
|
|
|
|
|
|
model.TipMsg = "[" + item["userName"] + "] 必须录入.";
|
|
model.DataFormat = item.Table.Columns.Contains("DataFormat") ? item["DataFormat"] + "" : "";
|
|
model.Default = item["defaultValue"] + "";
|
|
if (!dataCaches.GetValue(item, "DefaultValue", out string defaultValue))
|
|
{
|
|
defaultValue = BaseImpl.GetDefaultValue(item["defaultValue"] + "", ParentKey, OtherParams);
|
|
}
|
|
model.DefaultValue = defaultValue;
|
|
model.Location = new Point(left, top);
|
|
model.Size = new Size(width, height);
|
|
model.Sign = item.Table.Columns.Contains("TM_tagID") && !string.IsNullOrEmpty(item["TM_tagID"] + "") ? Convert.ToInt32(item["TM_tagID"] + "") : 0;
|
|
model.TextMember = item["lookupResult"] + "";
|
|
model.ValueMember = item["lookupKeyField"] + "";
|
|
model.SourceSql = item["lookupSql"] + "";
|
|
model.NullText = item.Table.Columns.Contains("InputHintText") ? item["InputHintText"] + "" : string.Empty;
|
|
model.TabOrder = item.Table.Columns.Contains("TabOrder") && !string.IsNullOrEmpty(item["TabOrder"] + "") ? Convert.ToInt32(item["TabOrder"] + "") : 0;
|
|
model.CalcExpr = item.Table.Columns.Contains("CalcExpr") ? item["CalcExpr"] + "" : string.Empty;
|
|
model.CalcOrder = item.Table.Columns.Contains("CalcOrder") && !string.IsNullOrEmpty(item["CalcOrder"] + "" + "") ? Convert.ToInt32(item["CalcOrder"] + "") : 1;
|
|
model.UnionFields = item.Table.Columns.Contains("UnionFields") ? item["UnionFields"] + "" : string.Empty;
|
|
model.UnionValues = item.Table.Columns.Contains("UnionValue") ? item["UnionValue"] + "" : string.Empty;
|
|
model.AddModuleId = item.Table.Columns.Contains("AddModuleId") ? item["AddModuleId"] + "" : string.Empty;
|
|
model.AddModuleResult = item.Table.Columns.Contains("AddModuleResult") ? item["AddModuleResult"] + "" : string.Empty;
|
|
model.AddModuleSpec = item.Table.Columns.Contains("AddModuleSpec") ? item["AddModuleSpec"] + "" : string.Empty;
|
|
model.IsRefreshSource = item.Table.Columns.Contains("refreshSource") && !string.IsNullOrEmpty(item["refreshSource"] + "") ? Convert.ToInt32(item["refreshSource"] + "") : 0;
|
|
|
|
model.FontSize = item.Table.Columns.Contains("FontSize") && !string.IsNullOrEmpty(item["FontSize"] + "") ? Convert.ToInt32(item["FontSize"] + "") : 0;
|
|
model.DisableCond = item.Table.Columns.Contains("DisableCond") ? item["DisableCond"] + "" : "";
|
|
model.DisableType = item.Table.Columns.Contains("DisableType") ? item["DisableType"] + "" : "";
|
|
model.FormKey = item.Table.Columns.Contains("formKey") ? item["formKey"] + "" : string.Empty;
|
|
model.IsAddControl = item.Table.Columns.Contains("IsAddControl") ? "1".Equals(item["IsAddControl"] + "") : false;
|
|
model.IsFixedValue = item.Table.Columns.Contains("IsFixedValue") ? "1".Equals(item["IsFixedValue"] + "") : false;
|
|
model.Tag = item;
|
|
|
|
model.clickAfterEmpty = item.Table.Columns.Contains("clickAfterEmpty") ? "1".Equals(item["clickAfterEmpty"] + "") : false;
|
|
|
|
model.OrderId = item.Table.Columns.Contains("OrderId") ? item["OrderId"] + "" : "";
|
|
model.RefreshButton = item.Table.Columns.Contains("RefreshButton") ? "1".Equals(item["RefreshButton"] + "") : false;
|
|
model.DataDec = item.Table.Columns.Contains("DataDec") && !string.IsNullOrEmpty(item["DataDec"] + "") ? Convert.ToInt32(item["DataDec"] + "") : 0;
|
|
model.CancelRowLimit = item.Table.Columns.Contains("CancelRowLimit") ? "1".Equals(item["CancelRowLimit"] + "") : false;
|
|
model.AddOrderByCond = item.Table.Columns.Contains("AddOrderByCond") ? item["AddOrderByCond"] + "" : "";
|
|
model.TreeCheckModel = item.Table.Columns.Contains("TreeCheckModel") ? item["TreeCheckModel"] + "" : "";
|
|
|
|
model.ControlTitleColor = item.Table.Columns.Contains("ControlTitleColor") ? item["ControlTitleColor"] + "" : "";
|
|
model.FileUploadControl = item.Table.Columns.Contains("FileUploadControl") ? "1".Equals(item["FileUploadControl"] + "") : false;
|
|
model.HighlightContent = item.Table.Columns.Contains("HighlightContent") ? "1".Equals(item["HighlightContent"] + "") : false;
|
|
model.Montage = item.Table.Columns.Contains("montage") ? "1".Equals(item["montage"] + "") : false;
|
|
model.DisplayPermissions = item.Table.Columns.Contains("DisplayPermissions") ? item["DisplayPermissions"] + "" : "";
|
|
model.LookUpWidth = item.Table.Columns.Contains("LookUpWidth") ? int.TryParse(item["LookUpWidth"] + "", out int lookUpWidth) ? lookUpWidth : 0 : 0;
|
|
model.LookUpFieldsWidth = item.Table.Columns.Contains("LookUpFieldsWidth") ? item["LookUpFieldsWidth"] + "" : "";
|
|
model.TextBoxProhibition = item.Table.Columns.Contains("TextBoxProhibition") ? "1".Equals(item["TextBoxProhibition"] + "") : false;
|
|
model.ConfigureColumnMode = item.Table.Columns.Contains("ConfigureColumnMode") && !string.IsNullOrWhiteSpace(item["ConfigureColumnMode"] + "") ? "1".Equals(item["ConfigureColumnMode"] + "") : false;
|
|
model.SplicingConditions = item.Table.Columns.Contains("SplicingConditions") ? item["SplicingConditions"] + "" : "";
|
|
model.IsRadio = item.Table.Columns.Contains("IsRadio") && !string.IsNullOrWhiteSpace(item["IsRadio"] + "") ? "1".Equals(item["IsRadio"] + "") : false;
|
|
model.ScanAfterEmpty = item.Table.Columns.Contains("ScanAfterEmpty") && !string.IsNullOrWhiteSpace(item["ScanAfterEmpty"] + "") ? "1".Equals(item["ScanAfterEmpty"] + "") : false;
|
|
model.ImportReturnValue = item.Table.Columns.Contains("ImportReturnValue") && !string.IsNullOrWhiteSpace(item["ImportReturnValue"] + "") ? "1".Equals(item["ImportReturnValue"] + "") : false;
|
|
model.ImportCurrentValue = item.Table.Columns.Contains("ImportCurrentValue") && !string.IsNullOrWhiteSpace(item["ImportCurrentValue"] + "") ? "1".Equals(item["ImportCurrentValue"] + "") : false;
|
|
model.SchedStartDataControl = item.Table.Columns.Contains("SchedStartDataControl") && !string.IsNullOrWhiteSpace(item["SchedStartDataControl"] + "") ? "1".Equals(item["SchedStartDataControl"] + "") : false;
|
|
model.ListBoxFontSize = item.Table.Columns.Contains("ListBoxFontSize") && !string.IsNullOrEmpty(item["ListBoxFontSize"] + "") ? Convert.ToInt32(item["ListBoxFontSize"] + "") : 0;
|
|
return model;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:创建控件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-09-01 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns>System.Windows.Forms.Control.</returns>
|
|
private System.Windows.Forms.Control InitControl(ControlModel model, bool isLoadBorder = true)
|
|
{
|
|
if (!string.IsNullOrEmpty(model.SourceSql) && !ControlType.IsNotLoadData(model.FieldType) && model.FieldType != ControlType.LabTreeType)
|
|
{
|
|
Task<DataTable> sourceTask = null;
|
|
if (StaticControl.AddParentGrid.Key != null && Model != null && StaticControl.AddParentGrid.Key.Equals(Model.ModuleCode))
|
|
{
|
|
GridControlEx parentGrid = StaticControl.AddParentGrid.Value;
|
|
GridColumnModel gridColumnModel = parentGrid.mControlSourceDic.Keys.Where(n => n.FieldName.Equals(model.FieldName)).FirstOrDefault();
|
|
if (gridColumnModel != null)
|
|
{
|
|
sourceTask = new Task<DataTable>(() =>
|
|
{
|
|
Task<DataTable> task = parentGrid.mControlSourceDic[gridColumnModel];
|
|
DataTable dataTable = task.Result;
|
|
task.Dispose();
|
|
return dataTable.Copy();
|
|
});
|
|
sourceTask.Start();
|
|
}
|
|
}
|
|
if (sourceTask == null)
|
|
{
|
|
sourceTask = new Task<DataTable>(() =>
|
|
{
|
|
DataTable dataTable = new DataTable();
|
|
using (SqlConnection sqlConnection = new SqlConnection(SqlHelper._connection.ConnectionString))
|
|
{
|
|
using (SqlCommand cmd = new SqlCommand())
|
|
{
|
|
try
|
|
{
|
|
string sqlValue = BaseImpl.GetDefaultValue(model.SourceSql);
|
|
sqlValue = ReplaceHelper.ReplaceParam(sqlValue);
|
|
if (sqlConnection.State != ConnectionState.Open)
|
|
{
|
|
sqlConnection.Open();
|
|
}
|
|
cmd.Connection = sqlConnection;
|
|
cmd.CommandTimeout = 0;
|
|
cmd.CommandText = sqlValue;
|
|
cmd.CommandType = CommandType.Text;
|
|
using (SqlDataAdapter adapter = new SqlDataAdapter(cmd))
|
|
{
|
|
adapter.Fill(dataTable);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Console.WriteLine(ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
sqlConnection.Close();
|
|
cmd.Dispose();
|
|
}
|
|
}
|
|
}
|
|
return dataTable;
|
|
});
|
|
sourceTask.Start(DataTableExtend.SchedulerUtil);
|
|
}
|
|
mControlSourceDic.Add(model, sourceTask);
|
|
}
|
|
BaseUserControl baseControl = new BaseUserControl();
|
|
Font mRowFont = new Font("Microsoft YaHei UI", 12);
|
|
switch (model.FieldType)
|
|
{
|
|
case ControlType.LabDate:
|
|
case ControlType.LabDateTime:
|
|
case ControlType.LabDateTimeShort:
|
|
case ControlType.LabTime:
|
|
case ControlType.LabShortTime:
|
|
case ControlType.LabShortDate:
|
|
// 日期控件
|
|
LabelDateEdit dateEdit = new LabelDateEdit();
|
|
dateEdit.TextEdit.KeyDown += new KeyEventHandler(OnTextEditKeyDown);
|
|
dateEdit.TextEdit.TextChanged += new EventHandler(OnTextEditTextChanged);
|
|
//有格式化配置,按配置格式化显示.否则按照控件类型格式化.
|
|
|
|
dateEdit.DateFormat(string.IsNullOrWhiteSpace(model.DataFormat) ? DateFormat.Format(model.FieldType) : model.DataFormat);
|
|
if (!isLoadBorder) dateEdit.TextEdit.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
|
|
if (model.FieldType == ControlType.LabDateTime)
|
|
{
|
|
dateEdit.TextEdit.Properties.VistaDisplayMode = DevExpress.Utils.DefaultBoolean.True;
|
|
dateEdit.TextEdit.Properties.VistaEditTime = DevExpress.Utils.DefaultBoolean.True;
|
|
}
|
|
if (model.FieldType == ControlType.LabShortDate)
|
|
{
|
|
dateEdit.TextEdit.Properties.VistaCalendarViewStyle = DevExpress.XtraEditors.VistaCalendarViewStyle.YearView;
|
|
}
|
|
baseControl = dateEdit;
|
|
break;
|
|
case ControlType.LabComboxValue:
|
|
case ControlType.LabComboxText:
|
|
case ControlType.LabComboxValueParam:
|
|
case ControlType.LabComboxTextParam:
|
|
// 下拉框
|
|
LabelComboxEdit comboxEdit = new LabelComboxEdit();
|
|
comboxEdit.ValueMember = ControlType.LabComboxValue == model.FieldType || ControlType.LabComboxValueParam == model.FieldType ? model.ValueMember : model.TextMember;
|
|
comboxEdit.ValueField = model.ValueMember;
|
|
comboxEdit.TextField = model.TextMember;
|
|
//comboxEdit.SetDataSource(dataSource);
|
|
// 假如为报表模式并且没有默认值,默认选择第一条记录
|
|
if (model.IsSearchControl && string.IsNullOrEmpty(model.DefaultValue))
|
|
comboxEdit.TextEdit.SelectedIndex = 0;
|
|
|
|
comboxEdit.TextEdit.KeyDown += new KeyEventHandler(OnTextEditKeyDown);
|
|
comboxEdit.TextEdit.TextChanged += new EventHandler(OnTextEditTextChanged);
|
|
if (!isLoadBorder) comboxEdit.TextEdit.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
|
|
baseControl = comboxEdit;
|
|
break;
|
|
case ControlType.LabMulitTreeValue:
|
|
case ControlType.LabMulitTreeText:
|
|
case ControlType.LabMulitTreeValueParam:
|
|
case ControlType.LabMulitTreeTextParam:
|
|
case ControlType.LabTreeLookValue:
|
|
case ControlType.LabTreeLookText:
|
|
case ControlType.LabCheckTreeLookValue:
|
|
case ControlType.LabCheckTreeLookText:
|
|
case ControlType.LabTreeLastlevelValue:
|
|
case ControlType.LabTreeLastlevelText:
|
|
case ControlType.LabCheckTreeLastlevelValue:
|
|
case ControlType.LabCheckTreeLastlevelText:
|
|
case ControlType.LabMultiComTreeboxValue:
|
|
case ControlType.LabMultiComTreeboxText:
|
|
case ControlType.LabMultiComTreeboxValueParam:
|
|
case ControlType.LabMultiComTreeboxTextParam:
|
|
// 自动树节点搜索框
|
|
LabelAutoTreeEdit autoTreeEdit = new LabelAutoTreeEdit();
|
|
autoTreeEdit.isMultiClick = (ControlType.LabMulitTreeValue == model.FieldType || ControlType.LabMulitTreeText == model.FieldType || ControlType.LabMulitTreeValueParam == model.FieldType || ControlType.LabMulitTreeTextParam == model.FieldType || ControlType.LabMultiComTreeboxValue == model.FieldType || ControlType.LabMultiComTreeboxText == model.FieldType || ControlType.LabMultiComTreeboxValueParam == model.FieldType || ControlType.LabMultiComTreeboxTextParam == model.FieldType);
|
|
autoTreeEdit.ValueMember = ControlType.LabMultiComTreeboxValueParam == model.FieldType || ControlType.LabMultiComTreeboxValue == model.FieldType || ControlType.LabMulitTreeValue == model.FieldType || ControlType.LabMulitTreeValueParam == model.FieldType || ControlType.LabTreeLookValue == model.FieldType || ControlType.LabCheckTreeLookValue == model.FieldType || ControlType.LabTreeLastlevelValue == model.FieldType || ControlType.LabCheckTreeLastlevelValue == model.FieldType ? model.ValueMember : model.TextMember;
|
|
autoTreeEdit.ValueField = model.ValueMember;
|
|
autoTreeEdit.TextField = model.TextMember;
|
|
if (ControlType.LabTreeLastlevelValue == model.FieldType || ControlType.LabTreeLastlevelText == model.FieldType || ControlType.LabCheckTreeLastlevelValue == model.FieldType || ControlType.LabCheckTreeLastlevelText == model.FieldType) autoTreeEdit.isRootNode = false;
|
|
|
|
//工具中和bs里 132-135都是只能选末级,136-139可以选中全部
|
|
if (ControlType.LabMultiComTreeboxValue == model.FieldType || ControlType.LabMultiComTreeboxText == model.FieldType || ControlType.LabMultiComTreeboxValueParam == model.FieldType || ControlType.LabMultiComTreeboxTextParam == model.FieldType)
|
|
{
|
|
|
|
autoTreeEdit.TextEdit.SelectAll = true;
|
|
}
|
|
|
|
//autoTreeEdit.FormKey = model.FieldName + "_" + model.FormKey;
|
|
//autoEdit.SetDataSource(dataSource);
|
|
autoTreeEdit.TextEdit.SourceSQL = model.SourceSql;
|
|
autoTreeEdit.TextEdit.SpeciesValue = ParentKey;
|
|
autoTreeEdit.TextEdit.ControlObj = this;
|
|
autoTreeEdit.TextEdit.KeyDown += new KeyEventHandler(OnTextEditKeyDown);
|
|
autoTreeEdit.TextEdit.TextChanged += new EventHandler(OnTextEditTextChanged);
|
|
if (!isLoadBorder) autoTreeEdit.TextEdit.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
|
|
baseControl = autoTreeEdit;
|
|
break;
|
|
case ControlType.LabAutoCompleteValue:
|
|
case ControlType.LabAutoCompleteText:
|
|
case ControlType.LabAutoCompleteValueParam:
|
|
case ControlType.LabAutoCompleteTextParam:
|
|
// 自动搜索框
|
|
if (!isRevTextEdit)
|
|
{
|
|
LabelAutoTextEdit autoEdit = new LabelAutoTextEdit();
|
|
if (model.RefreshButton)
|
|
{
|
|
autoEdit.Button.Visible = true;
|
|
autoEdit.RefreshDataSource += new EventHandler(OnLabelAutoGridLookRefreshDataSource);
|
|
}
|
|
autoEdit.clickAfterEmpty = model.clickAfterEmpty;
|
|
autoEdit.ValueMember = ControlType.LabAutoCompleteValue == model.FieldType || ControlType.LabAutoCompleteValueParam == model.FieldType ? model.ValueMember : model.TextMember;
|
|
autoEdit.ValueField = model.ValueMember;
|
|
autoEdit.TextField = model.TextMember;
|
|
autoEdit.FormKey = model.FieldName + "_" + model.FormKey;
|
|
//autoEdit.SetDataSource(dataSource);
|
|
autoEdit.TextEdit.SourceSQL = model.SourceSql;
|
|
autoEdit.TextEdit.SpeciesValue = ParentKey;
|
|
autoEdit.TextEdit.ControlObj = this;
|
|
autoEdit.TextEdit.KeyDown += new KeyEventHandler(OnTextEditKeyDown);
|
|
//autoEdit.TextEdit.TextChanged += new EventHandler(GetAutoSearcher_HandleSQL);
|
|
//autoEdit.TextEdit.TextChanged += new EventHandler(OnTextEditTextChanged);
|
|
autoEdit.TextEdit.HiddenValueChange += new EventHandler(OnTextEditTextChanged);
|
|
if (!isLoadBorder) autoEdit.TextEdit.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
|
|
baseControl = autoEdit;
|
|
}
|
|
else
|
|
{
|
|
LabelAutoTextRevEdit autoEdit = new LabelAutoTextRevEdit();
|
|
if (model.RefreshButton)
|
|
{
|
|
autoEdit.RefreshDataSource += new EventHandler(OnLabelAutoGridLookRefreshDataSource);
|
|
}
|
|
autoEdit.clickAfterEmpty = model.clickAfterEmpty;
|
|
autoEdit.ValueMember = ControlType.LabAutoCompleteValue == model.FieldType || ControlType.LabAutoCompleteValueParam == model.FieldType ? model.ValueMember : model.TextMember;
|
|
autoEdit.ValueField = model.ValueMember;
|
|
autoEdit.TextField = model.TextMember;
|
|
autoEdit.FormKey = model.FieldName + "_" + model.FormKey;
|
|
//autoEdit.SetDataSource(dataSource);
|
|
autoEdit.TextEdit.SourceSQL = model.SourceSql;
|
|
autoEdit.TextEdit.SpeciesValue = ParentKey;
|
|
autoEdit.TextEdit.ControlObj = this;
|
|
autoEdit.TextEdit.OnSearchCallBack += new EventHandler(OnTextEditSearchCallBack);
|
|
//autoEdit.TextEdit.KeyDown += new KeyEventHandler(OnTextEditKeyDown);
|
|
//autoEdit.TextEdit.TextChanged += new EventHandler(GetAutoSearcher_HandleSQL);
|
|
//autoEdit.TextEdit.TextChanged += new EventHandler(OnTextEditTextChanged);
|
|
autoEdit.TextEdit.HiddenValueChange += new EventHandler(OnTextEditTextChanged);
|
|
if (!isLoadBorder) autoEdit.TextEdit.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
|
|
baseControl = autoEdit;
|
|
}
|
|
break;
|
|
case ControlType.LabAutoGridValue:
|
|
case ControlType.LabAutoGridText:
|
|
case ControlType.LabAutoGridValueParam:
|
|
case ControlType.LabAutoGridTextParam:
|
|
// 智能搜索框
|
|
LabelAutoGridLook gridEdit = new LabelAutoGridLook();
|
|
gridEdit.ValueMember = ControlType.LabAutoGridValue == model.FieldType || ControlType.LabAutoGridValueParam == model.FieldType ? model.ValueMember : model.TextMember;
|
|
gridEdit.ValueField = model.ValueMember;
|
|
gridEdit.TextField = model.TextMember;
|
|
gridEdit.FormKey = model.FieldName + "_" + model.FormKey;
|
|
//GridEdit.SetDataSource(dataSource);
|
|
gridEdit.SourceSQL = model.SourceSql;
|
|
gridEdit.SpeciesValue = ParentKey;
|
|
gridEdit.ControlObj = this;
|
|
gridEdit.TextEdit.KeyDown += new KeyEventHandler(OnTextEditKeyDown);
|
|
//gridEdit.TextEdit.Leave += new EventHandler(OnTextEditTextChanged);
|
|
//gridEdit.HiddenValueChange += new EventHandler(OnTextEditTextChanged);
|
|
gridEdit.TextEdit.EditValueChanged += new EventHandler(OnTextEditTextChanged);
|
|
if (model.RefreshButton)
|
|
{
|
|
gridEdit.Button.Visible = true;
|
|
gridEdit.RefreshDataSource += new EventHandler(OnLabelAutoGridLookRefreshDataSource);
|
|
}
|
|
gridEdit.Isparameters = (ControlType.LabAutoGridValueParam == model.FieldType || ControlType.LabAutoGridTextParam == model.FieldType) ? true : false;
|
|
if (!isLoadBorder) gridEdit.TextEdit.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
|
|
baseControl = gridEdit;
|
|
break;
|
|
case ControlType.LabCheckBox:
|
|
//复选文本控件
|
|
LabelCheckEdit checkEdit = new LabelCheckEdit();
|
|
if (!isLoadBorder) checkEdit.TextEdit.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
|
|
baseControl = checkEdit;
|
|
break;
|
|
case ControlType.LabRemark:
|
|
// 备注框
|
|
LabelRemarkEdit remarkEdit = new LabelRemarkEdit();
|
|
if (model.HighlightContent)
|
|
{
|
|
remarkEdit.TextEdit.ForeColor = Color.Red;
|
|
|
|
}
|
|
remarkEdit.TextEdit.KeyDown += new KeyEventHandler(OnTextEditKeyDown);
|
|
remarkEdit.TextEdit.TextChanged += new EventHandler(OnTextEditTextChanged);
|
|
if (!isLoadBorder) remarkEdit.TextEdit.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
|
|
baseControl = remarkEdit;
|
|
if (model.FileUploadControl)
|
|
{
|
|
remarkEdit.BandAllowDrop();
|
|
}
|
|
break;
|
|
case ControlType.LabMemoEdit:
|
|
// 备注框A
|
|
LabelMemoEdit memoEdit = new LabelMemoEdit();
|
|
memoEdit.TextEdit.KeyDown += new KeyEventHandler(OnTextEditKeyDown);
|
|
memoEdit.TextEdit.TextChanged += new EventHandler(OnTextEditTextChanged);
|
|
if (!isLoadBorder) memoEdit.TextEdit.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
|
|
baseControl = memoEdit;
|
|
break;
|
|
case ControlType.LabMemoSpaceEdit:
|
|
// 备注框A
|
|
LabelMemoSpaceEdit memoSpacEdit = new LabelMemoSpaceEdit();
|
|
memoSpacEdit.TextEdit.KeyDown += new KeyEventHandler(OnTextEditKeyDown);
|
|
memoSpacEdit.TextEdit.TextChanged += new EventHandler(OnTextEditTextChanged);
|
|
if (!isLoadBorder) memoSpacEdit.TextEdit.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
|
|
baseControl = memoSpacEdit;
|
|
break;
|
|
case ControlType.LabCheckDateEx:
|
|
case ControlType.LabCheckDateTimeEx:
|
|
case ControlType.LabCheckDateTimeShort:
|
|
case ControlType.LabCheckTime:
|
|
case ControlType.LabCheckShortTime:
|
|
// 带复选框日期控件
|
|
LabelCheckDateEdit checkDateEdit = new LabelCheckDateEdit();
|
|
checkDateEdit.TextEdit.KeyDown += new KeyEventHandler(OnTextEditKeyDown);
|
|
checkDateEdit.TextEdit.TextChanged += new EventHandler(OnTextEditTextChanged);
|
|
if (model.FieldType == ControlType.LabCheckDateTimeEx)
|
|
{
|
|
checkDateEdit.TextEdit.Properties.VistaDisplayMode = DevExpress.Utils.DefaultBoolean.True;
|
|
checkDateEdit.TextEdit.Properties.VistaEditTime = DevExpress.Utils.DefaultBoolean.True;
|
|
}
|
|
if (!isLoadBorder) checkDateEdit.TextEdit.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
|
|
baseControl = checkDateEdit;
|
|
break;
|
|
case ControlType.LabMultiSelectText:
|
|
case ControlType.LabMultiSelectTextNew:
|
|
case ControlType.LabMultiSelectValue:
|
|
case ControlType.LabMultiSelectValueNew:
|
|
case ControlType.LabMultiSelectValueParam:
|
|
case ControlType.LabMultiSelectTextParam:
|
|
|
|
// 多选控件
|
|
LabelMultiAutoTextEdit multiAutoEdit = new LabelMultiAutoTextEdit();
|
|
multiAutoEdit.ValueMember = (ControlType.LabMultiSelectValue == model.FieldType || ControlType.LabMultiSelectValueNew == model.FieldType || ControlType.LabMultiSelectValueParam == model.FieldType) ? model.ValueMember : model.TextMember;
|
|
multiAutoEdit.ValueField = model.ValueMember;
|
|
multiAutoEdit.TextField = model.TextMember;
|
|
multiAutoEdit.ControlObj = this;
|
|
//multiAutoEdit.SetDataSource(dataSource);
|
|
multiAutoEdit.TextBoxProhibition = model.TextBoxProhibition;
|
|
multiAutoEdit.TextEdit.KeyDown += new KeyEventHandler(OnTextEditKeyDown);
|
|
multiAutoEdit.TextEdit.TextChanged += new EventHandler(OnTextEditTextChanged);
|
|
if (!isLoadBorder) multiAutoEdit.TextEdit.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
|
|
baseControl = multiAutoEdit;
|
|
break;
|
|
case ControlType.LabCheckMultiSelectValue:
|
|
case ControlType.LabCheckMultiSelectText:
|
|
case ControlType.LabCheckMultiSelectValueParam:
|
|
case ControlType.LabCheckMultiSelectTextParam:
|
|
// 带复选框多选控件
|
|
LabelCheckMultiAutoTextEdit checkmultiAutoEdit = new LabelCheckMultiAutoTextEdit();
|
|
checkmultiAutoEdit.MultiAutoEdit.ValueMember = ControlType.LabCheckMultiSelectValue == model.FieldType ? model.ValueMember : model.TextMember;
|
|
checkmultiAutoEdit.MultiAutoEdit.ValueField = model.ValueMember;
|
|
checkmultiAutoEdit.MultiAutoEdit.TextField = model.TextMember;
|
|
checkmultiAutoEdit.MultiAutoEdit.ControlObj = this;
|
|
checkmultiAutoEdit.MultiAutoEdit.TextBoxProhibition = model.TextBoxProhibition;
|
|
//checkmultiAutoEdit.MultiAutoEdit.SetDataSource(dataSource);
|
|
checkmultiAutoEdit.MultiAutoEdit.Model = model;
|
|
checkmultiAutoEdit.TextEdit.KeyDown += new KeyEventHandler(OnTextEditKeyDown);
|
|
checkmultiAutoEdit.TextEdit.TextChanged += new EventHandler(OnTextEditTextChanged);
|
|
if (!isLoadBorder) checkmultiAutoEdit.TextEdit.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
|
|
baseControl = checkmultiAutoEdit;
|
|
break;
|
|
case ControlType.LabCheckComboxText:
|
|
case ControlType.LabCheckComboxValue:
|
|
// 带复选框下拉框
|
|
LabelCheckComboxEdit checkComboxEdit = new LabelCheckComboxEdit();
|
|
checkComboxEdit.ComboxEdit.ValueMember = ControlType.LabCheckComboxValue == model.FieldType ? model.ValueMember : model.TextMember;
|
|
checkComboxEdit.ComboxEdit.ValueField = model.ValueMember;
|
|
checkComboxEdit.ComboxEdit.TextField = model.TextMember;
|
|
//checkComboxEdit.ComboxEdit.SetDataSource(dataSource);
|
|
|
|
if (model.IsSearchControl && string.IsNullOrEmpty(model.DefaultValue))
|
|
checkComboxEdit.ComboxEdit.TextEdit.SelectedIndex = 0;
|
|
checkComboxEdit.TextEdit.KeyDown += new KeyEventHandler(OnTextEditKeyDown);
|
|
checkComboxEdit.TextEdit.TextChanged += new EventHandler(OnTextEditTextChanged);
|
|
if (!isLoadBorder) checkComboxEdit.TextEdit.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
|
|
baseControl = checkComboxEdit;
|
|
break;
|
|
case ControlType.LabCheckAutoSeacherValue:
|
|
case ControlType.LabCheckAutoSeacherText:
|
|
// 带复选框自动搜索框
|
|
LabelCheckAutoTextEdit checkAutoTextEdit = new LabelCheckAutoTextEdit();
|
|
checkAutoTextEdit.clickAfterEmpty = model.clickAfterEmpty;
|
|
checkAutoTextEdit.AutoTextEdit.ValueMember = ControlType.LabCheckAutoSeacherValue == model.FieldType ? model.ValueMember : model.TextMember;
|
|
checkAutoTextEdit.AutoTextEdit.ValueField = model.ValueMember;
|
|
checkAutoTextEdit.AutoTextEdit.TextField = model.TextMember;
|
|
//checkAutoTextEdit.AutoTextEdit.SetDataSource(dataSource);
|
|
|
|
checkAutoTextEdit.TextEdit.SourceSQL = model.SourceSql;
|
|
checkAutoTextEdit.TextEdit.KeyDown += new KeyEventHandler(OnTextEditKeyDown);
|
|
checkAutoTextEdit.TextEdit.TextChanged += new EventHandler(OnTextEditTextChanged);
|
|
if (!isLoadBorder) checkAutoTextEdit.TextEdit.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
|
|
baseControl = checkAutoTextEdit;
|
|
break;
|
|
case ControlType.LabWWW:
|
|
// 网址框
|
|
LabelBrowserEdit browserEdit = new LabelBrowserEdit();
|
|
browserEdit.TextEdit.KeyDown += new KeyEventHandler(OnTextEditKeyDown);
|
|
browserEdit.TextEdit.TextChanged += new EventHandler(OnTextEditTextChanged);
|
|
if (!isLoadBorder) browserEdit.TextEdit.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
|
|
baseControl = browserEdit;
|
|
break;
|
|
case ControlType.LabQQ:
|
|
// QQ框
|
|
LabelQQEdit qqEdit = new LabelQQEdit();
|
|
qqEdit.TextEdit.KeyDown += new KeyEventHandler(OnTextEditKeyDown);
|
|
qqEdit.TextEdit.TextChanged += new EventHandler(OnTextEditTextChanged);
|
|
if (!isLoadBorder) qqEdit.TextEdit.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
|
|
baseControl = qqEdit;
|
|
break;
|
|
case ControlType.LabCalcText:
|
|
// 计算器
|
|
if (model.Visible)
|
|
{
|
|
LabelTextEdit textEdit = new LabelTextEdit();
|
|
textEdit.TextEdit.KeyDown += new KeyEventHandler(OnTextEditKeyDown);
|
|
textEdit.TextEdit.TextChanged += new EventHandler(OnTextEditTextChanged);
|
|
if (!isLoadBorder) textEdit.TextEdit.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
|
|
baseControl = textEdit;
|
|
}
|
|
else
|
|
{
|
|
LabelCalcEdit calcEdit = new LabelCalcEdit();
|
|
calcEdit.TextEdit.KeyDown += new KeyEventHandler(OnTextEditKeyDown);
|
|
calcEdit.TextEdit.TextChanged += new EventHandler(OnTextEditTextChanged);
|
|
if (!isLoadBorder) calcEdit.TextEdit.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
|
|
baseControl = calcEdit;
|
|
}
|
|
break;
|
|
case ControlType.LabPic:
|
|
// 图片框,存储数据库图片格式(老版本,将要淘汰)
|
|
baseControl = new LabelPictureEdit();
|
|
break;
|
|
case ControlType.LabPicEx:
|
|
// 图片框,存储数据库图片地址
|
|
baseControl = new LabelImageEdit();
|
|
break;
|
|
case ControlType.LabRichEdit:
|
|
// 富文本编辑框
|
|
LabelRichEdit richEdit = new LabelRichEdit();
|
|
baseControl = richEdit;
|
|
break;
|
|
case ControlType.LabComboxPopupValue:
|
|
case ControlType.LabComboxPopupText:
|
|
// 弹出下拉列表框
|
|
LabelComboxPopupEdit comboxPopupEdit = new LabelComboxPopupEdit();
|
|
comboxPopupEdit.ListBoxFontSize = model.ListBoxFontSize;
|
|
comboxPopupEdit.ControlObj = this;
|
|
comboxPopupEdit.TextEdit.TextChanged += new EventHandler(OnTextEditTextChanged);
|
|
if (!isLoadBorder) comboxPopupEdit.TextEdit.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
|
|
baseControl = comboxPopupEdit;
|
|
break;
|
|
case ControlType.LabComboxPopupMutilValue:
|
|
case ControlType.LabComboxPopupMutilText:
|
|
// 弹出多选列表框
|
|
LabelComboxMutilPopupEdit comboxMutilPopupEdit = new LabelComboxMutilPopupEdit();
|
|
comboxMutilPopupEdit.ListBoxFontSize = model.ListBoxFontSize;
|
|
comboxMutilPopupEdit.ControlObj = this;
|
|
comboxMutilPopupEdit.TextEdit.TextChanged += new EventHandler(OnTextEditTextChanged);
|
|
if (!isLoadBorder) comboxMutilPopupEdit.TextEdit.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
|
|
baseControl = comboxMutilPopupEdit;
|
|
break;
|
|
case ControlType.LabRadioGroupValue:
|
|
case ControlType.LabRadioGroupText:
|
|
// 单选按钮组
|
|
LabelRadioButtonGroupEdit radioButtonGroupEdit = new LabelRadioButtonGroupEdit();
|
|
radioButtonGroupEdit.SetDataSource(model, MainImpl.GetDataTableResult(model.SourceSql));
|
|
radioButtonGroupEdit.TextEdit.EditValueChanged += new EventHandler(OnTextEditTextChanged);
|
|
if (!isLoadBorder) radioButtonGroupEdit.TextEdit.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
|
|
baseControl = radioButtonGroupEdit;
|
|
break;
|
|
case ControlType.LabIntExtend:
|
|
// 数字扩展
|
|
if (model.Visible)
|
|
{
|
|
LabelTextEdit textEdit = new LabelTextEdit();
|
|
textEdit.TextEdit.KeyDown += new KeyEventHandler(OnTextEditKeyDown);
|
|
textEdit.TextEdit.TextChanged += new EventHandler(OnTextEditTextChanged);
|
|
baseControl = textEdit;
|
|
}
|
|
else
|
|
{
|
|
LabelIntExtendEdit intExtendEdit = new LabelIntExtendEdit();
|
|
intExtendEdit.TextEdit.TextChanged += new EventHandler(OnTextEditTextChanged);
|
|
baseControl = intExtendEdit;
|
|
}
|
|
break;
|
|
case ControlType.LabGridPopupValue:
|
|
case ControlType.LabGridPopupText:
|
|
case ControlType.LabGridPopupMutilValue:
|
|
case ControlType.LabGridPopupMutilText:
|
|
// 弹出选择表格(单选、多选)
|
|
LabelGridSelectEdit gridSelectEdit = new LabelGridSelectEdit();
|
|
gridSelectEdit.ControlObj = this;
|
|
gridSelectEdit.TextEdit.TextChanged += new EventHandler(OnTextEditTextChanged);
|
|
if (!isLoadBorder) gridSelectEdit.TextEdit.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
|
|
baseControl = gridSelectEdit;
|
|
break;
|
|
case ControlType.LabSelectReturnId:
|
|
case ControlType.LabSelectReturnText:
|
|
LabelMultiAutoTextEdit2 moduleReturnsId = new LabelMultiAutoTextEdit2();
|
|
moduleReturnsId.ValueMember = ControlType.LabSelectReturnId == model.FieldType ? model.ValueMember : model.TextMember;
|
|
moduleReturnsId.ValueField = model.ValueMember;
|
|
moduleReturnsId.TextField = model.TextMember;
|
|
moduleReturnsId.ControlObj = this;
|
|
moduleReturnsId.UnionModuleCodel = model.AddModuleId;
|
|
moduleReturnsId.SourceSQL = model.SourceSql;
|
|
moduleReturnsId.IsRadio = model.IsRadio;
|
|
moduleReturnsId.ConfigureColumnMode = model.ConfigureColumnMode;
|
|
moduleReturnsId.InitialFrame();
|
|
//如果没有配置控件数据源sql,就以弹出模块的sql为数据源sql。这里赋值是为了延迟加载数据源时model.SourceSql不为空
|
|
if (string.IsNullOrWhiteSpace(model.SourceSql)) model.SourceSql = moduleReturnsId.SourceSQL;
|
|
|
|
moduleReturnsId.TextEdit.KeyDown += new KeyEventHandler(OnTextEditKeyDown);
|
|
moduleReturnsId.TextEdit.TextChanged += new EventHandler(OnTextEditTextChanged);
|
|
if (!isLoadBorder) moduleReturnsId.TextEdit.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
|
|
baseControl = moduleReturnsId;
|
|
break;
|
|
case ControlType.LabSelectReturnIdNew:
|
|
case ControlType.LabSelectReturnTextNew:
|
|
LabelMultiAutoTextEdit4 moduleReturnsIdNew = new LabelMultiAutoTextEdit4();
|
|
moduleReturnsIdNew.ValueMember = ControlType.LabSelectReturnIdNew == model.FieldType ? model.ValueMember : model.TextMember;
|
|
moduleReturnsIdNew.ValueField = model.ValueMember;
|
|
moduleReturnsIdNew.TextField = model.TextMember;
|
|
moduleReturnsIdNew.ControlObj = this;
|
|
moduleReturnsIdNew.UnionModuleCodel = model.AddModuleId;
|
|
moduleReturnsIdNew.SourceSQL = model.SourceSql;
|
|
moduleReturnsIdNew.SplicingConditions = model.SplicingConditions;
|
|
moduleReturnsIdNew.IsRadio = model.IsRadio;
|
|
moduleReturnsIdNew.ConfigureColumnMode = model.ConfigureColumnMode;
|
|
moduleReturnsIdNew.InitialFrame();
|
|
|
|
// DataTable dataSource = new DataTable();
|
|
//moduleReturnsIdNew.SetDataSource(dataSource);
|
|
moduleReturnsIdNew.TextEdit.KeyDown += new KeyEventHandler(OnTextEditKeyDown);
|
|
moduleReturnsIdNew.TextEdit.TextChanged += new EventHandler(OnTextEditTextChanged);
|
|
if (!isLoadBorder) moduleReturnsIdNew.TextEdit.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
|
|
baseControl = moduleReturnsIdNew;
|
|
break;
|
|
case ControlType.DynamicallyGeneratedSql:
|
|
LabelMultiAutoTextEdit3 moduleSqlGenerated = new LabelMultiAutoTextEdit3();
|
|
// moduleSqlGenerated.SetDataSource();
|
|
|
|
moduleSqlGenerated.TextEdit.KeyDown += new KeyEventHandler(OnTextEditKeyDown);
|
|
moduleSqlGenerated.TextEdit.TextChanged += new EventHandler(OnTextEditTextChanged);
|
|
if (!isLoadBorder) moduleSqlGenerated.TextEdit.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
|
|
baseControl = moduleSqlGenerated;
|
|
break;
|
|
case ControlType.HighShotMeter:
|
|
HighShotMeterTextEdit highShotMeterTextEdit = new HighShotMeterTextEdit();
|
|
// moduleSqlGenerated.SetDataSource();
|
|
highShotMeterTextEdit.ControlObj = this;
|
|
highShotMeterTextEdit.TextEdit.KeyDown += new KeyEventHandler(OnTextEditKeyDown);
|
|
highShotMeterTextEdit.TextEdit.TextChanged += new EventHandler(OnTextEditTextChanged);
|
|
if (!isLoadBorder) highShotMeterTextEdit.TextEdit.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
|
|
baseControl = highShotMeterTextEdit;
|
|
break;
|
|
case ControlType.LabCheckText:
|
|
//文本框带勾选
|
|
LabelCheckText labelCheckText = new LabelCheckText();
|
|
labelCheckText.LabelTextEdit.TextEdit.KeyDown += new KeyEventHandler(OnTextEditKeyDown);
|
|
labelCheckText.LabelTextEdit.TextEdit.TextChanged += new EventHandler(OnTextEditTextChanged);
|
|
if (!isLoadBorder) labelCheckText.LabelTextEdit.TextEdit.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
|
|
baseControl = labelCheckText;
|
|
break;
|
|
case ControlType.Weigh:
|
|
LabelWeigh labelWeigh = new LabelWeigh();
|
|
labelWeigh.Tag = model;
|
|
labelWeigh.TextEdit.KeyDown += new KeyEventHandler(OnTextEditKeyDown);
|
|
labelWeigh.ButtonClick += new EventHandler(OnLabelWeighButtonClick);
|
|
baseControl = labelWeigh;
|
|
break;
|
|
case ControlType.LabApiBtuton:
|
|
LabApiButtonEdit labApiButtonEdit = new LabApiButtonEdit();
|
|
labApiButtonEdit.Tag = model;
|
|
//labApiButtonEdit.TextEdit.KeyDown += new KeyEventHandler(OnTextEditKeyDown);
|
|
labApiButtonEdit.OnRefreshDataCallBack += new EventHandler(OnLabApiDataCallBack);
|
|
baseControl = labApiButtonEdit;
|
|
break;
|
|
case ControlType.LabText:
|
|
case ControlType.LabTextInt:
|
|
default:
|
|
// 文本控件
|
|
{
|
|
LabelTextEdit textEdit = new LabelTextEdit();
|
|
if (model.FieldType == ControlType.LabTextInt)
|
|
{
|
|
textEdit.TextEdit.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.OnIntKeyPress);
|
|
textEdit.TextEdit.EditValueChanging += new DevExpress.XtraEditors.Controls.ChangingEventHandler(this.OnIntEditValueChanging);
|
|
}
|
|
textEdit.TextEdit.KeyDown += new KeyEventHandler(OnTextEditKeyDown);
|
|
textEdit.TextEdit.TextChanged += new EventHandler(OnTextEditTextChanged);
|
|
//有格式化配置,按配置格式化显示.否则按照控件类型格式化.
|
|
//if (model.FieldType == ControlType.LabTextInt && !string.IsNullOrWhiteSpace(model.DataFormat))
|
|
//{
|
|
// // 有格式化配置,按配置格式化显示.
|
|
// textEdit.TextFormat(model.DataFormat);
|
|
//}
|
|
if (model.FieldType == ControlType.LabPcSacn)
|
|
{
|
|
textEdit.ImeMode = System.Windows.Forms.ImeMode.Disable;//扫码框设置输入时不会弹出输入法框
|
|
}
|
|
if (!isLoadBorder) textEdit.TextEdit.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
|
|
baseControl = textEdit;
|
|
}
|
|
break;
|
|
}
|
|
this.mControlList.Add(model);
|
|
return baseControl;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 限制數值框粘貼不能粘貼中文
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void OnIntEditValueChanging(object sender, DevExpress.XtraEditors.Controls.ChangingEventArgs e)
|
|
{
|
|
string newText = e.NewValue as string;
|
|
|
|
|
|
// 第一个输入负号不会取消,出现了千位分隔符不会取消更改,末尾为百分号不会取消
|
|
if (!newText.Equals("-") && !string.IsNullOrEmpty(newText) && !Regex.IsMatch(newText, @"^(?:-(?:[0-9]+(?:,[0-9]{3})*(?:\.[0-9]*)?)|[0-9]+(?:,[0-9]{3})*(?:\.[0-9]*)?)(?:%)?$"))
|
|
{
|
|
e.Cancel = true; // 取消这次更改
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 限制數值框不能輸入中文
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void OnIntKeyPress(object sender, KeyPressEventArgs e)
|
|
{
|
|
// 检查输入的是否是数字或控制字符(例如退格键)
|
|
if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar) &&
|
|
(e.KeyChar != '.') && (e.KeyChar != '-') && (e.KeyChar != '%'))
|
|
{
|
|
e.Handled = true; // 不处理这个字符,即不会显示在控件中
|
|
}
|
|
|
|
// 只允许输入一个小数点
|
|
if ((e.KeyChar == '.') && ((sender as TextEdit).Text.IndexOf('.') > -1))
|
|
{
|
|
e.Handled = true;
|
|
}
|
|
|
|
// 只允许输入一个负号
|
|
if ((e.KeyChar == '-') && ((sender as TextEdit).Text.IndexOf('-') > -1))
|
|
{
|
|
e.Handled = true;
|
|
}
|
|
// 只允许输入一个百分号
|
|
if ((e.KeyChar == '%') && ((sender as TextEdit).Text.IndexOf('%') > -1))
|
|
{
|
|
e.Handled = true;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:智能搜索框点击按钮刷新数据源</para>
|
|
/// <para>创建人:曹屹峰</para>
|
|
/// <para>创建日期:2023-01-06 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void OnLabelAutoGridLookRefreshDataSource(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
WaitForm.ShowForm();
|
|
if (sender is LabelAutoGridLook)
|
|
{
|
|
LabelAutoGridLook gridEdit = sender as LabelAutoGridLook;
|
|
DataTable table = MainImpl.GetDataTableResult(gridEdit.SourceSQL);
|
|
gridEdit.SetDataSource(table);
|
|
}
|
|
if (sender is LabelAutoTextEdit)
|
|
{
|
|
LabelAutoTextEdit gridEdit = sender as LabelAutoTextEdit;
|
|
DataTable table = MainImpl.GetDataTableResult(gridEdit.TextEdit.SourceSQL);
|
|
gridEdit.SetDataSource(table);
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
|
|
}
|
|
finally
|
|
{
|
|
WaitForm.HideForm();
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:获取上一次选中行</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-09-04 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns>System.Int32.</returns>
|
|
private int GetFocusedRowHandle()
|
|
{
|
|
int oldRowHandle = 0;
|
|
if (_gridControl != null)
|
|
{
|
|
if (_gridControl.MainView is GridView)
|
|
{
|
|
oldRowHandle = (_gridControl.MainView as GridView).FocusedRowHandle;
|
|
}
|
|
if (_gridControl.MainView is LayoutView)
|
|
{
|
|
oldRowHandle = (_gridControl.MainView as LayoutView).FocusedRowHandle;
|
|
}
|
|
}
|
|
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>
|
|
/// <para>创建日期:2017-09-04 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="rowHandle">The row handle.</param>
|
|
/// <returns>System.Int32.</returns>
|
|
private void SetFocusedRowHandle(int rowHandle)
|
|
{
|
|
if (_gridControl != null)
|
|
{
|
|
if (_gridControl.MainView is GridView)
|
|
{
|
|
(_gridControl.MainView as GridView).SelectRowHandler(rowHandle);
|
|
}
|
|
|
|
if (_gridControl.MainView is LayoutView)
|
|
{
|
|
(_gridControl.MainView as LayoutView).ClearSelection();
|
|
(_gridControl.MainView as LayoutView).FocusedRowHandle = rowHandle;
|
|
(_gridControl.MainView as LayoutView).SelectRow(rowHandle);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <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>
|
|
/// <para>创建日期:2017-09-04 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns>System.String.</returns>
|
|
public string SetSearchSqlValue(string searchSql, bool hasReplaceCond = true, bool state = true)
|
|
{
|
|
string sqlValue = searchSql;
|
|
sqlValue = ReplaceLeftOrGridValue(searchSql, state);
|
|
List<string> paramList = ReplaceHelper.GetParamFields(sqlValue);
|
|
|
|
if (ReplaceHelper.IsProcedure(sqlValue))
|
|
{
|
|
foreach (string item in paramList)
|
|
{
|
|
string fileName = item.Replace("{", "").Replace("}", "");
|
|
sqlValue = sqlValue.Replace(item, GetControlValue(fileName));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (this._parentPanel != null && hasReplaceCond)
|
|
{
|
|
StringBuilder strWhere = new StringBuilder();
|
|
|
|
if (_leftSearch != null)
|
|
{
|
|
// 自定义查询条件处理
|
|
foreach (DataRow dr in this._leftSearch._controls.Rows)
|
|
{
|
|
int fieldTypeId = Convert.ToInt32(dr["fieldTypeId"] + "");
|
|
string cond = dr["checkCond"] + "";
|
|
string fieldName = dr["fieldName"].ToString().Replace("{", "").Replace("}", "");
|
|
string fieldValue = _leftSearch.GetControlValue(fieldName);
|
|
// 处理sql中的配置参数
|
|
foreach (string item in paramList)
|
|
{
|
|
if (item.Contains("{#") && fieldName.Equals(item.Replace("{#", "").Replace("}", ""), StringComparison.OrdinalIgnoreCase))
|
|
sqlValue = sqlValue.Replace(item, fieldValue);
|
|
if (item.Contains("{") && fieldName.Equals(item.Replace("{", "").Replace("}", ""), StringComparison.OrdinalIgnoreCase))
|
|
sqlValue = sqlValue.Replace(item, fieldValue);
|
|
}
|
|
}
|
|
}
|
|
if (this._fixButton != null)
|
|
{
|
|
// 固定查询条件处理
|
|
string field = this._fixField.SelectedValue + "";
|
|
string fieldText = this._fixKey.Text;
|
|
if (!string.IsNullOrWhiteSpace(field))
|
|
{
|
|
strWhere.Append(string.Format(" and (dbo.P_getpy('{0}') like '%{1}%' or {0} like '%{1}%')", field, fieldText));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// 自定义查询条件处理
|
|
foreach (DataRow dr in this._controls.Rows)
|
|
{
|
|
int fieldTypeId = Convert.ToInt32(dr["fieldTypeId"] + "");
|
|
string cond = dr["checkCond"] + "";
|
|
string fieldName = dr["fieldName"].ToString().Replace("{", "").Replace("}", "");
|
|
string fieldValue = GetControlValue(fieldName, true);
|
|
if (SystemInfo.Instance.TrimWhiteSpace)
|
|
cond = ReplaceHelper.ReplaceSearchControlCond(cond, fieldValue.Trim());
|
|
else
|
|
cond = ReplaceHelper.ReplaceSearchControlCond(cond, fieldValue);
|
|
|
|
// 带复选框控件构造sql语句时,假如没有值,则不构造查询条件
|
|
if ((fieldTypeId == ControlType.LabCheckAutoSeacherText ||
|
|
fieldTypeId == ControlType.LabCheckAutoSeacherValue ||
|
|
fieldTypeId == ControlType.LabCheckBox ||
|
|
fieldTypeId == ControlType.LabCheckComboxText ||
|
|
fieldTypeId == ControlType.LabCheckComboxValue ||
|
|
fieldTypeId == ControlType.LabCheckDateEx ||
|
|
fieldTypeId == ControlType.LabCheckDateTimeEx ||
|
|
fieldTypeId == ControlType.LabCheckDateTimeShort ||
|
|
fieldTypeId == ControlType.LabCheckShortTime ||
|
|
fieldTypeId == ControlType.LabCheckTime ||
|
|
fieldTypeId == ControlType.LabCheckMultiSelectValue ||
|
|
fieldTypeId == ControlType.LabCheckText ||
|
|
fieldTypeId == ControlType.LabCheckMultiSelectText) && string.IsNullOrWhiteSpace(fieldValue))
|
|
{
|
|
cond = "";
|
|
}
|
|
// 处理sql中的配置参数
|
|
foreach (string item in paramList)
|
|
{
|
|
if (item.Contains("{&") && fieldName.Equals(item.Replace("{&", "").Replace("}", ""), StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
sqlValue = sqlValue.Replace(item, cond);
|
|
cond = "";
|
|
}
|
|
if (item.Contains("{") && fieldName.Equals(item.Replace("{", "").Replace("}", ""), StringComparison.OrdinalIgnoreCase))
|
|
sqlValue = sqlValue.Replace(item, fieldValue);
|
|
}
|
|
strWhere.Append(" " + cond);
|
|
}
|
|
}
|
|
sqlValue = ReplaceHelper.ReplaceWhereCond(sqlValue) + strWhere.ToString();
|
|
}
|
|
}
|
|
return sqlValue;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:设置所有控件值</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-03-05 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="models">The models.</param>
|
|
/// <returns>System.String.</returns>
|
|
private void SetAllControlValueByUnEmpty(List<ControlModel> models)
|
|
{
|
|
if (models == null || models.Count == 0) return;
|
|
|
|
foreach (ControlModel model in this.ControlModels)
|
|
{
|
|
if (model.FieldType == ControlType.LabTreeType)
|
|
{
|
|
SetControlValue(model, this.ParentKey);
|
|
}
|
|
else if (!string.IsNullOrEmpty(model.DefaultValue))
|
|
{
|
|
SetControlValue(model, model.DefaultValue);
|
|
}
|
|
}
|
|
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:设置关联值和计算值</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-03-06 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="baseControl">The base control.</param>
|
|
private void SetUnionAncCalcControl(BaseUserControl baseControl)
|
|
{
|
|
if (baseControl != null && baseControl.Model != null)
|
|
{
|
|
ControlModel model = baseControl.Model as ControlModel;
|
|
if (this.CanExecControl)
|
|
{
|
|
// 是否存在计算值
|
|
this.SetCalcControl(model);
|
|
// 是否存在关联值
|
|
if (!string.IsNullOrWhiteSpace(model.UnionValues) && !string.IsNullOrWhiteSpace(model.UnionFields))
|
|
{
|
|
this.SetUnionControl(model);
|
|
}
|
|
}
|
|
this.SetDisableControl(model);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:设置关联值</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-12-06 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="model">The model.</param>
|
|
private void SetUnionControl(ControlModel model)
|
|
{
|
|
string fieldValue = GetControlValue(model);
|
|
|
|
string unionFields = model.UnionFields;
|
|
string unionValues = ReplaceControlValue(model.UnionValues);
|
|
|
|
try
|
|
{
|
|
DataTable table = BaseImpl.GetDataTableResult(unionValues);
|
|
foreach (string field in unionFields.Trim(',').Split(','))
|
|
{
|
|
if (table.Rows.Count > 0 && table.Columns.Contains(field))
|
|
{
|
|
SetControlValue(field, table.Rows[0][field] + "");
|
|
}
|
|
else
|
|
{
|
|
SetControlValue(field, "");
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Instance.WriteError(ex);
|
|
LogUtil.WriteError("设置关联值出错!", ex);
|
|
//MessageUtil.Show("设置关联值出错!" + ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-12-15 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="model">The model.</param>
|
|
private void SetCalcControl(ControlModel model)
|
|
{
|
|
if (this._calcControls == null || this._calcControls.Count == 0) return;
|
|
|
|
string fieldValue = GetControlValue(model);
|
|
|
|
List<ControlModel> calcModels = this._calcControls.FindAll(x => !string.IsNullOrEmpty(x.CalcExpr) && x.CalcOrder >= model.CalcOrder && x.CalcExpr.ToLower().Contains(model.FieldName.ToLower())).OrderBy(y => y.CalcOrder).ToList();
|
|
|
|
foreach (ControlModel item in calcModels)
|
|
{
|
|
try
|
|
{
|
|
string calcValue = "";
|
|
bool isTruncate = false;
|
|
bool isSql = false;
|
|
string calcExpr = item.CalcExpr;
|
|
if (item.CalcExpr.StartsWith("@truncate:"))
|
|
{
|
|
calcExpr = calcExpr.Substring(10);
|
|
isTruncate = true;
|
|
}
|
|
else if (item.CalcExpr.StartsWith("@") || calcExpr.StartsWith("!"))
|
|
{
|
|
isSql = true;
|
|
}
|
|
if (isSql)
|
|
{
|
|
calcExpr = ReplaceControlValue(calcExpr.Replace("{" + model.FieldName + "}", fieldValue));
|
|
calcValue = BaseImpl.GetDefaultValue(calcExpr);
|
|
}
|
|
else
|
|
{
|
|
if (string.IsNullOrWhiteSpace(fieldValue)) fieldValue = "0";
|
|
calcExpr = ReplaceControlValue(calcExpr.Replace("{" + model.FieldName + "}", fieldValue));
|
|
object evalResult = EvalHelper.Eval(ReplaceHelper.ReplaceEvalCond(calcExpr));
|
|
calcValue = JsonConvert.SerializeObject(evalResult);
|
|
//calcValue = EvalHelper.Eval(ReplaceHelper.ReplaceEvalCond(calcExpr)) + "";
|
|
}
|
|
if (isTruncate)
|
|
{
|
|
calcValue += calcValue.Contains(".") ? "0000000000" : ".0000000000";
|
|
calcValue = calcValue.Substring(0, calcValue.IndexOf(".")) + calcValue.Substring(calcValue.IndexOf("."), item.DataDec + 1);
|
|
}
|
|
else
|
|
{
|
|
//计算处理精度
|
|
//float feval = 0.0f;
|
|
if (!string.IsNullOrEmpty(calcValue) && !string.IsNullOrEmpty(item.DataFormat))
|
|
{
|
|
//计算后先执行保存小数位数
|
|
calcValue = string.Format("{0:" + item.DataFormat + "}", Convert.ToDecimal(calcValue));
|
|
//calcValue = string.IsNullOrEmpty(item.DataFormat) ? Math.Round(feval, 2).ToString() : string.Format("{0:" + item.DataFormat + "}", float.Parse(calcValue));
|
|
}
|
|
}
|
|
this.SetControlValue(item, calcValue);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Instance.WriteError(ex);
|
|
LogUtil.WriteError("判断是否存在计算值出错!", ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
//MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:设置控件禁编或隐藏</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2019-01-22 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="model">The model.</param>
|
|
/// <param name="fieldValue">The field value.</param>
|
|
private void SetDisableControl(ControlModel model)
|
|
{
|
|
ControlModel[] controls = this._models.Where(x => x.DisableCond.Contains("{" + model.FieldName + "}")).ToArray();
|
|
if (controls == null || controls.Length == 0) return;
|
|
|
|
string fieldValue = GetControlValue(model);
|
|
foreach (ControlModel item in controls)
|
|
{
|
|
try
|
|
{
|
|
string disableCond = this.ReplaceControlValue(item.DisableCond.Replace("{" + model.FieldName + "}", fieldValue));
|
|
string disableType = item.DisableType;
|
|
|
|
if ("1".Equals(disableType))
|
|
{
|
|
BaseUserControl control = FindControl(item);
|
|
//control.Visible = ("true".Equals(EvalHelper.Eval(ReplaceHelper.ReplaceEvalCond(disableCond)) + "", StringComparison.OrdinalIgnoreCase));
|
|
control.Visible = ("true".Equals(ValidateCond(disableCond, null) + "", StringComparison.OrdinalIgnoreCase));
|
|
}
|
|
else
|
|
{
|
|
BaseUserControl control = FindControl(item);
|
|
//control.Enabled = ("true".Equals(EvalHelper.Eval(ReplaceHelper.ReplaceEvalCond(disableCond)) + "", StringComparison.OrdinalIgnoreCase));
|
|
control.Enabled = ("true".Equals(ValidateCond(disableCond, null) + "", StringComparison.OrdinalIgnoreCase));
|
|
control.ReadOnly = !("true".Equals(ValidateCond(disableCond, null) + "", StringComparison.OrdinalIgnoreCase));
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//MessageUtil.Show(ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:检查可用条件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-09 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="cond">The cond.</param>
|
|
/// <param name="dataRow">The data row.</param>
|
|
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
|
private bool ValidateCond(string cond, DataRow dataRow)
|
|
{
|
|
bool result = false;
|
|
try
|
|
{
|
|
cond = ReplaceHelper.ReplaceRowParam(dataRow, cond);
|
|
if (cond.StartsWith("@") || cond.StartsWith("!"))
|
|
{
|
|
result = "1".Equals(BaseImpl.GetDefaultValue(cond));
|
|
}
|
|
else if (dataRow == null)
|
|
{
|
|
result = ReplaceHelper.EvalCond(cond);
|
|
}
|
|
else
|
|
{
|
|
result = ReplaceHelper.ReplaceRowParamCond(dataRow, cond);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
}
|
|
|
|
return result;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:替换左侧树结构、表格数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-09-04 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns>System.String.</returns>
|
|
public string ReplaceLeftOrGridValue(string sqlValue, bool state)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(sqlValue)) return sqlValue;
|
|
// 替换左侧树结构
|
|
if (_tvLeft != null)
|
|
{
|
|
TreeNode tn = _tvLeft.TreeView.SelectedNode;
|
|
if (tn == null)
|
|
tn = _tvLeft.TreeView.Nodes[0];
|
|
string ids = _tvLeft.GetCheckValues();
|
|
if (!sqlValue.ToUpper().Contains("EXEC"))
|
|
{
|
|
|
|
//sqlValue = ReplaceHelper.ReplaceWhereCond(sqlValue);
|
|
if (!string.IsNullOrWhiteSpace(ids))
|
|
{
|
|
if (!ids.Contains(tn.Name) && state == true)
|
|
{
|
|
sqlValue += _tvLeft.TreeView.Focused ? " and " + ParentUnionField + " like '" + tn.Name + "%'" : "";
|
|
}
|
|
else
|
|
{
|
|
sqlValue += " and " + ParentUnionField + " in (" + ids.Trim(',') + ")";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//2023-9-20删除此处条件拼接,ModuleEx中点击左侧树查询主表时,树条件已经拼接
|
|
//sqlValue += _tvLeft.TreeView.Focused ? " and " + ParentUnionField + " like '" + tn.Name + "%'" : "";
|
|
}
|
|
// select语句追加条件
|
|
sqlValue = ReplaceHelper.ReplaceTreeViewParentKeyCond(sqlValue, ids);
|
|
}
|
|
else
|
|
{
|
|
if (string.IsNullOrWhiteSpace(ids.Trim()))
|
|
{
|
|
ids = tn.Name;
|
|
}
|
|
// 存储过程替换参数
|
|
if (state)
|
|
{
|
|
sqlValue = ReplaceHelper.ReplaceTreeViewParentKeyCond(sqlValue, tn.Name);
|
|
}
|
|
else
|
|
{
|
|
if (!string.IsNullOrEmpty(ids))
|
|
sqlValue = ReplaceHelper.ReplaceTreeViewParentKeyCond(sqlValue, ids.Replace("'", ""));
|
|
}
|
|
}
|
|
}
|
|
// 替换左侧表格
|
|
if (_gridLeft != null && state)
|
|
{
|
|
GridView gridview = _gridLeft.GridControl.DefaultView as GridView;
|
|
|
|
DataRow rowItem = gridview.GetFocusedDataRow();
|
|
if (rowItem != null)
|
|
{
|
|
sqlValue = ReplaceHelper.ReplaceRowParam(rowItem, sqlValue);
|
|
if (!IsExecAtStart(sqlValue))//sqlValue.ToLower().StartsWith("exec")
|
|
{
|
|
|
|
|
|
//sqlValue = ReplaceHelper.ReplaceWhereCond(sqlValue);
|
|
sqlValue += " and " + ParentUnionField + "='" + rowItem[ParentKeyField] + "'";
|
|
}
|
|
}
|
|
if (_gridLeft is TreeGridControlEx)
|
|
{
|
|
rowItem = _gridLeft.GetViewFocusedDataRow();
|
|
if (rowItem != null)
|
|
{
|
|
sqlValue = ReplaceHelper.ReplaceRowParam(rowItem, sqlValue);
|
|
if (!IsExecAtStart(sqlValue))
|
|
{
|
|
sqlValue += this.TreeExactQuery ? " and " + ParentUnionField + "='" + rowItem[ParentKeyField] + "'" : " and " + ParentUnionField + " like '" + rowItem[ParentKeyField] + "%'";
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
return ReplaceHelper.ReplaceWhereCond(sqlValue) + WhereCond;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:打印</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2019-06-05 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="value">The value.</param>
|
|
/// <param name="printFile">The print file.</param>
|
|
private void Print(string value, string printFile, string parameter = "")
|
|
{
|
|
if (SystemModel == null) return;
|
|
string printPath = PubUtil.PrintFileAbsolutelyPath;
|
|
|
|
if (!File.Exists(printPath))
|
|
{
|
|
MessageUtil.Show(ResourceKeys.NotFoundPrintFile);
|
|
return;
|
|
}
|
|
|
|
try
|
|
{
|
|
// 判断是否满足打印条件
|
|
string printCond = this.ReplaceControlValue(this.SystemModel.PrintCond);
|
|
if (!string.IsNullOrEmpty(printCond) && !ReplaceHelper.EvalCond(printCond))
|
|
{
|
|
MessageUtil.Show(ResourceKeys.DisSatisfyPrintCond);
|
|
return;
|
|
}
|
|
|
|
string tmpSql = this.ReplaceControlValue(this.SystemModel.PrintSql);
|
|
string tmpSql1 = this.ReplaceControlValue(this.SystemModel.PrintSql1);
|
|
string tmpSql2 = this.ReplaceControlValue(this.SystemModel.PrintSql2);
|
|
if (!string.IsNullOrWhiteSpace(parameter))
|
|
{
|
|
string[] parameters = parameter.Split('|');
|
|
foreach (string item in parameters)
|
|
{
|
|
string[] Replacing = item.Split('=');
|
|
tmpSql = ReplaceHelper.ReplaceParamToValue(tmpSql, Replacing[0], Replacing[1]);
|
|
tmpSql1 = ReplaceHelper.ReplaceParamToValue(tmpSql1, Replacing[0], Replacing[1]);
|
|
tmpSql2 = ReplaceHelper.ReplaceParamToValue(tmpSql2, Replacing[0], Replacing[1]);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
DelphiHelper.LoadDelphiDll(printPath, printPath, printFile, tmpSql, tmpSql1, this.SystemModel.PrintType, tmpSql2);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//MessageUtil.Show(ex.Message + "\r\n" + ex.StackTrace);
|
|
LogHelper.Instance.WriteError(ex);
|
|
LogUtil.WriteError("打印出错!", ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:调用弹出dll</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2020-04-14 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void CallLibrary(string msgs)
|
|
{
|
|
if (msgs.Contains("module=") && (msgs.ToLower()).Contains(".dll;"))
|
|
{
|
|
msgs = msgs.Replace("module=", "");
|
|
string[] paramters = msgs.Split('=');
|
|
if (paramters.Length != 2)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.ProcNameSettingFault);
|
|
return;
|
|
}
|
|
string[] defaultParams = paramters[1].Split('^');
|
|
if (defaultParams.Length < 4)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.ExcuteMoudleFail);
|
|
return;
|
|
}
|
|
string dllName = defaultParams[1];
|
|
string moduleTitle = defaultParams[2];
|
|
string saveState = defaultParams[3];
|
|
if ("lskj.pubadd3.dll".Equals(dllName) || "lskj.pubadd2.dll".Equals(dllName) || "lskj.pubadd4.dll".Equals(dllName))
|
|
dllName = "Lskj.PubAdd.dll";
|
|
|
|
List<string> paramList = new List<string>();
|
|
for (int i = 4; i < 14; i++)
|
|
{
|
|
paramList.Add(defaultParams.Length > i ? defaultParams[i] : "");
|
|
}
|
|
//执行dll
|
|
string[] str = {
|
|
moduleTitle,
|
|
ERPInfo.Instance.UserId,
|
|
ERPInfo.Instance.UserName,
|
|
"1",
|
|
ERPInfo.Instance.WorkModid,
|
|
paramList[0],
|
|
paramList[1],
|
|
paramList[2],
|
|
paramList[3],
|
|
paramList[4],
|
|
paramList[5],
|
|
paramList[6],
|
|
paramList[7],
|
|
paramList[8],
|
|
paramList[9],
|
|
"",
|
|
"",
|
|
saveState
|
|
};
|
|
IForm form = FormHelper.LoadDllForm(dllName, str);
|
|
if (form == null)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.DyncmicDllNotFount);
|
|
return;
|
|
}
|
|
if (form.SubForm == null)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.DyncmicDllInitFault);
|
|
return;
|
|
}
|
|
form.SubForm.WindowState = FormWindowState.Normal;
|
|
form.SubForm.StartPosition = FormStartPosition.CenterScreen;
|
|
form.SubForm.Text = moduleTitle;
|
|
DialogResult dr = form.SubForm.ShowDialog();
|
|
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期: </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="msgs">The MSGS.</param>
|
|
private void CallDelphi(string msgs)
|
|
{
|
|
if (msgs.Contains("module=") && (msgs.ToLower()).Contains(".lsp;"))
|
|
{
|
|
string filepath = string.Empty;
|
|
string title = string.Empty;
|
|
string paramstr = string.Empty;
|
|
msgs = msgs.Replace("module=", "");
|
|
string[] paramters = msgs.Split(';');
|
|
|
|
List<string> paramList = new List<string>();
|
|
if (paramters != null && paramters.Length >= 2)
|
|
{
|
|
filepath = paramters[0].Replace("filepath=", "");
|
|
title = paramters[1].Replace("title=", "");
|
|
paramstr = paramters[2].Replace("params=", "");
|
|
paramList = paramstr.Split('^').ToList();
|
|
}
|
|
DelphiHelper.LoadDelphiDll(PubUtil.AbsolutelyLibPath + filepath, "", "", paramList[0], paramList[1], 0, paramList[2]);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:控件值改变时</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-12-06 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The source of the event.</param>
|
|
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
|
protected void OnTextEditTextChanged(object sender, EventArgs e)
|
|
{
|
|
BaseUserControl baseControl = (sender as System.Windows.Forms.Control).ToBaseUserControl();
|
|
this.SetUnionAncCalcControl(baseControl);
|
|
if (baseControl.Model != null && baseControl.Model.IsRefreshSource == 1 && OnSourceRefrshCallBack != null)
|
|
{
|
|
this.RefreshControl = baseControl.Model.FieldName;//条件表刷新上表的关键字段名
|
|
OnSourceRefrshCallBack(sender, null);
|
|
}
|
|
if (baseControl.Model != null && baseControl.Model.SchedStartDataControl && OnDataFileRefrshCallBack != null)
|
|
{
|
|
OnDataFileRefrshCallBack(sender, null);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-12-15 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The source of the event.</param>
|
|
/// <param name="e">The <see cref="KeyEventArgs"/> instance containing the event data.</param>
|
|
protected void OnTextEditKeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
BaseUserControl baseControl = null;
|
|
var ctr = sender as System.Windows.Forms.Control;
|
|
if (ctr != null && ctr.Parent != null && ctr.Parent.Parent != null)
|
|
baseControl = ctr.Parent.Parent as BaseUserControl;
|
|
|
|
if (e.KeyCode == Keys.Enter)
|
|
{
|
|
if (baseControl != null && baseControl.Model != null)
|
|
{
|
|
if (baseControl.Model.IsSearchControl)
|
|
{
|
|
// 搜索控件回车直接搜索
|
|
SearchArgs args = new SearchArgs();
|
|
// 查询之前
|
|
if (OnSearchBeforeCallBack != null)
|
|
OnSearchBeforeCallBack(sender, args);
|
|
|
|
if (args.Continue) this.SearchGrid(false);
|
|
|
|
// 查询之后
|
|
if (OnSearchAfterCallBack != null) OnSearchAfterCallBack(sender, e);
|
|
|
|
if (baseControl.Model.ScanAfterEmpty)
|
|
{
|
|
baseControl.EditText = string.Empty;
|
|
}
|
|
}
|
|
else if (baseControl.Model.IsAddControl)
|
|
{
|
|
if (OnAddCallBack != null)
|
|
{
|
|
OnAddCallBack(sender, e);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (e.Control == false)
|
|
{
|
|
// 非搜索控件回车跳到下一个可编辑控件
|
|
//_parentPanel.SelectNextControl(baseControl, true, false, true, false);
|
|
//扫码框和备注框不改变焦点
|
|
if (baseControl.Model.FieldType != ControlType.LabPcSacn && baseControl.Model.FieldType != ControlType.LabRemark)
|
|
{
|
|
if (baseControl.Model.FieldType == ControlType.LabAutoCompleteValue ||
|
|
baseControl.Model.FieldType == ControlType.LabAutoCompleteValueParam ||
|
|
baseControl.Model.FieldType == ControlType.LabAutoCompleteText ||
|
|
baseControl.Model.FieldType == ControlType.LabAutoCompleteValueParam)
|
|
{
|
|
LabelAutoTextEdit autoEdit = baseControl as LabelAutoTextEdit;
|
|
if (autoEdit.TextEdit.IsShowPopup)
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
else if (baseControl.Model.FieldType == ControlType.LabAutoGridValue ||
|
|
baseControl.Model.FieldType == ControlType.LabAutoGridValueParam ||
|
|
baseControl.Model.FieldType == ControlType.LabAutoGridText ||
|
|
baseControl.Model.FieldType == ControlType.LabAutoGridTextParam)
|
|
{
|
|
LabelAutoGridLook gridEdit = baseControl as LabelAutoGridLook;
|
|
if (gridEdit.IsShowPopup)
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
bool isSaveSkip = false;
|
|
BaseUserControl control = FindNextControl(baseControl, out isSaveSkip);
|
|
if (control != null)
|
|
{
|
|
control.Focus();
|
|
}
|
|
else
|
|
{
|
|
SendKeys.Send("{TAB}");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (baseControl != null && baseControl.Model != null)
|
|
{
|
|
if (baseControl.Model.FieldType == ControlType.LabPcSacn)
|
|
{
|
|
if (e.KeyCode == Keys.Back || e.KeyCode == Keys.Delete)
|
|
{
|
|
e.Handled = false;
|
|
e.SuppressKeyPress = false;
|
|
}
|
|
else
|
|
{
|
|
e.Handled = true;
|
|
e.SuppressKeyPress = true;
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:搜索回调</para>
|
|
/// <para>创建人:唐德馨</para>
|
|
/// <para>创建日期:2023-09-20 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
protected void OnTextEditSearchCallBack(object sender, EventArgs e)
|
|
{
|
|
BaseUserControl baseControl = null;
|
|
var ctr = sender as System.Windows.Forms.Control;
|
|
if (ctr != null && ctr.Parent != null && ctr.Parent.Parent != null)
|
|
baseControl = ctr.Parent.Parent as BaseUserControl;
|
|
if (baseControl != null && baseControl.Model != null)
|
|
{
|
|
if (baseControl.Model.IsSearchControl)
|
|
{
|
|
// 搜索控件回车直接搜索
|
|
SearchArgs args = new SearchArgs();
|
|
// 查询之前
|
|
if (OnSearchBeforeCallBack != null)
|
|
OnSearchBeforeCallBack(sender, args);
|
|
if (args.Continue) this.SearchGrid(false);
|
|
// 查询之后
|
|
if (OnSearchAfterCallBack != null) OnSearchAfterCallBack(sender, e);
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:搜索按钮点击</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-09-01 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The source of the event.</param>
|
|
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
|
protected void OnSimpleButtonClick(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (Model != null)
|
|
{
|
|
bool allowBefore = ApiHelper.IsExecEventApi(Interface.Api.OperateEvent.BeforeSearchBtnClick, Model.ModuleCode, 0);
|
|
//查询前调用Api接口
|
|
if (allowBefore)
|
|
{
|
|
DataRow dataRow = this.GetAllControlValueRow();
|
|
ApiHelper apiHelper = new ApiHelper(Model.ModuleCode, 0, dataRow);
|
|
apiHelper.OnEvent(Interface.Api.OperateEvent.BeforeSearchBtnClick, Interface.Api.ActionType.None);
|
|
if (apiHelper.apiHandlerModels.Count > 0)
|
|
{
|
|
Hashtable hashtable = apiHelper.apiHandlerModels[apiHelper.apiHandlerModels.Count - 1].resultPmsHashtables[0];
|
|
if (hashtable.ContainsKey("result"))
|
|
{
|
|
string jsonResult = hashtable["result"] + "";
|
|
DataTable dataTable = JsonConvert.DeserializeObject<DataTable>(jsonResult);
|
|
this._mainGridEx.SetGridViewDataSource(dataTable);
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageUtil.Show(ex.Message);
|
|
}
|
|
SearchArgs args = new SearchArgs();
|
|
// 查询之前
|
|
if (OnSearchBeforeCallBack != null)
|
|
OnSearchBeforeCallBack(sender, args);
|
|
|
|
if (args.Continue) this.SearchGrid(false);
|
|
|
|
// 查询之后
|
|
if (OnSearchAfterCallBack != null) OnSearchAfterCallBack(sender, e);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <para>说明:刷新按钮点击</para>
|
|
/// <para>创建人:曹屹峰</para>
|
|
/// <para>创建日期:2023-08-18 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The source of the event.</param>
|
|
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
|
protected void OnRefreshButtonClick(object sender, EventArgs e)
|
|
{
|
|
mLoading = false;
|
|
mTimerTick(null, null);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <para>说明:默认查询条件查询</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-16 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The source of the event.</param>
|
|
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
|
protected void OnFixButtonClick(object sender, EventArgs e)
|
|
{
|
|
SearchArgs args = new SearchArgs();
|
|
// 查询之前
|
|
if (OnSearchBeforeCallBack != null)
|
|
OnSearchBeforeCallBack(sender, args);
|
|
|
|
if (args.Continue) this.SearchGrid(false);
|
|
|
|
// 查询之后
|
|
if (OnSearchAfterCallBack != null) OnSearchAfterCallBack(sender, e);
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:高级搜索按钮鼠标离开时</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-09-04 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The source of the event.</param>
|
|
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
|
protected void OnDropDownLeave(object sender, EventArgs e)
|
|
{
|
|
if (_popupMenu != null) _popupMenu.HidePopup();
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:item click event</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-09-04 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The source of the event.</param>
|
|
/// <param name="e">The <see cref="ItemClickEventArgs"/> instance containing the event data.</param>
|
|
protected void OnPopupItemClick(object sender, ItemClickEventArgs e)
|
|
{
|
|
string searchValue = e.Item.Tag + "";
|
|
|
|
string[] searchSplits = searchValue.Split(new char[] { '|', '=' });
|
|
for (int i = 0; i < searchSplits.Length; i += 2)
|
|
{
|
|
string fieldName = searchSplits[i];
|
|
string fieldValue = searchSplits[i + 1];
|
|
|
|
this.SetControlValue(fieldName, fieldValue);
|
|
}
|
|
|
|
this._button.PerformClick();
|
|
}
|
|
/// <summary>
|
|
/// 条件搜索按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void OnBtnCondSearchClick(object sender, EventArgs e)
|
|
{
|
|
SimpleButton simpleButton = (SimpleButton)sender;
|
|
ModuleConditionsPanelEx conditionsPanel = (ModuleConditionsPanelEx)simpleButton.Tag;
|
|
DialogResult dialogResult = conditionsPanel.ShowDialog();
|
|
if (dialogResult == DialogResult.OK)
|
|
{
|
|
this.MainGridEx.LastSearchSql = conditionsPanel.CondSql;
|
|
conditionsPanel.ReplaceParentControlObj(this);
|
|
if (!string.IsNullOrWhiteSpace(conditionsPanel.CondSql))
|
|
{
|
|
this.SearchLastGrid();
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:保存方案</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-09-04 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The source of the event.</param>
|
|
/// <param name="e">The <see cref="ItemClickEventArgs"/> instance containing the event data.</param>
|
|
protected void OnPopupSaveItemClick(object sender, ItemClickEventArgs e)
|
|
{
|
|
FrmPrompt prompt = new FrmPrompt(ResourceKeys.InputProjectName);
|
|
prompt.Size = new Size(300, 200);
|
|
|
|
DialogResult dialog = prompt.ShowDialog();
|
|
if (dialog == DialogResult.OK)
|
|
{
|
|
string projectName = prompt.PromptMsg;
|
|
string controlValue = GetAllControlValue();
|
|
|
|
int result = BaseModuleImpl.SaveProject(projectName, controlValue, ModuleId + "");
|
|
if (result == 1)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.SaveSuccess);
|
|
this._schemes = BaseModuleImpl.GetSchemesList(this.ModuleId);
|
|
this.CreateSearchScheme();
|
|
}
|
|
else
|
|
{
|
|
MessageUtil.Show(result == 2 ? ResourceKeys.ExistsProjectName : ResourceKeys.SaveFault);
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:方案管理</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-09-04 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The source of the event.</param>
|
|
/// <param name="e">The <see cref="ItemClickEventArgs"/> instance containing the event data.</param>
|
|
protected void OnPopupManagerItemClick(object sender, ItemClickEventArgs e)
|
|
{
|
|
FrmProjectManager project = new FrmProjectManager();
|
|
project.ModuleId = this.ModuleId + "";
|
|
project.Projects = this._schemes;
|
|
DialogResult result = project.ShowDialog();
|
|
|
|
if (result == DialogResult.OK)
|
|
{
|
|
this._schemes = project.Projects;
|
|
this.CreateSearchScheme();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Box点击事件移除焦点
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void OnGroupClick(object sender, EventArgs e)
|
|
{
|
|
LabelGroupBox labelGroupBox = (LabelGroupBox)sender;
|
|
labelGroupBox.Focus();
|
|
}
|
|
/// <summary>
|
|
/// 获取控件models集合
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private Hashtable GetControlModelsValues(List<ControlModel> models)
|
|
{
|
|
Hashtable hashtable = new Hashtable();
|
|
foreach (ControlModel item in models)
|
|
{
|
|
hashtable.Add(item.FieldName, item.DefaultValue);
|
|
}
|
|
return hashtable;
|
|
}
|
|
/// <summary>
|
|
/// 接口控件按钮点击
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void OnLabelWeighButtonClick(object sender, EventArgs e)
|
|
{
|
|
LabelWeigh labelWeigh = (LabelWeigh)sender;
|
|
ControlModel controlModel = labelWeigh.Tag as ControlModel;
|
|
DataRow dataRow = this.GetAllControlValueRow();
|
|
ApiHelper apiHelper = new ApiHelper(SystemModel.ModeCode, Convert.ToInt32(controlModel.id), dataRow);
|
|
apiHelper.OnEvent(Interface.Api.OperateEvent.AfterLabApiBtnClick, Interface.Api.ActionType.None);
|
|
if (controlModel.FieldType == ControlType.Weigh)
|
|
{
|
|
string value = AfterLabelWeighButtonClick(controlModel, dataRow);
|
|
labelWeigh.EditText = value;
|
|
}
|
|
}
|
|
|
|
private string AfterLabelWeighButtonClick(ControlModel controlModel, DataRow dataRow)
|
|
{
|
|
string value = "";
|
|
try
|
|
{
|
|
string defaultValue = this.SystemModel != null ? ReplaceHelper.ReplaceRowParam(dataRow, controlModel.Default) : controlModel.DefaultValue;
|
|
value = BaseImpl.GetDefaultValue(defaultValue, ParentKey, OtherParams);
|
|
}
|
|
catch (Exception)
|
|
{
|
|
|
|
}
|
|
return value;
|
|
}
|
|
/// <summary>
|
|
/// 接口控件按钮点击
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void OnLabApiDataCallBack(object sender, EventArgs e)
|
|
{
|
|
LabApiButtonEdit labApiButtonEdit = (LabApiButtonEdit)sender;
|
|
ControlModel controlModel = labApiButtonEdit.Tag as ControlModel;
|
|
DataRow dataRow = this.GetAllControlValueRow();
|
|
string sourceSql = ReplaceHelper.ReplaceRowParam(dataRow, controlModel.SourceSql);
|
|
DataRow selectRow = BaseImpl.GetDataRowResult(sourceSql);
|
|
this.SetAllControlValue(selectRow);
|
|
}
|
|
/// <summary>
|
|
/// 判断是否是exec开头(可以处理sql前方有注释和空格的情况)
|
|
/// </summary>
|
|
/// <param name="sqlText"></param>
|
|
/// <returns></returns>
|
|
public static bool IsExecAtStart(string sqlText)
|
|
{
|
|
// Remove comments and whitespace at the start of the text
|
|
string cleanedText = Regex.Replace(sqlText, @"^(\s*--.*?(\r\n|\n)|\s*)*", "");
|
|
// Check if the remaining text starts with 'select'
|
|
return cleanedText.StartsWith("exec", StringComparison.OrdinalIgnoreCase);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <para>说明:图片控件释放资源</para>
|
|
/// <para>创建人:曹屹峰</para>
|
|
/// <para>创建日期:2023-12-07 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
|
public bool ReleaseImageResources()
|
|
{
|
|
foreach (ControlModel model in this.ControlModels)
|
|
{
|
|
BaseUserControl control = FindControl(model);
|
|
|
|
if (model.FieldType == ControlType.LabPicEx)
|
|
{
|
|
LabelImageEdit imageEdit = control as LabelImageEdit;
|
|
if (imageEdit.TextEdit.Image != null)
|
|
{
|
|
imageEdit.TextEdit.Image.Dispose();
|
|
}
|
|
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:从当前面板查找控件替换{xxx}值</para>
|
|
/// <para>创建人:曹屹峰</para>
|
|
/// <para>创建日期:2024-07-04 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="defaultValue">The default value.</param>
|
|
public string ReplaceFixedControlValue(string defaultValue)
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(defaultValue))
|
|
{
|
|
defaultValue = ReplaceHelper.ReplaceUserInfo(defaultValue);
|
|
var paramList = ReplaceHelper.GetParamFields(defaultValue);
|
|
|
|
System.Windows.Forms.Control controlGroupBox = _parentPanel.Controls
|
|
.Cast<System.Windows.Forms.Control>()
|
|
.FirstOrDefault(x => x.Name.Equals("GroupRightData", StringComparison.OrdinalIgnoreCase));
|
|
|
|
foreach (string item in paramList)
|
|
{
|
|
string field = item.Replace("{", "").Replace("}", "");
|
|
|
|
System.Windows.Forms.Control controlObj = new System.Windows.Forms.Control();
|
|
|
|
controlObj = _parentPanel.Controls
|
|
.Cast<System.Windows.Forms.Control>()
|
|
.FirstOrDefault(x => x.Name.Equals(field, StringComparison.OrdinalIgnoreCase));
|
|
|
|
if (controlGroupBox is GroupBox && controlObj == null)
|
|
{
|
|
controlObj = controlGroupBox.Controls
|
|
.Cast<System.Windows.Forms.Control>()
|
|
.FirstOrDefault(x => x.Name.Equals(field, StringComparison.OrdinalIgnoreCase));
|
|
}
|
|
|
|
if (controlObj != null)
|
|
{
|
|
string value = string.Empty;
|
|
if (controlObj is LabelDateEdit)
|
|
{
|
|
LabelDateEdit dateEdit = controlObj as LabelDateEdit;
|
|
value = dateEdit.TextEdit.EditValue == null ? dateEdit.EditText : dateEdit.TextEdit.DateTime.ToString("yyyy-MM-dd");
|
|
}
|
|
else if |