diff --git a/插件库/Lskj.PubBomAlter/DllBaseClass.cs b/插件库/Lskj.PubBomAlter/DllBaseClass.cs new file mode 100644 index 0000000..e9d153a --- /dev/null +++ b/插件库/Lskj.PubBomAlter/DllBaseClass.cs @@ -0,0 +1,117 @@ +using Lskj.Business; +using Lskj.Business.Impl; +using Lskj.Core; +using Lskj.Model; +using Lskj.Util; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Windows.Forms; + +namespace Lskj.PubBomAlter +{ + /// + /// c#库被调用统一接口类 + /// + public sealed class DllBaseClass : IForm + { + public DllBaseClass() + { + } + public DllBaseClass(string[] obj) + { + try + { + DynamicBomAlterModel bomAlterModel = new DynamicBomAlterModel(obj); + FrmMain main = new FrmMain(); + main.ModelObj = obj; + main.BomAlterModel = bomAlterModel; + this.SubForm = main; + } + catch (Exception ex) + { + LogUtil.WriteError("Lskj.PubBomAlter.dll--参数错误-->" + obj.ToString(), ex); + } + } + /// + /// 窗口 + /// + public Form SubForm { get; set; } + } + /// + /// 入口模型 + /// + public class DynamicBomAlterModel : DynamicModel + { + /// + /// 保存的语句 + /// + public string SaveSql; + /// + /// 验证的语句 + /// + public string VerifySql; + /// + /// 反写确认按钮 + /// + public string AllowFxBtn; + public override string[] OtherParams() + { + return this.Params; + } + /// + /// 初始化默认参数(1.标题、2、用户ID、3.用户名、4.权限、5.模块编号、6.菜单ID) + /// + /// The arguments. + public DynamicBomAlterModel(string[] args) + : base(args) + { + // 右键菜单打开的模块没有moduleId,部分特殊模块没有moduleId比如添加界面. + if (!string.IsNullOrEmpty(args[5])) + { + base.ModuleId = Convert.ToInt32(args[5]); + } + if (args.Length > 6 && !string.IsNullOrWhiteSpace(args[6])) + { + base.ModuleCode = args[6]; + } + if (args.Length > 7 && !string.IsNullOrWhiteSpace(args[7])) + { + SaveSql = args[7]; + } + if (args.Length > 8 && !string.IsNullOrWhiteSpace(args[8])) + { + AllowFxBtn = args[8] + ""; + } + if (args.Length > 9 && !string.IsNullOrWhiteSpace(args[9])) + { + VerifySql = args[9]; + } + if (args.Length > 10) + { + this.Params = new string[args.Length]; + for (int i = 10; i < args.Length; i++) + { + Params[i - 10] = args[i]; + } + } + if (!string.IsNullOrEmpty(args[args.Length - 1])) + { + try + { + JObject rowObject = JsonConvert.DeserializeObject(args[args.Length - 1]); + JArray jArray = new JArray(); + jArray.Add(rowObject); + DataTable dataTable = JsonConvert.DeserializeObject(JsonConvert.SerializeObject(jArray)); + this.MaintabFocusedRow = dataTable.Rows[0]; + } + catch (Exception) + { + } + } + } + } +} diff --git a/插件库/Lskj.PubBomAlter/FrmMain.Designer.cs b/插件库/Lskj.PubBomAlter/FrmMain.Designer.cs new file mode 100644 index 0000000..40fbcd4 --- /dev/null +++ b/插件库/Lskj.PubBomAlter/FrmMain.Designer.cs @@ -0,0 +1,418 @@ + +namespace Lskj.PubBomAlter +{ + partial class FrmMain + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows 窗体设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要修改 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent() + { + this.scrollableControl = new DevExpress.XtraEditors.XtraScrollableControl(); + this.splitRightContainer = new DevExpress.XtraEditors.SplitContainerControl(); + this.splitControlContainer = new DevExpress.XtraEditors.SplitContainerControl(); + this.topPanel = new DevExpress.XtraEditors.PanelControl(); + this.treeGridControlEx = new Lskj.Control.TreeGridControlEx(); + this.pl_buttom = new DevExpress.XtraEditors.PanelControl(); + this.btnApply = new DevExpress.XtraEditors.SimpleButton(); + this.btnSave = new DevExpress.XtraEditors.SimpleButton(); + this.pl_top = new DevExpress.XtraEditors.PanelControl(); + this.pl_top_search = new DevExpress.XtraEditors.PanelControl(); + this.pl_top_fix_search = new DevExpress.XtraEditors.PanelControl(); + this.cbField = new System.Windows.Forms.ComboBox(); + this.btnFixSearch = new DevExpress.XtraEditors.SimpleButton(); + this.txtFixKey = new System.Windows.Forms.TextBox(); + this.label1 = new System.Windows.Forms.Label(); + this.pl_Bottom = new DevExpress.XtraEditors.PanelControl(); + this.gcMainControlEx = new Lskj.Control.GridControlEx(); + this.panelControl1 = new DevExpress.XtraEditors.PanelControl(); + this.btnPmsSave = new DevExpress.XtraEditors.SimpleButton(); + this.rightDetailPanel = new System.Windows.Forms.Panel(); + this.gcDetailControlEx = new Lskj.Control.GridControlEx(); + this.pl_buttomflow = new System.Windows.Forms.FlowLayoutPanel(); + this.btnFxSave = new DevExpress.XtraEditors.SimpleButton(); + ((System.ComponentModel.ISupportInitialize)(this.splitRightContainer)).BeginInit(); + this.splitRightContainer.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.splitControlContainer)).BeginInit(); + this.splitControlContainer.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.topPanel)).BeginInit(); + this.topPanel.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pl_buttom)).BeginInit(); + this.pl_buttom.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pl_top)).BeginInit(); + this.pl_top.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pl_top_search)).BeginInit(); + this.pl_top_search.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pl_top_fix_search)).BeginInit(); + this.pl_top_fix_search.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pl_Bottom)).BeginInit(); + this.pl_Bottom.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.panelControl1)).BeginInit(); + this.panelControl1.SuspendLayout(); + this.rightDetailPanel.SuspendLayout(); + this.pl_buttomflow.SuspendLayout(); + this.SuspendLayout(); + // + // scrollableControl + // + this.scrollableControl.Appearance.BackColor = System.Drawing.Color.White; + this.scrollableControl.Appearance.Options.UseBackColor = true; + this.scrollableControl.Dock = System.Windows.Forms.DockStyle.Top; + this.scrollableControl.Location = new System.Drawing.Point(0, 0); + this.scrollableControl.Name = "scrollableControl"; + this.scrollableControl.Size = new System.Drawing.Size(1134, 78); + this.scrollableControl.TabIndex = 14; + // + // splitRightContainer + // + this.splitRightContainer.Appearance.BackColor = System.Drawing.Color.Transparent; + this.splitRightContainer.Appearance.Options.UseBackColor = true; + this.splitRightContainer.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.Default; + this.splitRightContainer.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitRightContainer.Location = new System.Drawing.Point(0, 78); + this.splitRightContainer.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.splitRightContainer.Name = "splitRightContainer"; + this.splitRightContainer.Panel1.Controls.Add(this.splitControlContainer); + this.splitRightContainer.Panel1.Text = "Panel1"; + this.splitRightContainer.Panel2.Controls.Add(this.rightDetailPanel); + this.splitRightContainer.Panel2.Text = "Panel2"; + this.splitRightContainer.Size = new System.Drawing.Size(1134, 566); + this.splitRightContainer.SplitterPosition = 718; + this.splitRightContainer.TabIndex = 26; + this.splitRightContainer.Text = "splitContainerControl1"; + // + // splitControlContainer + // + this.splitControlContainer.Appearance.BackColor = System.Drawing.Color.Transparent; + this.splitControlContainer.Appearance.Options.UseBackColor = true; + this.splitControlContainer.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.Default; + this.splitControlContainer.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitControlContainer.Location = new System.Drawing.Point(0, 0); + this.splitControlContainer.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.splitControlContainer.Name = "splitControlContainer"; + this.splitControlContainer.Panel1.Controls.Add(this.topPanel); + this.splitControlContainer.Panel1.Text = "Panel1"; + this.splitControlContainer.Panel2.Controls.Add(this.pl_Bottom); + this.splitControlContainer.Panel2.Text = "Panel2"; + this.splitControlContainer.Size = new System.Drawing.Size(718, 566); + this.splitControlContainer.SplitterPosition = 380; + this.splitControlContainer.TabIndex = 3; + this.splitControlContainer.Text = "splitContainerControl1"; + // + // topPanel + // + this.topPanel.Appearance.BackColor = System.Drawing.Color.Transparent; + this.topPanel.Appearance.Options.UseBackColor = true; + this.topPanel.Controls.Add(this.treeGridControlEx); + this.topPanel.Controls.Add(this.pl_buttom); + this.topPanel.Controls.Add(this.pl_top); + this.topPanel.Dock = System.Windows.Forms.DockStyle.Fill; + this.topPanel.Location = new System.Drawing.Point(0, 0); + this.topPanel.Margin = new System.Windows.Forms.Padding(4); + this.topPanel.Name = "topPanel"; + this.topPanel.Size = new System.Drawing.Size(380, 566); + this.topPanel.TabIndex = 21; + // + // treeGridControlEx + // + this.treeGridControlEx.AdapterObj = null; + this.treeGridControlEx.Dock = System.Windows.Forms.DockStyle.Fill; + this.treeGridControlEx.Location = new System.Drawing.Point(2, 29); + this.treeGridControlEx.Margin = new System.Windows.Forms.Padding(4); + this.treeGridControlEx.Name = "treeGridControlEx"; + this.treeGridControlEx.SiftEnumObj = Lskj.Control.GridControlEx.HeaderSiftEnum.Sum; + this.treeGridControlEx.Size = new System.Drawing.Size(376, 500); + this.treeGridControlEx.SysModel = null; + this.treeGridControlEx.TabIndex = 29; + // + // pl_buttom + // + this.pl_buttom.Appearance.BackColor = System.Drawing.Color.Transparent; + this.pl_buttom.Appearance.Options.UseBackColor = true; + this.pl_buttom.Controls.Add(this.pl_buttomflow); + this.pl_buttom.Dock = System.Windows.Forms.DockStyle.Bottom; + this.pl_buttom.Location = new System.Drawing.Point(2, 529); + this.pl_buttom.Margin = new System.Windows.Forms.Padding(2); + this.pl_buttom.Name = "pl_buttom"; + this.pl_buttom.Size = new System.Drawing.Size(376, 35); + this.pl_buttom.TabIndex = 28; + // + // btnApply + // + this.btnApply.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btnApply.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnApply.Appearance.Options.UseFont = true; + this.btnApply.Location = new System.Drawing.Point(211, 3); + this.btnApply.Name = "btnApply"; + this.btnApply.Size = new System.Drawing.Size(80, 26); + this.btnApply.TabIndex = 41; + this.btnApply.Text = "提交审批(&A)"; + // + // btnSave + // + this.btnSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btnSave.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnSave.Appearance.Options.UseFont = true; + this.btnSave.Location = new System.Drawing.Point(297, 3); + this.btnSave.Name = "btnSave"; + this.btnSave.Size = new System.Drawing.Size(72, 26); + this.btnSave.TabIndex = 40; + this.btnSave.Text = "保存(&S)"; + // + // pl_top + // + this.pl_top.Appearance.BackColor = System.Drawing.Color.Transparent; + this.pl_top.Appearance.Options.UseBackColor = true; + this.pl_top.Controls.Add(this.pl_top_search); + this.pl_top.Dock = System.Windows.Forms.DockStyle.Top; + this.pl_top.Location = new System.Drawing.Point(2, 2); + this.pl_top.Margin = new System.Windows.Forms.Padding(2); + this.pl_top.Name = "pl_top"; + this.pl_top.Size = new System.Drawing.Size(376, 27); + this.pl_top.TabIndex = 26; + // + // pl_top_search + // + this.pl_top_search.Appearance.BackColor = System.Drawing.Color.Transparent; + this.pl_top_search.Appearance.Options.UseBackColor = true; + this.pl_top_search.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder; + this.pl_top_search.Controls.Add(this.pl_top_fix_search); + this.pl_top_search.Dock = System.Windows.Forms.DockStyle.Fill; + this.pl_top_search.Location = new System.Drawing.Point(2, 2); + this.pl_top_search.Margin = new System.Windows.Forms.Padding(2); + this.pl_top_search.Name = "pl_top_search"; + this.pl_top_search.Size = new System.Drawing.Size(372, 23); + this.pl_top_search.TabIndex = 8; + // + // pl_top_fix_search + // + this.pl_top_fix_search.Appearance.BackColor = System.Drawing.Color.Transparent; + this.pl_top_fix_search.Appearance.Options.UseBackColor = true; + this.pl_top_fix_search.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder; + this.pl_top_fix_search.Controls.Add(this.cbField); + this.pl_top_fix_search.Controls.Add(this.btnFixSearch); + this.pl_top_fix_search.Controls.Add(this.txtFixKey); + this.pl_top_fix_search.Controls.Add(this.label1); + this.pl_top_fix_search.Dock = System.Windows.Forms.DockStyle.Fill; + this.pl_top_fix_search.Location = new System.Drawing.Point(0, 0); + this.pl_top_fix_search.Margin = new System.Windows.Forms.Padding(2); + this.pl_top_fix_search.Name = "pl_top_fix_search"; + this.pl_top_fix_search.Size = new System.Drawing.Size(372, 23); + this.pl_top_fix_search.TabIndex = 9; + // + // cbField + // + this.cbField.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.cbField.FormattingEnabled = true; + this.cbField.Location = new System.Drawing.Point(28, 5); + this.cbField.Margin = new System.Windows.Forms.Padding(2); + this.cbField.Name = "cbField"; + this.cbField.Size = new System.Drawing.Size(81, 22); + this.cbField.TabIndex = 1; + this.cbField.Tag = ""; + // + // btnFixSearch + // + this.btnFixSearch.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnFixSearch.Appearance.Options.UseFont = true; + this.btnFixSearch.Location = new System.Drawing.Point(230, 3); + this.btnFixSearch.Margin = new System.Windows.Forms.Padding(2); + this.btnFixSearch.Name = "btnFixSearch"; + this.btnFixSearch.Size = new System.Drawing.Size(47, 19); + this.btnFixSearch.TabIndex = 33; + this.btnFixSearch.Text = "查询(&Q)"; + // + // txtFixKey + // + this.txtFixKey.Location = new System.Drawing.Point(112, 5); + this.txtFixKey.Margin = new System.Windows.Forms.Padding(2); + this.txtFixKey.Name = "txtFixKey"; + this.txtFixKey.Size = new System.Drawing.Size(116, 22); + this.txtFixKey.TabIndex = 32; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(5, 8); + this.label1.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(31, 14); + this.label1.TabIndex = 0; + this.label1.Text = "查询"; + // + // pl_Bottom + // + this.pl_Bottom.Controls.Add(this.gcMainControlEx); + this.pl_Bottom.Controls.Add(this.panelControl1); + this.pl_Bottom.Dock = System.Windows.Forms.DockStyle.Fill; + this.pl_Bottom.Location = new System.Drawing.Point(0, 0); + this.pl_Bottom.Name = "pl_Bottom"; + this.pl_Bottom.Size = new System.Drawing.Size(333, 566); + this.pl_Bottom.TabIndex = 48; + // + // gcMainControlEx + // + this.gcMainControlEx.AdapterObj = null; + this.gcMainControlEx.Dock = System.Windows.Forms.DockStyle.Fill; + this.gcMainControlEx.Location = new System.Drawing.Point(2, 2); + this.gcMainControlEx.Margin = new System.Windows.Forms.Padding(5); + this.gcMainControlEx.Name = "gcMainControlEx"; + this.gcMainControlEx.SiftEnumObj = Lskj.Control.GridControlEx.HeaderSiftEnum.Sum; + this.gcMainControlEx.Size = new System.Drawing.Size(329, 527); + this.gcMainControlEx.SysModel = null; + this.gcMainControlEx.TabIndex = 51; + // + // panelControl1 + // + this.panelControl1.Appearance.BackColor = System.Drawing.Color.Transparent; + this.panelControl1.Appearance.Options.UseBackColor = true; + this.panelControl1.Controls.Add(this.btnPmsSave); + this.panelControl1.Dock = System.Windows.Forms.DockStyle.Bottom; + this.panelControl1.Location = new System.Drawing.Point(2, 529); + this.panelControl1.Margin = new System.Windows.Forms.Padding(2); + this.panelControl1.Name = "panelControl1"; + this.panelControl1.Size = new System.Drawing.Size(329, 35); + this.panelControl1.TabIndex = 50; + // + // btnPmsSave + // + this.btnPmsSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btnPmsSave.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnPmsSave.Appearance.Options.UseFont = true; + this.btnPmsSave.Location = new System.Drawing.Point(253, 5); + this.btnPmsSave.Name = "btnPmsSave"; + this.btnPmsSave.Size = new System.Drawing.Size(72, 26); + this.btnPmsSave.TabIndex = 40; + this.btnPmsSave.Text = "保存(&S)"; + // + // rightDetailPanel + // + this.rightDetailPanel.Controls.Add(this.gcDetailControlEx); + this.rightDetailPanel.Dock = System.Windows.Forms.DockStyle.Fill; + this.rightDetailPanel.Location = new System.Drawing.Point(0, 0); + this.rightDetailPanel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.rightDetailPanel.Name = "rightDetailPanel"; + this.rightDetailPanel.Size = new System.Drawing.Size(411, 566); + this.rightDetailPanel.TabIndex = 19; + // + // gcDetailControlEx + // + this.gcDetailControlEx.AdapterObj = null; + this.gcDetailControlEx.Dock = System.Windows.Forms.DockStyle.Fill; + this.gcDetailControlEx.Location = new System.Drawing.Point(0, 0); + this.gcDetailControlEx.Margin = new System.Windows.Forms.Padding(5); + this.gcDetailControlEx.Name = "gcDetailControlEx"; + this.gcDetailControlEx.SiftEnumObj = Lskj.Control.GridControlEx.HeaderSiftEnum.Sum; + this.gcDetailControlEx.Size = new System.Drawing.Size(411, 566); + this.gcDetailControlEx.SysModel = null; + this.gcDetailControlEx.TabIndex = 52; + // + // pl_buttomflow + // + this.pl_buttomflow.Controls.Add(this.btnSave); + this.pl_buttomflow.Controls.Add(this.btnApply); + this.pl_buttomflow.Controls.Add(this.btnFxSave); + this.pl_buttomflow.Dock = System.Windows.Forms.DockStyle.Fill; + this.pl_buttomflow.FlowDirection = System.Windows.Forms.FlowDirection.RightToLeft; + this.pl_buttomflow.Location = new System.Drawing.Point(2, 2); + this.pl_buttomflow.Name = "pl_buttomflow"; + this.pl_buttomflow.Size = new System.Drawing.Size(372, 31); + this.pl_buttomflow.TabIndex = 1; + // + // btnFxSave + // + this.btnFxSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btnFxSave.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnFxSave.Appearance.Options.UseFont = true; + this.btnFxSave.Location = new System.Drawing.Point(125, 3); + this.btnFxSave.Name = "btnFxSave"; + this.btnFxSave.Size = new System.Drawing.Size(80, 26); + this.btnFxSave.TabIndex = 42; + this.btnFxSave.Text = "批量确认"; + // + // FrmMain + // + this.Appearance.BackColor = System.Drawing.SystemColors.Control; + this.Appearance.Options.UseBackColor = true; + this.Appearance.Options.UseFont = true; + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1134, 644); + this.Controls.Add(this.splitRightContainer); + this.Controls.Add(this.scrollableControl); + this.Margin = new System.Windows.Forms.Padding(2); + this.Name = "FrmMain"; + this.Text = "FrmMain"; + ((System.ComponentModel.ISupportInitialize)(this.splitRightContainer)).EndInit(); + this.splitRightContainer.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.splitControlContainer)).EndInit(); + this.splitControlContainer.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.topPanel)).EndInit(); + this.topPanel.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.pl_buttom)).EndInit(); + this.pl_buttom.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.pl_top)).EndInit(); + this.pl_top.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.pl_top_search)).EndInit(); + this.pl_top_search.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.pl_top_fix_search)).EndInit(); + this.pl_top_fix_search.ResumeLayout(false); + this.pl_top_fix_search.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pl_Bottom)).EndInit(); + this.pl_Bottom.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.panelControl1)).EndInit(); + this.panelControl1.ResumeLayout(false); + this.rightDetailPanel.ResumeLayout(false); + this.pl_buttomflow.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + private DevExpress.XtraEditors.XtraScrollableControl scrollableControl; + private DevExpress.XtraEditors.SplitContainerControl splitRightContainer; + private DevExpress.XtraEditors.SplitContainerControl splitControlContainer; + private DevExpress.XtraEditors.PanelControl topPanel; + private DevExpress.XtraEditors.PanelControl pl_Bottom; + private System.Windows.Forms.Panel rightDetailPanel; + private DevExpress.XtraEditors.PanelControl pl_top; + private DevExpress.XtraEditors.PanelControl pl_top_search; + private DevExpress.XtraEditors.PanelControl pl_top_fix_search; + private System.Windows.Forms.ComboBox cbField; + private DevExpress.XtraEditors.SimpleButton btnFixSearch; + private System.Windows.Forms.TextBox txtFixKey; + private System.Windows.Forms.Label label1; + private DevExpress.XtraEditors.PanelControl pl_buttom; + private DevExpress.XtraEditors.SimpleButton btnSave; + private Control.GridControlEx gcMainControlEx; + private DevExpress.XtraEditors.PanelControl panelControl1; + private DevExpress.XtraEditors.SimpleButton btnPmsSave; + private Control.GridControlEx gcDetailControlEx; + private DevExpress.XtraEditors.SimpleButton btnApply; + private Control.TreeGridControlEx treeGridControlEx; + private System.Windows.Forms.FlowLayoutPanel pl_buttomflow; + private DevExpress.XtraEditors.SimpleButton btnFxSave; + } +} + diff --git a/插件库/Lskj.PubBomAlter/FrmMain.cs b/插件库/Lskj.PubBomAlter/FrmMain.cs new file mode 100644 index 0000000..845398e --- /dev/null +++ b/插件库/Lskj.PubBomAlter/FrmMain.cs @@ -0,0 +1,2330 @@ +using DevExpress.XtraEditors; +using DevExpress.XtraGrid.Views.Grid; +using DevExpress.XtraGrid.Views.Grid.ViewInfo; +using DevExpress.XtraTreeList; +using DevExpress.XtraTreeList.Nodes; +using Lskj.Business.Impl; +using Lskj.Control; +using Lskj.Control.Model; +using Lskj.Core; +using Lskj.Data; +using Lskj.Model; +using Lskj.PubBomAlter.Model; +using Lskj.Util; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Data.SqlClient; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading; +using System.Windows.Forms; + +namespace Lskj.PubBomAlter +{ + public partial class FrmMain : BaseForm + { + public DynamicBomAlterModel BomAlterModel; + public string[] ModelObj; + /// + /// 模块表 + /// + public TreeGridControlEx TreeGridObj + { + get { return treeGridControlEx; } + } + /// + /// 查询对象 + /// + public MyControl SearchObj; + /// + /// 数据源绑定完成后 + /// + public event EventHandler OnAfterDataSourceCallback; + /// + /// 上方控件面板 + /// + private XtraScrollableControl MainControlPanel = new XtraScrollableControl(); + /// + /// 主表控件 + /// + public MyControl TopControlObj; + /// + /// 模块行数据 + /// + private DataRow modelRow; + /// + /// 系统模块对象 + /// + private ModuleModel sysModel; + /// + /// 列数据源 + /// + private DataTable _gridColumns; + /// + /// 无需更新的列 + /// + private string[] _disUpdateColumns = { "id" }; + /// + /// 明细表 + /// + private DataTable detailsTab; + /// + /// 上方控件对象 + /// + public DynamicModel TopDynamic; + /// + /// 上方控件对象 + /// + public ModuleModel TopModuleObj; + /// + /// 中间表格对象 + /// + public DynamicModel GcMainDynamic; + /// + /// 中间表格对象 + /// + public ModuleModel GcMainModuleObj; + /// + /// 右边表格对象 + /// + public DynamicModel GcDetailDynamic; + /// + /// 右边表格对象 + /// + public ModuleModel GcDetailModuleObj; + /// + /// 动态控件对象集合 + /// + private List ControlList = new List(); + /// + /// 规格控件 + /// + private BaseUserControl _SpecBaseControl; + /// + /// 型号控件 + /// + private BaseUserControl _ModelBaseControl; + /// + /// 综合属性控件 + /// + private BaseUserControl _ZhSxBaseControl; + /// + /// 名称控件 + /// + private BaseUserControl _NameBaseControl; + /// + /// 名称控件 + /// + private BaseUserControl _UnitBaseControl; + /// + /// 名称控件 + /// + private BaseUserControl _CzBaseControl; + /// + /// 规格控件 + /// + public BaseUserControl SpecBaseControl + { + get + { + if (_SpecBaseControl == null) + { + _SpecBaseControl = this.TopControlObj.FindControl("spec"); + } + return _SpecBaseControl; + } + } + /// + /// 型号控件 + /// + public BaseUserControl ModelBaseControl + { + get + { + if (_ModelBaseControl == null) + { + _ModelBaseControl = this.TopControlObj.FindControl("model"); + } + return _ModelBaseControl; + } + } + /// + /// 综合属性控件 + /// + public BaseUserControl ZhSxBaseControl + { + get + { + if (_ZhSxBaseControl == null) + { + _ZhSxBaseControl = this.TopControlObj.FindControl("ProductDescrip"); + } + return _ZhSxBaseControl; + } + } + /// + /// 材质属性控件 + /// + public BaseUserControl CzBaseControl + { + get + { + if (_CzBaseControl == null) + { + _CzBaseControl = this.TopControlObj.FindControl("grade"); + } + return _CzBaseControl; + } + } + /// + /// 名称控件 + /// + public BaseUserControl NameBaseControl + { + get + { + if (_NameBaseControl == null) + { + _NameBaseControl = this.TopControlObj.FindControl("appellation"); + } + return _NameBaseControl; + } + } + /// + /// 单位控件 + /// + public BaseUserControl UnitBaseControl + { + get + { + if (_UnitBaseControl == null) + { + _UnitBaseControl = this.TopControlObj.FindControl("Productunitname"); + } + return _UnitBaseControl; + } + } + public FrmMain() + { + InitializeComponent(); + this.Load += OnFrmMainLoad; + } + /// + /// 窗体加载时 + /// + /// + /// + private void OnFrmMainLoad(object sender, EventArgs e) + { + try + { + WaitForm.ShowForm(); + InitlizeSpiltLocation(); + InitTreeGridControl(); + CreateControlLocation(); + InitGcMainControl(); + InitGcDetailControl(); + InitEvents(); + } + catch (Exception ex) + { + MessageUtil.Show(ex.Message); + } + finally + { + WaitForm.HideForm(); + } + } + /// + /// 右键完成后执行 + /// + /// + /// + private void OnGridViewRightCallBack(object sender, EventArgs e) + { + try + { + SearchObj.SearchGrid(); + } + catch (Exception ex) + { + MessageUtil.Show(ex.Message); + } + } + /// + /// 右键完成后执行 + /// + /// + /// + private void OnGridDetailViewRightCallBack(object sender, EventArgs e) + { + try + { + DataRow dataRow = gcMainControlEx.GridView.GetFocusedDataRow(); + if (dataRow != null) + { + SysSetModel setModel = new SysSetModel(dataRow); + if (setModel != null && (setModel.Item.Equals("1") || setModel.Item.Equals("5"))) + { + string controlName = !string.IsNullOrWhiteSpace(setModel.DbName) ? setModel.DbName : setModel.SysName; + string selectSql = "select * from(select row_number() over (partition by mid order by orderid)hh,* from p_productsyslisttab)a where mid = '{0}' order by '{1}'"; + if (!string.IsNullOrEmpty(setModel.OrderField)) + { + selectSql = string.Format(selectSql, setModel.Id, setModel.OrderField); + } + else + { + selectSql = string.Format(selectSql, setModel.Id, "orderid"); + } + DataTable dataSource = BaseImpl.GetDataTableResult(selectSql); + int index = this.gcDetailControlEx.GridView.FocusedRowHandle; + this.gcDetailControlEx.GridControl.DataSource = dataSource; + this.gcDetailControlEx.GridView.FocusedRowHandle = index; + } + else + { + this.gcDetailControlEx.GridControl.DataSource = null; + } + } + } + catch (Exception ex) + { + MessageUtil.Show(ex.Message); + } + } + /// + /// 设置分割条位置 + /// + private void InitlizeSpiltLocation() + { + try + { + string splitRightWidth = IniHelper.Read(string.Format("PubBomAlter_SplitRight_{0}", this.BomAlterModel.ModuleCode));//通过Key获取Value值 + if (!string.IsNullOrEmpty(splitRightWidth)) + { + this.splitRightContainer.SplitterPosition = Convert.ToInt32(splitRightWidth); + } + string splitControlWidth = IniHelper.Read(string.Format("PubBomAlter_SplitControl_{0}", this.BomAlterModel.ModuleCode));//通过Key获取Value值 + if (!string.IsNullOrEmpty(splitControlWidth)) + { + this.splitControlContainer.SplitterPosition = Convert.ToInt32(splitControlWidth); + } + } + catch (Exception ex) + { + MessageUtil.Show(ex.Message); + } + } + /// + /// 构建控件 + /// + private void InitTreeGridControl() + { + detailsTab = BaseModuleImpl.GetBaseDetailPages(this.BomAlterModel.ModuleCode); + modelRow = MainImpl.GetSystemdllTab(BomAlterModel.ModuleCode);//获取单个模块信息 + sysModel = new ModuleModel(modelRow);// 系统模块实体对象 + TreeGridObj.TreeListObj.OptionsBehavior.AllowExpandOnDblClick = false; + TreeGridObj.Model = BomAlterModel; + DataTable queryTable = BaseModuleImpl.GetCustomQueryFields(sysModel.CondKey);//加载自定义配置字段 + sysModel.PrefixKey = BaseImpl.GetColumnPrefix(sysModel.MenuTable);//获取列前缀 + SearchObj = new MyControl(sysModel.MenuSql, TreeGridObj);//替换sql语句中的bmp字段 + SearchObj.OnDataSourceBindCallBack += OnSearchObjDataSourceBindCallBack; + SearchObj.OnSearchAfterCallBack += OnSearchObjSearchAfterCallBack; + bool fixedQuery = queryTable == null || queryTable.Rows.Count == 0; + if (fixedQuery) + { + pl_top_fix_search.Visible = true; + // 加载固定查询条件 + DataTable table = BaseModuleImpl.GetFixedQueryFields(BomAlterModel.ModuleCode);//加载固定查询条件 + cbField.DisplayMember = "fieldText"; + cbField.ValueMember = "fieldName"; + cbField.DataSource = table; + SearchObj.InitDefaultSearchControl(table, pl_top_fix_search); + } + else + { + // 加载配置查询条件 + pl_top_fix_search.Visible = false; + SearchObj.OtherParams = BomAlterModel.OtherParams(); + pl_top.Height = SearchObj.InitSearchControl(queryTable, pl_top_search); + } + _gridColumns = BaseModuleImpl.GetBaseGridColumns(BomAlterModel.ModuleCode); + TreeGridObj.SetEditColumns(_gridColumns, GridCustomColumnStruct.BaseMainGridView + sysModel.FormKey); + TreeGridObj.SetGridRowColors(BaseModuleImpl.GetBaseGridRowColors(BomAlterModel.ModuleCode)); + TreeGridObj.TreeListObj.MouseClick += OnTreeListObjMouseClick; + DataTable rightMenusTable = BaseModuleImpl.GetBaseGridRightMenus(BomAlterModel.ModuleCode); + TreeGridObj.SetGridRightMenus(rightMenusTable, BomAlterModel, OnGridViewRightCallBack, SearchObj); + } + /// + /// 构建控件 + /// + private void InitGcMainControl() + { + if (detailsTab != null && detailsTab.Rows.Count > 2) + { + string unionModule = detailsTab.Rows[2]["unionModule"] + ""; + GcMainDynamic = new DynamicModel(new string[] { ModelObj[0], ModelObj[1], ModelObj[2], ModelObj[3], unionModule }); + DataRow dllRow = MainImpl.GetSystemdllTab(GcMainDynamic.ModuleCode);//获取单个模块信息 + if (dllRow == null) + { + MessageUtil.Show("模块编号[" + GcMainDynamic.ModuleCode + "],配置错误!\r\n该模块信息未找到!"); + return; + } + GcMainModuleObj = new ModuleModel(dllRow);//系统模块实体对象 + InitializeGcMainView(); + } + } + /// + /// 构建控件 + /// + private void InitGcDetailControl() + { + WaitForm.ShowForm(); + try + { + if (detailsTab != null && detailsTab.Rows.Count > 1) + { + string unionModule = detailsTab.Rows[1]["unionModule"] + ""; + GcDetailDynamic = new DynamicModel(new string[] { ModelObj[0], ModelObj[1], ModelObj[2], ModelObj[3], unionModule }); + DataRow dllRow = MainImpl.GetSystemdllTab(GcDetailDynamic.ModuleCode);//获取单个模块信息 + if (dllRow == null) + { + MessageUtil.Show("模块编号[" + GcDetailDynamic.ModuleCode + "],配置错误!\r\n该模块信息未找到!"); + return; + } + GcDetailModuleObj = new ModuleModel(dllRow);//系统模块实体对象 + InitializeGcDetailView(); + } + } + catch (Exception ex) + { + Console.WriteLine(ex.Message); + } + WaitForm.HideForm(); + } + /// + /// 说明:初始化表格操作 + /// 创建人:王一帆 + /// 创建日期:2023-10-13 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + private void InitializeGcDetailView() + { + this.gcDetailControlEx.GridView.OptionsSelection.MultiSelect = true; + this.gcDetailControlEx.GridView.OptionsSelection.MultiSelectMode = GridMultiSelectMode.CheckBoxRowSelect; + this.gcDetailControlEx.GridView.OptionsSelection.EnableAppearanceFocusedCell = true; + this.gcDetailControlEx.GridView.OptionsBehavior.EditorShowMode = DevExpress.Utils.EditorShowMode.MouseDown; + DataTable gridColumns = BaseModuleImpl.GetBaseGridColumns(GcDetailDynamic.ModuleCode);//获取主表列数据 + this.gcDetailControlEx.Model = GcDetailDynamic; + this.gcDetailControlEx.SetReadOnlyColumns(gridColumns, GridCustomColumnStruct.BaseMainGridView + this.GcDetailModuleObj.FormKey); + this.gcDetailControlEx.SetGridRowColors(BaseModuleImpl.GetBaseGridRowColors(GcDetailDynamic.ModuleCode));//设置表格颜色 + DataTable rightMenusTable = BaseModuleImpl.GetBaseGridRightMenus(GcDetailDynamic.ModuleCode); + this.gcDetailControlEx.SetGridRightMenus(rightMenusTable, GcDetailDynamic, OnGridDetailViewRightCallBack); + this.gcDetailControlEx.GridView.OptionsView.ShowFooter = false; + } + /// + /// 说明:初始化表格操作 + /// 创建人:王一帆 + /// 创建日期:2023-10-13 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + private void InitializeGcMainView() + { + //this.gcMainControlEx.GridView.OptionsBehavior.EditorShowMode = DevExpress.Utils.EditorShowMode.MouseDown; + DataTable gridColumns = BaseModuleImpl.GetBaseGridColumns(GcMainDynamic.ModuleCode);//获取主表列数据 + this.gcMainControlEx.Model = GcMainDynamic; + this.gcMainControlEx.SetEditColumns(gridColumns, GridCustomColumnStruct.BaseMainGridView + this.GcMainModuleObj.FormKey); + this.gcMainControlEx.SetGridRowColors(BaseModuleImpl.GetBaseGridRowColors(GcMainDynamic.ModuleCode));//设置表格颜色 + this.gcMainControlEx.GridView.OptionsView.ShowFooter = false; + this.gcMainControlEx.GridView.FocusedRowChanged += OnGcGridViewFocusedRowChanged; + this.gcMainControlEx.GridView.CellValueChanged += OnGcMainGridCellValueChanged; + } + /// + /// 说明:初始化主模块控件 + /// 创建人:唐德馨 + /// 创建日期:2023-10-19 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + private void CreateControlLocation() + { + try + { + if (detailsTab != null && detailsTab.Rows.Count > 0) + { + string unionModule = detailsTab.Rows[0]["unionModule"] + ""; + TopDynamic = new DynamicModel(new string[] { ModelObj[0], ModelObj[1], ModelObj[2], ModelObj[3], unionModule }); + DataRow dllRow = MainImpl.GetSystemdllTab(this.TopDynamic.ModuleCode);//获取单个模块信息 + if (dllRow == null) + { + MessageUtil.Show("模块编号[" + this.TopDynamic.ModuleCode + "],配置错误!\r\n该模块信息未找到!"); + return; + } + this.TopModuleObj = new ModuleModel(dllRow);//系统模块实体对象 + } + DataTable mainControlTable = BaseModuleImpl.GetControlLocation(TopModuleObj.FormKey, this.TopDynamic.ModuleCode); + this.TopControlObj = new MyControl() + { + ParentPanel = this.scrollableControl, + SystemModel = this.TopModuleObj, + OtherParams = this.BomAlterModel.OtherParams() + }; + this.TopControlObj.InitControl(mainControlTable, this.scrollableControl, null, true); + this.scrollableControl.AutoScroll = true; + this.scrollableControl.HorizontalScroll.Visible = false;//设置禁止水平滚动条 + + this.TopControlObj.OnDataSourceBindCallBack += TopControlObj_OnDataSourceBindCallBack; + } + catch (Exception) + { + } + } + + + + /// + /// 添加事件 + /// + private void InitEvents() + { + if (BomAlterModel.AllowFxBtn.Equals("1")) + { + btnFxSave.Visible = true; + } + else + { + btnFxSave.Visible = false; + } + if (!string.IsNullOrEmpty(BomAlterModel.SaveSql)) + { + btnApply.Visible = true; + } + else + { + btnApply.Visible = false; + } + //TreeGridObj.TreeListObj.MouseDoubleClick += OnTreeListObjMouseDoubleClick; + TreeGridObj.TreeListObj.CustomDrawNodeButton += OnTreeListObjCustomDrawNodeButton; + this.splitRightContainer.SplitterPositionChanged += OnSplitMainContainerPositionChanged; + this.splitControlContainer.SplitterPositionChanged += OnSplitMainContainerPositionChanged; + //this.pl_Top.Click += OnScrollableControlClick; + //this.pl_scrollBottom.Click += OnScrollableControlClick; + this.btnPmsSave.Click += OnBtnPmsSaveClick; + this.btnSave.Click += OnBtnSaveClick; + this.btnApply.Click += OnBtnApplyClick; + this.btnFxSave.Click += OnBtnFxSaveClick; + this.gcDetailControlEx.GridView.DoubleClick += OnGcDetailGridViewDoubleClick; + this.gcDetailControlEx.GridView.SelectionChanged += OnGridViewSelectionChanged; + } + /// + /// 树表格行点击 + /// + /// + /// + private void OnTreeListObjMouseClick(object sender, MouseEventArgs e) + { + try + { + this.OnAfterDataSourceCallback -= OnAfterDataSource; + gcMainControlEx.GridControl.DataSource = null; + TreeList treeListGrid = sender as TreeList; + Point gcPoint = treeListGrid.PointToScreen(treeListGrid.Location); + Point pt = new Point(MousePosition.X - gcPoint.X, MousePosition.Y - gcPoint.Y); + TreeListHitInfo _hitInfo = treeListGrid.CalcHitInfo(pt); + if (_hitInfo != null && _hitInfo.Node != null) + { + if (BomAlterModel != null && BomAlterModel.MaintabFocusedRow != null) + { + TopControlObj.ResetControlValue(); + TopControlObj.SetAllControlValue(BomAlterModel.MaintabFocusedRow); + } + TreeListNode focusedNode = treeListGrid.FocusedNode; + DataRow dataRow = (treeListGrid.GetDataRecordByNode(focusedNode) as DataRowView).Row; + if (dataRow.Table.Columns.Contains("Plm_lmb_SmartBmFa")) + { + string projectId = dataRow["Plm_lmb_SmartBmFa"] + ""; + this.OnAfterDataSourceCallback += OnAfterDataSource; + SetDynamicControl(projectId); + } + } + } + catch (Exception ex) + { + MessageUtil.Show(ex.Message); + } + } + /// + /// 数据源加载完成后事件 + /// + /// + /// + private void OnAfterDataSource(object sender, EventArgs e) + { + WaitForm.ShowForm(); + this.Invoke(new Action(() => + { + TreeListNode focusedNode = TreeGridObj.TreeListObj.FocusedNode; + DataRow dataRow = (TreeGridObj.TreeListObj.GetDataRecordByNode(focusedNode) as DataRowView).Row; + SetAllControlValue(dataRow); + })); + WaitForm.HideForm(); + } + /// + /// 更改菜单点击 + /// + /// + /// + private void OnToolStripMenuItemClick(object sender, EventArgs e) + { + try + { + TreeList treeListGrid = treeGridControlEx.TreeListObj; + TreeListNode focusedNode = treeListGrid.FocusedNode; + DataRow dataRow = (treeListGrid.GetDataRecordByNode(focusedNode) as DataRowView).Row; + if (focusedNode.ParentNode == null || (focusedNode.ParentNode != null && (focusedNode.ParentNode[$"{sysModel.PrefixKey}updatetig"] + "").Equals("1"))) + { + string sourceSql = GcMainModuleObj.MenuSql; + sourceSql = ReplaceHelper.ReplaceRowParam(dataRow, sourceSql); + DataTable sourceTable = BaseImpl.GetDataTableResult(sourceSql); + gcMainControlEx.GridControl.DataSource = sourceTable; + } + else + { + MessageUtil.Show("父节点未修改"); + } + } + catch (Exception ex) + { + MessageUtil.Show(ex.Message); + } + } + /// + /// 参数表格点击时 + /// + /// + /// + private void OnGcGridViewFocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e) + { + DataRow dataRow = gcMainControlEx.GridView.GetFocusedDataRow(); + if (dataRow != null) + { + SysSetModel setModel = new SysSetModel(dataRow); + if (setModel != null && (setModel.Item.Equals("1") || setModel.Item.Equals("5"))) + { + string controlName = !string.IsNullOrWhiteSpace(setModel.DbName) ? setModel.DbName : setModel.SysName; + DataTable dataSource = null; + string existsPr = BaseImpl.GetResult("SELECT 1 FROM sys.procedures WHERE name = 'ParameterList' AND schema_id = SCHEMA_ID('dbo')") + ""; + if (existsPr.Equals("1")) + { + dataSource = BaseImpl.GetDataTableResult($"exec ParameterList '{setModel.Id}',''"); + } + else + { + string selectSql = "select midno as id,sysnamelist as sysnamelist,bak as bak from (select row_number() over (partition by mid order by orderid)hh,* from p_productsyslisttab)a where mid = '{0}' order by {1}"; + if (!string.IsNullOrEmpty(setModel.OrderField)) + { + selectSql = string.Format(selectSql, setModel.Id, setModel.OrderField); + } + else + { + selectSql = string.Format(selectSql, setModel.Id, "orderid"); + } + dataSource = BaseImpl.GetDataTableResult(selectSql); + } + this.gcDetailControlEx.GridControl.DataSource = dataSource; + string editValue = this.GetControlValue(controlName, true); + if (!string.IsNullOrEmpty(editValue)) + { + DataRow selectRow = dataSource.AsEnumerable().Where(n => (n["id"] + "").Equals(editValue)).FirstOrDefault(); + if (selectRow != null) + { + int index = dataSource.Rows.IndexOf(selectRow); + index = this.gcDetailControlEx.GridView.GetRowHandle(index); + this.gcDetailControlEx.GridView.SelectRow(index); + } + } + } + else + { + this.gcDetailControlEx.GridControl.DataSource = null; + } + } + } + /// + /// 表格值改变时 + /// + /// + /// + private void OnGcMainGridCellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) + { + if (e.Column.FieldName.Equals("sysvalue")) + { + DataRow focusedRow = gcMainControlEx.GridView.GetDataRow(e.RowHandle); + string dbName = focusedRow["DbName"] + ""; + string sysName = focusedRow["SysName"] + ""; + string controlName = !string.IsNullOrWhiteSpace(dbName) ? dbName : sysName; + string value = focusedRow["sysvalue"] + ""; + focusedRow["sysvalue"] = ""; + SetControlValue(controlName, value); + } + } + /// + /// 绘制树表格前图标 + /// + /// + /// + private void OnTreeListObjCustomDrawNodeButton(object sender, CustomDrawNodeButtonEventArgs e) + { + if (((treeGridControlEx.TreeListObj.GetDataRecordByNode(e.Node) as DataRowView).Row[$"{sysModel.PrefixKey}updatetig"] + "").Equals("1")) + { + Image image = Properties.Resources.update; + Rectangle nodeBounds = e.Bounds; + int x = nodeBounds.Left; + int y = nodeBounds.Top; + e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; + e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; + e.Graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; + e.Graphics.CompositingQuality = CompositingQuality.HighQuality; + e.Graphics.DrawImage(image, x, y, nodeBounds.Width, nodeBounds.Height); + e.Handled = true; + } + } + /// + /// 设置动态控件 + /// + private void SetDynamicControl(string projectId) + { + this.MainControlPanel.Controls.Clear(); + this.ControlList.Clear(); + try + { + if (!string.IsNullOrEmpty(projectId)) + { + TreeListNode focusedNode = treeGridControlEx.TreeListObj.FocusedNode; + DataRow dataRow = (treeGridControlEx.TreeListObj.GetDataRecordByNode(focusedNode) as DataRowView).Row; + DataTable dataTable = new DataTable(); + //string dataSourceSql = string.Format("select * from p_productsyssettab where speciesid = '{0}' and groupname = '{1}' and ban = 0 order by orderid", speciesid, groupname); + //string dataSourceSql = string.Format("select '' as sysvalue,* from p_productsyssettab where groupid = '{0}' and ban = 0 order by orderid", projectId); + string sourceSql = GcMainModuleObj.MenuSql; + sourceSql = ReplaceHelper.ReplaceRowParam(dataRow, sourceSql); + dataTable = BaseImpl.GetDataTableResult(sourceSql); + gcMainControlEx.GridControl.DataSource = dataTable; + 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; + labelAutoTextEdit.TextEdit.AutoShowPopup = false; + 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.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.TextChanged += new EventHandler(OnTextEditTextChanged); + //labelMultiAutoTextEdit.ReadOnly = setModel.ProhibitEdited; + baseControl = labelMultiAutoTextEdit; + break; + //备注框A + case "4": + LabelMemoEdit labelMemoEdit = new LabelMemoEdit(); + 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; + labelAutoMemoEdit.TextEdit.AutoShowPopup = false; + 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.TextChanged += new EventHandler(OnTextEditTextChanged); + baseControl = labelAutoMemoEdit; + break; + //文本框控件 + case "2": + default: + LabelTextEdit labelTextEdit = new LabelTextEdit(); + labelTextEdit.TextEdit.TextChanged += new EventHandler(OnTextEditTextChanged); + 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.MainControlPanel.Controls.Add(baseControl); + this.ControlList.Add(setModel); + if (x + baseControl.Width + 15 + baseControl.Width > this.splitRightContainer.Panel1.Width) + { + x = 10; + y += baseControl.Height + 9; + } + else + { + x += baseControl.Width + 15; + } + } + SetControlDataSource(); + //Thread thread = new Thread(SetControlDataSource); + //thread.Start(); + } + } + catch (Exception) + { + } + } + /// + /// 延迟加载数据源 + /// + 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.MainControlPanel.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 = BaseImpl.GetDataTableResult(selectSql); + } + LabelAutoTextEdit labelAutoTextEdit = ctr as LabelAutoTextEdit; + if (dataSource.Columns.Count >= 2) + { + string keyField = dataSource.Columns[0].ColumnName; + string valueField = dataSource.Columns[1].ColumnName; + setModel.ValueMember = keyField; + setModel.TextMember = valueField; + labelAutoTextEdit.ValueField = keyField; + labelAutoTextEdit.TextField = valueField; + labelAutoTextEdit.ValueMember = keyField; + } + 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 keyField = dataSource.Columns[0].ColumnName; + string valueField = dataSource.Columns[1].ColumnName; + setModel.ValueMember = keyField; + setModel.TextMember = valueField; + labelMultiAutoTextEdit.ValueField = keyField; + labelMultiAutoTextEdit.TextField = valueField; + labelMultiAutoTextEdit.ValueMember = keyField; + } + 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 keyField = dataSource.Columns[0].ColumnName; + string valueField = dataSource.Columns[1].ColumnName; + setModel.ValueMember = keyField; + setModel.TextMember = valueField; + labelAutoMemoEdit.ValueField = keyField; + labelAutoMemoEdit.TextField = valueField; + labelAutoMemoEdit.ValueMember = keyField; + } + 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.MainControlPanel.Controls.Find(controlName, false).FirstOrDefault(); + BaseUserControl baseUserControl = ctr as BaseUserControl; + if (baseUserControl.InvokeRequired) + { + baseUserControl.Invoke(new Action(() => + { + baseUserControl.EditText = defaultValue; + })); + } + else + { + baseUserControl.EditText = defaultValue; + } + } + } + if (OnAfterDataSourceCallback != null) + { + OnAfterDataSourceCallback(null, null); + } + } + catch (Exception ex) + { + MessageUtil.Show(ex.Message); + } + } + /// + /// 动态控件值改变时 + /// + /// + /// + 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);//关联计算 + } + if (model.OrderId.Equals(1) && this.NameBaseControl != null)//反写名称 + { + this.NameBaseControl.EditText = baseControl.EditText; + //string speciesid = this.treeLeftViewEx.TreeView.SelectedNode.Name; + //string whereSql = string.Format(" and speciesno = '{0}' ", speciesid); + //this.SetMainGridView(whereSql); + } + if (model.SpecDbName.Equals(1) && this.SpecBaseControl != null)//反写规格 + { + List specControls = this.MainControlPanel.Controls.Cast().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 modelControls = this.MainControlPanel.Controls.Cast().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 zhsxControls = this.MainControlPanel.Controls.Cast().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 czControls = this.MainControlPanel.Controls.Cast().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(); + } + model.SourceRow["sysvalue"] = baseControl.EditText; + } + /// + /// 反写规格型号时获取BaseUserControl的值 + /// + /// + /// + /// + 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; + } + /// + /// 说明:设置关联值 + /// 创建人:龚宇超 + /// 创建日期:2017-12-06 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The model. + private void SetUnionControl(SysSetModel model) + { + string unionFields = model.UnionFields; + string unionValues = ReplaceControlValue(model.UnionValues, this.MainControlPanel); + 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); + } + } + /// + /// 说明:从当前面板查找控件替换{xxx}值 + /// 创建人:龚宇超 + /// 创建日期:2017-12-06 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The default value. + public string ReplaceControlValue(string defaultValue, System.Windows.Forms.Control control) + { + if (!string.IsNullOrWhiteSpace(defaultValue)) + { + defaultValue = ReplaceHelper.ReplaceUserInfo(defaultValue); + var paramList = ReplaceHelper.GetParamFields(defaultValue); + foreach (string item in paramList) + { + string field = item.Replace("{", "").Replace("}", ""); + if (FindControl(field, control) != null) + { + string value = GetControlValue(field); + defaultValue = defaultValue.Replace(item, value); + } + } + } + return defaultValue; + } + /// + /// 说明:获取控件值 + /// 创建人:龚宇超 + /// 创建日期:2017-09-04 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// Name of the control. + /// System.String. + public string GetControlValue(string controlName, bool getId = false) + { + string value = string.Empty; + var ctrs = MainControlPanel.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 (getId) + { + value = labelAutoTextEdit.EditValue; + } + else + { + if (setModel.FxTypeDB.Equals("编码")) + { + value = labelAutoTextEdit.EditValue; + } + else if (setModel.FxTypeDB.Equals("名称")) + { + value = labelAutoTextEdit.EditText; + } + } + break; + //多选框控件 + case "3": + LabelMultiAutoTextEdit labelMultiAutoTextEdit = ctr as LabelMultiAutoTextEdit; + if (getId) + { + value = labelMultiAutoTextEdit.EditValue; + } + else + { + 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 (getId) + { + value = labelAutoMemoEdit.EditValue; + } + else + { + if (setModel.FxTypeDB.Equals("编码")) + { + value = labelAutoMemoEdit.EditValue; + } + else if (setModel.FxTypeDB.Equals("名称")) + { + value = labelAutoMemoEdit.EditText; + } + } + break; + //文本框控件 + case "2": + default: + LabelTextEdit labelTextEdit = ctr as LabelTextEdit; + value = labelTextEdit.EditText; + break; + } + } + return value; + } + /// + /// 设置控件值 + /// + /// + /// + public void SetControlValue(string controlName, object controlValue) + { + BaseUserControl baseControl = FindControl(controlName, this.MainControlPanel); + if (baseControl == null) return; + baseControl.EditText = controlValue + ""; + } + + /// + /// 设置控件值 + /// + /// + public void SetAllControlValue(DataRow dataRow) + { + string primaryVlaue = dataRow["productid"] + ""; + DataRow selectSource = BaseImpl.GetDataRowResult(string.Format("select * from p_producttab where productid = '{0}'", primaryVlaue)); + //if (selectSource != null) + //{ + // TopControlObj.SetAllControlValue(selectSource); + //} + //if (dataRow != null) + //{ + // TopControlObj.SetAllControlValue(dataRow); + //} + //if (BomAlterModel != null && BomAlterModel.MaintabFocusedRow != null) + //{ + // TopControlObj.SetAllControlValue(BomAlterModel.MaintabFocusedRow); + //} + List modelControls = this.MainControlPanel.Controls.Cast().Where(n => !string.IsNullOrEmpty((n.Tag as SysSetModel).DbName)).OrderBy(n => (n.Tag as SysSetModel).OrderId).ToList(); + if (selectSource == null) + { + primaryVlaue = dataRow[$"{sysModel.PrefixKey}id"] + ""; + selectSource = BaseImpl.GetDataRowResult($"select * from {sysModel.MenuTable} where {sysModel.PrefixKey}id = '{primaryVlaue}'"); + foreach (BaseUserControl item in modelControls) + { + SysSetModel sysSetModel = item.Tag as SysSetModel; + string value = ""; + if (selectSource != null) + { + value = selectSource.Table.Columns.Contains(sysSetModel.DbName) ? selectSource[sysSetModel.DbName] + "" : ""; + } + item.EditText = value; + } + } + else + { + foreach (BaseUserControl item in modelControls) + { + SysSetModel sysSetModel = item.Tag as SysSetModel; + string value = ""; + if (selectSource != null) + { + value = selectSource.Table.Columns.Contains(sysSetModel.DbName) ? selectSource[sysSetModel.DbName] + "" : ""; + } + item.EditText = value; + } + } + //if (!string.IsNullOrEmpty(lastValues)) + //{ + // string[] lastValueArray = lastValues.Split('\\'); + // for (int i = 0; i < modelControls.Count; i++) + // { + // if (i == 0) + // { + // continue; + // } + // int index = i - 1; + // string value = index >= 0 && lastValueArray.Length > index ? lastValueArray[index] : ""; + // BaseUserControl item = modelControls[i]; + // item.EditText = value; + // } + //} + } + /// + /// 说明:查找控件(无需要传入txt_) + /// 创建人:龚宇超 + /// 创建日期:2017-11-08 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// Name of the control. + /// BaseUserControl. + public BaseUserControl FindControl(string controlName, System.Windows.Forms.Control control) + { + System.Windows.Forms.Control controlObj = new System.Windows.Forms.Control(); + controlObj = control.Controls.Cast().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; + } + /// + /// 分隔条位置改变时 + /// + /// + /// + private void OnSplitMainContainerPositionChanged(object sender, EventArgs e) + { + try + { + if (this.BomAlterModel != null) + { + IniHelper.Write(string.Format("PubBomAlter_SplitRight_{0}", this.BomAlterModel.ModuleCode), this.splitRightContainer.SplitterPosition + ""); + IniHelper.Write(string.Format("PubBomAlter_SplitControl_{0}", this.BomAlterModel.ModuleCode), this.splitControlContainer.SplitterPosition + ""); + } + } + catch (Exception ex) + { + MessageUtil.Show(ex.Message); + } + } + /// + /// 表格双击选中 + /// + /// + /// + private void OnGcDetailGridViewDoubleClick(object sender, EventArgs e) + { + Point point = this.gcDetailControlEx.GridControl.PointToClient(MousePosition); + GridHitInfo hitInfo = this.gcDetailControlEx.GridView.CalcHitInfo(point); + if (hitInfo.InRow) + { + if (hitInfo.RowHandle >= 0) + { + if (this.gcDetailControlEx.GridView.IsRowSelected(hitInfo.RowHandle)) + { + this.gcDetailControlEx.GridView.UnselectRow(hitInfo.RowHandle); + } + else + { + this.gcDetailControlEx.GridView.SelectRow(hitInfo.RowHandle); + } + } + } + } + /// + /// 选中改变事件 + /// + /// + /// + private void OnGridViewSelectionChanged(object sender, DevExpress.Data.SelectionChangedEventArgs e) + { + DataRow focusedRow = this.gcMainControlEx.GridView.GetFocusedDataRow(); + this.gcDetailControlEx.GridView.SelectionChanged -= OnGridViewSelectionChanged; + //清除所有选择 + this.gcDetailControlEx.GridView.ClearSelection(); + if (e.Action == CollectionChangeAction.Add)//选中 + { + this.gcDetailControlEx.GridView.SelectRow(e.ControllerRow); + } + this.gcDetailControlEx.GridView.SelectionChanged += OnGridViewSelectionChanged; + int[] indexs = this.gcDetailControlEx.GridView.GetSelectedRows(); + string dbName = focusedRow["DbName"] + ""; + string sysName = focusedRow["SysName"] + ""; + string controlName = !string.IsNullOrWhiteSpace(dbName) ? "txt_" + dbName : "txt_" + sysName; + System.Windows.Forms.Control ctr = this.MainControlPanel.Controls.Find(controlName, false).FirstOrDefault(); + if (ctr != null) + { + BaseUserControl selectControl = ctr as BaseUserControl; + if (indexs.Length > 0 && focusedRow != null) + { + DataRow dataRow = this.gcDetailControlEx.GridView.GetDataRow(indexs[0]); + string value = dataRow["sysnamelist"] + ""; + selectControl.EditText = value; + } + else + { + selectControl.EditText = ""; + } + } + } + /// + /// 说明:验证数据合法性 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// true if XXXX, false otherwise. + 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; + } + /// + /// 参数保存按钮点击 + /// + /// + /// + private void OnBtnPmsSaveClick(object sender, EventArgs e) + { + TreeListNode focusedNode = treeGridControlEx.TreeListObj.FocusedNode; + DataRow focusedRow = (treeGridControlEx.TreeListObj.GetDataRecordByNode(focusedNode) as DataRowView).Row; + if (focusedNode.ParentNode == null || (focusedNode.ParentNode != null && ((treeGridControlEx.TreeListObj.GetDataRecordByNode(focusedNode.ParentNode) as DataRowView).Row[$"{sysModel.PrefixKey}updatetig"] + "").Equals("1"))) + { + try + { + WaitForm.ShowForm("正在保存数据"); + if (this.VerifyNull(this.MainControlPanel)) + { + if (!string.IsNullOrEmpty(BomAlterModel.VerifySql)) + { + 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", sysModel.MenuTable)) + ""; + DataTable tableColumns = BaseImpl.GetTableColumns(sysModel.MenuTable); + string primaryKey = BaseImpl.GetBasePrimaryKey(this.BomAlterModel.ModuleCode); + string newBillNo = focusedRow[primaryKey] + ""; + ControlModel model = this.TopControlObj._models.FirstOrDefault(x => x.FieldName == primaryKey); + List keyList = new List() { "speciesno", "operatorname", "operatedate", "smartbmfa" }; + StringBuilder sqlBuilder = new StringBuilder(); + StringBuilder alterTableSqlBuilder = new StringBuilder(); + List modelControls = this.MainControlPanel.Controls.Cast().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)) + { + if (!tableColumns.Columns.Contains(sysSetModel.DbName)) + { + alterTableSqlBuilder.AppendLine($"alter table {sysModel.MenuTable} add {sysSetModel.DbName} varchar(1000);"); + } + keyList.Add(sysSetModel.DbName.ToLower()); + sqlBuilder.Append(string.Format("{0} = '{1}',", sysSetModel.DbName, fxValue.Replace("'", "''"))); + } + } + foreach (ControlModel item in this.TopControlObj.ControlModels) + { + if (!item.IsSave || + "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 || + Autogrowcolumn.ToLower() == item.FieldName.ToLower()) + continue; + BaseUserControl userControl = this.TopControlObj.FindControl(item); + if (userControl != null) + { + string fieldValue = this.TopControlObj.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())) + { + if (!tableColumns.Columns.Contains(item.FieldName)) + { + alterTableSqlBuilder.AppendLine($"alter table {sysModel.MenuTable} add {item.FieldName} varchar(1000);"); + } + sqlBuilder.Append(string.IsNullOrEmpty(fieldValue) ? string.Format("{0} = {1}", item.FieldName, this.TopControlObj.GetNullValue(item)) : string.Format("{0}='{1}',", item.FieldName, fieldValue)); + } + } + } + if (!string.IsNullOrWhiteSpace(alterTableSqlBuilder.ToString())) + { + BaseImpl.ExecSqlValue(alterTableSqlBuilder.ToString()); + } + string execSql = ""; + if (!string.IsNullOrWhiteSpace(sqlBuilder.ToString())) + { + execSql = string.Format("update {0} set {1} where {2} = '{3}'", sysModel.MenuTable, sqlBuilder.ToString().TrimEnd(','), primaryKey, newBillNo); + } + BaseSaveModel saveModel = new BaseSaveModel + { + BaseSaveType = SaveType.Update, + BaseSql = execSql, + KeyField = primaryKey, + FieldValue = newBillNo, + MenuCode = sysModel.ModeCode, + TableName = sysModel.MenuTable, + ComfirmFlag = 0, + NewVer = sysModel.NewVer + }; + int result = BaseModuleImpl.SaveBasePanelData(saveModel); + if (result == 1) + { + + } + else + { + MessageUtil.Show(ResourceKeys.SaveFault + "\r\n" + saveModel.FaultMsg); + return; + } + string pattern = @"(\w+)\((.*?)\)"; + Regex regex = new Regex(pattern); + Match match = regex.Match(BomAlterModel.VerifySql); + if (match.Success) + { + string functionName = match.Groups[1].Value; + string parameters = match.Groups[2].Value; + if (!string.IsNullOrEmpty(functionName)) + { + DataTable sqlParametersTab = BaseImpl.GetDataTableResult($"SELECT PARAMETER_NAME,PARAMETER_MODE,CHARACTER_MAXIMUM_LENGTH,DATA_TYPE FROM INFORMATION_SCHEMA.PARAMETERS WHERE SPECIFIC_NAME = '{functionName}' ORDER BY ORDINAL_POSITION;"); + using (SqlCommand command = new SqlCommand(functionName, SqlHelper._connection)) + { + string[] parametersArray = parameters.Split(','); + foreach (DataRow parameterRow in sqlParametersTab.Rows) + { + string parameterName = parameterRow["PARAMETER_NAME"] + ""; + string parameterMode = parameterRow["PARAMETER_MODE"] + ""; + int.TryParse(parameterRow["CHARACTER_MAXIMUM_LENGTH"] + "", out int dataLength); + string dataType = parameterRow["DATA_TYPE"] + ""; + SqlParameter sqlParameter = null; + if (parameterMode.Equals("int")) + { + sqlParameter = new SqlParameter(parameterName, SqlDbType.Int); + } + else + { + sqlParameter = new SqlParameter(parameterName, SqlDbType.VarChar, dataLength); + } + if (parameterMode.Equals("IN")) + { + sqlParameter.Direction = ParameterDirection.Input; + } + else + { + sqlParameter.Direction = ParameterDirection.Output; + } + command.Parameters.Add(sqlParameter); + } + for (int i = 0; i < command.Parameters.Count; i++) + { + SqlParameter sqlParameter = command.Parameters[i]; + if (parametersArray.Length > i) + { + string commandParameter = parametersArray[i]; + string field = commandParameter.Replace("@", "").Replace("{", "").Replace("}", ""); + string value = focusedRow.Table.Columns.Contains(field) ? focusedRow[field] + "" : commandParameter.Replace("@", ""); + value = SearchObj.ReplaceControlValue(value); + value = TopControlObj.ReplaceControlValue(value); + value = ReplaceControlValue(value, MainControlPanel); + value = value.Replace("@", "").Replace("{", "").Replace("}", ""); + sqlParameter.Value = value; + } + } + SqlParameter returnValue = new SqlParameter("@return", SqlDbType.Int, 4); + returnValue.Direction = ParameterDirection.ReturnValue; + command.Parameters.Add(returnValue); + command.CommandType = CommandType.StoredProcedure; + command.ExecuteNonQuery(); + if ((returnValue.Value + "").Equals("1")) + { + SearchObj.SearchGrid(); + } + SqlParameter outSqlParameter = command.Parameters.Cast().Where(n => n.Direction == ParameterDirection.Output).FirstOrDefault(); + if (outSqlParameter != null) + { + string outMessage = outSqlParameter.Value + ""; + if (!string.IsNullOrEmpty(outMessage)) + { + MessageUtil.Show(outSqlParameter.Value + ""); + } + } + } + } + else + { + MessageUtil.Show("保存逻辑配置错误"); + } + } + else + { + MessageUtil.Show("保存逻辑配置错误"); + } + } + else + { + MessageUtil.Show("保存逻辑配置错误,不能为空"); + } + } + } + catch (Exception ex) + { + MessageUtil.Show(ex.Message); + } + finally + { + WaitForm.HideForm(); + } + } + else + { + MessageUtil.Show("父节点未修改"); + } + } + /// + /// 保存按钮 + /// + private void OnBtnSaveClick(object sender, EventArgs e) + { + TreeGridControlEx treeMain = TreeGridObj; + string tableName = this.sysModel.MenuTable; + if (string.IsNullOrEmpty(tableName)) + { + MessageUtil.Show(ResourceKeys.MenuTableNameIsNull); + return; + } + List mList = new List(); + DataRow[] modifiedRows = (treeMain.TreeListObj.DataSource as DataTable) + .Rows + .Cast() + .Where(x => x.RowState == DataRowState.Modified || x.RowState == DataRowState.Added) + .ToArray(); + + if (modifiedRows == null || modifiedRows.Length == 0) + { + MessageUtil.Show(ResourceKeys.UnUpdateData); + return; + } + else + { + string _parmaryKey = BaseImpl.GetBasePrimaryKey(this.BomAlterModel.ModuleCode);//获取主键 + DataColumnCollection columns = BaseImpl.GetTableColumns(tableName).Columns; + foreach (DataRow row in modifiedRows) + { + string updateSql = "update {0} set {1} where {2}='{3}';"; + string insertSql = "insert into {0}({1}) values({2});"; + string updateFields = string.Empty; + string insertFields = string.Empty; + string insertValues = string.Empty; + BaseSaveModel model = new BaseSaveModel() + { + MenuCode = this.BomAlterModel.ModuleCode, + TableName = tableName, + KeyField = _parmaryKey, + NewVer = this.sysModel.NewVer + }; + foreach (DataColumn col in columns) + { + // 区分大小写匹配列 + DataRow hasContainRow = _gridColumns.Rows.Cast().FirstOrDefault(x => x["fieldname"] + "" == col.ColumnName); + if (hasContainRow != null && col.ColumnName != _parmaryKey && !_disUpdateColumns.Contains(col.ColumnName)) + { + if (row.RowState == DataRowState.Modified && string.IsNullOrEmpty(sysModel.CustomColumnSQL)) + { + if ((col.DataType == typeof(DateTime)) && (row[col.ColumnName] + "" == "")) + { + updateFields += string.Format("[{0}]=null,", col.ColumnName); + } + else + { + if (col.DataType == typeof(Decimal) && string.IsNullOrWhiteSpace((row[col.ColumnName] + "").Replace("'", "''"))) + { + updateFields += string.Format("[{0}]='{1}',", col.ColumnName, 0); + } + else + { + updateFields += string.Format("[{0}]='{1}',", col.ColumnName, (row[col.ColumnName] + "").Replace("'", "''")); + } + + } + } + else if (row.RowState == DataRowState.Added || (row.RowState == DataRowState.Modified && !string.IsNullOrEmpty(sysModel.CustomColumnSQL))) + { + // 动态生成列,保存时默认全部为新增 + string fieldValue = (row[col.ColumnName] + "").Replace("'", "''"); + insertFields += "[" + col.ColumnName + "],"; + if (!string.IsNullOrWhiteSpace(fieldValue)) + { + insertValues += col.DataType == typeof(DateTime) ? "'" + Convert.ToDateTime(fieldValue).ToString("yyyy-MM-dd HH:mm:ss") + "'," : "'" + fieldValue + "',"; + } + else + { + if (col.DataType == typeof(Decimal) || col.DataType == typeof(Int32)) + insertValues += "0,"; + else if (col.DataType == typeof(DateTime)) + insertValues += "NULL,"; + else + insertValues += "'',"; + } + } + } + } + updateFields = updateFields.TrimEnd(','); + insertFields = insertFields.TrimEnd(','); + insertValues = insertValues.TrimEnd(','); + + if (!string.IsNullOrEmpty(updateFields)) + { + model.FieldValue = row[_parmaryKey] + ""; + model.BaseSaveType = SaveType.Update; + model.BaseSql = string.Format(updateSql, tableName, updateFields, _parmaryKey, row[_parmaryKey]); + } + if (!string.IsNullOrEmpty(insertFields)) + { + model.BaseSaveType = SaveType.Add; + model.FieldValue = row[_parmaryKey] + ""; + model.BaseSql = string.Format(insertSql, tableName, insertFields, insertValues); + } + mList.Add(model); + } + try + { + // 批量保存数据 + if (BaseModuleImpl.SaveBaseGridData(mList)) + { + (treeMain.TreeListObj.DataSource as DataTable).AcceptChanges(); + if (this.SearchObj != null) + { + this.SearchObj.SearchLastGrid(); + } + MessageUtil.Show(ResourceKeys.SaveSuccess); + } + else + { + StringBuilder builder = new StringBuilder(); + builder.Append("失败列表\r\n"); + foreach (BaseSaveModel item in mList) + { + if (!string.IsNullOrEmpty(item.FaultMsg)) + builder.Append("原因:" + item.FaultMsg + "\r\n"); ; + } + LogHelper.Instance.WriteLog(builder.ToString()); + MessageUtil.Show(builder.ToString()); + } + } + catch (Exception ex) + { + string Message = ErrorMessage.PromptErrorMessage(ex); + MessageUtil.Show(Message, ex.Message); + } + } + } + /// + /// 提交按钮 + /// + private void OnBtnApplyClick(object sender, EventArgs e) + { + TreeListNode focusedNode = treeGridControlEx.TreeListObj.FocusedNode; + DataRow focusedRow = (treeGridControlEx.TreeListObj.GetDataRecordByNode(focusedNode) as DataRowView).Row; + if (!string.IsNullOrEmpty(BomAlterModel.SaveSql)) + { + string pattern = @"(\w+)\((.*?)\)"; + Regex regex = new Regex(pattern); + Match match = regex.Match(BomAlterModel.SaveSql); + if (match.Success) + { + string functionName = match.Groups[1].Value; + string parameters = match.Groups[2].Value; + if (!string.IsNullOrEmpty(functionName)) + { + DataTable sqlParametersTab = BaseImpl.GetDataTableResult($"SELECT PARAMETER_NAME,PARAMETER_MODE,CHARACTER_MAXIMUM_LENGTH,DATA_TYPE FROM INFORMATION_SCHEMA.PARAMETERS WHERE SPECIFIC_NAME = '{functionName}' ORDER BY ORDINAL_POSITION;"); + using (SqlCommand command = new SqlCommand(functionName, SqlHelper._connection)) + { + string[] parametersArray = parameters.Split(','); + foreach (DataRow parameterRow in sqlParametersTab.Rows) + { + string parameterName = parameterRow["PARAMETER_NAME"] + ""; + string parameterMode = parameterRow["PARAMETER_MODE"] + ""; + int.TryParse(parameterRow["CHARACTER_MAXIMUM_LENGTH"] + "", out int dataLength); + string dataType = parameterRow["DATA_TYPE"] + ""; + SqlParameter sqlParameter = null; + if (parameterMode.Equals("int")) + { + sqlParameter = new SqlParameter(parameterName, SqlDbType.Int); + } + else + { + sqlParameter = new SqlParameter(parameterName, SqlDbType.VarChar, dataLength); + } + if (parameterMode.Equals("IN")) + { + sqlParameter.Direction = ParameterDirection.Input; + } + else + { + sqlParameter.Direction = ParameterDirection.Output; + } + command.Parameters.Add(sqlParameter); + } + for (int i = 0; i < command.Parameters.Count; i++) + { + SqlParameter sqlParameter = command.Parameters[i]; + if (parametersArray.Length > i) + { + string commandParameter = parametersArray[i]; + string field = commandParameter.Replace("@", "").Replace("{", "").Replace("}", ""); + string value = focusedRow.Table.Columns.Contains(field) ? focusedRow[field] + "" : commandParameter.Replace("@", ""); + value = SearchObj.ReplaceControlValue(value); + value = TopControlObj.ReplaceControlValue(value); + value = ReplaceControlValue(value, MainControlPanel); + value = value.Replace("@", "").Replace("{", "").Replace("}", ""); + sqlParameter.Value = value; + } + } + SqlParameter returnValue = new SqlParameter("@return", SqlDbType.Int, 4); + returnValue.Direction = ParameterDirection.ReturnValue; + command.Parameters.Add(returnValue); + command.CommandType = CommandType.StoredProcedure; + command.ExecuteNonQuery(); + if ((returnValue.Value + "").Equals("1")) + { + MessageUtil.Show("保存成功"); + } + else + { + SqlParameter outSqlParameter = command.Parameters.Cast().Where(n => n.Direction == ParameterDirection.Output).FirstOrDefault(); + if (outSqlParameter != null) + { + string outMessage = outSqlParameter.Value + ""; + if (!string.IsNullOrEmpty(outMessage)) + { + MessageUtil.Show(outSqlParameter.Value + ""); + } + } + } + } + } + else + { + MessageUtil.Show("保存逻辑配置错误"); + } + } + else + { + MessageUtil.Show("保存逻辑配置错误"); + } + } + else + { + MessageUtil.Show("保存逻辑配置错误,不能为空"); + } + } + /// + /// 批量反写 + /// + /// + /// + private void OnBtnFxSaveClick(object sender, EventArgs e) + { + WaitForm.ShowForm("正在保存数据..."); + try + { + DataTable sourceTable = treeGridControlEx.TreeListObj.DataSource as DataTable; + string pattern = @"(\w+)\((.*?)\)"; + Regex regex = new Regex(pattern); + Match match = regex.Match(BomAlterModel.VerifySql); + if (match.Success) + { + string functionName = match.Groups[1].Value; + string parameters = match.Groups[2].Value; + if (!string.IsNullOrEmpty(functionName)) + { + DataTable sqlParametersTab = BaseImpl.GetDataTableResult($"SELECT PARAMETER_NAME,PARAMETER_MODE,CHARACTER_MAXIMUM_LENGTH,DATA_TYPE FROM INFORMATION_SCHEMA.PARAMETERS WHERE SPECIFIC_NAME = '{functionName}' ORDER BY ORDINAL_POSITION;"); + + foreach (DataRow sourceRow in sourceTable.Rows) + { + string xgtigName = $"{sysModel.PrefixKey}xgtig"; + string idName = $"{sysModel.PrefixKey}id"; + if (sourceRow.Table.Columns.Contains(xgtigName) && (sourceRow[xgtigName] + "").Equals("1")) + { + if (sourceTable.Columns.Contains("Plm_lmb_SmartBmFa")) + { + string projectId = sourceRow["Plm_lmb_SmartBmFa"] + ""; + if (!string.IsNullOrEmpty(projectId)) + { + string id = sourceRow.Table.Columns.Contains(idName) ? sourceRow[idName] + "" : ""; + string specValue = ""; + string modelValue = ""; + string zhsxValue = ""; + string unitValue = ""; + string czValue = ""; + string nameValue = ""; + string sourceSql = GcMainModuleObj.MenuSql; + sourceSql = ReplaceHelper.ReplaceRowParam(sourceRow, sourceSql); + DataTable dataTable = BaseImpl.GetDataTableResult(sourceSql); + List controlList = new List(); + foreach (DataRow item in dataTable.Rows) + { + controlList.Add(new SysSetModel(item)); + } + string primaryVlaue = sourceRow["productid"] + ""; + DataRow selectSource = BaseImpl.GetDataRowResult(string.Format("select * from p_producttab where productid = '{0}'", primaryVlaue)); + if (selectSource == null) + { + primaryVlaue = sourceRow[$"{sysModel.PrefixKey}id"] + ""; + selectSource = BaseImpl.GetDataRowResult($"select * from {sysModel.MenuTable} where {sysModel.PrefixKey}id = '{primaryVlaue}'"); + } + SysSetModel nameModel = controlList.Where(n => n.OrderId.Equals(1)).FirstOrDefault(); + if (nameModel != null) + { + nameValue = selectSource.Table.Columns.Contains(nameModel.DbName) ? selectSource[nameModel.DbName] + "" : ""; + } + //反写规格 + List specModels = controlList.Where(n => n.SpecDbName.Equals(1)).OrderBy(n => n.SpecSort).ToList(); + StringBuilder specText = new StringBuilder(); + for (int i = 0; i < specModels.Count; i++) + { + SysSetModel specModel = specModels[i]; + string value = selectSource.Table.Columns.Contains(specModel.DbName) ? selectSource[specModel.DbName] + "" : ""; + if (!string.IsNullOrWhiteSpace(value)) + { + if (i == 0) + { + specText.Append(string.Format("{0}{1}{2}", specModel.ConnectorStrGg, value, specModel.EndConnectorStrGg)); + } + else + { + specText.Append(string.Format("{0}{1}{2}{3}", specModel.ConnectorStr, specModel.ConnectorStrGg, value, specModel.EndConnectorStrGg)); + } + } + } + specValue = specText.ToString(); + //反写型号 + List modelModels = controlList.Where(n => n.ModelDbName.Equals(1)).OrderBy(n => n.ModelSort).ToList(); + StringBuilder modelText = new StringBuilder(); + for (int i = 0; i < modelModels.Count; i++) + { + SysSetModel modelModel = modelModels[i]; + string value = selectSource.Table.Columns.Contains(modelModel.DbName) ? selectSource[modelModel.DbName] + "" : ""; + if (!string.IsNullOrWhiteSpace(value)) + { + if (i == 0) + { + modelText.Append(string.Format("{0}{1}{2}", modelModel.ConnectorStrGg, value, modelModel.EndConnectorStrGg)); + } + else + { + modelText.Append(string.Format("{0}{1}{2}{3}", modelModel.ConnectorStr, modelModel.ConnectorStrGg, value, modelModel.EndConnectorStrGg)); + } + } + } + modelValue = modelText.ToString(); + //反写综合属性 + List zhsxModels = controlList.Where(n => n.ZhSxdbName.Equals(1)).OrderBy(n => n.ProDeSort).ToList(); + StringBuilder zhsxText = new StringBuilder(); + for (int i = 0; i < zhsxModels.Count; i++) + { + SysSetModel zhsxModel = zhsxModels[i]; + string value = selectSource.Table.Columns.Contains(zhsxModel.DbName) ? selectSource[zhsxModel.DbName] + "" : ""; + if (value.Equals("无")) + { + value = ""; + } + if (!string.IsNullOrWhiteSpace(value)) + { + if (i == 0) + { + zhsxText.Append(string.Format("{0}{1}{2}", zhsxModel.ConnectorStrZhsx, value, zhsxModel.EndConnectorStrZhsx)); + } + else + { + zhsxText.Append(string.Format("{0}{1}{2}{3}", zhsxModel.ConnectorStr, zhsxModel.ConnectorStrZhsx, value, zhsxModel.EndConnectorStrZhsx)); + } + } + } + zhsxValue = zhsxText.ToString(); + //反写材质属性 + List czModels = controlList.Where(n => n.CzdbName.Equals(1)).OrderBy(n => n.GradeSort).ToList(); + StringBuilder czText = new StringBuilder(); + for (int i = 0; i < czModels.Count; i++) + { + SysSetModel czModel = czModels[i]; + string value = selectSource.Table.Columns.Contains(czModel.DbName) ? selectSource[czModel.DbName] + "" : ""; + if (value.Equals("无")) + { + value = ""; + } + if (!string.IsNullOrWhiteSpace(value)) + { + if (i == 0) + { + czText.Append(string.Format("{0}{1}{2}", czModel.ConnectorStrCz, value, czModel.EndConnectorStrCz)); + } + else + { + czText.Append(string.Format("{0}{1}{2}{3}", czModel.ConnectorStr, czModel.ConnectorStrCz, value, czModel.EndConnectorStrCz)); + } + } + } + czValue = czText.ToString(); + using (SqlCommand command = new SqlCommand(functionName, SqlHelper._connection)) + { + string[] parametersArray = parameters.Split(','); + foreach (DataRow parameterRow in sqlParametersTab.Rows) + { + string parameterName = parameterRow["PARAMETER_NAME"] + ""; + string parameterMode = parameterRow["PARAMETER_MODE"] + ""; + int.TryParse(parameterRow["CHARACTER_MAXIMUM_LENGTH"] + "", out int dataLength); + string dataType = parameterRow["DATA_TYPE"] + ""; + SqlParameter sqlParameter = null; + if (parameterMode.Equals("int")) + { + sqlParameter = new SqlParameter(parameterName, SqlDbType.Int); + } + else + { + sqlParameter = new SqlParameter(parameterName, SqlDbType.VarChar, dataLength); + } + if (parameterMode.Equals("IN")) + { + sqlParameter.Direction = ParameterDirection.Input; + } + else + { + sqlParameter.Direction = ParameterDirection.Output; + } + command.Parameters.Add(sqlParameter); + } + for (int i = 0; i < command.Parameters.Count; i++) + { + SqlParameter sqlParameter = command.Parameters[i]; + if (parametersArray.Length > i) + { + string commandParameter = parametersArray[i]; + string field = commandParameter.Replace("@", "").Replace("{", "").Replace("}", ""); + string value = ""; + if (field.Equals("spec")) + { + value = specValue; + } + else if (field.Equals("model")) + { + value = modelValue; + } + else if (field.Equals("grade")) + { + value = czValue; + } + else if (field.Equals("productdescrip")) + { + value = zhsxValue; + } + else if (field.Equals("appellation")) + { + value = nameValue; + } + else + { + value = sourceRow.Table.Columns.Contains(field) ? sourceRow[field] + "" : commandParameter.Replace("@", ""); + value = value.Replace("@", "").Replace("{", "").Replace("}", ""); + } + sqlParameter.Value = value; + } + } + SqlParameter returnValue = new SqlParameter("@return", SqlDbType.Int, 4); + returnValue.Direction = ParameterDirection.ReturnValue; + command.Parameters.Add(returnValue); + command.CommandType = CommandType.StoredProcedure; + command.ExecuteNonQuery(); + } + } + } + } + } + } + else + { + MessageUtil.Show("保存逻辑配置错误"); + } + } + else + { + MessageUtil.Show("保存逻辑配置错误"); + } + } + catch (Exception) + { + } + finally + { + WaitForm.HideForm(); + SearchObj.SearchGrid(); + } + } + /// + /// 自动刷新 + /// + /// + /// + private void OnSearchObjDataSourceBindCallBack(object sender, EventArgs e) + { + if (sysModel.CsHasDefultSearch) + { + SearchObj.SearchGrid(); + } + } + /// + /// 查询后事件 + /// + /// + /// + private void OnSearchObjSearchAfterCallBack(object sender, EventArgs e) + { + try + { + btnFxSave.Enabled = false; + string xgtigName = $"{sysModel.PrefixKey}xgtig"; + DataTable sourceTable = treeGridControlEx.TreeListObj.DataSource as DataTable; + if (sourceTable != null && sourceTable.Columns.Contains(xgtigName)) + { + var selectRows = sourceTable.AsEnumerable().Where(n => (n[xgtigName] + "").Equals("1")); + btnFxSave.Enabled = selectRows.Count() > 0; + } + this.OnAfterDataSourceCallback -= OnAfterDataSource; + TreeListNode focusedNode = TreeGridObj.TreeListObj.FocusedNode; + if (focusedNode != null) + { + DataRow dataRow = (TreeGridObj.TreeListObj.GetDataRecordByNode(focusedNode) as DataRowView).Row; + if (dataRow.Table.Columns.Contains("Plm_lmb_SmartBmFa")) + { + string projectId = dataRow["Plm_lmb_SmartBmFa"] + ""; + this.OnAfterDataSourceCallback += OnAfterDataSource; + SetDynamicControl(projectId); + } + } + } + catch (Exception ex) + { + MessageUtil.Show(ex.Message); + } + } + + + /// + /// 设置上方控件值 + /// + /// + /// + private void TopControlObj_OnDataSourceBindCallBack(object sender, EventArgs e) + { + if (BomAlterModel != null && BomAlterModel.MaintabFocusedRow != null) + { + TopControlObj.SetAllControlValue(BomAlterModel.MaintabFocusedRow); + } + } + } +} diff --git a/插件库/Lskj.PubBomAlter/FrmMain.resx b/插件库/Lskj.PubBomAlter/FrmMain.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/插件库/Lskj.PubBomAlter/FrmMain.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/插件库/Lskj.PubBomAlter/Lskj.PubBomAlter.csproj b/插件库/Lskj.PubBomAlter/Lskj.PubBomAlter.csproj new file mode 100644 index 0000000..0038878 --- /dev/null +++ b/插件库/Lskj.PubBomAlter/Lskj.PubBomAlter.csproj @@ -0,0 +1,131 @@ + + + + + Debug + AnyCPU + {D6C0C7F7-23CE-4A7F-8E13-89A7948CF4A4} + Library + Lskj.PubBomAlter + Lskj.PubBomAlter + v4.0 + 512 + true + + + + + x86 + true + full + false + ..\..\Debug\Lib\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + False + ..\..\引用DLL\Newtonsoft.Json.dll + + + + + + + + + + + + + + + + + Form + + + FrmMain.cs + + + + + + + FrmMain.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + True + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + {7EAFCCC2-A18F-49E9-85C6-A984966CFD01} + Lskj.Business + + + {447CDC40-659F-4CCA-9ED6-8E818B4CF8BF} + Lskj.Control + + + {2a1be6ac-1077-491b-a754-c5822fe8121e} + Lskj.Core + + + {308B9B18-9BE2-495C-9C64-EED81D567813} + Lskj.Data + + + {24E9A18A-BAF8-4052-809E-582B4FC6A8C4} + Lskj.Interface.Api + + + {52BC40E0-C0C6-4F78-996B-CAE028D209CA} + Lskj.Model + + + {A51BF642-6543-4DE3-8948-83F558B72BD4} + Lskj.Util + + + + + + + \ No newline at end of file diff --git a/插件库/Lskj.PubBomAlter/Model/ComboBoxModel.cs b/插件库/Lskj.PubBomAlter/Model/ComboBoxModel.cs new file mode 100644 index 0000000..afea02b --- /dev/null +++ b/插件库/Lskj.PubBomAlter/Model/ComboBoxModel.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; + +namespace Lskj.PubBomAlter.Model +{ + public class ComboBoxModel + { + public ComboBoxModel(DataRow _rowItem) + { + SourceItem = _rowItem; + } + public DataRow SourceItem; + public string ValueMember; + public string DisplayMember; + public string Text + { + get + { + return SourceItem[DisplayMember] + ""; + } + } + public string Value + { + get + { + return SourceItem[ValueMember] + ""; + } + } + + public override string ToString() + { + return SourceItem[DisplayMember] + ""; + } + } +} diff --git a/插件库/Lskj.PubBomAlter/Model/ProjectModel.cs b/插件库/Lskj.PubBomAlter/Model/ProjectModel.cs new file mode 100644 index 0000000..030e3f0 --- /dev/null +++ b/插件库/Lskj.PubBomAlter/Model/ProjectModel.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Lskj.PubBomAlter.Model +{ + public class ProjectModel + { + public ProjectModel(object editText, object valueText) + { + this.EditText = editText; + this.ValueText = valueText; + } + public object EditText { get; set; } + public object ValueText { get; set; } + public override string ToString() + { + return EditText != null ? this.EditText.ToString() : ""; + } + } +} diff --git a/插件库/Lskj.PubBomAlter/Model/SysSetModel.cs b/插件库/Lskj.PubBomAlter/Model/SysSetModel.cs new file mode 100644 index 0000000..579b2cc --- /dev/null +++ b/插件库/Lskj.PubBomAlter/Model/SysSetModel.cs @@ -0,0 +1,281 @@ +using Lskj.Control.Model; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; + +namespace Lskj.PubBomAlter.Model +{ + /// + /// PubProductSysMge实体类 + /// + public class SysSetModel : ControlModel + { + /// + /// 数据源 + /// + public DataRow SourceRow; + public int Id { get; set; } + public int GroupId { get; set; } + /// + /// 方案名称 + /// + public string GroupName { get; set; } + /// + /// 序号 + /// + public int OrderId { get; set; } + /// + /// 反写规格序号 + /// + public int SpecSort { get; set; } + /// + /// 反写型号序号 + /// + public int ModelSort { get; set; } + /// + /// 反写综合属性序号 + /// + public int ProDeSort { get; set; } + /// + /// 反写材质序号 + /// + public int GradeSort { get; set; } + /// + /// 节点 + /// + public string SpeciesId { get; set; } + /// + /// 节点名 + /// + public string SpeciesName { get; set; } + /// + /// 参数名 + /// + public string SysName { get; set; } + public int SysCount { get; set; } + public int SysInt { get; set; } + /// + /// 备注 + /// + public string SysInfo { get; set; } + //禁用标识 + public int Ban { get; set; } + /// + /// 类型 ,1仅限选择,2仅限输入 + /// + public string Item { get; set; } + public string XZ1 { get; set; } + /// + /// 反写字段 + /// + public string DbName { get; set; } + public int? DbNameCount { get; set; } + /// + /// 是否反写规格 + /// + public int? SpecDbName { get; set; } + /// + /// 是否反写型号 + /// + public int? ModelDbName { get; set; } + /// + /// 是否反写综合属性 + /// + public int? ZhSxdbName { get; set; } + /// + /// 是否反写材质 + /// + public int? CzdbName { get; set; } + /// + /// 反写规格型号类型 + /// + public string FxType { get; set; } + /// + /// 反写字段类型 + /// + public string FxTypeDB { get; set; } + /// + /// 数据源来源类型 + /// + public string DataSourceType { get; set; } + /// + /// 数据源来源sql + /// + public string DataSourceSql { get; set; } + /// + /// 生成BOM标识 + /// + public int? BomTig { get; set; } + /// + /// 连接符 + /// + public string ConnectorStr { get; set; } + /// + /// 默认编码 + /// + public string DefaultID { get; set; } + /// + /// 默认名称 + /// + public string DefaultName { get; set; } + /// + /// 必填标识 + /// + public int? MustTig { get; set; } + /// + /// 关联字段 + /// + public string UnionFields { get; set; } + /// + /// 关联值 + /// + /// The union values. + public string UnionValues { get; set; } + /// + /// 禁编 + /// + /// The union values. + public bool ProhibitEdited { get; set; } + /// + /// 排序字段 + /// + /// The union values. + public string OrderField { get; set; } + /// + /// 日期格式 + /// + public string DataFormat { get; set; } + /// + /// 必填条件 + /// + public string RequiredCond { get; set; } + + /// + /// 连接符(后方) + /// + public string EndConnectorStr { get; set; } + + + /// + /// 反写类型(反写规格) + /// + public string FxTypeGg { get; set; } + /// + /// 反写类型(反写型号) + /// + public string FxTypeXh { get; set; } + /// + /// 反写类型(反写综合属性) + /// + public string FxTypeZhsx { get; set; } + /// + /// 反写类型(反写材质) + /// + public string FxTypeCz { get; set; } + + + /// + /// 前连接符 (反写规格) + /// + public string ConnectorStrGg { get; set; } + // + /// 后连接符 (反写规格) + /// + public string EndConnectorStrGg { get; set; } + /// + /// 前连接符 (反写型号) + /// + public string ConnectorStrXh { get; set; } + // + /// 后连接符 (反写型号) + /// + public string EndConnectorStrXh { get; set; } + /// + /// 前连接符 (反写综合属性) + /// + public string ConnectorStrZhsx { get; set; } + // + /// 后连接符 (反写综合属性) + /// + public string EndConnectorStrZhsx { get; set; } + /// + /// 前连接符 (反写材质) + /// + public string ConnectorStrCz { get; set; } + // + /// 后连接符 (反写材质) + /// + public string EndConnectorStrCz { get; set; } + + + public SysSetModel(DataRow rowItem) + { + this.SourceRow = rowItem; + this.Id = rowItem.Table.Columns.Contains("id") && int.TryParse(rowItem["id"] + "", out int id) ? id : 0; + this.GroupId = rowItem.Table.Columns.Contains("Groupid") && int.TryParse(rowItem["Groupid"] + "", out int groupId) ? groupId : 0; + this.GroupName = rowItem.Table.Columns.Contains("GroupName") ? rowItem["GroupName"] + "" : ""; + this.OrderId = rowItem.Table.Columns.Contains("orderid") && int.TryParse(rowItem["orderid"] + "", out int orderid) ? orderid : 0; + this.SpecSort = rowItem.Table.Columns.Contains("SpecSort") && int.TryParse(rowItem["SpecSort"] + "", out int specSort) ? specSort : 0; + this.ModelSort = rowItem.Table.Columns.Contains("ModelSort") && int.TryParse(rowItem["ModelSort"] + "", out int modelSort) ? modelSort : 0; + this.ProDeSort = rowItem.Table.Columns.Contains("ProDeSort") && int.TryParse(rowItem["ProDeSort"] + "", out int proDeSort) ? proDeSort : 0; + this.GradeSort = rowItem.Table.Columns.Contains("GradeSort") && int.TryParse(rowItem["GradeSort"] + "", out int gradeSort) ? gradeSort : 0; + this.SpeciesId = rowItem.Table.Columns.Contains("speciesid") ? rowItem["speciesid"] + "" : ""; + this.SpeciesName = rowItem.Table.Columns.Contains("speciesname") ? rowItem["speciesname"] + "" : ""; + this.SysName = rowItem.Table.Columns.Contains("sysname") ? rowItem["sysname"] + "" : ""; + this.SysCount = rowItem.Table.Columns.Contains("syscount") && int.TryParse(rowItem["syscount"] + "", out int syscount) ? syscount : 0; + this.SysInt = rowItem.Table.Columns.Contains("sysint") && int.TryParse(rowItem["sysint"] + "", out int sysint) ? sysint : 0; + this.SysInfo = rowItem.Table.Columns.Contains("sysinfo") ? rowItem["sysinfo"] + "" : ""; + this.Ban = rowItem.Table.Columns.Contains("ban") && int.TryParse(rowItem["ban"] + "", out int ban) ? ban : 0; + this.Item = rowItem.Table.Columns.Contains("Item") ? rowItem["Item"] + "" : ""; + this.XZ1 = rowItem.Table.Columns.Contains("XZ1") ? rowItem["XZ1"] + "" : ""; + this.DbName = rowItem.Table.Columns.Contains("dbname") ? rowItem["dbname"] + "" : ""; + this.DbNameCount = rowItem.Table.Columns.Contains("dbnameCount") ? rowItem["dbnameCount"] == DBNull.Value ? (int?)null : Convert.ToInt32(rowItem["dbnameCount"] + "") : 0; + this.SpecDbName = rowItem.Table.Columns.Contains("specdbname") ? rowItem["specdbname"] == DBNull.Value ? (int?)null : Convert.ToInt32(rowItem["specdbname"] + "") : 0; + this.ModelDbName = rowItem.Table.Columns.Contains("modeldbname") ? rowItem["modeldbname"] == DBNull.Value ? (int?)null : Convert.ToInt32(rowItem["modeldbname"] + "") : 0; + this.ZhSxdbName = rowItem.Table.Columns.Contains("ZhSxdbName") ? rowItem["ZhSxdbName"] == DBNull.Value ? (int?)null : Convert.ToInt32(rowItem["ZhSxdbName"] + "") : 0; + this.CzdbName = rowItem.Table.Columns.Contains("CzdbName") ? rowItem["CzdbName"] == DBNull.Value ? (int?)null : Convert.ToInt32(rowItem["CzdbName"] + "") : 0; + this.FxType = rowItem.Table.Columns.Contains("FxType") ? rowItem["FxType"] + "" : ""; + this.FxTypeDB = rowItem.Table.Columns.Contains("FxTypeDB") ? rowItem["FxTypeDB"] + "" : ""; + this.DataSourceType = rowItem.Table.Columns.Contains("DataSourceType") ? rowItem["DataSourceType"] + "" : ""; + this.DataSourceSql = rowItem.Table.Columns.Contains("DataSourceSql") ? rowItem["DataSourceSql"] + "" : ""; + this.BomTig = rowItem.Table.Columns.Contains("BomTig") ? rowItem["BomTig"] == DBNull.Value ? (int?)null : Convert.ToInt32(rowItem["BomTig"] + "") : 0; + + this.ConnectorStr = rowItem.Table.Columns.Contains("ConnectorStr") ? rowItem["ConnectorStr"] + "" : ""; + this.EndConnectorStr = rowItem.Table.Columns.Contains("EndConnectorStr") ? rowItem["EndConnectorStr"] + "" : ""; + + this.DefaultID = rowItem.Table.Columns.Contains("defaultID") ? rowItem["defaultID"] + "" : ""; + this.DefaultName = rowItem.Table.Columns.Contains("defaultName") ? rowItem["defaultName"] + "" : ""; + this.MustTig = rowItem.Table.Columns.Contains("musttig") ? rowItem["musttig"] == DBNull.Value ? (int?)null : Convert.ToInt32(rowItem["musttig"] + "") : 0; + this.UnionFields = rowItem.Table.Columns.Contains("RelevanceField") ? rowItem["RelevanceField"] + "" : ""; + this.UnionValues = rowItem.Table.Columns.Contains("RelevanceValue") ? rowItem["RelevanceValue"] + "" : ""; + this.ProhibitEdited = rowItem.Table.Columns.Contains("ProhibitEdited") ? "1".Equals(rowItem["ProhibitEdited"] + "") : false; + this.LookUpFieldsWidth = rowItem.Table.Columns.Contains("LookUpFieldsWidth") ? rowItem["LookUpFieldsWidth"] + "" : ""; + this.LookUpWidth = 0; + this.OrderField = rowItem.Table.Columns.Contains("lsidx_id") ? rowItem["lsidx_id"] + "" : ""; + this.DataFormat = rowItem.Table.Columns.Contains("DataFormat") ? rowItem["DataFormat"] + "" : ""; + this.RequiredCond = rowItem.Table.Columns.Contains("RequiredCond") ? rowItem["RequiredCond"] + "" : ""; + this.DisableCond = rowItem.Table.Columns.Contains("DisableCond") ? rowItem["DisableCond"] + "" : ""; + + + this.FxTypeGg = rowItem.Table.Columns.Contains("FxTypeGg") && !string.IsNullOrEmpty(rowItem["FxTypeGg"] + "") ? rowItem["FxTypeGg"] + "" : this.FxType; + this.FxTypeXh = rowItem.Table.Columns.Contains("FxTypeXh") && !string.IsNullOrEmpty(rowItem["FxTypeXh"] + "") ? rowItem["FxTypeXh"] + "" : this.FxType; + this.FxTypeZhsx = rowItem.Table.Columns.Contains("FxTypeZhsx") && !string.IsNullOrEmpty(rowItem["FxTypeZhsx"] + "") ? rowItem["FxTypeZhsx"] + "" : this.FxType; + this.FxTypeCz = rowItem.Table.Columns.Contains("FxTypeCz") && !string.IsNullOrEmpty(rowItem["FxTypeCz"] + "") ? rowItem["FxTypeCz"] + "" : this.FxType; + + this.ConnectorStrGg = rowItem.Table.Columns.Contains("ConnectorStrGg") && !string.IsNullOrEmpty(rowItem["ConnectorStrGg"] + "") ? rowItem["ConnectorStrGg"] + "" : ""; + this.EndConnectorStrGg = rowItem.Table.Columns.Contains("EndConnectorStrGg") && !string.IsNullOrEmpty(rowItem["EndConnectorStrGg"] + "") ? rowItem["EndConnectorStrGg"] + "" : ""; + + this.ConnectorStrXh = rowItem.Table.Columns.Contains("ConnectorStrXh") && !string.IsNullOrEmpty(rowItem["ConnectorStrXh"] + "") ? rowItem["ConnectorStrXh"] + "" : ""; + this.EndConnectorStrXh = rowItem.Table.Columns.Contains("EndConnectorStrXh") && !string.IsNullOrEmpty(rowItem["EndConnectorStrXh"] + "") ? rowItem["EndConnectorStrXh"] + "" : ""; + + this.ConnectorStrZhsx = rowItem.Table.Columns.Contains("ConnectorStrZhsx") && !string.IsNullOrEmpty(rowItem["ConnectorStrZhsx"] + "") ? rowItem["ConnectorStrZhsx"] + "" : ""; + this.EndConnectorStrZhsx = rowItem.Table.Columns.Contains("EndConnectorStrZhsx") && !string.IsNullOrEmpty(rowItem["EndConnectorStrZhsx"] + "") ? rowItem["EndConnectorStrZhsx"] + "" : ""; + + this.ConnectorStrCz = rowItem.Table.Columns.Contains("ConnectorStrCz") && !string.IsNullOrEmpty(rowItem["ConnectorStrCz"] + "") ? rowItem["ConnectorStrCz"] + "" : ""; + this.EndConnectorStrCz = rowItem.Table.Columns.Contains("EndConnectorStrCz") && !string.IsNullOrEmpty(rowItem["EndConnectorStrCz"] + "") ? rowItem["EndConnectorStrCz"] + "" : ""; + + } + } +} diff --git a/插件库/Lskj.PubBomAlter/Properties/AssemblyInfo.cs b/插件库/Lskj.PubBomAlter/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..8f800d1 --- /dev/null +++ b/插件库/Lskj.PubBomAlter/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的一般信息由以下 +// 控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("Lskj.PubBomAlter")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Lskj.PubBomAlter")] +[assembly: AssemblyCopyright("Copyright © 2024")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 会使此程序集中的类型 +//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 +//请将此类型的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("d6c0c7f7-23ce-4a7f-8e13-89a7948cf4a4")] + +// 程序集的版本信息由下列四个值组成: +// +// 主版本 +// 次版本 +// 生成号 +// 修订号 +// +//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 +//通过使用 "*",如下所示: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/插件库/Lskj.PubBomAlter/Properties/Resources.Designer.cs b/插件库/Lskj.PubBomAlter/Properties/Resources.Designer.cs new file mode 100644 index 0000000..0e20115 --- /dev/null +++ b/插件库/Lskj.PubBomAlter/Properties/Resources.Designer.cs @@ -0,0 +1,73 @@ +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本:4.0.30319.42000 +// +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 +// +//------------------------------------------------------------------------------ + +namespace Lskj.PubBomAlter.Properties { + using System; + + + /// + /// 一个强类型的资源类,用于查找本地化的字符串等。 + /// + // 此类是由 StronglyTypedResourceBuilder + // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 + // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen + // (以 /str 作为命令选项),或重新生成 VS 项目。 + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// 返回此类使用的缓存的 ResourceManager 实例。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Lskj.PubBomAlter.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// 重写当前线程的 CurrentUICulture 属性,对 + /// 使用此强类型资源类的所有资源查找执行重写。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap update { + get { + object obj = ResourceManager.GetObject("update", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/插件库/Lskj.PubBomAlter/Properties/Resources.resx b/插件库/Lskj.PubBomAlter/Properties/Resources.resx new file mode 100644 index 0000000..9533901 --- /dev/null +++ b/插件库/Lskj.PubBomAlter/Properties/Resources.resx @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + ..\Resources\update.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/插件库/Lskj.PubBomAlter/Properties/Settings.Designer.cs b/插件库/Lskj.PubBomAlter/Properties/Settings.Designer.cs new file mode 100644 index 0000000..533b9ac --- /dev/null +++ b/插件库/Lskj.PubBomAlter/Properties/Settings.Designer.cs @@ -0,0 +1,29 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + + +namespace Lskj.PubBomAlter.Properties +{ + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/插件库/Lskj.PubBomAlter/Properties/Settings.settings b/插件库/Lskj.PubBomAlter/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/插件库/Lskj.PubBomAlter/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/插件库/Lskj.PubBomAlter/Resources/update.png b/插件库/Lskj.PubBomAlter/Resources/update.png new file mode 100644 index 0000000..02e61f6 Binary files /dev/null and b/插件库/Lskj.PubBomAlter/Resources/update.png differ diff --git a/插件库/Lskj.PubBomAlter/app.config b/插件库/Lskj.PubBomAlter/app.config new file mode 100644 index 0000000..2c604d3 --- /dev/null +++ b/插件库/Lskj.PubBomAlter/app.config @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file