2168 lines
102 KiB
C#
2168 lines
102 KiB
C#
using DevExpress.XtraEditors;
|
|
using DevExpress.XtraGrid;
|
|
using DevExpress.XtraGrid.Columns;
|
|
using Lskj.Business;
|
|
using Lskj.Business.Impl;
|
|
using Lskj.Control;
|
|
using Lskj.Control.Model;
|
|
using Lskj.Core;
|
|
using Lskj.Data;
|
|
using Lskj.Model;
|
|
using Lskj.PubProductSysMge.Model;
|
|
using Lskj.Util;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Text.RegularExpressions;
|
|
using System.Threading;
|
|
using System.Windows.Forms;
|
|
|
|
namespace Lskj.PubProductSysMge
|
|
{
|
|
public partial class FrmMain : BaseForm
|
|
{
|
|
#region 私有变量
|
|
/// <summary>
|
|
/// 表格列
|
|
/// </summary>
|
|
private DataTable _gridColumns = new DataTable();
|
|
/// <summary>
|
|
/// The _grid all columns
|
|
/// </summary>
|
|
private DataTable _gridAllColumns = new DataTable();
|
|
/// <summary>
|
|
/// 左侧表格列字段
|
|
/// </summary>
|
|
private DataRow _leftGridField;
|
|
private string _leftField;
|
|
/// <summary>
|
|
/// 必须录入字段
|
|
/// </summary>
|
|
private DataRow[] _nullFields = new DataRow[] { };
|
|
/// <summary>
|
|
/// 主键
|
|
/// </summary>
|
|
private string ParmaryKey;
|
|
/// <summary>
|
|
/// 左侧树数据
|
|
/// </summary>
|
|
private DataRow LeftTreeRow;
|
|
/// <summary>
|
|
/// 左侧树主键关联右侧数据字段
|
|
/// </summary>
|
|
private string ParentUnionField;
|
|
/// <summary>
|
|
/// 左侧树配置字段
|
|
/// </summary>
|
|
private string LeftField;
|
|
/// <summary>
|
|
/// 主模块控件数据源
|
|
/// </summary>
|
|
private DataTable MainControlTable;
|
|
/// <summary>
|
|
/// 主模块控件对象
|
|
/// </summary>
|
|
private MyControl MainControlObj;
|
|
/// <summary>
|
|
/// 动态模块对象
|
|
/// </summary>
|
|
private MyControl TopControlObj;
|
|
/// <summary>
|
|
/// 动态控件对象集合
|
|
/// </summary>
|
|
private List<SysSetModel> ControlList = new List<SysSetModel>();
|
|
/// <summary>
|
|
/// 左侧树节点正在加载,防止连续点击重复进入加载流程。
|
|
/// </summary>
|
|
private bool _isTreeNodeLoading = false;
|
|
/// <summary>
|
|
/// 左侧树当前正在加载的节点,用于加载期间恢复选中状态。
|
|
/// </summary>
|
|
private TreeNode _loadingTreeNode = null;
|
|
/// <summary>
|
|
/// 程序内部切换方案下拉框时,屏蔽 SelectedIndexChanged 的嵌套加载。
|
|
/// </summary>
|
|
private bool _suppressProjectSelectedIndexChanged = false;
|
|
/// <summary>
|
|
/// 规格控件
|
|
/// </summary>
|
|
private BaseUserControl _SpecBaseControl;
|
|
/// <summary>
|
|
/// 型号控件
|
|
/// </summary>
|
|
private BaseUserControl _ModelBaseControl;
|
|
/// <summary>
|
|
/// 综合属性控件
|
|
/// </summary>
|
|
private BaseUserControl _ZhSxBaseControl;
|
|
/// <summary>
|
|
/// 名称控件
|
|
/// </summary>
|
|
private BaseUserControl _NameBaseControl;
|
|
/// <summary>
|
|
/// 名称控件
|
|
/// </summary>
|
|
private BaseUserControl _UnitBaseControl;
|
|
/// <summary>
|
|
/// 名称控件
|
|
/// </summary>
|
|
private BaseUserControl _CzBaseControl;
|
|
#endregion
|
|
#region 公有变量
|
|
/// <summary>
|
|
/// 共有入口参数
|
|
/// </summary>
|
|
public DynamicProductSysMgeModel Model;
|
|
/// <summary>
|
|
/// 主表数据类
|
|
/// </summary>
|
|
public ModuleModel MainModuleObj;
|
|
/// <summary>
|
|
/// 主表条件类
|
|
/// </summary>
|
|
public MyControl SearchMainObj;
|
|
/// <summary>
|
|
/// 规格控件
|
|
/// </summary>
|
|
public BaseUserControl SpecBaseControl
|
|
{
|
|
get
|
|
{
|
|
if (_SpecBaseControl == null)
|
|
{
|
|
_SpecBaseControl = this.MainControlObj.FindControl("spec");
|
|
}
|
|
return _SpecBaseControl;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 型号控件
|
|
/// </summary>
|
|
public BaseUserControl ModelBaseControl
|
|
{
|
|
get
|
|
{
|
|
if (_ModelBaseControl == null)
|
|
{
|
|
_ModelBaseControl = this.MainControlObj.FindControl("model");
|
|
}
|
|
return _ModelBaseControl;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 综合属性控件
|
|
/// </summary>
|
|
public BaseUserControl ZhSxBaseControl
|
|
{
|
|
get
|
|
{
|
|
if (_ZhSxBaseControl == null)
|
|
{
|
|
_ZhSxBaseControl = this.MainControlObj.FindControl("ProductDescrip");
|
|
}
|
|
return _ZhSxBaseControl;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 材质属性控件
|
|
/// </summary>
|
|
public BaseUserControl CzBaseControl
|
|
{
|
|
get
|
|
{
|
|
if (_CzBaseControl == null)
|
|
{
|
|
_CzBaseControl = this.MainControlObj.FindControl("grade");
|
|
}
|
|
return _CzBaseControl;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 名称控件
|
|
/// </summary>
|
|
public BaseUserControl NameBaseControl
|
|
{
|
|
get
|
|
{
|
|
if (_NameBaseControl == null)
|
|
{
|
|
_NameBaseControl = this.MainControlObj.FindControl("appellation");
|
|
}
|
|
return _NameBaseControl;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 单位控件
|
|
/// </summary>
|
|
public BaseUserControl UnitBaseControl
|
|
{
|
|
get
|
|
{
|
|
if (_UnitBaseControl == null)
|
|
{
|
|
_UnitBaseControl = this.MainControlObj.FindControl("Productunitname");
|
|
}
|
|
return _UnitBaseControl;
|
|
}
|
|
}
|
|
#endregion
|
|
#region 方法
|
|
/// <summary>
|
|
/// 构造方法
|
|
/// </summary>
|
|
public FrmMain(DynamicProductSysMgeModel model = null)
|
|
{
|
|
InitializeComponent();
|
|
this.Model = model != null ? model : null;
|
|
splitControlContainer.Panel1.BackColor = Color.White;
|
|
}
|
|
/// <summary>
|
|
/// 初始化事件绑定
|
|
/// </summary>
|
|
private void InitEvent()
|
|
{
|
|
this.splitMainContainer.SplitterPositionChanged += OnSplitMainContainerPositionChanged;
|
|
this.splitRightContainer.SplitterPositionChanged += OnSplitMainContainerPositionChanged;
|
|
this.splitControlContainer.SplitterPositionChanged += OnSplitMainContainerPositionChanged;
|
|
this.pl_Top.Click += OnScrollableControlClick;
|
|
this.pl_Bottom.Click += OnScrollableControlClick;
|
|
this.btnSave.Click += OnBtnSaveClick;
|
|
this.btnUpdate.Click += OnBtnUpdateClick;
|
|
this.btnCondSearch.Click += OnBtnCondSearchClick;
|
|
this.projectComBoEdit.SelectedIndexChanged += OnProjectSelectedIndexChanged;
|
|
this.btnCopy.Click += OnBtnCopyAndAddClick;
|
|
}
|
|
/// <summary>
|
|
/// 初始化控件
|
|
/// </summary>
|
|
private void InitControl()
|
|
{
|
|
WaitForm.ShowForm();
|
|
try
|
|
{
|
|
this.Model.Privilege = this.Model.Privilege.Equals("3") ? "1" : Model.ModuleId > 0 ? BaseImpl.GetUserPurviewsByMenuId(Model.ModuleId + "") + "" : BaseImpl.GetUserPurviewsByMenuCode(Model.ModuleCode) + "";// 权限(1.有操作权限.0.无权限.2.只读权限.3.右键配置权限全部开放)
|
|
DataRow modelRow = MainImpl.GetSystemdllTab(this.Model.ModuleCode);//获取单个模块信息
|
|
if (this.Model.HasReadPrivilege())
|
|
{
|
|
this.btnSave.Visible = false;
|
|
this.btnUpdate.Visible = false;
|
|
this.btnCopy.Visible = false;
|
|
}
|
|
|
|
|
|
if (modelRow == null)
|
|
{
|
|
MessageUtil.Show("模块编号[" + this.Model.ModuleCode + "],配置错误!\r\n该模块信息未找到!");
|
|
return;
|
|
}
|
|
this.MainModuleObj = new ModuleModel(modelRow);//系统模块实体对象
|
|
switch (this.MainModuleObj.MenuType)
|
|
{
|
|
case 1:
|
|
case 4://左侧为树节点
|
|
this.InitlizeSpiltLocation();//设置分割条位置
|
|
this.treeLeftViewEx.TreeInhibitSort = this.MainModuleObj.TreeInhibitSort;
|
|
this.SetLeftTreeView();//设置左侧树数据
|
|
if (this.MainModuleObj.IsHideTreeViewBoxs)
|
|
{
|
|
this.treeLeftViewEx.TreeView.CheckBoxes = false;
|
|
}
|
|
//树节点添加右键刷新数据源
|
|
if (this.MainModuleObj.TreeNodeRefresh)
|
|
{
|
|
ContextMenuStrip contextMenu = new ContextMenuStrip();
|
|
ToolStripMenuItem menuItem1 = new ToolStripMenuItem("刷新");
|
|
menuItem1.ImageIndex = 0;
|
|
menuItem1.Click += TreeNodeRefresh;
|
|
contextMenu.Items.Add(menuItem1);
|
|
this.treeLeftViewEx.ContextMenuStrip = contextMenu;
|
|
}
|
|
break;
|
|
case 3://左侧为空
|
|
default:
|
|
this.splitMainContainer.PanelVisibility = SplitPanelVisibility.Panel2;
|
|
break;
|
|
}
|
|
InitMain();//构建主模块控件
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
WaitForm.HideForm();
|
|
}
|
|
/// <summary>
|
|
/// 初始化主模块控件
|
|
/// </summary>
|
|
private void InitMain()
|
|
{
|
|
this._leftField = BaseModuleImpl.GetBaseLeftField(this.Model.ModuleCode);
|
|
this.ParmaryKey = BaseImpl.GetBasePrimaryKey(this.Model.ModuleCode);//获取主键
|
|
this._gridColumns = BaseModuleImpl.GetBaseGridColumns(this.Model.ModuleCode);//获取主表列数据
|
|
this._gridAllColumns = BaseModuleImpl.GetBaseGridAllColumns(this.Model.ModuleCode);//获取所有列数据
|
|
if (this._gridColumns != null && this._gridColumns.Rows.Count > 0)
|
|
{
|
|
this._nullFields = this._gridColumns.Select("nullable=1");
|
|
this._leftGridField = this._gridColumns.Select("fieldsqlTag=3").FirstOrDefault();
|
|
}
|
|
this.InitializeGridView();
|
|
this.CreateControlLocation();
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:初始化表格操作</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2023-10-13 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void InitializeGridView(bool ProcessExists = false)
|
|
{
|
|
this.gcMain.Model = this.Model;
|
|
if (this.MainModuleObj.IsDynamicColumn)
|
|
{
|
|
this.gcMain.GridView.OptionsView.ColumnAutoWidth = true;
|
|
}
|
|
if (!this.MainModuleObj.IsDynamicColumn)
|
|
{
|
|
if (MainModuleObj.CanEdit)
|
|
{
|
|
this.gcMain.SetEditColumns(this._gridColumns, GridCustomColumnStruct.BaseMainGridView + this.MainModuleObj.FormKey);
|
|
}
|
|
else
|
|
{
|
|
this.gcMain.SetReadOnlyColumns(this._gridColumns, GridCustomColumnStruct.BaseMainGridView + this.MainModuleObj.FormKey);
|
|
}
|
|
}
|
|
this.gcMain.SetGridRowColors(BaseModuleImpl.GetBaseGridRowColors(this.Model.ModuleCode));//设置表格颜色
|
|
this.gcMain.SetGridRightMenus(BaseModuleImpl.GetBaseGridRightMenus(this.Model.ModuleCode), Model, OnGridViewRightCallBack, null);//设置表格菜单
|
|
this.gcMain.GridView.DoubleClick += OnGridViewDoubleClick;
|
|
this.SearchMainObj = new MyControl(this.MainModuleObj.MenuSql, gcMain, this.treeLeftViewEx, null, null);
|
|
this.SearchMainObj.ParentUnionField = this.ParentUnionField;
|
|
DataTable queryTable = BaseModuleImpl.GetCustomQueryFields(this.MainModuleObj.CondKey);//获取主模块构建的条件
|
|
if (queryTable != null && queryTable.Rows.Count > 0)
|
|
{
|
|
// 加载自定义查询条件
|
|
this.plm_bot_cond.Visible = true;
|
|
this.plm_bot_cond.Controls.Clear();
|
|
this.SearchMainObj.InitSearchControl(queryTable, this.plm_bot_cond, null, null, false);
|
|
this.SearchMainObj.ButtonObj.Visible = false;
|
|
System.Windows.Forms.Control control = this.plm_bot_cond.Controls.Find("btnCondSearch", true).FirstOrDefault();
|
|
this.plm_bot_cond.Width = control.Location.X;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:初始化主模块控件</para>
|
|
/// <para>创建人:唐德馨</para>
|
|
/// <para>创建日期:2023-10-19 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void CreateControlLocation()
|
|
{
|
|
try
|
|
{
|
|
this.TopControlObj = new MyControl()
|
|
{
|
|
ParentPanel = this.pl_Top
|
|
};
|
|
if (this.Model != null && this.MainModuleObj != null)
|
|
{
|
|
this.LeftField = BaseModuleImpl.GetBaseLeftField(this.Model.ModuleCode);
|
|
this.MainControlTable = BaseModuleImpl.GetControlLocation(this.MainModuleObj.FormKey, this.Model.ModuleCode);
|
|
this.MainControlObj = new MyControl()
|
|
{
|
|
SystemModel = this.MainModuleObj,
|
|
OtherParams = this.Model.OtherParams(),
|
|
popUpDyncModel = this.Model
|
|
};
|
|
this.MainControlObj.InitControl(this.MainControlTable, this.pl_Bottom, null, true);
|
|
this.pl_Bottom.AutoScroll = true;
|
|
this.pl_Bottom.HorizontalScroll.Visible = false;//设置禁止水平滚动条
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 设置分割条位置
|
|
/// </summary>
|
|
private void InitlizeSpiltLocation()
|
|
{
|
|
try
|
|
{
|
|
string splitMainWidth = IniHelper.Read(string.Format("PubProductSysMge_SplitMain_{0}", this.Model.ModuleCode));//通过Key获取Value值
|
|
if (!string.IsNullOrEmpty(splitMainWidth))
|
|
{
|
|
this.splitMainContainer.SplitterPosition = Convert.ToInt32(splitMainWidth);
|
|
}
|
|
string splitRightWidth = IniHelper.Read(string.Format("PubProductSysMge_SplitRight_{0}", this.Model.ModuleCode));//通过Key获取Value值
|
|
if (!string.IsNullOrEmpty(splitRightWidth))
|
|
{
|
|
this.splitRightContainer.SplitterPosition = Convert.ToInt32(splitRightWidth);
|
|
}
|
|
string splitControlWidth = IniHelper.Read(string.Format("PubProductSysMge_SplitControl_{0}", this.Model.ModuleCode));//通过Key获取Value值
|
|
if (!string.IsNullOrEmpty(splitMainWidth))
|
|
{
|
|
this.splitControlContainer.SplitterPosition = Convert.ToInt32(splitControlWidth);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageUtil.Show(ex.Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 设置左侧树数据
|
|
/// </summary>
|
|
private void SetLeftTreeView()
|
|
{
|
|
this.LeftTreeRow = BaseModuleImpl.GetBaseLeftTreeField(this.Model.ModuleCode);//获取表格左侧树字段
|
|
if (this.LeftTreeRow != null)
|
|
{
|
|
this.ParentUnionField = this.LeftTreeRow["fieldname"] + "";
|
|
string parentKeyField = this.LeftTreeRow["fieldsqlid"] + "";
|
|
this.treeLeftViewEx.TreeNodeKeyField = parentKeyField;
|
|
this.treeLeftViewEx.TreeNodeTextField = this.LeftTreeRow["fieldsqlname"] + "";
|
|
this.treeLeftViewEx.OnTreeNodeMouseClick += new TreeNodeMouseClickEventHandler(OnTreeLeftTreeNodeSelected);
|
|
this.treeLeftViewEx.TreeNodeLength = this.LeftTreeRow.Table.Columns.Contains("TreeNodeLength") ? this.LeftTreeRow["TreeNodeLength"] + "" : "";
|
|
this.treeLeftViewEx.BindTreeView(BaseImpl.GetDataTableResult(this.LeftTreeRow["fieldsql"] + ""));
|
|
if (this.LeftTreeRow.Table.Columns.Contains("TreeNodeSearch") && "1".Equals(this.LeftTreeRow["TreeNodeSearch"] + "")) this.treeLeftViewEx.pl_top.Visible = true;
|
|
}
|
|
else
|
|
{
|
|
// 根据模块上配置的sql加载树
|
|
if (this.MainModuleObj != null && !string.IsNullOrEmpty(this.MainModuleObj.TreeSQL))
|
|
{
|
|
this.ParentUnionField = "SpeciesNo";
|
|
string parentKeyField = "SpeciesNo";
|
|
this.treeLeftViewEx.TreeNodeKeyField = parentKeyField;
|
|
this.treeLeftViewEx.TreeNodeTextField = "SpeciesName";
|
|
this.treeLeftViewEx.OnTreeNodeMouseClick += new TreeNodeMouseClickEventHandler(OnTreeLeftTreeNodeSelected);
|
|
this.treeLeftViewEx.BindTreeView(BaseImpl.GetDataTableResult(this.MainModuleObj.TreeSQL));
|
|
}
|
|
else if (this.MainModuleObj.DefaultTreeSql)
|
|
{
|
|
this.ParentUnionField = "SpeciesNo";
|
|
string parentKeyField = "SpeciesNo";
|
|
this.treeLeftViewEx.TreeNodeKeyField = parentKeyField;
|
|
this.treeLeftViewEx.TreeNodeTextField = "SpeciesName";
|
|
this.treeLeftViewEx.OnTreeNodeMouseClick += new TreeNodeMouseClickEventHandler(OnTreeLeftTreeNodeSelected);
|
|
this.treeLeftViewEx.BindTreeView(BaseImpl.GetDataTableResult("select a.SpeciesNo,a.SpeciesName from p_productspeciestab a where a.ban=0"));
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:加载主表格数据</para>
|
|
/// <para>创建人:唐德馨</para>
|
|
/// <para>创建日期:2023-10-24 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="where">The where key.</param>
|
|
private void SetMainGridView(string where = "", bool selectHandler = false, bool initColumns = true)
|
|
{
|
|
int handler = this.gcMain.GridView.FocusedRowHandle;
|
|
string sqlValue = ReplaceHelper.ReplaceUserInfo(this.MainModuleObj.MenuSql);
|
|
sqlValue = ReplaceHelper.ReplaceWhereCond(sqlValue);
|
|
if (string.IsNullOrWhiteSpace(where))
|
|
{
|
|
sqlValue = SearchMainObj.SetSearchSqlValue(sqlValue, true, false);
|
|
}
|
|
sqlValue = MainImpl.GetDefaultValue(sqlValue);
|
|
sqlValue = IsSelectAtStart(sqlValue) ? sqlValue + where : sqlValue;
|
|
sqlValue = sqlValue + " order by id desc";
|
|
DataTable sourceTable = MainImpl.GetDataTableResult(sqlValue);
|
|
if (initColumns && this.MainModuleObj.IsDynamicColumn)
|
|
{
|
|
this.gcMain.GridView.Columns.Clear();
|
|
this.gcMain.GridControl.DataSource = null;
|
|
for (int i = 0; i < this.ControlList.Count; i++)
|
|
{
|
|
SysSetModel setModel = this.ControlList[i];
|
|
DataColumn dataColumn = sourceTable.Columns.Cast<DataColumn>().Where(n => n.ColumnName.Equals(setModel.DbName, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
|
|
if (dataColumn != null)
|
|
{
|
|
GridColumn gridColumn = new GridColumn();
|
|
gridColumn.FieldName = dataColumn.ColumnName;
|
|
gridColumn.Name = dataColumn.ColumnName;
|
|
gridColumn.Caption = setModel.SysName;
|
|
gridColumn.Visible = true;
|
|
gridColumn.VisibleIndex = setModel.OrderId;
|
|
gridColumn.OptionsColumn.AllowEdit = false;
|
|
this.gcMain.GridView.Columns.Add(gridColumn);
|
|
if (i == 0)
|
|
{
|
|
this.gcMain.GridView.OptionsView.ShowFooter = true;
|
|
gridColumn.Summary.AddRange(new GridSummaryItem[] { new GridColumnSummaryItem(DevExpress.Data.SummaryItemType.Count, gridColumn.FieldName, "合计: {0:#,###}行") });
|
|
this.gcMain.GridView.GroupSummary.AddRange(new GridSummaryItem[] { new GridGroupSummaryItem(DevExpress.Data.SummaryItemType.Count, gridColumn.FieldName, null, "合计: {0:#,###}行") });
|
|
}
|
|
}
|
|
}
|
|
}
|
|
int topRowIndex = gcMain.GridView.GetVisibleRowHandle(gcMain.GridView.TopRowIndex);//顶部可见行
|
|
if (this.gcMain.GridView.Columns.Count > 0)
|
|
{
|
|
this.gcMain.GridControl.DataSource = sourceTable;
|
|
this.gcMain.AdjustIndicatorWidthSmart();
|
|
}
|
|
//this.gcMain.GridView.BestFitColumns();
|
|
if (selectHandler)
|
|
{
|
|
this.gcMain.GridView.FocusedRowHandle = handler;
|
|
if (topRowIndex > 0) gcMain.GridView.TopRowIndex = topRowIndex;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 判断是否是selete开头(可以处理sql前方有注释和空格的情况)
|
|
/// </summary>
|
|
/// <param name="sqlText"></param>
|
|
/// <returns></returns>
|
|
private bool IsSelectAtStart(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("select", StringComparison.OrdinalIgnoreCase);
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:设置动态控件显示刷新</para>
|
|
/// <para>创建人:唐德馨</para>
|
|
/// <para>创建日期:2023-10-24 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="where">The where key.</param>
|
|
private void SetDynamicControl(TreeNode treeNode)
|
|
{
|
|
|
|
splitControlContainer.Panel1.Controls.Remove(this.pl_Top);
|
|
this.pl_Top.Dispose();
|
|
this.pl_Top = new XtraScrollableControl();
|
|
this.pl_Top.BackColor = Color.White;
|
|
this.pl_Top.Dock = DockStyle.Fill;
|
|
splitControlContainer.Panel1.Controls.Add(this.pl_Top);
|
|
|
|
//this.TopControlObj.ParentPanel.Dispose();
|
|
//this.TopControlObj.ParentPanel = pl_Top;
|
|
this.TopControlObj = new MyControl()
|
|
{
|
|
ParentPanel = this.pl_Top
|
|
};
|
|
|
|
this.ControlList.Clear();
|
|
try
|
|
{
|
|
ComboBoxModel selectedProject = projectComBoEdit.SelectedItem as ComboBoxModel;
|
|
if (selectedProject == null || treeNode == null) return;
|
|
string projectId = selectedProject.Value;
|
|
if (treeNode != null && !string.IsNullOrEmpty(projectId))
|
|
{
|
|
DataTable dataTable = new DataTable();
|
|
string dataSourceSql = string.Format("select * from p_productsyssettab where groupid = '{0}' and ban = 0 order by orderid", projectId);
|
|
dataTable = MainImpl.GetDataTableResult(dataSourceSql);
|
|
int x = 10;
|
|
int y = 10;
|
|
foreach (DataRow controlRow in dataTable.Rows)
|
|
{
|
|
BaseUserControl baseControl = new BaseUserControl();
|
|
SysSetModel setModel = new SysSetModel(controlRow);
|
|
switch (setModel.Item)//控件类型
|
|
{
|
|
//下拉框控件
|
|
case "1":
|
|
LabelAutoTextEdit labelAutoTextEdit = new LabelAutoTextEdit();
|
|
setModel.FieldType = 5;
|
|
setModel.ValueMember = "id";
|
|
setModel.TextMember = "sysnamelist";
|
|
labelAutoTextEdit.Model = setModel;
|
|
labelAutoTextEdit.clickAfterEmpty = false;
|
|
labelAutoTextEdit.ValueField = "id";
|
|
labelAutoTextEdit.TextField = "sysnamelist";
|
|
labelAutoTextEdit.ValueMember = labelAutoTextEdit.ValueField;
|
|
labelAutoTextEdit.TextEdit.ControlObj = TopControlObj;
|
|
if (!string.IsNullOrEmpty(setModel.DataSourceSql))
|
|
{
|
|
labelAutoTextEdit.TextEdit.SourceSQL = setModel.DataSourceSql;
|
|
//labelAutoTextEdit.TextEdit.SourceSQL = "select id ,unit as sysnamelist from P_UnitTab where 1=1 and #OperatorId='{shape}'#";
|
|
}
|
|
else
|
|
{
|
|
labelAutoTextEdit.TextEdit.SourceSQL = string.Format("select b.midno as id,b.sysnamelist as sysnamelist,b.bak as bak from p_productsyssettab a join p_productsyslisttab b on a.id = b.mid where mid = '{0}'", setModel.Id);
|
|
}
|
|
labelAutoTextEdit.TextEdit.KeyDown += new KeyEventHandler(OnTextEditKeyDown);
|
|
labelAutoTextEdit.TextEdit.TextChanged += new EventHandler(OnTextEditTextChanged);
|
|
//labelAutoTextEdit.ReadOnly = setModel.ProhibitEdited;
|
|
baseControl = labelAutoTextEdit;
|
|
|
|
break;
|
|
//多选框控件
|
|
case "3":
|
|
LabelMultiAutoTextEdit labelMultiAutoTextEdit = new LabelMultiAutoTextEdit();
|
|
setModel.FieldType = 14;
|
|
setModel.ValueMember = "id";
|
|
setModel.TextMember = "sysnamelist";
|
|
labelMultiAutoTextEdit.Model = setModel;
|
|
labelMultiAutoTextEdit.ValueField = "id";
|
|
labelMultiAutoTextEdit.TextField = "sysnamelist";
|
|
labelMultiAutoTextEdit.ValueMember = labelMultiAutoTextEdit.ValueField;
|
|
labelMultiAutoTextEdit.TextEdit.KeyDown += new KeyEventHandler(OnTextEditKeyDown);
|
|
labelMultiAutoTextEdit.TextEdit.TextChanged += new EventHandler(OnTextEditTextChanged);
|
|
//labelMultiAutoTextEdit.ReadOnly = setModel.ProhibitEdited;
|
|
baseControl = labelMultiAutoTextEdit;
|
|
break;
|
|
//备注框A
|
|
case "4":
|
|
LabelMemoEdit labelMemoEdit = new LabelMemoEdit();
|
|
labelMemoEdit.TextEdit.KeyDown += new KeyEventHandler(OnTextEditKeyDown);
|
|
labelMemoEdit.TextEdit.TextChanged += new EventHandler(OnTextEditTextChanged);
|
|
baseControl = labelMemoEdit;
|
|
break;
|
|
//下拉备注框
|
|
case "5":
|
|
LabelAutoMemoEdit labelAutoMemoEdit = new LabelAutoMemoEdit();
|
|
setModel.FieldType = 5;
|
|
setModel.ValueMember = "id";
|
|
setModel.TextMember = "sysnamelist";
|
|
labelAutoMemoEdit.Model = setModel;
|
|
labelAutoMemoEdit.clickAfterEmpty = false;
|
|
labelAutoMemoEdit.ValueField = "id";
|
|
labelAutoMemoEdit.TextField = "sysnamelist";
|
|
labelAutoMemoEdit.ValueMember = labelAutoMemoEdit.ValueField;
|
|
labelAutoMemoEdit.TextEdit.ControlObj = TopControlObj;
|
|
if (!string.IsNullOrEmpty(setModel.DataSourceSql))
|
|
{
|
|
labelAutoMemoEdit.TextEdit.SourceSQL = setModel.DataSourceSql;
|
|
}
|
|
else
|
|
{
|
|
labelAutoMemoEdit.TextEdit.SourceSQL = string.Format("select b.midno as id,b.sysnamelist as sysnamelist,b.bak as bak from p_productsyssettab a join p_productsyslisttab b on a.id = b.mid where mid = '{0}'", setModel.Id);
|
|
//labelAutoTextEdit.TextEdit.SourceSQL = " select b.midno as id,b.sysnamelist as sysnamelist,b.bak as bak from p_productsyssettab a join p_productsyslisttab b on a.id = b.mid where mid = '15' and # str1='{str1}'#";
|
|
}
|
|
labelAutoMemoEdit.TextEdit.KeyDown += new KeyEventHandler(OnTextEditKeyDown);
|
|
labelAutoMemoEdit.TextEdit.TextChanged += new EventHandler(OnTextEditTextChanged);
|
|
baseControl = labelAutoMemoEdit;
|
|
break;
|
|
//文本(标签)
|
|
case "6":
|
|
LabelTitle labelTitle = new LabelTitle();
|
|
baseControl = labelTitle;
|
|
break;
|
|
//复选框
|
|
case "7":
|
|
LabelCheckEdit checkEdit = new LabelCheckEdit();
|
|
baseControl = checkEdit;
|
|
break;
|
|
//日期框
|
|
case "9":
|
|
LabelDateEdit dateEdit = new LabelDateEdit();
|
|
dateEdit.TextEdit.KeyDown += new KeyEventHandler(OnTextEditKeyDown);
|
|
dateEdit.TextEdit.TextChanged += new EventHandler(OnTextEditTextChanged);
|
|
//有格式化配置,按配置格式化显示.否则按照控件类型格式化.
|
|
|
|
dateEdit.DateFormat(setModel.DataFormat);
|
|
baseControl = dateEdit;
|
|
break;
|
|
//文本框控件
|
|
case "2":
|
|
default:
|
|
LabelTextEdit labelTextEdit = new LabelTextEdit();
|
|
if (setModel.Item == "8")
|
|
{
|
|
labelTextEdit.TextEdit.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.OnIntKeyPress);
|
|
labelTextEdit.TextEdit.EditValueChanging += new DevExpress.XtraEditors.Controls.ChangingEventHandler(this.OnIntEditValueChanging);
|
|
}
|
|
labelTextEdit.TextEdit.KeyDown += new KeyEventHandler(OnTextEditKeyDown);
|
|
labelTextEdit.TextEdit.TextChanged += new EventHandler(OnTextEditTextChanged);
|
|
//labelTextEdit.ReadOnly = setModel.ProhibitEdited;
|
|
baseControl = labelTextEdit;
|
|
break;
|
|
}
|
|
string controlName = !string.IsNullOrWhiteSpace(setModel.DbName) ? "txt_" + setModel.DbName : "txt_" + setModel.SysName;
|
|
baseControl.Name = controlName;
|
|
baseControl.LabelText = setModel.SysName;
|
|
baseControl.Size = new Size(300, 21);
|
|
baseControl.Required = setModel.MustTig == 1;
|
|
baseControl.Tag = setModel;
|
|
baseControl.Model = setModel;
|
|
baseControl.TabIndex = dataTable.Rows.IndexOf(controlRow);
|
|
baseControl.Location = new Point(x, y);
|
|
baseControl.ReadOnly = setModel.ProhibitEdited;
|
|
this.pl_Top.Controls.Add(baseControl);
|
|
this.ControlList.Add(setModel);
|
|
if (x + baseControl.Width + 15 + baseControl.Width > this.splitMainContainer.Panel2.Width)
|
|
{
|
|
x = 10;
|
|
y += baseControl.Height + 9;
|
|
}
|
|
else
|
|
{
|
|
x += baseControl.Width + 15;
|
|
}
|
|
}
|
|
SetControlDataSource();
|
|
//Thread thread = new Thread(SetControlDataSource);
|
|
//thread.Start();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
}
|
|
|
|
|
|
|
|
}
|
|
/// <summary>
|
|
/// 延迟加载数据源
|
|
/// </summary>
|
|
private void SetControlDataSource()
|
|
{
|
|
try
|
|
{
|
|
foreach (SysSetModel setModel in this.ControlList)
|
|
{
|
|
string controlName = !string.IsNullOrWhiteSpace(setModel.DbName) ? "txt_" + setModel.DbName : "txt_" + setModel.SysName;
|
|
System.Windows.Forms.Control ctr = this.pl_Top.Controls.Find(controlName, false).FirstOrDefault();
|
|
if (ctr != null && setModel.Item.Equals("1"))
|
|
{
|
|
DataTable dataSource = new DataTable();
|
|
if (setModel.DataSourceType.Equals("来源SQL"))
|
|
{
|
|
dataSource = MainImpl.GetDataTableResult(setModel.DataSourceSql);
|
|
}
|
|
else
|
|
{
|
|
string selectSql = "select b.midno as id,b.sysnamelist as sysnamelist,b.bak as bak from p_productsyssettab a join p_productsyslisttab b on a.id = b.mid where mid = '{0}' order by b.{1}";
|
|
if (!string.IsNullOrEmpty(setModel.OrderField))
|
|
{
|
|
selectSql = string.Format(selectSql, setModel.Id, setModel.OrderField);
|
|
}
|
|
else
|
|
{
|
|
selectSql = string.Format(selectSql, setModel.Id, "orderid");
|
|
}
|
|
dataSource = MainImpl.GetDataTableResult(selectSql);
|
|
}
|
|
LabelAutoTextEdit labelAutoTextEdit = ctr as LabelAutoTextEdit;
|
|
if (dataSource.Columns.Count >= 2)
|
|
{
|
|
string ValueMember = dataSource.Columns[0].ColumnName;
|
|
string TextMember = dataSource.Columns[1].ColumnName;
|
|
setModel.ValueMember = ValueMember;
|
|
setModel.TextMember = TextMember;
|
|
labelAutoTextEdit.ValueField = ValueMember;
|
|
labelAutoTextEdit.TextField = TextMember;
|
|
labelAutoTextEdit.ValueMember = ValueMember;
|
|
}
|
|
labelAutoTextEdit.SetDataSource(dataSource);
|
|
}
|
|
else if (ctr != null && setModel.Item.Equals("3"))
|
|
{
|
|
DataTable dataSource = new DataTable();
|
|
if (setModel.DataSourceType.Equals("来源SQL"))
|
|
{
|
|
dataSource = MainImpl.GetDataTableResult(setModel.DataSourceSql);
|
|
}
|
|
else
|
|
{
|
|
string selectSql = "select b.midno as id,b.sysnamelist as sysnamelist,b.bak as bak from p_productsyssettab a join p_productsyslisttab b on a.id = b.mid where mid = '{0}' order by b.{1}";
|
|
if (!string.IsNullOrEmpty(setModel.OrderField))
|
|
{
|
|
selectSql = string.Format(selectSql, setModel.Id, setModel.OrderField);
|
|
}
|
|
else
|
|
{
|
|
selectSql = string.Format(selectSql, setModel.Id, "orderid");
|
|
}
|
|
dataSource = MainImpl.GetDataTableResult(selectSql);
|
|
}
|
|
LabelMultiAutoTextEdit labelMultiAutoTextEdit = ctr as LabelMultiAutoTextEdit;
|
|
if (dataSource.Columns.Count >= 2)
|
|
{
|
|
string ValueMember = dataSource.Columns[0].ColumnName;
|
|
string TextMember = dataSource.Columns[1].ColumnName;
|
|
setModel.ValueMember = ValueMember;
|
|
setModel.TextMember = TextMember;
|
|
labelMultiAutoTextEdit.ValueField = ValueMember;
|
|
labelMultiAutoTextEdit.TextField = TextMember;
|
|
labelMultiAutoTextEdit.ValueMember = ValueMember;
|
|
}
|
|
labelMultiAutoTextEdit.SetDataSource(dataSource);
|
|
}
|
|
else if (ctr != null && setModel.Item.Equals("5"))
|
|
{
|
|
DataTable dataSource = new DataTable();
|
|
if (setModel.DataSourceType.Equals("来源SQL"))
|
|
{
|
|
dataSource = MainImpl.GetDataTableResult(setModel.DataSourceSql);
|
|
}
|
|
else
|
|
{
|
|
string selectSql = "select b.midno as id,b.sysnamelist as sysnamelist,b.bak as bak from p_productsyssettab a join p_productsyslisttab b on a.id = b.mid where mid = '{0}' order by b.{1}";
|
|
if (!string.IsNullOrEmpty(setModel.OrderField))
|
|
{
|
|
selectSql = string.Format(selectSql, setModel.Id, setModel.OrderField);
|
|
}
|
|
else
|
|
{
|
|
selectSql = string.Format(selectSql, setModel.Id, "orderid");
|
|
}
|
|
dataSource = MainImpl.GetDataTableResult(selectSql);
|
|
}
|
|
LabelAutoMemoEdit labelAutoMemoEdit = ctr as LabelAutoMemoEdit;
|
|
if (dataSource.Columns.Count >= 2)
|
|
{
|
|
string ValueMember = dataSource.Columns[0].ColumnName;
|
|
string TextMember = dataSource.Columns[1].ColumnName;
|
|
setModel.ValueMember = ValueMember;
|
|
setModel.TextMember = TextMember;
|
|
labelAutoMemoEdit.ValueField = ValueMember;
|
|
labelAutoMemoEdit.TextField = TextMember;
|
|
labelAutoMemoEdit.ValueMember = ValueMember;
|
|
}
|
|
labelAutoMemoEdit.SetDataSource(dataSource);
|
|
}
|
|
}
|
|
foreach (SysSetModel setModel in this.ControlList)
|
|
{
|
|
string defaultValue = "";
|
|
if (!string.IsNullOrEmpty(setModel.DefaultID))
|
|
{
|
|
defaultValue = setModel.DefaultID;
|
|
}
|
|
if (!string.IsNullOrEmpty(setModel.DefaultName))
|
|
{
|
|
defaultValue = this.TopControlObj.ReplaceControlValue(setModel.DefaultName);
|
|
if (defaultValue.StartsWith("@") || defaultValue.StartsWith("!"))
|
|
{
|
|
defaultValue = BaseImpl.GetDefaultValue(defaultValue);
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(defaultValue))
|
|
{
|
|
string controlName = !string.IsNullOrWhiteSpace(setModel.DbName) ? "txt_" + setModel.DbName : "txt_" + setModel.SysName;
|
|
System.Windows.Forms.Control ctr = this.pl_Top.Controls.Find(controlName, false).FirstOrDefault();
|
|
BaseUserControl baseUserControl = ctr as BaseUserControl;
|
|
baseUserControl.Invoke(new Action(() =>
|
|
{
|
|
baseUserControl.EditText = defaultValue;
|
|
}));
|
|
}
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:验证数据合法性</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(System.Windows.Forms.Control parentPanel)
|
|
{
|
|
foreach (System.Windows.Forms.Control item in parentPanel.Controls)
|
|
{
|
|
if (item is BaseUserControl)
|
|
{
|
|
var baseControl = item as BaseUserControl;
|
|
SysSetModel setModel = baseControl.Tag as SysSetModel;
|
|
if (string.IsNullOrWhiteSpace(baseControl.EditText) && setModel != null && setModel.MustTig == 1)
|
|
{
|
|
baseControl.Focus();
|
|
MessageUtil.Show(string.Format("{0}未填写数据", baseControl.LabelText));
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
/// <summary>
|
|
/// 反写规格型号时获取BaseUserControl的值
|
|
/// </summary>
|
|
/// <param name="baseUserControl"></param>
|
|
/// <param name="setModel"></param>
|
|
/// <returns></returns>
|
|
private string GetBaseControlValue(BaseUserControl baseUserControl, string type = "")
|
|
{
|
|
string rtnValue = "";
|
|
try
|
|
{
|
|
SysSetModel setModel = baseUserControl.Tag as SysSetModel;
|
|
if (string.IsNullOrWhiteSpace(type)) type = setModel.FxType;
|
|
|
|
switch (setModel.Item)//控件类型
|
|
{
|
|
case "1":
|
|
LabelAutoTextEdit labelAutoTextEdit = baseUserControl as LabelAutoTextEdit;
|
|
if (type.Equals("名称"))
|
|
{
|
|
rtnValue = labelAutoTextEdit.EditText;
|
|
}
|
|
else if (type.Equals("编码"))
|
|
{
|
|
rtnValue = labelAutoTextEdit.EditValue;
|
|
}
|
|
break;
|
|
case "3":
|
|
LabelMultiAutoTextEdit labelMultiAutoTextEdit = baseUserControl as LabelMultiAutoTextEdit;
|
|
if (type.Equals("名称"))
|
|
{
|
|
rtnValue = labelMultiAutoTextEdit.EditText;
|
|
}
|
|
else if (type.Equals("编码"))
|
|
{
|
|
rtnValue = labelMultiAutoTextEdit.EditValue;
|
|
}
|
|
break;
|
|
//备注框A
|
|
case "4":
|
|
LabelMemoEdit labelMemoEdit = baseUserControl as LabelMemoEdit;
|
|
rtnValue = labelMemoEdit.EditText;
|
|
break;
|
|
//下拉备注框
|
|
case "5":
|
|
LabelAutoMemoEdit labelAutoMemoEdit = baseUserControl as LabelAutoMemoEdit;
|
|
if (type.Equals("名称"))
|
|
{
|
|
rtnValue = labelAutoMemoEdit.EditText;
|
|
}
|
|
else if (type.Equals("编码"))
|
|
{
|
|
rtnValue = labelAutoMemoEdit.EditValue;
|
|
}
|
|
break;
|
|
//标签
|
|
case "6":
|
|
rtnValue = "";
|
|
break;
|
|
//复选框
|
|
case "7":
|
|
LabelCheckEdit checkEdit = baseUserControl as LabelCheckEdit;
|
|
rtnValue = checkEdit.EditText;
|
|
break;
|
|
//日期框
|
|
case "9":
|
|
LabelDateEdit dateEdit = baseUserControl as LabelDateEdit;
|
|
rtnValue = dateEdit.TextEdit.EditValue == null ? dateEdit.EditText : dateEdit.TextEdit.EditValue.ToString();
|
|
break;
|
|
case "2":
|
|
default:
|
|
LabelTextEdit labelTextEdit = baseUserControl as LabelTextEdit;
|
|
rtnValue = labelTextEdit.EditText;
|
|
break;
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
if (rtnValue.Equals("无"))
|
|
{
|
|
rtnValue = "";
|
|
}
|
|
return rtnValue;
|
|
}
|
|
#endregion
|
|
#region 事件
|
|
/// <summary>
|
|
/// 窗体加载时
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected override void OnLoad(EventArgs e)
|
|
{
|
|
InitControl();
|
|
InitEvent();
|
|
}
|
|
/// <summary>
|
|
/// 分隔条位置改变时
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void OnSplitMainContainerPositionChanged(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (this.Model != null)
|
|
{
|
|
IniHelper.Write(string.Format("PubProductSysMge_SplitMain_{0}", this.Model.ModuleCode), this.splitMainContainer.SplitterPosition + "");
|
|
IniHelper.Write(string.Format("PubProductSysMge_SplitRight_{0}", this.Model.ModuleCode), this.splitRightContainer.SplitterPosition + "");
|
|
IniHelper.Write(string.Format("PubProductSysMge_SplitControl_{0}", this.Model.ModuleCode), this.splitControlContainer.SplitterPosition + "");
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageUtil.Show(ex.Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 方案选择改变时
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void OnProjectSelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
if (_suppressProjectSelectedIndexChanged || _isTreeNodeLoading)
|
|
{
|
|
return;
|
|
}
|
|
|
|
WaitForm.ShowForm();
|
|
try
|
|
{
|
|
this.MainControlObj.ResetControlValue();
|
|
TreeNode treeNode = this.treeLeftViewEx.TreeView.SelectedNode;
|
|
SetDynamicControl(treeNode);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageUtil.Show(ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
WaitForm.HideForm();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 树节点点击后刷新数据
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void OnTreeLeftTreeNodeSelected(object sender, TreeNodeMouseClickEventArgs e)
|
|
{
|
|
if (_isTreeNodeLoading)
|
|
{
|
|
if (_loadingTreeNode != null && this.treeLeftViewEx.TreeView.SelectedNode != _loadingTreeNode)
|
|
{
|
|
this.treeLeftViewEx.TreeView.SelectedNode = _loadingTreeNode;
|
|
}
|
|
return;
|
|
}
|
|
|
|
_isTreeNodeLoading = true;
|
|
_loadingTreeNode = e.Node;
|
|
try
|
|
{
|
|
WaitForm.ShowForm();
|
|
if (e.Node == null)
|
|
{
|
|
MessageUtil.Show("请选择节点");
|
|
return;
|
|
}
|
|
this.treeLeftViewEx.TreeView.SelectedNode = e.Node;
|
|
string nodeName = this.treeLeftViewEx.TreeView.SelectedNode != null ? this.treeLeftViewEx.TreeView.SelectedNode.Name : "";
|
|
this.speciesNoEdit.Text = "";
|
|
this.speciesNameEdit.Text = "";
|
|
//this.projectComBoEdit.Text = "";
|
|
//this.projectComBoEdit.Tag = "";
|
|
this.btnUpdate.Enabled = false;
|
|
this.btnSave.Enabled = true;
|
|
this.MainControlObj.ResetControlValue();
|
|
//this.pl_Top.Controls.Clear();
|
|
this.DisposeTopControls();
|
|
this.ControlList.Clear();
|
|
|
|
//string projectId = MainImpl.GetResult(string.Format("select BmFaID from P_ProductSpeciesTab where speciesno = '{0}'", e.Node.Name)) + "";
|
|
//string projectName = MainImpl.GetResult(string.Format("select ItemName from p_productsyssetGrouptab where id = '{0}'", projectId)) + "";
|
|
string sql = "select id,ItemName from p_productsyssetGrouptab where speciesno = '{0}'";
|
|
if (!string.IsNullOrWhiteSpace(this.MainModuleObj.TreeClickSchemeSql)) sql = this.MainModuleObj.TreeClickSchemeSql;
|
|
DataTable dataTable = MainImpl.GetDataTableResult(string.Format(sql, e.Node.Name));
|
|
|
|
this.speciesNoEdit.Text = e.Node.Name;
|
|
this.speciesNameEdit.Text = e.Node.Text;
|
|
//this.projectComBoEdit.Text = projectName;
|
|
//this.projectComBoEdit.Tag = projectId;
|
|
bool hasProjectItem = false;
|
|
_suppressProjectSelectedIndexChanged = true;
|
|
try
|
|
{
|
|
this.projectComBoEdit.Text = "";
|
|
this.projectComBoEdit.Properties.Items.Clear();
|
|
if (e.Node.Nodes.Count == 0)
|
|
{
|
|
foreach (DataRow item in dataTable.Rows)
|
|
{
|
|
|
|
ComboBoxModel comboBoxModel = new ComboBoxModel(item)
|
|
{
|
|
ValueMember = dataTable.Columns[0].ColumnName,
|
|
DisplayMember = dataTable.Columns[1].ColumnName,
|
|
};
|
|
this.projectComBoEdit.Properties.Items.Add(comboBoxModel);
|
|
}
|
|
if (this.projectComBoEdit.Properties.Items.Count > 0)
|
|
{
|
|
this.projectComBoEdit.SelectedIndex = 0;
|
|
hasProjectItem = true;
|
|
}
|
|
}
|
|
}
|
|
finally
|
|
{
|
|
_suppressProjectSelectedIndexChanged = false;
|
|
}
|
|
|
|
if (hasProjectItem)
|
|
{
|
|
SetDynamicControl(e.Node);
|
|
}
|
|
string where = null;
|
|
if (string.IsNullOrWhiteSpace(this.ParentUnionField))
|
|
{
|
|
where = string.Format(" and {0} like '{1}%'", this.treeLeftViewEx.TreeNodeKeyField, e.Node.Name);
|
|
}
|
|
else
|
|
{
|
|
where = string.Format(" and {0} like '{1}%'", this.ParentUnionField, e.Node.Name);
|
|
}
|
|
|
|
if (this.MainModuleObj.LeafNodeRefresh && e.Node.Nodes.Count != 0) return;
|
|
|
|
if (nodeName == e.Node.Name)
|
|
{
|
|
this.SetMainGridView(where, false, false);
|
|
}
|
|
else
|
|
{
|
|
this.SetMainGridView(where);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageUtil.Show(ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
_loadingTreeNode = null;
|
|
_isTreeNodeLoading = false;
|
|
WaitForm.HideForm();
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 清空并释放顶部动态控件,避免 Controls.Clear 只移除不释放导致资源累积。
|
|
/// </summary>
|
|
private void DisposeTopControls()
|
|
{
|
|
if (this.pl_Top == null || this.pl_Top.IsDisposed)
|
|
{
|
|
return;
|
|
}
|
|
|
|
for (int i = this.pl_Top.Controls.Count - 1; i >= 0; i--)
|
|
{
|
|
System.Windows.Forms.Control control = this.pl_Top.Controls[i];
|
|
this.pl_Top.Controls.RemoveAt(i);
|
|
control.Dispose();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 控件面板点击时切换焦点,实现隐藏弹出框
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void OnScrollableControlClick(object sender, EventArgs e)
|
|
{
|
|
ScrollableControl scrollableControl = (ScrollableControl)sender;
|
|
scrollableControl.Focus();
|
|
}
|
|
/// <summary>
|
|
/// 动态控件按钮点击时
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void OnTextEditKeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
//BaseUserControl baseControl = (sender as System.Windows.Forms.Control).ToBaseUserControl();
|
|
//baseControl.EditText = baseControl.EditText;
|
|
}
|
|
/// <summary>
|
|
/// 动态控件值改变时
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void OnTextEditTextChanged(object sender, EventArgs e)
|
|
{
|
|
BaseUserControl baseControl = (sender as System.Windows.Forms.Control).ToBaseUserControl();
|
|
SysSetModel model = baseControl.Tag as SysSetModel;
|
|
// 是否存在关联值
|
|
if (!string.IsNullOrWhiteSpace(model.UnionValues) && !string.IsNullOrWhiteSpace(model.UnionFields))
|
|
{
|
|
this.SetUnionControl(model);//关联计算
|
|
}
|
|
|
|
this.SetDisableControl(model);
|
|
|
|
|
|
if (model.OrderId.Equals(1) && this.NameBaseControl != null)//反写名称
|
|
{
|
|
this.NameBaseControl.EditText = baseControl.EditText;
|
|
}
|
|
if (model.SpecDbName.Equals(1) && this.SpecBaseControl != null)//反写规格
|
|
{
|
|
List<BaseUserControl> specControls = this.pl_Top.Controls.Cast<BaseUserControl>().Where(n => (n.Tag as SysSetModel).SpecDbName.Equals(1) && !string.IsNullOrWhiteSpace(n.EditText)).OrderBy(n => (n.Tag as SysSetModel).SpecSort).ToList();
|
|
StringBuilder specText = new StringBuilder();
|
|
for (int i = 0; i < specControls.Count; i++)
|
|
{
|
|
BaseUserControl item = specControls[i];
|
|
if (string.IsNullOrWhiteSpace(item.EditText)) continue;
|
|
SysSetModel sysSetModel = item.Tag as SysSetModel;
|
|
string editText = GetBaseControlValue(item, sysSetModel.FxTypeGg);
|
|
if (!string.IsNullOrWhiteSpace(editText))
|
|
{
|
|
if (i == 0)
|
|
{
|
|
specText.Append(string.Format("{0}{1}{2}", sysSetModel.ConnectorStrGg, editText, sysSetModel.EndConnectorStrGg));
|
|
}
|
|
else
|
|
{
|
|
specText.Append(string.Format("{0}{1}{2}{3}", sysSetModel.ConnectorStr, sysSetModel.ConnectorStrGg, editText, sysSetModel.EndConnectorStrGg));
|
|
}
|
|
}
|
|
}
|
|
this.SpecBaseControl.EditText = specText.ToString();
|
|
}
|
|
if (model.ModelDbName.Equals(1) && this.ModelBaseControl != null)//反写型号
|
|
{
|
|
List<BaseUserControl> modelControls = this.pl_Top.Controls.Cast<BaseUserControl>().Where(n => (n.Tag as SysSetModel).ModelDbName.Equals(1) && !string.IsNullOrWhiteSpace(n.EditText)).OrderBy(n => (n.Tag as SysSetModel).ModelSort).ToList();
|
|
StringBuilder modelText = new StringBuilder();
|
|
for (int i = 0; i < modelControls.Count; i++)
|
|
{
|
|
BaseUserControl item = modelControls[i];
|
|
if (string.IsNullOrWhiteSpace(item.EditText)) continue;
|
|
SysSetModel sysSetModel = item.Tag as SysSetModel;
|
|
string editText = GetBaseControlValue(item, sysSetModel.FxTypeXh);
|
|
if (!string.IsNullOrWhiteSpace(editText))
|
|
{
|
|
if (i == 0)
|
|
{
|
|
modelText.Append(string.Format("{0}{1}{2}", sysSetModel.ConnectorStrXh, editText, sysSetModel.EndConnectorStrXh));
|
|
}
|
|
else
|
|
{
|
|
modelText.Append(string.Format("{0}{1}{2}{3}", sysSetModel.ConnectorStr, sysSetModel.ConnectorStrXh, editText, sysSetModel.EndConnectorStrXh));
|
|
}
|
|
}
|
|
}
|
|
this.ModelBaseControl.EditText = modelText.ToString();
|
|
}
|
|
if (model.ZhSxdbName.Equals(1) && this.ZhSxBaseControl != null)//反写综合属性
|
|
{
|
|
List<BaseUserControl> zhsxControls = this.pl_Top.Controls.Cast<BaseUserControl>().Where(n => (n.Tag as SysSetModel).ZhSxdbName.Equals(1) && !string.IsNullOrWhiteSpace(n.EditText)).OrderBy(n => (n.Tag as SysSetModel).ProDeSort).ToList();
|
|
StringBuilder zhsxText = new StringBuilder();
|
|
for (int i = 0; i < zhsxControls.Count; i++)
|
|
{
|
|
BaseUserControl item = zhsxControls[i];
|
|
if (string.IsNullOrWhiteSpace(item.EditText)) continue;
|
|
SysSetModel sysSetModel = item.Tag as SysSetModel;
|
|
string editText = GetBaseControlValue(item, sysSetModel.FxTypeZhsx);
|
|
if (editText.Equals("无"))
|
|
{
|
|
editText = "";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(editText))
|
|
{
|
|
if (i == 0)
|
|
{
|
|
zhsxText.Append(string.Format("{0}{1}{2}", sysSetModel.ConnectorStrZhsx, editText, sysSetModel.EndConnectorStrZhsx));
|
|
}
|
|
else
|
|
{
|
|
zhsxText.Append(string.Format("{0}{1}{2}{3}", sysSetModel.ConnectorStr, sysSetModel.ConnectorStrZhsx, editText, sysSetModel.EndConnectorStrZhsx));
|
|
}
|
|
}
|
|
}
|
|
this.ZhSxBaseControl.EditText = zhsxText.ToString();
|
|
}
|
|
if (model.CzdbName.Equals(1) && this.CzBaseControl != null)//反写材质属性
|
|
{
|
|
List<BaseUserControl> czControls = this.pl_Top.Controls.Cast<BaseUserControl>().Where(n => (n.Tag as SysSetModel).CzdbName.Equals(1) && !string.IsNullOrWhiteSpace(n.EditText)).OrderBy(n => (n.Tag as SysSetModel).GradeSort).ToList();
|
|
StringBuilder czText = new StringBuilder();
|
|
for (int i = 0; i < czControls.Count; i++)
|
|
{
|
|
BaseUserControl item = czControls[i];
|
|
if (string.IsNullOrWhiteSpace(item.EditText)) continue;
|
|
SysSetModel sysSetModel = item.Tag as SysSetModel;
|
|
string editText = GetBaseControlValue(item, sysSetModel.FxTypeCz);
|
|
if (editText.Equals("无"))
|
|
{
|
|
editText = "";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(editText))
|
|
{
|
|
if (i == 0)
|
|
{
|
|
czText.Append(string.Format("{0}{1}{2}", sysSetModel.ConnectorStrCz, editText, sysSetModel.EndConnectorStrCz));
|
|
}
|
|
else
|
|
{
|
|
czText.Append(string.Format("{0}{1}{2}{3}", sysSetModel.ConnectorStr, sysSetModel.ConnectorStrCz, editText, sysSetModel.EndConnectorStrCz));
|
|
}
|
|
}
|
|
}
|
|
this.CzBaseControl.EditText = czText.ToString();
|
|
}
|
|
|
|
}
|
|
|
|
|
|
/// <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(SysSetModel model)
|
|
{
|
|
SysSetModel[] controls = this.ControlList.Where(x => x.DisableCond.Contains("{" + model.DbName + "}") || x.RequiredCond.Contains("{" + model.DbName + "}")).ToArray();
|
|
if (controls == null || controls.Length == 0) return;
|
|
|
|
string fieldValue = GetControlValue(model.DbName);
|
|
foreach (SysSetModel item in controls)
|
|
{
|
|
try
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(item.DisableCond))
|
|
{
|
|
string disableCond = this.ReplaceControlValue(item.DisableCond.Replace("{" + model.DbName + "}", fieldValue));
|
|
BaseUserControl control = FindControl(item.DbName);
|
|
control.Enabled = ("true".Equals(ValidateCond(disableCond, null) + "", StringComparison.OrdinalIgnoreCase));
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(item.RequiredCond))
|
|
{
|
|
string requiredCond = this.ReplaceControlValue(item.RequiredCond.Replace("{" + model.DbName + "}", fieldValue));
|
|
BaseUserControl control = FindControl(item.DbName);
|
|
control.Required = ("true".Equals(ValidateCond(requiredCond, null) + "", StringComparison.OrdinalIgnoreCase));
|
|
item.MustTig = control.Required ? 1 : 0;
|
|
control.ReadOnly = control.Model.ReadOnly;//重新设置编辑状态可以改变必填颜色
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//MessageUtil.Show(ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 生成编码按钮点击
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void OnBtnSaveClick(object sender, EventArgs e)
|
|
{
|
|
WaitForm.ShowForm("正在保存数据");
|
|
try
|
|
{
|
|
// 获取特定路径的节点名称
|
|
TreeNode[] nodes = treeLeftViewEx.TreeView.Nodes.Find(this.speciesNoEdit.Text, true); // 搜索所有层级
|
|
if (nodes.Length == 0 || nodes[0].Nodes.Count > 0)
|
|
{
|
|
MessageUtil.Show("请选择根节点");
|
|
return;
|
|
}
|
|
|
|
//if (this.treeLeftViewEx.TreeView.SelectedNode.Nodes.Count > 0)
|
|
//{
|
|
// MessageUtil.Show("请选择根节点");
|
|
// return;
|
|
//}
|
|
if (this.VerifyNull(this.pl_Top))
|
|
{
|
|
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", this.MainModuleObj.MenuTable)) + "";
|
|
string primaryKey = BaseImpl.GetBasePrimaryKey(this.Model.ModuleCode);
|
|
string primaryValue = this.GetControlValue(primaryKey);
|
|
DataTable tableColumns = BaseImpl.GetTableColumns(this.MainModuleObj.MenuTable);
|
|
ControlModel model = this.MainControlObj._models.FirstOrDefault(x => x.FieldName == primaryKey);
|
|
string parentValue = this.speciesNoEdit.Text;//this.treeLeftViewEx.TreeView.SelectedNode.Name;
|
|
StringBuilder keyBuilder = new StringBuilder();
|
|
StringBuilder valueBuilder = new StringBuilder();
|
|
List<string> keyList = new List<string>() { "speciesno", "operatorname", "operatedate", "smartbmfa" };
|
|
List<BaseUserControl> modelControls = this.pl_Top.Controls.Cast<BaseUserControl>().Where(n => !string.IsNullOrEmpty((n.Tag as SysSetModel).DbName)).OrderBy(n => (n.Tag as SysSetModel).OrderId).ToList();
|
|
foreach (BaseUserControl item in modelControls)
|
|
{
|
|
SysSetModel sysSetModel = item.Tag as SysSetModel;
|
|
string fxValue = "";
|
|
try
|
|
{
|
|
string controlName = !string.IsNullOrWhiteSpace(sysSetModel.DbName) ? sysSetModel.DbName : sysSetModel.SysName;
|
|
fxValue = this.GetControlValue(controlName);
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
if (!keyList.Contains(sysSetModel.DbName.ToLower()))
|
|
{
|
|
keyList.Add(sysSetModel.DbName.ToLower());
|
|
keyBuilder.Append(string.Format("{0},", sysSetModel.DbName));
|
|
valueBuilder.Append(string.Format("N'{0}',", fxValue.Replace("'", "''")));
|
|
}
|
|
}
|
|
foreach (ControlModel item in MainControlObj.ControlModels)
|
|
{
|
|
if (!item.IsSave ||
|
|
_leftField.Equals(item.FieldName) ||
|
|
"ID".Equals(item.FieldName, StringComparison.CurrentCultureIgnoreCase) ||
|
|
item.FieldType == ControlType.LabPic ||
|
|
item.FieldType == ControlType.LabPicEx || !tableColumns.Columns.Contains(item.FieldName) ||
|
|
Autogrowcolumn.ToLower() == item.FieldName.ToLower())
|
|
continue;
|
|
string fieldValue = MainControlObj.GetControlValue(item);
|
|
if (fieldValue == "****") continue;
|
|
if (item.FieldType == 7)
|
|
{
|
|
if (fieldValue.Contains('%')) fieldValue = (double.Parse(fieldValue.Replace("%", "")) * 0.01).ToString();
|
|
if (fieldValue.Contains(',')) fieldValue = fieldValue.Replace(",", "");
|
|
}
|
|
if (!keyList.Contains(item.FieldName.ToLower()))
|
|
{
|
|
keyList.Add(item.FieldName.ToLower());
|
|
keyBuilder.Append(item.FieldName + ",");
|
|
if (string.IsNullOrEmpty(fieldValue) && item.Isintordecimal) fieldValue = "0";//数值保存时为空的话默认保存为0;
|
|
valueBuilder.Append(string.IsNullOrEmpty(fieldValue) ? MainControlObj.GetNullValue(item) : string.Format("N'{0}',", fieldValue));
|
|
}
|
|
}
|
|
//string insertSql = string.Format("insert into {10} ({11}spec,model,productid,appellation,productdescrip,speciesno,productunitname,OperatorName,Operatedate,SmartBmFa) values ({12}'{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}')\r\n",
|
|
// SpecBaseControl != null ? SpecBaseControl.EditText : "", ModelBaseControl != null ? ModelBaseControl.EditText : "", primaryValue, NameBaseControl != null ? NameBaseControl.EditText : "", ZhSxBaseControl != null ? ZhSxBaseControl.EditText : "", parentValue, UnitBaseControl != null ? UnitBaseControl.EditText : "", ERPInfo.Instance.UserName, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), this.projectEdit.Tag, MainModuleObj.MenuTable, keyBuilder.ToString(), valueBuilder.ToString());
|
|
string projectId = (projectComBoEdit.SelectedItem as ComboBoxModel).Value;
|
|
string insertSql = string.Format("insert into {0} ({1},speciesno,OperatorName,Operatedate,SmartBmFa) values ({2},'{3}','{4}','{5}','{6}')\r\n", this.MainModuleObj.MenuTable, keyBuilder.ToString().TrimEnd(','), valueBuilder.ToString().TrimEnd(','), parentValue, ERPInfo.Instance.UserName, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), projectId);
|
|
BaseSaveModel saveModel = new BaseSaveModel
|
|
{
|
|
BaseSaveType = SaveType.Add,
|
|
BaseSql = insertSql,
|
|
KeyField = primaryKey,
|
|
FieldValue = primaryValue,
|
|
MenuCode = MainModuleObj.ModeCode,
|
|
TableName = MainModuleObj.MenuTable,
|
|
ComfirmFlag = 0,
|
|
NewVer = MainModuleObj.NewVer
|
|
};
|
|
int result = BaseModuleImpl.SaveBasePanelData(saveModel);
|
|
if (result == 1)
|
|
{
|
|
if (saveModel.NewVer == 1 && saveModel.BaseSaveType == SaveType.Add)
|
|
saveModel.FieldValue = primaryValue = saveModel.FaultMsg;
|
|
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);
|
|
}
|
|
MessageUtil.Show(ResourceKeys.SaveSuccess);
|
|
this.MainControlObj.ResetControlValue();
|
|
SetDynamicControl(nodes[0]);
|
|
string where = null;
|
|
string nodeName = this.speciesNoEdit.Text; //this.treeLeftViewEx.TreeView.SelectedNode.Name;
|
|
if (string.IsNullOrWhiteSpace(this.ParentUnionField))
|
|
{
|
|
where = string.Format(" and {0} = N'{1}'", this.treeLeftViewEx.TreeNodeKeyField, nodeName);
|
|
}
|
|
else
|
|
{
|
|
where = string.Format(" and {0} = N'{1}'", this.ParentUnionField, nodeName);
|
|
}
|
|
this.SetMainGridView(where, false, false);
|
|
}
|
|
else
|
|
{
|
|
MessageUtil.Show(ResourceKeys.SaveFault + "\r\n" + saveModel.FaultMsg);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageUtil.Show(ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
WaitForm.HideForm();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 修改编码事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void OnBtnUpdateClick(object sender, EventArgs e)
|
|
{
|
|
WaitForm.ShowForm("正在修改数据");
|
|
try
|
|
{
|
|
if (!this.MainModuleObj.AllowUpdateInSysMge)
|
|
{
|
|
MessageUtil.Show("档案禁止修改");
|
|
return;
|
|
}
|
|
if (this.VerifyNull(this.pl_Top))
|
|
{
|
|
//DataRow focusRow = this.gcMain.GridView.GetFocusedDataRow();
|
|
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", this.MainModuleObj.MenuTable)) + "";
|
|
DataTable tableColumns = BaseImpl.GetTableColumns(this.MainModuleObj.MenuTable);
|
|
//string newBillNo = focusRow["productid"] + "";
|
|
string primaryKey = BaseImpl.GetBasePrimaryKey(this.Model.ModuleCode);
|
|
ControlModel model = this.MainControlObj._models.FirstOrDefault(x => x.FieldName == primaryKey);
|
|
|
|
string newBillNo = this.MainControlObj.GetControlValue(model.FieldName);
|
|
string parentValue = this.speciesNoEdit.Text;
|
|
//string parentValue = focusRow["speciesNo"] + "";
|
|
|
|
List<string> keyList = new List<string>() { "speciesno", "operatorname", "operatedate", "smartbmfa" };
|
|
StringBuilder sqlBuilder = new StringBuilder();
|
|
List<BaseUserControl> modelControls = this.pl_Top.Controls.Cast<BaseUserControl>().Where(n => !string.IsNullOrEmpty((n.Tag as SysSetModel).DbName)).OrderBy(n => (n.Tag as SysSetModel).OrderId).ToList();
|
|
foreach (BaseUserControl item in modelControls)
|
|
{
|
|
SysSetModel sysSetModel = item.Tag as SysSetModel;
|
|
string fxValue = "";
|
|
try
|
|
{
|
|
string controlName = !string.IsNullOrWhiteSpace(sysSetModel.DbName) ? sysSetModel.DbName : sysSetModel.SysName;
|
|
fxValue = this.GetControlValue(controlName);
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
if (!sysSetModel.DbName.Equals(primaryKey, StringComparison.OrdinalIgnoreCase) && !sysSetModel.DbName.Equals("productid", StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
keyList.Add(sysSetModel.DbName.ToLower());
|
|
sqlBuilder.Append(string.Format("{0} = N'{1}',", sysSetModel.DbName, fxValue.Replace("'", "''")));
|
|
}
|
|
}
|
|
foreach (ControlModel item in this.MainControlObj.ControlModels)
|
|
{
|
|
if (!item.IsSave ||
|
|
_leftField.Equals(item.FieldName) ||
|
|
"ID".Equals(item.FieldName, StringComparison.CurrentCultureIgnoreCase) ||
|
|
item.FieldName.Equals(primaryKey, StringComparison.CurrentCultureIgnoreCase) ||
|
|
item.FieldName.Equals("productid", StringComparison.CurrentCultureIgnoreCase) ||
|
|
item.FieldType == ControlType.LabPic ||
|
|
item.FieldType == ControlType.LabPicEx || !tableColumns.Columns.Contains(item.FieldName) ||
|
|
Autogrowcolumn.ToLower() == item.FieldName.ToLower())
|
|
continue;
|
|
BaseUserControl userControl = this.MainControlObj.FindControl(item);
|
|
// userControl.IsUpdate() 保存所有数据
|
|
if (userControl != null)
|
|
{
|
|
string fieldValue = this.MainControlObj.GetControlValue(item);
|
|
if (fieldValue == "****") continue;
|
|
if (item.FieldType == 7)
|
|
{
|
|
if (fieldValue.Contains('%')) fieldValue = (double.Parse(fieldValue.Replace("%", "")) * 0.01).ToString();
|
|
if (fieldValue.Contains(',')) fieldValue = fieldValue.Replace(",", "");
|
|
}
|
|
if (string.IsNullOrEmpty(fieldValue) && item.Isintordecimal) fieldValue = "0";//数值保存时为空的话默认保存为0;
|
|
if (!keyList.Contains(item.FieldName.ToLower()))
|
|
{
|
|
sqlBuilder.Append(string.IsNullOrEmpty(fieldValue) ? string.Format("{0} = {1}", item.FieldName, this.MainControlObj.GetNullValue(item)) : string.Format("{0}='{1}',", item.FieldName, fieldValue));
|
|
}
|
|
}
|
|
}
|
|
string execSql = "";
|
|
if (!string.IsNullOrWhiteSpace(sqlBuilder.ToString()))
|
|
{
|
|
string projectId = (projectComBoEdit.SelectedItem as ComboBoxModel).Value;
|
|
execSql = string.Format("update {0} set {1},speciesno = '{2}', operatorname = '{3}', operatedate = '{4}', smartbmfa = '{5}' where {6} = '{7}'", this.MainModuleObj.MenuTable, sqlBuilder.ToString().TrimEnd(','), parentValue, ERPInfo.Instance.UserName, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), projectId, primaryKey, newBillNo);
|
|
}
|
|
BaseSaveModel saveModel = new BaseSaveModel
|
|
{
|
|
BaseSaveType = SaveType.Update,
|
|
BaseSql = execSql,
|
|
KeyField = primaryKey,
|
|
FieldValue = newBillNo,
|
|
MenuCode = MainModuleObj.ModeCode,
|
|
TableName = MainModuleObj.MenuTable,
|
|
ComfirmFlag = 0,
|
|
NewVer = MainModuleObj.NewVer
|
|
};
|
|
int result = BaseModuleImpl.SaveBasePanelData(saveModel);
|
|
if (result == 1)
|
|
{
|
|
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);
|
|
}
|
|
MessageUtil.Show(ResourceKeys.SaveSuccess);
|
|
string where = null;
|
|
string nodeName = parentValue;//focusRow["speciesNo"] + "";
|
|
if (string.IsNullOrWhiteSpace(this.ParentUnionField))
|
|
{
|
|
where = string.Format(" and {0} = N'{1}'", this.treeLeftViewEx.TreeNodeKeyField, nodeName);
|
|
}
|
|
else
|
|
{
|
|
where = string.Format(" and {0} = N'{1}'", this.ParentUnionField, nodeName);
|
|
}
|
|
this.SetMainGridView(where, true, false);
|
|
}
|
|
else
|
|
{
|
|
MessageUtil.Show(ResourceKeys.SaveFault + "\r\n" + saveModel.FaultMsg);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageUtil.Show(ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
WaitForm.HideForm();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 搜索按钮点击
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void OnBtnCondSearchClick(object sender, EventArgs e)
|
|
{
|
|
WaitForm.ShowForm();
|
|
try
|
|
{
|
|
this.SetMainGridView("", false, false);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageUtil.Show(ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
WaitForm.HideForm();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 双击表格行事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void OnGridViewDoubleClick(object sender, EventArgs e)
|
|
{
|
|
WaitForm.ShowForm();
|
|
try
|
|
{
|
|
//if (this.treeLeftViewEx.TreeView.SelectedNode.Nodes.Count > 0)
|
|
//{
|
|
// MessageUtil.Show("请选择根节点");
|
|
// return;
|
|
//}
|
|
DataRow focusRow = this.gcMain.GridView.GetFocusedDataRow();
|
|
if (focusRow == null) return;
|
|
string primaryVlaue = focusRow["productid"] + "";
|
|
DataRow selectSource = MainImpl.GetDataRowResult(string.Format("select * from p_producttab where productid = '{0}'", primaryVlaue));
|
|
string projectId = selectSource["SmartBmFa"] + "";
|
|
string speciesNo = selectSource["speciesNo"] + "";
|
|
if (string.IsNullOrEmpty(projectId))
|
|
{
|
|
MessageUtil.Show("该档案未通过智能编码生成,不支持智能编码修改");
|
|
this.MainControlObj.ResetControlValue();
|
|
TreeNode treeNode = this.treeLeftViewEx.TreeView.SelectedNode;
|
|
SetDynamicControl(treeNode);
|
|
this.btnUpdate.Enabled = false;
|
|
this.btnSave.Enabled = true;
|
|
return;
|
|
}
|
|
|
|
|
|
//获取选中行对应的方案
|
|
string sql = "select id,ItemName from p_productsyssetGrouptab where id = '{0}' and speciesNo='{1}'";
|
|
if (!string.IsNullOrWhiteSpace(this.MainModuleObj.TableClickSchemeSql)) sql = this.MainModuleObj.TableClickSchemeSql;
|
|
DataTable dataTable = MainImpl.GetDataTableResult(string.Format(sql, projectId, speciesNo));
|
|
|
|
this.projectComBoEdit.Text = "";
|
|
this.projectComBoEdit.Properties.Items.Clear();
|
|
foreach (DataRow item in dataTable.Rows)
|
|
{
|
|
ComboBoxModel comboBoxModel = new ComboBoxModel(item)
|
|
{
|
|
ValueMember = dataTable.Columns[0].ColumnName,
|
|
DisplayMember = dataTable.Columns[1].ColumnName,
|
|
};
|
|
this.projectComBoEdit.Properties.Items.Add(comboBoxModel);
|
|
}
|
|
|
|
if (dataTable != null && dataTable.Rows.Count > 0)
|
|
{
|
|
this.projectComBoEdit.SelectedIndex = 0;
|
|
TreeNode[] foundNodes = this.treeLeftViewEx.TreeView.Nodes.Find(speciesNo, true);
|
|
|
|
if (foundNodes.Length > 0)
|
|
{
|
|
//this.treeLeftViewEx.TreeView.SelectedNode = foundNodes[0];
|
|
this.speciesNoEdit.Text = speciesNo;
|
|
string foundNodeName = foundNodes[0].Text;
|
|
this.speciesNameEdit.Text = foundNodeName;
|
|
|
|
this.SetDynamicControl(foundNodes[0]);
|
|
}
|
|
//中间部分控件赋值
|
|
this.MainControlObj.SetAllControlValue(focusRow);
|
|
//上方控件赋值
|
|
List<BaseUserControl> modelControls = this.pl_Top.Controls.Cast<BaseUserControl>().Where(n => !string.IsNullOrEmpty((n.Tag as SysSetModel).DbName)).OrderBy(n => (n.Tag as SysSetModel).OrderId).ToList();
|
|
foreach (BaseUserControl item in modelControls)
|
|
{
|
|
SysSetModel sysSetModel = item.Tag as SysSetModel;
|
|
string value = selectSource.Table.Columns.Contains(sysSetModel.DbName) ? selectSource[sysSetModel.DbName] + "" : "";
|
|
//double doubleValue;
|
|
item.EditText = value;
|
|
//if (double.TryParse(value, out doubleValue))
|
|
//{
|
|
// item.EditText = doubleValue + "";
|
|
//}
|
|
//else
|
|
//{
|
|
// item.EditText = value;
|
|
//}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
MessageUtil.Show($"不存在方案{projectId}");
|
|
this.MainControlObj.ResetControlValue();
|
|
TreeNode treeNode = this.treeLeftViewEx.TreeView.SelectedNode;
|
|
SetDynamicControl(treeNode);
|
|
this.btnUpdate.Enabled = false;
|
|
this.btnSave.Enabled = true;
|
|
return;
|
|
}
|
|
this.btnUpdate.Enabled = true;
|
|
this.btnSave.Enabled = false;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageUtil.Show(ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
WaitForm.HideForm();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 右键菜单回调
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void OnGridViewRightCallBack(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
this.MainControlObj.ResetControlValue();
|
|
SetDynamicControl(this.treeLeftViewEx.TreeView.SelectedNode);
|
|
string where = null;
|
|
string nodeName = this.treeLeftViewEx.TreeView.SelectedNode.Name;
|
|
if (string.IsNullOrWhiteSpace(this.ParentUnionField))
|
|
{
|
|
where = string.Format(" and {0} = N'{1}'", this.treeLeftViewEx.TreeNodeKeyField, nodeName);
|
|
}
|
|
else
|
|
{
|
|
where = string.Format(" and {0} = N'{1}'", this.ParentUnionField, nodeName);
|
|
}
|
|
this.SetMainGridView(where, false, false);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show(ex.Message);
|
|
}
|
|
}
|
|
#endregion
|
|
/// <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(SysSetModel 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);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 设置控件值
|
|
/// </summary>
|
|
/// <param name="controlName"></param>
|
|
/// <param name="controlValue"></param>
|
|
public void SetControlValue(string controlName, object controlValue)
|
|
{
|
|
BaseUserControl baseControl = FindControl(controlName);
|
|
if (baseControl == null) return;
|
|
baseControl.EditText = controlValue + "";
|
|
}
|
|
/// <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))
|
|
{
|
|
string parentValue = this.treeLeftViewEx.TreeView.SelectedNode.Name;
|
|
defaultValue = ReplaceHelper.ReplaceUserInfo(defaultValue);
|
|
defaultValue = ReplaceHelper.ReplaceTreeViewParentKeyCond(defaultValue, parentValue);
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
return defaultValue;
|
|
}
|
|
/// <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)
|
|
{
|
|
System.Windows.Forms.Control controlObj = new System.Windows.Forms.Control();
|
|
|
|
controlObj = this.pl_Top.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;
|
|
}
|
|
|
|
if (controlObj != null && controlObj is BaseUserControl)
|
|
{
|
|
return controlObj as BaseUserControl;
|
|
}
|
|
return null;
|
|
}
|
|
/// <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)
|
|
{
|
|
string value = string.Empty;
|
|
var ctrs = pl_Top.Controls.Find("txt_" + controlName, true);
|
|
if (ctrs != null && ctrs.Length > 0)
|
|
{
|
|
var ctr = ctrs[0];
|
|
BaseUserControl uControl = ctr as BaseUserControl;
|
|
SysSetModel setModel = uControl.Tag as SysSetModel;
|
|
switch (setModel.Item)//控件类型
|
|
{
|
|
//下拉框控件
|
|
case "1":
|
|
LabelAutoTextEdit labelAutoTextEdit = ctr as LabelAutoTextEdit;
|
|
if (setModel.FxTypeDB.Equals("编码"))
|
|
{
|
|
value = labelAutoTextEdit.EditValue;
|
|
}
|
|
else if (setModel.FxTypeDB.Equals("名称"))
|
|
{
|
|
value = labelAutoTextEdit.EditText;
|
|
}
|
|
break;
|
|
//多选框控件
|
|
case "3":
|
|
LabelMultiAutoTextEdit labelMultiAutoTextEdit = ctr as LabelMultiAutoTextEdit;
|
|
if (setModel.FxType.Equals("名称"))
|
|
{
|
|
value = labelMultiAutoTextEdit.EditText;
|
|
}
|
|
else if (setModel.FxType.Equals("编码"))
|
|
{
|
|
value = labelMultiAutoTextEdit.EditValue;
|
|
}
|
|
break;
|
|
//备注框A
|
|
case "4":
|
|
LabelMemoEdit labelMemoEdit = ctr as LabelMemoEdit;
|
|
value = labelMemoEdit.EditText;
|
|
break;
|
|
//下拉备注框
|
|
case "5":
|
|
LabelAutoMemoEdit labelAutoMemoEdit = ctr as LabelAutoMemoEdit;
|
|
if (setModel.FxTypeDB.Equals("编码"))
|
|
{
|
|
value = labelAutoMemoEdit.EditValue;
|
|
}
|
|
else if (setModel.FxTypeDB.Equals("名称"))
|
|
{
|
|
value = labelAutoMemoEdit.EditText;
|
|
}
|
|
break;
|
|
//标签
|
|
case "6":
|
|
value = "";
|
|
break;
|
|
//复选框
|
|
case "7":
|
|
LabelCheckEdit checkEdit = ctr as LabelCheckEdit;
|
|
value = checkEdit.EditText;
|
|
break;
|
|
//日期框
|
|
case "9":
|
|
LabelDateEdit dateEdit = ctr as LabelDateEdit;
|
|
value = dateEdit.TextEdit.EditValue == null ? dateEdit.EditText : dateEdit.TextEdit.EditValue.ToString();
|
|
break;
|
|
//文本框控件
|
|
case "2":
|
|
default:
|
|
LabelTextEdit labelTextEdit = ctr as LabelTextEdit;
|
|
value = labelTextEdit.EditText;
|
|
break;
|
|
}
|
|
}
|
|
return value;
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 刷新树节点
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void TreeNodeRefresh(object sender, EventArgs e)
|
|
{
|
|
//TreeNode node = this.treeLeftViewEx.TreeView.SelectedNode;
|
|
if (this.LeftTreeRow != null)
|
|
{
|
|
this.treeLeftViewEx.BindTreeView(BaseImpl.GetDataTableResult(this.LeftTreeRow["fieldsql"] + ""));
|
|
}
|
|
else
|
|
{
|
|
// 根据模块上配置的sql加载树
|
|
if (this.MainModuleObj != null && !string.IsNullOrEmpty(this.MainModuleObj.TreeSQL))
|
|
{
|
|
this.treeLeftViewEx.BindTreeView(BaseImpl.GetDataTableResult(this.MainModuleObj.TreeSQL));
|
|
}
|
|
else if (this.MainModuleObj.DefaultTreeSql)
|
|
{
|
|
this.treeLeftViewEx.BindTreeView(BaseImpl.GetDataTableResult("select a.SpeciesNo,a.SpeciesName from p_productspeciestab a where a.ban=0"));
|
|
}
|
|
}
|
|
// 选中第一个节点并刷新右侧数据
|
|
if (this.treeLeftViewEx.TreeView.Nodes.Count > 0)
|
|
{
|
|
this.treeLeftViewEx.TreeView.SelectedNode = this.treeLeftViewEx.TreeView.Nodes[0];
|
|
TreeNodeMouseClickEventArgs viewEventArgs = new TreeNodeMouseClickEventArgs(this.treeLeftViewEx.TreeView.SelectedNode, MouseButtons.None, 0, 0, 0);
|
|
this.OnTreeLeftTreeNodeSelected(null, viewEventArgs);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
///点击复制新增按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void OnBtnCopyAndAddClick(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (this.pl_Top.Controls.Count > 0)
|
|
{
|
|
this.MainControlObj.CopyControlValue();
|
|
//重置所有设置了默认值的控件
|
|
//foreach (ControlModel model in this.MainControlObj)
|
|
//{
|
|
//}
|
|
this.btnUpdate.Enabled = false;
|
|
this.btnSave.Enabled = true;
|
|
if (SystemInfo.Instance.PubProductSysMgeCopyAndSave)
|
|
{
|
|
this.OnBtnSaveClick(null, null);
|
|
}
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <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>
|
|
/// 限制數值框粘貼不能粘貼中文
|
|
/// </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>
|
|
/// <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;
|
|
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);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
}
|
|
}
|