1385 lines
66 KiB
C#
1385 lines
66 KiB
C#
using DevExpress.Data;
|
|
using DevExpress.XtraEditors;
|
|
using DevExpress.XtraGrid;
|
|
using DevExpress.XtraGrid.Columns;
|
|
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.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 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
|
|
|
|
|
|
|
|
|
|
public FrmMain(DynamicProductSysMgeModel model = null)
|
|
{
|
|
InitializeComponent();
|
|
Model = ((model != null) ? model : null);
|
|
}
|
|
|
|
private void InitEvent()
|
|
{
|
|
splitMainContainer.SplitterPositionChanged += OnSplitMainContainerPositionChanged;
|
|
splitRightContainer.SplitterPositionChanged += OnSplitMainContainerPositionChanged;
|
|
splitControlContainer.SplitterPositionChanged += OnSplitMainContainerPositionChanged;
|
|
pl_Top.Click += OnScrollableControlClick;
|
|
pl_Bottom.Click += OnScrollableControlClick;
|
|
btnSave.Click += OnBtnSaveClick;
|
|
btnUpdate.Click += OnBtnUpdateClick;
|
|
btnCondSearch.Click += OnBtnCondSearchClick;
|
|
}
|
|
|
|
private void InitControl()
|
|
{
|
|
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00e1: Expected O, but got Unknown
|
|
WaitForm.ShowForm((string)null);
|
|
try
|
|
{
|
|
((DynamicModel)Model).Privilege = (((DynamicModel)Model).Privilege.Equals("3") ? "1" : ((((DynamicModel)Model).ModuleId > 0) ? (BaseImpl.GetUserPurviewsByMenuId(((DynamicModel)Model).ModuleId.ToString() ?? "").ToString() ?? "") : (BaseImpl.GetUserPurviewsByMenuCode(((DynamicModel)Model).ModuleCode).ToString() ?? "")));
|
|
DataRow systemdllTab = MainImpl.GetSystemdllTab(((DynamicModel)Model).ModuleCode);
|
|
if (systemdllTab == null)
|
|
{
|
|
MessageUtil.Show("模块编号[" + ((DynamicModel)Model).ModuleCode + "],配置错误!\r\n该模块信息未找到!");
|
|
return;
|
|
}
|
|
MainModuleObj = new ModuleModel(systemdllTab);
|
|
switch (MainModuleObj.MenuType)
|
|
{
|
|
case 1:
|
|
case 4:
|
|
InitlizeSpiltLocation();
|
|
SetLeftTreeView();
|
|
if (MainModuleObj.IsHideTreeViewBoxs)
|
|
{
|
|
treeLeftViewEx.TreeView.CheckBoxes = false;
|
|
}
|
|
break;
|
|
default:
|
|
splitMainContainer.PanelVisibility = SplitPanelVisibility.Panel2;
|
|
break;
|
|
}
|
|
InitMain();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
WaitForm.HideForm();
|
|
}
|
|
|
|
private void InitMain()
|
|
{
|
|
_leftField = BaseModuleImpl.GetBaseLeftField(((DynamicModel)Model).ModuleCode);
|
|
ParmaryKey = BaseImpl.GetBasePrimaryKey(((DynamicModel)Model).ModuleCode);
|
|
_gridColumns = BaseModuleImpl.GetBaseGridColumns(((DynamicModel)Model).ModuleCode);
|
|
_gridAllColumns = BaseModuleImpl.GetBaseGridAllColumns(((DynamicModel)Model).ModuleCode);
|
|
if (_gridColumns != null && _gridColumns.Rows.Count > 0)
|
|
{
|
|
_nullFields = _gridColumns.Select("nullable=1");
|
|
_leftGridField = _gridColumns.Select("fieldsqlTag=3").FirstOrDefault();
|
|
}
|
|
InitializeGridView();
|
|
CreateControlLocation();
|
|
}
|
|
|
|
private void InitializeGridView(bool ProcessExists = false)
|
|
{
|
|
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0134: Expected O, but got Unknown
|
|
gcMain.Model = (DynamicModel)(object)Model;
|
|
if (MainModuleObj.IsDynamicColumn)
|
|
{
|
|
gcMain.GridView.OptionsView.ColumnAutoWidth = true;
|
|
}
|
|
if (!MainModuleObj.IsDynamicColumn)
|
|
{
|
|
if (MainModuleObj.CanEdit)
|
|
{
|
|
gcMain.SetEditColumns(_gridColumns, GridCustomColumnStruct.BaseMainGridView + MainModuleObj.FormKey);
|
|
}
|
|
else
|
|
{
|
|
gcMain.SetReadOnlyColumns(_gridColumns, GridCustomColumnStruct.BaseMainGridView + MainModuleObj.FormKey);
|
|
}
|
|
}
|
|
gcMain.SetGridRowColors(BaseModuleImpl.GetBaseGridRowColors(((DynamicModel)Model).ModuleCode));
|
|
GridExtend.SetGridRightMenus(gcMain, BaseModuleImpl.GetBaseGridRightMenus(((DynamicModel)Model).ModuleCode, (ModuleType)0), (DynamicModel)(object)Model, (EventHandler)null, (MyControl)null, (ContextMenuStrip)null);
|
|
gcMain.GridView.DoubleClick += OnGridViewDoubleClick;
|
|
SearchMainObj = new MyControl(MainModuleObj.MenuSql, gcMain, treeLeftViewEx, (GridControlEx)null, (MyControl)null);
|
|
SearchMainObj.ParentUnionField = ParentUnionField;
|
|
DataTable customQueryFields = BaseModuleImpl.GetCustomQueryFields(MainModuleObj.CondKey);
|
|
if (customQueryFields != null && customQueryFields.Rows.Count > 0)
|
|
{
|
|
plm_bot_cond.Visible = true;
|
|
plm_bot_cond.Controls.Clear();
|
|
SearchMainObj.InitSearchControl(customQueryFields, plm_bot_cond, (DataTable)null, (DynamicModel)null, false);
|
|
SearchMainObj.ButtonObj.Visible = false;
|
|
System.Windows.Forms.Control control = plm_bot_cond.Controls.Find("btnCondSearch", searchAllChildren: true).FirstOrDefault();
|
|
plm_bot_cond.Width = control.Location.X;
|
|
}
|
|
}
|
|
|
|
private void CreateControlLocation()
|
|
{
|
|
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_001a: Expected O, but got Unknown
|
|
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00a1: Expected O, but got Unknown
|
|
try
|
|
{
|
|
TopControlObj = new MyControl
|
|
{
|
|
ParentPanel = pl_Top
|
|
};
|
|
if (Model != null && MainModuleObj != null)
|
|
{
|
|
LeftField = BaseModuleImpl.GetBaseLeftField(((DynamicModel)Model).ModuleCode);
|
|
MainControlTable = BaseModuleImpl.GetControlLocation(MainModuleObj.FormKey, ((DynamicModel)Model).ModuleCode);
|
|
MainControlObj = new MyControl
|
|
{
|
|
SystemModel = MainModuleObj,
|
|
OtherParams = ((DynamicModel)Model).OtherParams(),
|
|
popUpDyncModel = (DynamicModel)(object)Model
|
|
};
|
|
MainControlObj.InitControl(MainControlTable, pl_Bottom, (DataTable)null, true);
|
|
pl_Bottom.AutoScroll = true;
|
|
pl_Bottom.HorizontalScroll.Visible = false;
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
}
|
|
|
|
private void InitlizeSpiltLocation()
|
|
{
|
|
try
|
|
{
|
|
string value = IniHelper.Read($"PubProductSysMge_SplitMain_{((DynamicModel)Model).ModuleCode}");
|
|
if (!string.IsNullOrEmpty(value))
|
|
{
|
|
splitMainContainer.SplitterPosition = Convert.ToInt32(value);
|
|
}
|
|
string value2 = IniHelper.Read($"PubProductSysMge_SplitRight_{((DynamicModel)Model).ModuleCode}");
|
|
if (!string.IsNullOrEmpty(value2))
|
|
{
|
|
splitRightContainer.SplitterPosition = Convert.ToInt32(value2);
|
|
}
|
|
string value3 = IniHelper.Read($"PubProductSysMge_SplitControl_{((DynamicModel)Model).ModuleCode}");
|
|
if (!string.IsNullOrEmpty(value))
|
|
{
|
|
splitControlContainer.SplitterPosition = Convert.ToInt32(value3);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageUtil.Show(ex.Message);
|
|
}
|
|
}
|
|
|
|
private void SetLeftTreeView()
|
|
{
|
|
LeftTreeRow = BaseModuleImpl.GetBaseLeftTreeField(((DynamicModel)Model).ModuleCode);
|
|
if (LeftTreeRow != null)
|
|
{
|
|
ParentUnionField = LeftTreeRow["fieldname"]?.ToString() ?? "";
|
|
string treeNodeKeyField = LeftTreeRow["fieldsqlid"]?.ToString() ?? "";
|
|
treeLeftViewEx.TreeNodeKeyField = treeNodeKeyField;
|
|
treeLeftViewEx.TreeNodeTextField = LeftTreeRow["fieldsqlname"]?.ToString() ?? "";
|
|
treeLeftViewEx.OnTreeNodeMouseClick += OnTreeLeftTreeNodeSelected;
|
|
treeLeftViewEx.TreeNodeLength = ((!LeftTreeRow.Table.Columns.Contains("TreeNodeLength")) ? "" : (LeftTreeRow["TreeNodeLength"]?.ToString() ?? ""));
|
|
treeLeftViewEx.BindTreeView(BaseImpl.GetDataTableResult(LeftTreeRow["fieldsql"]?.ToString() ?? ""));
|
|
if (LeftTreeRow.Table.Columns.Contains("TreeNodeSearch") && "1".Equals(LeftTreeRow["TreeNodeSearch"]?.ToString() ?? ""))
|
|
{
|
|
treeLeftViewEx.pl_top.Visible = true;
|
|
}
|
|
}
|
|
else if (MainModuleObj != null && !string.IsNullOrEmpty(MainModuleObj.TreeSQL))
|
|
{
|
|
ParentUnionField = "SpeciesNo";
|
|
string treeNodeKeyField2 = "SpeciesNo";
|
|
treeLeftViewEx.TreeNodeKeyField = treeNodeKeyField2;
|
|
treeLeftViewEx.TreeNodeTextField = "SpeciesName";
|
|
treeLeftViewEx.OnTreeNodeMouseClick += OnTreeLeftTreeNodeSelected;
|
|
treeLeftViewEx.BindTreeView(BaseImpl.GetDataTableResult(MainModuleObj.TreeSQL));
|
|
}
|
|
else if (MainModuleObj.DefaultTreeSql)
|
|
{
|
|
ParentUnionField = "SpeciesNo";
|
|
string treeNodeKeyField3 = "SpeciesNo";
|
|
treeLeftViewEx.TreeNodeKeyField = treeNodeKeyField3;
|
|
treeLeftViewEx.TreeNodeTextField = "SpeciesName";
|
|
treeLeftViewEx.OnTreeNodeMouseClick += OnTreeLeftTreeNodeSelected;
|
|
treeLeftViewEx.BindTreeView(BaseImpl.GetDataTableResult("select a.SpeciesNo,a.SpeciesName from p_productspeciestab a where a.ban=0"));
|
|
}
|
|
}
|
|
|
|
private void SetMainGridView(string where = "", bool selectHandler = false, bool initColumns = true)
|
|
{
|
|
int focusedRowHandle = gcMain.GridView.FocusedRowHandle;
|
|
string text = ReplaceHelper.ReplaceUserInfo(MainModuleObj.MenuSql);
|
|
text = ReplaceHelper.ReplaceWhereCond(text);
|
|
if (string.IsNullOrWhiteSpace(where))
|
|
{
|
|
text = SearchMainObj.SetSearchSqlValue(text, true, false);
|
|
}
|
|
text = BaseImpl.GetDefaultValue(text, "", (string[])null);
|
|
text = (IsSelectAtStart(text) ? (text + where) : text);
|
|
text += " order by id desc";
|
|
DataTable dataTableResult = BaseImpl.GetDataTableResult(text);
|
|
if (initColumns && MainModuleObj.IsDynamicColumn)
|
|
{
|
|
gcMain.GridView.Columns.Clear();
|
|
gcMain.GridControl.DataSource = null;
|
|
for (int i = 0; i < ControlList.Count; i++)
|
|
{
|
|
SysSetModel setModel = ControlList[i];
|
|
DataColumn dataColumn = (from DataColumn n in dataTableResult.Columns
|
|
where n.ColumnName.Equals(setModel.DbName, StringComparison.OrdinalIgnoreCase)
|
|
select n).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;
|
|
gcMain.GridView.Columns.Add(gridColumn);
|
|
if (i == 0)
|
|
{
|
|
gcMain.GridView.OptionsView.ShowFooter = true;
|
|
gridColumn.Summary.AddRange(new GridSummaryItem[1]
|
|
{
|
|
new GridColumnSummaryItem(SummaryItemType.Count, gridColumn.FieldName, "合计: {0:#,###}行")
|
|
});
|
|
gcMain.GridView.GroupSummary.AddRange(new GridSummaryItem[1]
|
|
{
|
|
new GridGroupSummaryItem(SummaryItemType.Count, gridColumn.FieldName, null, "合计: {0:#,###}行")
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (gcMain.GridView.Columns.Count > 0)
|
|
{
|
|
gcMain.GridControl.DataSource = dataTableResult;
|
|
}
|
|
if (selectHandler)
|
|
{
|
|
gcMain.GridView.FocusedRowHandle = focusedRowHandle;
|
|
}
|
|
}
|
|
|
|
private bool IsSelectAtStart(string sqlText)
|
|
{
|
|
string text = Regex.Replace(sqlText, "^(\\s*--.*?(\\r\\n|\\n)|\\s*)*", "");
|
|
return text.StartsWith("select", StringComparison.OrdinalIgnoreCase);
|
|
}
|
|
|
|
private void SetDynamicControl(TreeNode treeNode)
|
|
{
|
|
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00c9: Expected O, but got Unknown
|
|
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_011b: Expected O, but got Unknown
|
|
//IL_0216: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_021d: Expected O, but got Unknown
|
|
//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_02b0: Expected O, but got Unknown
|
|
pl_Top.Controls.Clear();
|
|
ControlList.Clear();
|
|
try
|
|
{
|
|
if (treeNode == null || string.IsNullOrEmpty(projectEdit.Tag?.ToString() ?? ""))
|
|
{
|
|
return;
|
|
}
|
|
DataTable dataTable = new DataTable();
|
|
string name = treeNode.Name;
|
|
string arg = projectEdit.Tag?.ToString() ?? "";
|
|
string text = $"select * from p_productsyssettab where groupid = '{arg}' and ban = 0 order by orderid";
|
|
dataTable = BaseImpl.GetDataTableResult(text);
|
|
int num = 10;
|
|
int num2 = 10;
|
|
foreach (DataRow row in dataTable.Rows)
|
|
{
|
|
BaseUserControl val = new BaseUserControl();
|
|
SysSetModel sysSetModel = new SysSetModel(row);
|
|
switch (sysSetModel.Item)
|
|
{
|
|
case "1":
|
|
{
|
|
LabelAutoTextEdit val4 = new LabelAutoTextEdit();
|
|
((ControlModel)sysSetModel).FieldType = 5;
|
|
((ControlModel)sysSetModel).ValueMember = "id";
|
|
((ControlModel)sysSetModel).TextMember = "sysnamelist";
|
|
((BaseUserControl)val4).Model = (ControlModel)(object)sysSetModel;
|
|
val4.clickAfterEmpty = false;
|
|
val4.ValueField = "id";
|
|
val4.TextField = "sysnamelist";
|
|
val4.ValueMember = val4.ValueField;
|
|
val4.TextEdit.ControlObj = TopControlObj;
|
|
if (!string.IsNullOrEmpty(sysSetModel.DataSourceSql))
|
|
{
|
|
val4.TextEdit.SourceSQL = sysSetModel.DataSourceSql;
|
|
}
|
|
else
|
|
{
|
|
val4.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 = '{sysSetModel.Id}'";
|
|
}
|
|
((System.Windows.Forms.Control)(object)val4.TextEdit).KeyDown += OnTextEditKeyDown;
|
|
((System.Windows.Forms.Control)(object)val4.TextEdit).TextChanged += OnTextEditTextChanged;
|
|
val = (BaseUserControl)(object)val4;
|
|
break;
|
|
}
|
|
case "3":
|
|
{
|
|
LabelMultiAutoTextEdit val3 = new LabelMultiAutoTextEdit();
|
|
((ControlModel)sysSetModel).FieldType = 14;
|
|
((ControlModel)sysSetModel).ValueMember = "id";
|
|
((ControlModel)sysSetModel).TextMember = "sysnamelist";
|
|
((BaseUserControl)val3).Model = (ControlModel)(object)sysSetModel;
|
|
val3.ValueField = "id";
|
|
val3.TextField = "sysnamelist";
|
|
val3.ValueMember = val3.ValueField;
|
|
val3.TextEdit.KeyDown += OnTextEditKeyDown;
|
|
val3.TextEdit.TextChanged += OnTextEditTextChanged;
|
|
val = (BaseUserControl)(object)val3;
|
|
break;
|
|
}
|
|
default:
|
|
{
|
|
LabelTextEdit val2 = new LabelTextEdit();
|
|
val2.TextEdit.KeyDown += OnTextEditKeyDown;
|
|
val2.TextEdit.TextChanged += OnTextEditTextChanged;
|
|
val = (BaseUserControl)(object)val2;
|
|
break;
|
|
}
|
|
}
|
|
string name2 = ((!string.IsNullOrWhiteSpace(sysSetModel.DbName)) ? ("txt_" + sysSetModel.DbName) : ("txt_" + sysSetModel.SysName));
|
|
((System.Windows.Forms.Control)(object)val).Name = name2;
|
|
val.LabelText = sysSetModel.SysName;
|
|
((System.Windows.Forms.Control)(object)val).Size = new Size(300, 21);
|
|
val.Required = sysSetModel.MustTig == 1;
|
|
((System.Windows.Forms.Control)(object)val).Tag = sysSetModel;
|
|
val.Model = (ControlModel)(object)sysSetModel;
|
|
((System.Windows.Forms.Control)(object)val).TabIndex = dataTable.Rows.IndexOf(row);
|
|
((System.Windows.Forms.Control)(object)val).Location = new Point(num, num2);
|
|
pl_Top.Controls.Add((System.Windows.Forms.Control)(object)val);
|
|
ControlList.Add(sysSetModel);
|
|
if (num + ((System.Windows.Forms.Control)(object)val).Width + 15 + ((System.Windows.Forms.Control)(object)val).Width > splitMainContainer.Panel2.Width)
|
|
{
|
|
num = 10;
|
|
num2 += ((System.Windows.Forms.Control)(object)val).Height + 9;
|
|
}
|
|
else
|
|
{
|
|
num += ((System.Windows.Forms.Control)(object)val).Width + 15;
|
|
}
|
|
}
|
|
Thread thread = new Thread(SetControlDataSource);
|
|
thread.Start();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
}
|
|
|
|
private void SetControlDataSource()
|
|
{
|
|
try
|
|
{
|
|
foreach (SysSetModel control3 in ControlList)
|
|
{
|
|
string key = ((!string.IsNullOrWhiteSpace(control3.DbName)) ? ("txt_" + control3.DbName) : ("txt_" + control3.SysName));
|
|
System.Windows.Forms.Control control = pl_Top.Controls.Find(key, searchAllChildren: false).FirstOrDefault();
|
|
if (control != null && control3.Item.Equals("1"))
|
|
{
|
|
DataTable dataTable = new DataTable();
|
|
dataTable = ((!control3.DataSourceType.Equals("来源SQL")) ? BaseImpl.GetDataTableResult($"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 = '{control3.Id}' order by b.orderid") : BaseImpl.GetDataTableResult(control3.DataSourceSql));
|
|
LabelAutoTextEdit val = (LabelAutoTextEdit)(object)((control is LabelAutoTextEdit) ? control : null);
|
|
val.SetDataSource(dataTable);
|
|
}
|
|
else if (control != null && control3.Item.Equals("3"))
|
|
{
|
|
DataTable dataTable2 = new DataTable();
|
|
dataTable2 = ((!control3.DataSourceType.Equals("来源SQL")) ? BaseImpl.GetDataTableResult($"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 = '{control3.Id}' order by b.orderid") : BaseImpl.GetDataTableResult(control3.DataSourceSql));
|
|
LabelMultiAutoTextEdit val2 = (LabelMultiAutoTextEdit)(object)((control is LabelMultiAutoTextEdit) ? control : null);
|
|
val2.SetDataSource(dataTable2);
|
|
}
|
|
}
|
|
foreach (SysSetModel control4 in ControlList)
|
|
{
|
|
string defaultValue = "";
|
|
if (!string.IsNullOrEmpty(control4.DefaultID))
|
|
{
|
|
defaultValue = control4.DefaultID;
|
|
}
|
|
if (!string.IsNullOrEmpty(control4.DefaultName))
|
|
{
|
|
defaultValue = control4.DefaultName;
|
|
}
|
|
if (!string.IsNullOrEmpty(defaultValue))
|
|
{
|
|
string key2 = ((!string.IsNullOrWhiteSpace(control4.DbName)) ? ("txt_" + control4.DbName) : ("txt_" + control4.SysName));
|
|
System.Windows.Forms.Control control2 = pl_Top.Controls.Find(key2, searchAllChildren: false).FirstOrDefault();
|
|
BaseUserControl baseUserControl = (BaseUserControl)(object)((control2 is BaseUserControl) ? control2 : null);
|
|
((System.Windows.Forms.Control)(object)baseUserControl).Invoke((Delegate)(Action)delegate
|
|
{
|
|
baseUserControl.EditText = defaultValue;
|
|
});
|
|
}
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
}
|
|
|
|
public bool VerifyNull(System.Windows.Forms.Control parentPanel)
|
|
{
|
|
foreach (System.Windows.Forms.Control control in parentPanel.Controls)
|
|
{
|
|
if (control is BaseUserControl)
|
|
{
|
|
BaseUserControl val = (BaseUserControl)(object)((control is BaseUserControl) ? control : null);
|
|
SysSetModel sysSetModel = ((System.Windows.Forms.Control)(object)val).Tag as SysSetModel;
|
|
if (string.IsNullOrWhiteSpace(val.EditText) && sysSetModel != null && sysSetModel.MustTig == 1)
|
|
{
|
|
((System.Windows.Forms.Control)(object)val).Focus();
|
|
MessageUtil.Show($"{val.LabelText}未填写数据");
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
private string GetBaseControlValue(BaseUserControl baseUserControl)
|
|
{
|
|
string text = "";
|
|
try
|
|
{
|
|
SysSetModel sysSetModel = ((System.Windows.Forms.Control)(object)baseUserControl).Tag as SysSetModel;
|
|
switch (sysSetModel.Item)
|
|
{
|
|
case "1":
|
|
{
|
|
LabelAutoTextEdit val3 = (LabelAutoTextEdit)(object)((baseUserControl is LabelAutoTextEdit) ? baseUserControl : null);
|
|
if (sysSetModel.FxType.Equals("名称"))
|
|
{
|
|
text = ((BaseUserControl)val3).EditText;
|
|
}
|
|
else if (sysSetModel.FxType.Equals("编码"))
|
|
{
|
|
text = val3.EditValue;
|
|
}
|
|
break;
|
|
}
|
|
case "3":
|
|
{
|
|
LabelMultiAutoTextEdit val2 = (LabelMultiAutoTextEdit)(object)((baseUserControl is LabelMultiAutoTextEdit) ? baseUserControl : null);
|
|
if (sysSetModel.FxType.Equals("名称"))
|
|
{
|
|
text = ((BaseUserControl)val2).EditText;
|
|
}
|
|
else if (sysSetModel.FxType.Equals("编码"))
|
|
{
|
|
text = val2.EditValue;
|
|
}
|
|
break;
|
|
}
|
|
default:
|
|
{
|
|
LabelTextEdit val = (LabelTextEdit)(object)((baseUserControl is LabelTextEdit) ? baseUserControl : null);
|
|
text = ((BaseUserControl)val).EditText;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
if (text.Equals("无"))
|
|
{
|
|
text = "";
|
|
}
|
|
return text;
|
|
}
|
|
|
|
protected override void OnLoad(EventArgs e)
|
|
{
|
|
InitControl();
|
|
InitEvent();
|
|
}
|
|
|
|
private void OnSplitMainContainerPositionChanged(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (Model != null)
|
|
{
|
|
IniHelper.Write($"PubProductSysMge_SplitMain_{((DynamicModel)Model).ModuleCode}", splitMainContainer.SplitterPosition.ToString() ?? "");
|
|
IniHelper.Write($"PubProductSysMge_SplitRight_{((DynamicModel)Model).ModuleCode}", splitRightContainer.SplitterPosition.ToString() ?? "");
|
|
IniHelper.Write($"PubProductSysMge_SplitControl_{((DynamicModel)Model).ModuleCode}", splitControlContainer.SplitterPosition.ToString() ?? "");
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageUtil.Show(ex.Message);
|
|
}
|
|
}
|
|
|
|
private void OnTreeLeftTreeNodeSelected(object sender, TreeNodeMouseClickEventArgs e)
|
|
{
|
|
WaitForm.ShowForm((string)null);
|
|
string text = ((treeLeftViewEx.TreeView.SelectedNode != null) ? treeLeftViewEx.TreeView.SelectedNode.Name : "");
|
|
speciesNoEdit.Text = "";
|
|
speciesNameEdit.Text = "";
|
|
projectEdit.Text = "";
|
|
projectEdit.Tag = "";
|
|
btnUpdate.Enabled = false;
|
|
btnSave.Enabled = true;
|
|
MainControlObj.ResetControlValue(false, false);
|
|
pl_Top.Controls.Clear();
|
|
ControlList.Clear();
|
|
try
|
|
{
|
|
string text2 = BaseImpl.GetResult($"select BmFaID from P_ProductSpeciesTab where speciesno = '{e.Node.Name}'")?.ToString() ?? "";
|
|
string text3 = BaseImpl.GetResult($"select ItemName from p_productsyssetGrouptab where id = '{text2}'")?.ToString() ?? "";
|
|
speciesNoEdit.Text = e.Node.Name;
|
|
speciesNameEdit.Text = e.Node.Text;
|
|
projectEdit.Text = text3;
|
|
projectEdit.Tag = text2;
|
|
SetDynamicControl(e.Node);
|
|
string text4 = null;
|
|
text4 = ((!string.IsNullOrWhiteSpace(ParentUnionField)) ? $" and {ParentUnionField} = '{e.Node.Name}'" : $" and {treeLeftViewEx.TreeNodeKeyField} = '{e.Node.Name}'");
|
|
if (text == e.Node.Name)
|
|
{
|
|
SetMainGridView(text4, selectHandler: false, initColumns: false);
|
|
}
|
|
else
|
|
{
|
|
SetMainGridView(text4);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageUtil.Show(ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
WaitForm.HideForm();
|
|
}
|
|
}
|
|
|
|
private void OnScrollableControlClick(object sender, EventArgs e)
|
|
{
|
|
ScrollableControl scrollableControl = (ScrollableControl)sender;
|
|
scrollableControl.Focus();
|
|
}
|
|
|
|
private void OnTextEditKeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
}
|
|
|
|
private void OnTextEditTextChanged(object sender, EventArgs e)
|
|
{
|
|
BaseUserControl val = BaseUserControlExtend.ToBaseUserControl(sender as System.Windows.Forms.Control);
|
|
SysSetModel sysSetModel = ((System.Windows.Forms.Control)(object)val).Tag as SysSetModel;
|
|
if (!string.IsNullOrWhiteSpace(sysSetModel.UnionValues) && !string.IsNullOrWhiteSpace(sysSetModel.UnionFields))
|
|
{
|
|
SetUnionControl(sysSetModel);
|
|
}
|
|
if (sysSetModel.OrderId.Equals(1) && NameBaseControl != null)
|
|
{
|
|
NameBaseControl.EditText = val.EditText;
|
|
}
|
|
if (sysSetModel.SpecDbName.Equals(1) && SpecBaseControl != null)
|
|
{
|
|
List<BaseUserControl> list = (from BaseUserControl n in pl_Top.Controls
|
|
where (((System.Windows.Forms.Control)(object)n).Tag as SysSetModel).SpecDbName.Equals(1)
|
|
orderby (((System.Windows.Forms.Control)(object)n).Tag as SysSetModel).OrderId
|
|
select n).ToList();
|
|
StringBuilder stringBuilder = new StringBuilder();
|
|
for (int i = 0; i < list.Count; i++)
|
|
{
|
|
BaseUserControl val2 = list[i];
|
|
if (string.IsNullOrWhiteSpace(val2.EditText))
|
|
{
|
|
continue;
|
|
}
|
|
SysSetModel sysSetModel2 = ((System.Windows.Forms.Control)(object)val2).Tag as SysSetModel;
|
|
string baseControlValue = GetBaseControlValue(val2);
|
|
if (!string.IsNullOrWhiteSpace(baseControlValue))
|
|
{
|
|
if (i == 0)
|
|
{
|
|
stringBuilder.Append($"{baseControlValue}");
|
|
}
|
|
else
|
|
{
|
|
stringBuilder.Append($"{sysSetModel2.ConnectorStr}{baseControlValue}");
|
|
}
|
|
}
|
|
}
|
|
SpecBaseControl.EditText = stringBuilder.ToString();
|
|
}
|
|
if (sysSetModel.ModelDbName.Equals(1) && ModelBaseControl != null)
|
|
{
|
|
List<BaseUserControl> list2 = (from BaseUserControl n in pl_Top.Controls
|
|
where (((System.Windows.Forms.Control)(object)n).Tag as SysSetModel).ModelDbName.Equals(1)
|
|
orderby (((System.Windows.Forms.Control)(object)n).Tag as SysSetModel).OrderId
|
|
select n).ToList();
|
|
StringBuilder stringBuilder2 = new StringBuilder();
|
|
for (int j = 0; j < list2.Count; j++)
|
|
{
|
|
BaseUserControl val3 = list2[j];
|
|
if (string.IsNullOrWhiteSpace(val3.EditText))
|
|
{
|
|
continue;
|
|
}
|
|
SysSetModel sysSetModel3 = ((System.Windows.Forms.Control)(object)val3).Tag as SysSetModel;
|
|
string baseControlValue2 = GetBaseControlValue(val3);
|
|
if (!string.IsNullOrWhiteSpace(baseControlValue2))
|
|
{
|
|
if (j == 0)
|
|
{
|
|
stringBuilder2.Append($"{baseControlValue2}");
|
|
}
|
|
else
|
|
{
|
|
stringBuilder2.Append($"{sysSetModel3.ConnectorStr}{baseControlValue2}");
|
|
}
|
|
}
|
|
}
|
|
ModelBaseControl.EditText = stringBuilder2.ToString();
|
|
}
|
|
if (!sysSetModel.ZhSxdbName.Equals(1) || ZhSxBaseControl == null)
|
|
{
|
|
return;
|
|
}
|
|
List<BaseUserControl> list3 = (from BaseUserControl n in pl_Top.Controls
|
|
where (((System.Windows.Forms.Control)(object)n).Tag as SysSetModel).ZhSxdbName.Equals(1)
|
|
orderby (((System.Windows.Forms.Control)(object)n).Tag as SysSetModel).OrderId
|
|
select n).ToList();
|
|
StringBuilder stringBuilder3 = new StringBuilder();
|
|
for (int k = 0; k < list3.Count; k++)
|
|
{
|
|
BaseUserControl val4 = list3[k];
|
|
if (string.IsNullOrWhiteSpace(val4.EditText))
|
|
{
|
|
continue;
|
|
}
|
|
SysSetModel sysSetModel4 = ((System.Windows.Forms.Control)(object)val4).Tag as SysSetModel;
|
|
string text = val4.EditText;
|
|
if (text.Equals("无"))
|
|
{
|
|
text = "";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(text))
|
|
{
|
|
if (k == 0)
|
|
{
|
|
stringBuilder3.Append($"{text}");
|
|
}
|
|
else
|
|
{
|
|
stringBuilder3.Append(string.Format("{0}{1}", "_", text));
|
|
}
|
|
}
|
|
}
|
|
ZhSxBaseControl.EditText = stringBuilder3.ToString();
|
|
}
|
|
|
|
private void OnBtnSaveClick(object sender, EventArgs e)
|
|
{
|
|
//IL_04c8: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_04cd: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_04cf: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_04d4: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_04dc: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_04e8: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_04ef: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0500: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0511: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0518: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_052b: Expected O, but got Unknown
|
|
//IL_0554: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_055a: Invalid comparison between Unknown and I4
|
|
//IL_05a8: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_05af: Expected O, but got Unknown
|
|
//IL_05b1: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_05b6: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_05b8: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_05ba: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_05bc: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_05bf: Invalid comparison between Unknown and I4
|
|
//IL_05c3: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_05c6: Invalid comparison between Unknown and I4
|
|
WaitForm.ShowForm("正在保存数据");
|
|
try
|
|
{
|
|
if (!VerifyNull(pl_Top))
|
|
{
|
|
return;
|
|
}
|
|
string text = BaseImpl.GetResult(string.Format("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.columns WHERE TABLE_NAME='{0}' AND COLUMNPROPERTY(OBJECT_ID('{0}'),COLUMN_NAME,'IsIdentity')=1", MainModuleObj.MenuTable))?.ToString() ?? "";
|
|
string primaryKey = BaseImpl.GetBasePrimaryKey(((DynamicModel)Model).ModuleCode);
|
|
string controlValue = GetControlValue(primaryKey);
|
|
DataTable tableColumns = BaseImpl.GetTableColumns(MainModuleObj.MenuTable);
|
|
ControlModel val = MainControlObj._models.FirstOrDefault((ControlModel x) => x.FieldName == primaryKey);
|
|
string name = treeLeftViewEx.TreeView.SelectedNode.Name;
|
|
StringBuilder stringBuilder = new StringBuilder();
|
|
StringBuilder stringBuilder2 = new StringBuilder();
|
|
List<string> list = new List<string> { "speciesno", "operatorname", "operatedate", "smartbmfa" };
|
|
List<BaseUserControl> list2 = (from BaseUserControl n in pl_Top.Controls
|
|
where !string.IsNullOrEmpty((((System.Windows.Forms.Control)(object)n).Tag as SysSetModel).DbName)
|
|
orderby (((System.Windows.Forms.Control)(object)n).Tag as SysSetModel).OrderId
|
|
select n).ToList();
|
|
foreach (BaseUserControl item in list2)
|
|
{
|
|
SysSetModel sysSetModel = ((System.Windows.Forms.Control)(object)item).Tag as SysSetModel;
|
|
string text2 = "";
|
|
try
|
|
{
|
|
string controlName = ((!string.IsNullOrWhiteSpace(sysSetModel.DbName)) ? sysSetModel.DbName : sysSetModel.SysName);
|
|
text2 = GetControlValue(controlName);
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
if (!list.Contains(sysSetModel.DbName.ToLower()))
|
|
{
|
|
list.Add(sysSetModel.DbName.ToLower());
|
|
stringBuilder.Append($"{sysSetModel.DbName},");
|
|
stringBuilder2.Append(string.Format("'{0}',", text2.Replace("'", "''")));
|
|
}
|
|
}
|
|
foreach (ControlModel controlModel in MainControlObj.ControlModels)
|
|
{
|
|
if (!controlModel.IsSave || _leftField.Equals(controlModel.FieldName) || "ID".Equals(controlModel.FieldName, StringComparison.CurrentCultureIgnoreCase) || controlModel.FieldType == 99 || controlModel.FieldType == 100 || !tableColumns.Columns.Contains(controlModel.FieldName) || text.ToLower() == controlModel.FieldName.ToLower())
|
|
{
|
|
continue;
|
|
}
|
|
string text3 = MainControlObj.GetControlValue(controlModel);
|
|
if (text3 == "****")
|
|
{
|
|
continue;
|
|
}
|
|
if (controlModel.FieldType == 7)
|
|
{
|
|
if (text3.Contains('%'))
|
|
{
|
|
text3 = (double.Parse(text3.Replace("%", "")) * 0.01).ToString();
|
|
}
|
|
if (text3.Contains(','))
|
|
{
|
|
text3 = text3.Replace(",", "");
|
|
}
|
|
}
|
|
if (!list.Contains(controlModel.FieldName.ToLower()))
|
|
{
|
|
list.Add(controlModel.FieldName.ToLower());
|
|
stringBuilder.Append(controlModel.FieldName + ",");
|
|
if (string.IsNullOrEmpty(text3) && controlModel.Isintordecimal)
|
|
{
|
|
text3 = "0";
|
|
}
|
|
stringBuilder2.Append(string.IsNullOrEmpty(text3) ? MainControlObj.GetNullValue(controlModel) : $"'{text3}',");
|
|
}
|
|
}
|
|
string baseSql = string.Format("insert into {0} ({1},speciesno,OperatorName,Operatedate,SmartBmFa) values ({2},'{3}','{4}','{5}','{6}')\r\n", MainModuleObj.MenuTable, stringBuilder.ToString().TrimEnd(','), stringBuilder2.ToString().TrimEnd(','), name, ERPInfo.Instance.UserName, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), projectEdit.Tag);
|
|
BaseSaveModel val2 = new BaseSaveModel
|
|
{
|
|
BaseSaveType = (SaveType)1,
|
|
BaseSql = baseSql,
|
|
KeyField = primaryKey,
|
|
FieldValue = controlValue,
|
|
MenuCode = MainModuleObj.ModeCode,
|
|
TableName = MainModuleObj.MenuTable,
|
|
ComfirmFlag = 0,
|
|
NewVer = MainModuleObj.NewVer
|
|
};
|
|
int num = BaseModuleImpl.SaveBasePanelData(val2, "0");
|
|
if (num == 1)
|
|
{
|
|
if (val2.NewVer == 1 && (int)val2.BaseSaveType == 1)
|
|
{
|
|
controlValue = (val2.FieldValue = val2.FaultMsg);
|
|
}
|
|
if (ApiHelper.IsExecEventApi((Interface.Api.OperateEvent)4, val2.MenuCode, 0))
|
|
{
|
|
ApiHelper val3 = new ApiHelper(val2.MenuCode, val2.FieldValue, val2.KeyField, val2.TableName, 0, (DataRow)null);
|
|
SaveType baseSaveType = val2.BaseSaveType;
|
|
SaveType val4 = baseSaveType;
|
|
if ((int)val4 != 1)
|
|
{
|
|
if ((int)val4 == 2)
|
|
{
|
|
val3.OnEvent((Interface.Api.OperateEvent)4, (Interface.Api.ActionType)2, true);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
val3.OnEvent((Interface.Api.OperateEvent)4, (Interface.Api.ActionType)1, true);
|
|
}
|
|
if (!string.IsNullOrEmpty(val3.apiResutMsg))
|
|
{
|
|
MessageUtil.Show(val3.apiResutMsg);
|
|
}
|
|
}
|
|
MessageUtil.Show(ResourceKeys.SaveSuccess);
|
|
MainControlObj.ResetControlValue(false, false);
|
|
SetDynamicControl(treeLeftViewEx.TreeView.SelectedNode);
|
|
string text4 = null;
|
|
string name2 = treeLeftViewEx.TreeView.SelectedNode.Name;
|
|
text4 = ((!string.IsNullOrWhiteSpace(ParentUnionField)) ? $" and {ParentUnionField} = '{name2}'" : $" and {treeLeftViewEx.TreeNodeKeyField} = '{name2}'");
|
|
SetMainGridView(text4, selectHandler: false, initColumns: false);
|
|
}
|
|
else
|
|
{
|
|
MessageUtil.Show(ResourceKeys.SaveFault + "\r\n" + val2.FaultMsg);
|
|
}
|
|
}
|
|
catch (Exception ex2)
|
|
{
|
|
MessageUtil.Show(ex2.Message);
|
|
}
|
|
finally
|
|
{
|
|
WaitForm.HideForm();
|
|
}
|
|
}
|
|
|
|
private void OnBtnUpdateClick(object sender, EventArgs e)
|
|
{
|
|
//IL_053a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_053f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0541: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0546: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_054e: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_055a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0562: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0573: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0584: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_058b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_059e: Expected O, but got Unknown
|
|
//IL_05ee: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_05f5: Expected O, but got Unknown
|
|
//IL_05f7: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_05fc: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_05fe: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0600: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0602: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0605: Invalid comparison between Unknown and I4
|
|
//IL_0609: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_060c: Invalid comparison between Unknown and I4
|
|
WaitForm.ShowForm("正在修改数据");
|
|
try
|
|
{
|
|
if (!VerifyNull(pl_Top))
|
|
{
|
|
return;
|
|
}
|
|
DataRow focusedDataRow = gcMain.GridView.GetFocusedDataRow();
|
|
string text = BaseImpl.GetResult(string.Format("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.columns WHERE TABLE_NAME='{0}' AND COLUMNPROPERTY(OBJECT_ID('{0}'),COLUMN_NAME,'IsIdentity')=1", MainModuleObj.MenuTable))?.ToString() ?? "";
|
|
DataTable tableColumns = BaseImpl.GetTableColumns(MainModuleObj.MenuTable);
|
|
string text2 = focusedDataRow["productid"]?.ToString() ?? "";
|
|
string primaryKey = BaseImpl.GetBasePrimaryKey(((DynamicModel)Model).ModuleCode);
|
|
ControlModel val = MainControlObj._models.FirstOrDefault((ControlModel x) => x.FieldName == primaryKey);
|
|
string name = treeLeftViewEx.TreeView.SelectedNode.Name;
|
|
List<string> list = new List<string> { "speciesno", "operatorname", "operatedate", "smartbmfa" };
|
|
StringBuilder stringBuilder = new StringBuilder();
|
|
List<BaseUserControl> list2 = (from BaseUserControl n in pl_Top.Controls
|
|
where !string.IsNullOrEmpty((((System.Windows.Forms.Control)(object)n).Tag as SysSetModel).DbName)
|
|
orderby (((System.Windows.Forms.Control)(object)n).Tag as SysSetModel).OrderId
|
|
select n).ToList();
|
|
foreach (BaseUserControl item in list2)
|
|
{
|
|
SysSetModel sysSetModel = ((System.Windows.Forms.Control)(object)item).Tag as SysSetModel;
|
|
string text3 = "";
|
|
try
|
|
{
|
|
string controlName = ((!string.IsNullOrWhiteSpace(sysSetModel.DbName)) ? sysSetModel.DbName : sysSetModel.SysName);
|
|
text3 = GetControlValue(controlName);
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
if (!sysSetModel.DbName.Equals(primaryKey, StringComparison.OrdinalIgnoreCase) && !sysSetModel.DbName.Equals("productid", StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
list.Add(sysSetModel.DbName.ToLower());
|
|
stringBuilder.Append(string.Format("{0} = '{1}',", sysSetModel.DbName, text3.Replace("'", "''")));
|
|
}
|
|
}
|
|
foreach (ControlModel controlModel in MainControlObj.ControlModels)
|
|
{
|
|
if (!controlModel.IsSave || _leftField.Equals(controlModel.FieldName) || "ID".Equals(controlModel.FieldName, StringComparison.CurrentCultureIgnoreCase) || controlModel.FieldName.Equals(primaryKey, StringComparison.CurrentCultureIgnoreCase) || controlModel.FieldName.Equals("productid", StringComparison.CurrentCultureIgnoreCase) || controlModel.FieldType == 99 || controlModel.FieldType == 100 || !tableColumns.Columns.Contains(controlModel.FieldName) || text.ToLower() == controlModel.FieldName.ToLower())
|
|
{
|
|
continue;
|
|
}
|
|
BaseUserControl val2 = MainControlObj.FindControl(controlModel);
|
|
if (val2 == null)
|
|
{
|
|
continue;
|
|
}
|
|
string text4 = MainControlObj.GetControlValue(controlModel);
|
|
if (text4 == "****")
|
|
{
|
|
continue;
|
|
}
|
|
if (controlModel.FieldType == 7)
|
|
{
|
|
if (text4.Contains('%'))
|
|
{
|
|
text4 = (double.Parse(text4.Replace("%", "")) * 0.01).ToString();
|
|
}
|
|
if (text4.Contains(','))
|
|
{
|
|
text4 = text4.Replace(",", "");
|
|
}
|
|
}
|
|
if (string.IsNullOrEmpty(text4) && controlModel.Isintordecimal)
|
|
{
|
|
text4 = "0";
|
|
}
|
|
if (!list.Contains(controlModel.FieldName.ToLower()))
|
|
{
|
|
stringBuilder.Append(string.IsNullOrEmpty(text4) ? $"{controlModel.FieldName} = {MainControlObj.GetNullValue(controlModel)}" : $"{controlModel.FieldName}='{text4}',");
|
|
}
|
|
}
|
|
string baseSql = "";
|
|
if (!string.IsNullOrWhiteSpace(stringBuilder.ToString()))
|
|
{
|
|
baseSql = string.Format("update {0} set {1},speciesno = '{2}', operatorname = '{3}', operatedate = '{4}', smartbmfa = '{5}' where {6} = '{7}'", MainModuleObj.MenuTable, stringBuilder.ToString().TrimEnd(','), name, ERPInfo.Instance.UserName, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), projectEdit.Tag, primaryKey, text2);
|
|
}
|
|
BaseSaveModel val3 = new BaseSaveModel
|
|
{
|
|
BaseSaveType = (SaveType)2,
|
|
BaseSql = baseSql,
|
|
KeyField = primaryKey,
|
|
FieldValue = text2,
|
|
MenuCode = MainModuleObj.ModeCode,
|
|
TableName = MainModuleObj.MenuTable,
|
|
ComfirmFlag = 0,
|
|
NewVer = MainModuleObj.NewVer
|
|
};
|
|
int num = BaseModuleImpl.SaveBasePanelData(val3, "0");
|
|
if (num == 1)
|
|
{
|
|
if (ApiHelper.IsExecEventApi((Interface.Api.OperateEvent)4, val3.MenuCode, 0))
|
|
{
|
|
ApiHelper val4 = new ApiHelper(val3.MenuCode, val3.FieldValue, val3.KeyField, val3.TableName, 0, (DataRow)null);
|
|
SaveType baseSaveType = val3.BaseSaveType;
|
|
SaveType val5 = baseSaveType;
|
|
if ((int)val5 != 1)
|
|
{
|
|
if ((int)val5 == 2)
|
|
{
|
|
val4.OnEvent((Interface.Api.OperateEvent)4, (Interface.Api.ActionType)2, true);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
val4.OnEvent((Interface.Api.OperateEvent)4, (Interface.Api.ActionType)1, true);
|
|
}
|
|
if (!string.IsNullOrEmpty(val4.apiResutMsg))
|
|
{
|
|
MessageUtil.Show(val4.apiResutMsg);
|
|
}
|
|
}
|
|
MessageUtil.Show(ResourceKeys.SaveSuccess);
|
|
string text5 = null;
|
|
string name2 = treeLeftViewEx.TreeView.SelectedNode.Name;
|
|
text5 = ((!string.IsNullOrWhiteSpace(ParentUnionField)) ? $" and {ParentUnionField} = '{name2}'" : $" and {treeLeftViewEx.TreeNodeKeyField} = '{name2}'");
|
|
SetMainGridView(text5, selectHandler: true, initColumns: false);
|
|
}
|
|
else
|
|
{
|
|
MessageUtil.Show(ResourceKeys.SaveFault + "\r\n" + val3.FaultMsg);
|
|
}
|
|
}
|
|
catch (Exception ex2)
|
|
{
|
|
MessageUtil.Show(ex2.Message);
|
|
}
|
|
finally
|
|
{
|
|
WaitForm.HideForm();
|
|
}
|
|
}
|
|
|
|
private void OnBtnCondSearchClick(object sender, EventArgs e)
|
|
{
|
|
WaitForm.ShowForm((string)null);
|
|
try
|
|
{
|
|
SetMainGridView("", selectHandler: false, initColumns: false);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageUtil.Show(ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
WaitForm.HideForm();
|
|
}
|
|
}
|
|
|
|
private void OnGridViewDoubleClick(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
DataRow focusedDataRow = gcMain.GridView.GetFocusedDataRow();
|
|
string arg = focusedDataRow["productid"]?.ToString() ?? "";
|
|
DataRow dataRowResult = BaseImpl.GetDataRowResult($"select * from p_producttab where productid = '{arg}'");
|
|
List<BaseUserControl> list = (from BaseUserControl n in pl_Top.Controls
|
|
where !string.IsNullOrEmpty((((System.Windows.Forms.Control)(object)n).Tag as SysSetModel).DbName)
|
|
orderby (((System.Windows.Forms.Control)(object)n).Tag as SysSetModel).OrderId
|
|
select n).ToList();
|
|
foreach (BaseUserControl item in list)
|
|
{
|
|
SysSetModel sysSetModel = ((System.Windows.Forms.Control)(object)item).Tag as SysSetModel;
|
|
string text = ((!dataRowResult.Table.Columns.Contains(sysSetModel.DbName)) ? "" : (dataRowResult[sysSetModel.DbName]?.ToString() ?? ""));
|
|
if (double.TryParse(text, out var result))
|
|
{
|
|
item.EditText = result.ToString() ?? "";
|
|
}
|
|
else
|
|
{
|
|
item.EditText = text;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageUtil.Show(ex.Message);
|
|
}
|
|
btnUpdate.Enabled = true;
|
|
btnSave.Enabled = false;
|
|
}
|
|
|
|
private void SetUnionControl(SysSetModel model)
|
|
{
|
|
string unionFields = model.UnionFields;
|
|
string text = ReplaceControlValue(model.UnionValues);
|
|
try
|
|
{
|
|
DataTable dataTableResult = BaseImpl.GetDataTableResult(text);
|
|
string[] array = unionFields.Trim(',').Split(',');
|
|
foreach (string text2 in array)
|
|
{
|
|
if (dataTableResult.Rows.Count > 0 && dataTableResult.Columns.Contains(text2))
|
|
{
|
|
SetControlValue(text2, dataTableResult.Rows[0][text2]?.ToString() ?? "");
|
|
}
|
|
else
|
|
{
|
|
SetControlValue(text2, "");
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Instance.WriteError(ex, (LogType)0);
|
|
string text3 = ErrorMessage.PromptErrorMessage(ex, "", "");
|
|
MessageUtil.Show(text3, ex.Message);
|
|
}
|
|
}
|
|
|
|
public void SetControlValue(string controlName, object controlValue)
|
|
{
|
|
BaseUserControl val = FindControl(controlName);
|
|
if (val != null)
|
|
{
|
|
val.EditText = controlValue?.ToString() ?? "";
|
|
}
|
|
}
|
|
|
|
public string ReplaceControlValue(string defaultValue)
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(defaultValue))
|
|
{
|
|
string name = treeLeftViewEx.TreeView.SelectedNode.Name;
|
|
defaultValue = ReplaceHelper.ReplaceUserInfo(defaultValue);
|
|
defaultValue = ReplaceHelper.ReplaceTreeViewParentKeyCond(defaultValue, name);
|
|
List<string> paramFields = ReplaceHelper.GetParamFields(defaultValue);
|
|
foreach (string item in paramFields)
|
|
{
|
|
string controlName = item.Replace("{", "").Replace("}", "");
|
|
if (FindControl(controlName) != null)
|
|
{
|
|
string controlValue = GetControlValue(controlName);
|
|
defaultValue = defaultValue.Replace(item, controlValue);
|
|
}
|
|
}
|
|
}
|
|
return defaultValue;
|
|
}
|
|
|
|
public BaseUserControl FindControl(string controlName)
|
|
{
|
|
System.Windows.Forms.Control control = new System.Windows.Forms.Control();
|
|
control = pl_Top.Controls.Cast<System.Windows.Forms.Control>().FirstOrDefault((System.Windows.Forms.Control x) => x.Name.Equals("txt_" + controlName, StringComparison.OrdinalIgnoreCase));
|
|
if (control != null && control is BaseUserControl)
|
|
{
|
|
return (BaseUserControl)(object)((control is BaseUserControl) ? control : null);
|
|
}
|
|
if (control != null && control is BaseUserControl)
|
|
{
|
|
return (BaseUserControl)(object)((control is BaseUserControl) ? control : null);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public string GetControlValue(string controlName)
|
|
{
|
|
string result = string.Empty;
|
|
System.Windows.Forms.Control[] array = pl_Top.Controls.Find("txt_" + controlName, searchAllChildren: true);
|
|
if (array != null && array.Length != 0)
|
|
{
|
|
System.Windows.Forms.Control control = array[0];
|
|
BaseUserControl val = (BaseUserControl)(object)((control is BaseUserControl) ? control : null);
|
|
SysSetModel sysSetModel = ((System.Windows.Forms.Control)(object)val).Tag as SysSetModel;
|
|
switch (sysSetModel.Item)
|
|
{
|
|
case "1":
|
|
{
|
|
LabelAutoTextEdit val4 = (LabelAutoTextEdit)(object)((control is LabelAutoTextEdit) ? control : null);
|
|
if (sysSetModel.FxTypeDB.Equals("编码"))
|
|
{
|
|
result = val4.EditValue;
|
|
}
|
|
else if (sysSetModel.FxTypeDB.Equals("名称"))
|
|
{
|
|
result = ((BaseUserControl)val4).EditText;
|
|
}
|
|
break;
|
|
}
|
|
case "3":
|
|
{
|
|
LabelMultiAutoTextEdit val3 = (LabelMultiAutoTextEdit)(object)((control is LabelMultiAutoTextEdit) ? control : null);
|
|
if (sysSetModel.FxType.Equals("名称"))
|
|
{
|
|
result = ((BaseUserControl)val3).EditText;
|
|
}
|
|
else if (sysSetModel.FxType.Equals("编码"))
|
|
{
|
|
result = val3.EditValue;
|
|
}
|
|
break;
|
|
}
|
|
default:
|
|
{
|
|
LabelTextEdit val2 = (LabelTextEdit)(object)((control is LabelTextEdit) ? control : null);
|
|
result = ((BaseUserControl)val2).EditText;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|