From ce90860163ee8fa78f42a77634b7e274f144d5ec Mon Sep 17 00:00:00 2001 From: wyf Date: Thu, 20 Mar 2025 08:16:32 +0000 Subject: [PATCH] SVN r360 SVN-Revision: r360 --- 插件库/Lskj.PubBomImport/DllBaseClass.cs | 111 ++ .../Lskj.PubBomImport/FrmBillInfo.Designer.cs | 721 +++++++ 插件库/Lskj.PubBomImport/FrmBillInfo.cs | 331 ++++ 插件库/Lskj.PubBomImport/FrmBillInfo.resx | 120 ++ 插件库/Lskj.PubBomImport/FrmMain.Designer.cs | 290 +++ 插件库/Lskj.PubBomImport/FrmMain.cs | 1668 +++++++++++++++++ 插件库/Lskj.PubBomImport/FrmMain.resx | 120 ++ .../Lskj.PubBomImport.csproj | 118 ++ .../Properties/AssemblyInfo.cs | 9 + 9 files changed, 3488 insertions(+) create mode 100644 插件库/Lskj.PubBomImport/DllBaseClass.cs create mode 100644 插件库/Lskj.PubBomImport/FrmBillInfo.Designer.cs create mode 100644 插件库/Lskj.PubBomImport/FrmBillInfo.cs create mode 100644 插件库/Lskj.PubBomImport/FrmBillInfo.resx create mode 100644 插件库/Lskj.PubBomImport/FrmMain.Designer.cs create mode 100644 插件库/Lskj.PubBomImport/FrmMain.cs create mode 100644 插件库/Lskj.PubBomImport/FrmMain.resx create mode 100644 插件库/Lskj.PubBomImport/Lskj.PubBomImport.csproj create mode 100644 插件库/Lskj.PubBomImport/Properties/AssemblyInfo.cs diff --git a/插件库/Lskj.PubBomImport/DllBaseClass.cs b/插件库/Lskj.PubBomImport/DllBaseClass.cs new file mode 100644 index 0000000..eee1110 --- /dev/null +++ b/插件库/Lskj.PubBomImport/DllBaseClass.cs @@ -0,0 +1,111 @@ +/****************************** +* 说明:PubSpec 模块 +* 创建人:龚宇超 +* 创建日期:2018-01-02 +* 修改人: +* 修改日期: +* 修改备注: +* 版本:1.0.0.0 +******************************/ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Lskj.Util; +using Lskj.Business; +using System.Windows.Forms; +using Lskj.Model; +using DevExpress.XtraGrid.Views.Grid; +using Newtonsoft.Json.Linq; +using Newtonsoft.Json; +using System.Data; + +namespace Lskj.PubBomImport +{ + /// + /// PubSpec 模块 + /// + public class DllBaseClass : IForm + { + public DllBaseClass() + { + + } + public DllBaseClass(string[] obj) + { + try + { + FrmMain main = new FrmMain(); + this.SubForm = main; + main.Model = new DynamicBomImport(obj); + } + catch (Exception ex) + { + LogUtil.WriteError("Lskj.PubSpecialImport.dll--参数错误-->" + obj.ToString(), ex); + } + } + public Form SubForm { get; set; } + } + /// + /// PubSpecialImport入库参数 + /// + public class DynamicBomImport : DynamicModel + { + public string MenuName = ""; + public string FirstRowIndex = ""; + public string SpecialValueIndex = ""; + public string SheetName = ""; + /// + /// 读取筛选条件 + /// + public string ReadTableCond = ""; + /// + /// 忽略合并明细列标题行 + /// + public bool CustomerServiceApp = false; + /// + /// 显示模式,如果为1则隐藏配置界面 + /// + public string ShowType = ""; + /// + /// 单据 BillMasterSql + /// + public string BillMasterSql = ""; + /// + /// 单据 BillDetailSql + /// + public string BillDetailSql = ""; + public DynamicBomImport(string[] args) + : base(args) + { + // 右键菜单打开的模块没有moduleId,部分特殊模块没有moduleId比如添加界面. + MenuName = args[0]; + 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])) + { + FirstRowIndex = args[7] + ""; + } + if (args.Length > 8 && !string.IsNullOrWhiteSpace(args[8])) + { + SpecialValueIndex = args[8] + ""; + } + if (args.Length > 9 && !string.IsNullOrWhiteSpace(args[9])) + { + SheetName = args[9] + ""; + } + if (args.Length > 10 && !string.IsNullOrWhiteSpace(args[10])) + { + ReadTableCond = args[10] + ""; + } + if (args.Length > 11 && !string.IsNullOrWhiteSpace(args[11])) + { + CustomerServiceApp = (args[11] + "").Equals("1"); + } + if (args.Length > 12 && !string.IsNullOrWhiteSpace \ No newline at end of file diff --git a/插件库/Lskj.PubBomImport/FrmBillInfo.Designer.cs b/插件库/Lskj.PubBomImport/FrmBillInfo.Designer.cs new file mode 100644 index 0000000..701bb93 --- /dev/null +++ b/插件库/Lskj.PubBomImport/FrmBillInfo.Designer.cs @@ -0,0 +1,721 @@ + +namespace Lskj.PubBomImport +{ + partial class FrmBillInfo + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.pl_main = new DevExpress.XtraEditors.PanelControl(); + this.pl_main_center = new DevExpress.XtraEditors.PanelControl(); + this.pl_main_center_detail = new DevExpress.XtraEditors.PanelControl(); + this.gcMain = new Lskj.Control.GridControlEx(); + this.pl_main_center_master = new DevExpress.XtraEditors.XtraScrollableControl(); + this.pl_treeview_detault_search = new DevExpress.XtraEditors.PanelControl(); + this.panelControl4 = new DevExpress.XtraEditors.PanelControl(); + this.textEdit1 = new DevExpress.XtraEditors.TextEdit(); + this.lceCombobox = new Lskj.Control.LabelComboxEdit(); + this.panelControl3 = new DevExpress.XtraEditors.PanelControl(); + this.btnTreeSearch = new DevExpress.XtraEditors.SimpleButton(); + this.pl_main_bottom = new DevExpress.XtraEditors.PanelControl(); + this.dbpFP = new DevExpress.XtraEditors.DropDownButton(); + this.btnRefresh = new DevExpress.XtraEditors.SimpleButton(); + this.btnHiding = new DevExpress.XtraEditors.SimpleButton(); + this.btnHelp = new DevExpress.XtraEditors.SimpleButton(); + this.pl_templete = new DevExpress.XtraEditors.PanelControl(); + this.cb_templete = new DevExpress.XtraEditors.ComboBoxEdit(); + this.lbl_templete = new DevExpress.XtraEditors.LabelControl(); + this.pl_input = new DevExpress.XtraEditors.PanelControl(); + this.cb_input = new DevExpress.XtraEditors.ComboBoxEdit(); + this.txt_input = new DevExpress.XtraEditors.TextEdit(); + this.labelControl2 = new DevExpress.XtraEditors.LabelControl(); + this.btn_input = new DevExpress.XtraEditors.SimpleButton(); + this.dpbImport = new DevExpress.XtraEditors.DropDownButton(); + this.btnBillAdd = new DevExpress.XtraEditors.SimpleButton(); + this.btnBillApply = new DevExpress.XtraEditors.SimpleButton(); + this.dpCopyBill = new DevExpress.XtraEditors.DropDownButton(); + this.btnPrint = new DevExpress.XtraEditors.DropDownButton(); + this.dpbTools = new DevExpress.XtraEditors.DropDownButton(); + this.btnDelete = new DevExpress.XtraEditors.SimpleButton(); + this.btnBillSave = new DevExpress.XtraEditors.SimpleButton(); + this.pl_main_top = new DevExpress.XtraEditors.PanelControl(); + this.pl_main_top_center = new DevExpress.XtraEditors.PanelControl(); + this.lbTitle = new System.Windows.Forms.Label(); + this.pl_main_top_right = new DevExpress.XtraEditors.PanelControl(); + this.lblOrderNo = new DevExpress.XtraEditors.LabelControl(); + this.labelControl1 = new DevExpress.XtraEditors.LabelControl(); + this.pl_main_top_left = new DevExpress.XtraEditors.PanelControl(); + this.pl_red = new DevExpress.XtraEditors.PanelControl(); + this.rdRed = new System.Windows.Forms.RadioButton(); + this.pl_blue = new DevExpress.XtraEditors.PanelControl(); + this.rdBlue = new System.Windows.Forms.RadioButton(); + ((System.ComponentModel.ISupportInitialize)(this.pl_main)).BeginInit(); + this.pl_main.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pl_main_center)).BeginInit(); + this.pl_main_center.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pl_main_center_detail)).BeginInit(); + this.pl_main_center_detail.SuspendLayout(); + this.pl_main_center_master.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pl_treeview_detault_search)).BeginInit(); + this.pl_treeview_detault_search.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.panelControl4)).BeginInit(); + this.panelControl4.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.textEdit1.Properties)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.panelControl3)).BeginInit(); + this.panelControl3.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pl_main_bottom)).BeginInit(); + this.pl_main_bottom.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pl_templete)).BeginInit(); + this.pl_templete.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.cb_templete.Properties)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pl_input)).BeginInit(); + this.pl_input.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.cb_input.Properties)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.txt_input.Properties)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pl_main_top)).BeginInit(); + this.pl_main_top.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pl_main_top_center)).BeginInit(); + this.pl_main_top_center.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pl_main_top_right)).BeginInit(); + this.pl_main_top_right.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pl_main_top_left)).BeginInit(); + this.pl_main_top_left.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pl_red)).BeginInit(); + this.pl_red.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pl_blue)).BeginInit(); + this.pl_blue.SuspendLayout(); + this.SuspendLayout(); + // + // pl_main + // + this.pl_main.Appearance.BackColor = System.Drawing.Color.Transparent; + this.pl_main.Appearance.Options.UseBackColor = true; + this.pl_main.Controls.Add(this.pl_main_center); + this.pl_main.Controls.Add(this.pl_main_bottom); + this.pl_main.Controls.Add(this.pl_main_top); + this.pl_main.Dock = System.Windows.Forms.DockStyle.Fill; + this.pl_main.Location = new System.Drawing.Point(0, 0); + this.pl_main.Name = "pl_main"; + this.pl_main.Size = new System.Drawing.Size(666, 518); + this.pl_main.TabIndex = 2; + // + // pl_main_center + // + this.pl_main_center.Appearance.BackColor = System.Drawing.Color.Transparent; + this.pl_main_center.Appearance.Options.UseBackColor = true; + this.pl_main_center.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder; + this.pl_main_center.Controls.Add(this.pl_main_center_detail); + this.pl_main_center.Controls.Add(this.pl_main_center_master); + this.pl_main_center.Dock = System.Windows.Forms.DockStyle.Fill; + this.pl_main_center.Location = new System.Drawing.Point(2, 40); + this.pl_main_center.Name = "pl_main_center"; + this.pl_main_center.Size = new System.Drawing.Size(662, 439); + this.pl_main_center.TabIndex = 2; + // + // pl_main_center_detail + // + this.pl_main_center_detail.Appearance.BackColor = System.Drawing.Color.Transparent; + this.pl_main_center_detail.Appearance.Options.UseBackColor = true; + this.pl_main_center_detail.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder; + this.pl_main_center_detail.Controls.Add(this.gcMain); + this.pl_main_center_detail.Dock = System.Windows.Forms.DockStyle.Fill; + this.pl_main_center_detail.Location = new System.Drawing.Point(0, 164); + this.pl_main_center_detail.Name = "pl_main_center_detail"; + this.pl_main_center_detail.Size = new System.Drawing.Size(662, 275); + this.pl_main_center_detail.TabIndex = 5; + // + // gcMain + // + this.gcMain.AdapterObj = null; + this.gcMain.BackColor = System.Drawing.Color.Transparent; + this.gcMain.Dock = System.Windows.Forms.DockStyle.Fill; + this.gcMain.Location = new System.Drawing.Point(0, 0); + this.gcMain.Margin = new System.Windows.Forms.Padding(5); + this.gcMain.Name = "gcMain"; + this.gcMain.SiftEnumObj = Lskj.Control.GridControlEx.HeaderSiftEnum.Sum; + this.gcMain.Size = new System.Drawing.Size(662, 275); + this.gcMain.TabIndex = 0; + // + // pl_main_center_master + // + this.pl_main_center_master.AutoScroll = false; + this.pl_main_center_master.Controls.Add(this.pl_treeview_detault_search); + this.pl_main_center_master.Dock = System.Windows.Forms.DockStyle.Top; + this.pl_main_center_master.Location = new System.Drawing.Point(0, 0); + this.pl_main_center_master.Name = "pl_main_center_master"; + this.pl_main_center_master.Size = new System.Drawing.Size(662, 164); + this.pl_main_center_master.TabIndex = 6; + // + // pl_treeview_detault_search + // + this.pl_treeview_detault_search.Appearance.BackColor = System.Drawing.Color.Transparent; + this.pl_treeview_detault_search.Appearance.Options.UseBackColor = true; + this.pl_treeview_detault_search.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder; + this.pl_treeview_detault_search.Controls.Add(this.panelControl4); + this.pl_treeview_detault_search.Controls.Add(this.panelControl3); + this.pl_treeview_detault_search.Location = new System.Drawing.Point(39, 104); + this.pl_treeview_detault_search.Margin = new System.Windows.Forms.Padding(5, 3, 5, 3); + this.pl_treeview_detault_search.Name = "pl_treeview_detault_search"; + this.pl_treeview_detault_search.Size = new System.Drawing.Size(270, 28); + this.pl_treeview_detault_search.TabIndex = 24; + this.pl_treeview_detault_search.Visible = false; + // + // panelControl4 + // + this.panelControl4.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder; + this.panelControl4.Controls.Add(this.textEdit1); + this.panelControl4.Controls.Add(this.lceCombobox); + this.panelControl4.Dock = System.Windows.Forms.DockStyle.Fill; + this.panelControl4.Location = new System.Drawing.Point(0, 0); + this.panelControl4.Name = "panelControl4"; + this.panelControl4.Padding = new System.Windows.Forms.Padding(2, 4, 2, 0); + this.panelControl4.Size = new System.Drawing.Size(206, 28); + this.panelControl4.TabIndex = 25; + // + // textEdit1 + // + this.textEdit1.Dock = System.Windows.Forms.DockStyle.Fill; + this.textEdit1.Location = new System.Drawing.Point(113, 4); + this.textEdit1.Name = "textEdit1"; + this.textEdit1.Properties.Appearance.Font = new System.Drawing.Font("宋体", 10F); + this.textEdit1.Properties.Appearance.Options.UseFont = true; + this.textEdit1.Size = new System.Drawing.Size(91, 20); + this.textEdit1.TabIndex = 5; + // + // lceCombobox + // + this.lceCombobox.BackColor = System.Drawing.SystemColors.Control; + this.lceCombobox.Dock = System.Windows.Forms.DockStyle.Left; + this.lceCombobox.EditText = ""; + this.lceCombobox.Font = new System.Drawing.Font("宋体", 9F); + this.lceCombobox.FontSize = 0F; + this.lceCombobox.LabelText = "查询"; + this.lceCombobox.Location = new System.Drawing.Point(2, 4); + this.lceCombobox.Margin = new System.Windows.Forms.Padding(4); + this.lceCombobox.Model = null; + this.lceCombobox.Name = "lceCombobox"; + this.lceCombobox.NullText = ""; + this.lceCombobox.ReadOnly = false; + this.lceCombobox.Required = false; + this.lceCombobox.Size = new System.Drawing.Size(111, 24); + this.lceCombobox.TabIndex = 4; + // + // panelControl3 + // + this.panelControl3.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder; + this.panelControl3.Controls.Add(this.btnTreeSearch); + this.panelControl3.Dock = System.Windows.Forms.DockStyle.Right; + this.panelControl3.Location = new System.Drawing.Point(206, 0); + this.panelControl3.Name = "panelControl3"; + this.panelControl3.Padding = new System.Windows.Forms.Padding(3); + this.panelControl3.Size = new System.Drawing.Size(64, 28); + this.panelControl3.TabIndex = 25; + // + // btnTreeSearch + // + this.btnTreeSearch.AllowFocus = false; + this.btnTreeSearch.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnTreeSearch.Appearance.Options.UseFont = true; + this.btnTreeSearch.Dock = System.Windows.Forms.DockStyle.Right; + this.btnTreeSearch.Location = new System.Drawing.Point(1, 3); + this.btnTreeSearch.Name = "btnTreeSearch"; + this.btnTreeSearch.Size = new System.Drawing.Size(60, 22); + this.btnTreeSearch.TabIndex = 21; + this.btnTreeSearch.Text = "查询"; + // + // pl_main_bottom + // + this.pl_main_bottom.Appearance.BackColor = System.Drawing.Color.Transparent; + this.pl_main_bottom.Appearance.Options.UseBackColor = true; + this.pl_main_bottom.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder; + this.pl_main_bottom.Controls.Add(this.dbpFP); + this.pl_main_bottom.Controls.Add(this.btnRefresh); + this.pl_main_bottom.Controls.Add(this.btnHiding); + this.pl_main_bottom.Controls.Add(this.btnHelp); + this.pl_main_bottom.Controls.Add(this.pl_templete); + this.pl_main_bottom.Controls.Add(this.pl_input); + this.pl_main_bottom.Controls.Add(this.dpbImport); + this.pl_main_bottom.Controls.Add(this.btnBillAdd); + this.pl_main_bottom.Controls.Add(this.btnBillApply); + this.pl_main_bottom.Controls.Add(this.dpCopyBill); + this.pl_main_bottom.Controls.Add(this.btnPrint); + this.pl_main_bottom.Controls.Add(this.dpbTools); + this.pl_main_bottom.Controls.Add(this.btnDelete); + this.pl_main_bottom.Controls.Add(this.btnBillSave); + this.pl_main_bottom.Dock = System.Windows.Forms.DockStyle.Bottom; + this.pl_main_bottom.Location = new System.Drawing.Point(2, 479); + this.pl_main_bottom.Name = "pl_main_bottom"; + this.pl_main_bottom.Size = new System.Drawing.Size(662, 37); + this.pl_main_bottom.TabIndex = 1; + // + // dbpFP + // + this.dbpFP.AllowFocus = false; + this.dbpFP.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.dbpFP.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.dbpFP.Appearance.Options.UseFont = true; + this.dbpFP.Location = new System.Drawing.Point(-199, 7); + this.dbpFP.Name = "dbpFP"; + this.dbpFP.Size = new System.Drawing.Size(58, 26); + this.dbpFP.TabIndex = 34; + this.dbpFP.Text = "分配"; + // + // btnRefresh + // + this.btnRefresh.AllowFocus = false; + this.btnRefresh.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnRefresh.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnRefresh.Appearance.Options.UseFont = true; + this.btnRefresh.Location = new System.Drawing.Point(-135, 7); + this.btnRefresh.Name = "btnRefresh"; + this.btnRefresh.Size = new System.Drawing.Size(74, 26); + this.btnRefresh.TabIndex = 33; + this.btnRefresh.Text = "刷新列数据"; + // + // btnHiding + // + this.btnHiding.AllowFocus = false; + this.btnHiding.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnHiding.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnHiding.Appearance.Options.UseFont = true; + this.btnHiding.Location = new System.Drawing.Point(-59, 7); + this.btnHiding.Name = "btnHiding"; + this.btnHiding.Size = new System.Drawing.Size(67, 26); + this.btnHiding.TabIndex = 32; + this.btnHiding.Text = "隐藏主表"; + this.btnHiding.Visible = false; + // + // btnHelp + // + this.btnHelp.AllowFocus = false; + this.btnHelp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnHelp.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnHelp.Appearance.Options.UseFont = true; + this.btnHelp.Location = new System.Drawing.Point(10, 7); + this.btnHelp.Name = "btnHelp"; + this.btnHelp.Size = new System.Drawing.Size(67, 26); + this.btnHelp.TabIndex = 30; + this.btnHelp.Text = "帮助文档"; + // + // pl_templete + // + this.pl_templete.Controls.Add(this.cb_templete); + this.pl_templete.Controls.Add(this.lbl_templete); + this.pl_templete.Location = new System.Drawing.Point(3, 3); + this.pl_templete.LookAndFeel.SkinName = "VS2010"; + this.pl_templete.LookAndFeel.Style = DevExpress.LookAndFeel.LookAndFeelStyle.Style3D; + this.pl_templete.Name = "pl_templete"; + this.pl_templete.Size = new System.Drawing.Size(195, 29); + this.pl_templete.TabIndex = 29; + this.pl_templete.Visible = false; + // + // cb_templete + // + this.cb_templete.Location = new System.Drawing.Point(58, 4); + this.cb_templete.Name = "cb_templete"; + this.cb_templete.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] { + new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)}); + this.cb_templete.Properties.DropDownRows = 8; + this.cb_templete.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor; + this.cb_templete.Size = new System.Drawing.Size(133, 20); + this.cb_templete.TabIndex = 19; + // + // lbl_templete + // + this.lbl_templete.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lbl_templete.Location = new System.Drawing.Point(5, 8); + this.lbl_templete.Name = "lbl_templete"; + this.lbl_templete.Size = new System.Drawing.Size(48, 12); + this.lbl_templete.TabIndex = 16; + this.lbl_templete.Text = "选择模版"; + // + // pl_input + // + this.pl_input.Controls.Add(this.cb_input); + this.pl_input.Controls.Add(this.txt_input); + this.pl_input.Controls.Add(this.labelControl2); + this.pl_input.Controls.Add(this.btn_input); + this.pl_input.Location = new System.Drawing.Point(3, 3); + this.pl_input.LookAndFeel.SkinName = "VS2010"; + this.pl_input.LookAndFeel.Style = DevExpress.LookAndFeel.LookAndFeelStyle.Style3D; + this.pl_input.Name = "pl_input"; + this.pl_input.Size = new System.Drawing.Size(280, 29); + this.pl_input.TabIndex = 27; + this.pl_input.Visible = false; + // + // cb_input + // + this.cb_input.Location = new System.Drawing.Point(58, 4); + this.cb_input.Name = "cb_input"; + this.cb_input.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] { + new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)}); + this.cb_input.Properties.DropDownRows = 8; + this.cb_input.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor; + this.cb_input.Size = new System.Drawing.Size(79, 20); + this.cb_input.TabIndex = 19; + // + // txt_input + // + this.txt_input.Location = new System.Drawing.Point(149, 4); + this.txt_input.Name = "txt_input"; + this.txt_input.Properties.Appearance.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.txt_input.Properties.Appearance.Options.UseFont = true; + this.txt_input.Size = new System.Drawing.Size(98, 20); + this.txt_input.TabIndex = 18; + // + // labelControl2 + // + this.labelControl2.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.labelControl2.Location = new System.Drawing.Point(5, 8); + this.labelControl2.Name = "labelControl2"; + this.labelControl2.Size = new System.Drawing.Size(48, 12); + this.labelControl2.TabIndex = 16; + this.labelControl2.Text = "快速录入"; + // + // btn_input + // + this.btn_input.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btn_input.Appearance.Options.UseFont = true; + this.btn_input.Location = new System.Drawing.Point(249, 4); + this.btn_input.Name = "btn_input"; + this.btn_input.Size = new System.Drawing.Size(27, 21); + this.btn_input.TabIndex = 13; + this.btn_input.Text = ">>"; + // + // dpbImport + // + this.dpbImport.AllowFocus = false; + this.dpbImport.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.dpbImport.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.dpbImport.Appearance.Options.UseFont = true; + this.dpbImport.DropDownArrowStyle = DevExpress.XtraEditors.DropDownArrowStyle.Show; + this.dpbImport.Location = new System.Drawing.Point(155, 7); + this.dpbImport.Name = "dpbImport"; + this.dpbImport.Size = new System.Drawing.Size(74, 26); + this.dpbImport.TabIndex = 26; + this.dpbImport.Text = "导入导出"; + // + // btnBillAdd + // + this.btnBillAdd.AllowFocus = false; + this.btnBillAdd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnBillAdd.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnBillAdd.Appearance.Options.UseFont = true; + this.btnBillAdd.Location = new System.Drawing.Point(307, 7); + this.btnBillAdd.Name = "btnBillAdd"; + this.btnBillAdd.Size = new System.Drawing.Size(67, 26); + this.btnBillAdd.TabIndex = 19; + this.btnBillAdd.Text = "新建单据"; + // + // btnBillApply + // + this.btnBillApply.AllowFocus = false; + this.btnBillApply.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnBillApply.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnBillApply.Appearance.Options.UseFont = true; + this.btnBillApply.Location = new System.Drawing.Point(514, 7); + this.btnBillApply.Name = "btnBillApply"; + this.btnBillApply.Size = new System.Drawing.Size(67, 26); + this.btnBillApply.TabIndex = 25; + this.btnBillApply.Text = "保存提交"; + // + // dpCopyBill + // + this.dpCopyBill.AllowFocus = false; + this.dpCopyBill.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.dpCopyBill.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.dpCopyBill.Appearance.Options.UseFont = true; + this.dpCopyBill.DropDownArrowStyle = DevExpress.XtraEditors.DropDownArrowStyle.Show; + this.dpCopyBill.Location = new System.Drawing.Point(231, 7); + this.dpCopyBill.Name = "dpCopyBill"; + this.dpCopyBill.Size = new System.Drawing.Size(74, 26); + this.dpCopyBill.TabIndex = 24; + this.dpCopyBill.Text = "复制单据"; + // + // btnPrint + // + this.btnPrint.AllowFocus = false; + this.btnPrint.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnPrint.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnPrint.Appearance.Options.UseFont = true; + this.btnPrint.DropDownArrowStyle = DevExpress.XtraEditors.DropDownArrowStyle.Show; + this.btnPrint.Location = new System.Drawing.Point(583, 7); + this.btnPrint.Name = "btnPrint"; + this.btnPrint.Size = new System.Drawing.Size(74, 26); + this.btnPrint.TabIndex = 23; + this.btnPrint.Text = "打印单据"; + // + // dpbTools + // + this.dpbTools.AllowFocus = false; + this.dpbTools.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.dpbTools.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.dpbTools.Appearance.Options.UseFont = true; + this.dpbTools.DropDownArrowStyle = DevExpress.XtraEditors.DropDownArrowStyle.Show; + this.dpbTools.Location = new System.Drawing.Point(79, 7); + this.dpbTools.Name = "dpbTools"; + this.dpbTools.Size = new System.Drawing.Size(74, 26); + this.dpbTools.TabIndex = 22; + this.dpbTools.Text = "常用工具"; + // + // btnDelete + // + this.btnDelete.AllowFocus = false; + this.btnDelete.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnDelete.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnDelete.Appearance.Options.UseFont = true; + this.btnDelete.Location = new System.Drawing.Point(376, 7); + this.btnDelete.Name = "btnDelete"; + this.btnDelete.Size = new System.Drawing.Size(67, 26); + this.btnDelete.TabIndex = 20; + this.btnDelete.Text = "删除记录"; + // + // btnBillSave + // + this.btnBillSave.AllowFocus = false; + this.btnBillSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnBillSave.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnBillSave.Appearance.Options.UseFont = true; + this.btnBillSave.Location = new System.Drawing.Point(445, 7); + this.btnBillSave.Name = "btnBillSave"; + this.btnBillSave.Size = new System.Drawing.Size(67, 26); + this.btnBillSave.TabIndex = 21; + this.btnBillSave.Text = "保存单据"; + // + // pl_main_top + // + this.pl_main_top.Appearance.BackColor = System.Drawing.SystemColors.Control; + this.pl_main_top.Appearance.Options.UseBackColor = true; + this.pl_main_top.Controls.Add(this.pl_main_top_center); + this.pl_main_top.Controls.Add(this.pl_main_top_right); + this.pl_main_top.Controls.Add(this.pl_main_top_left); + this.pl_main_top.Dock = System.Windows.Forms.DockStyle.Top; + this.pl_main_top.Location = new System.Drawing.Point(2, 2); + this.pl_main_top.Name = "pl_main_top"; + this.pl_main_top.Size = new System.Drawing.Size(662, 38); + this.pl_main_top.TabIndex = 0; + // + // pl_main_top_center + // + this.pl_main_top_center.Appearance.BackColor = System.Drawing.Color.Transparent; + this.pl_main_top_center.Appearance.Options.UseBackColor = true; + this.pl_main_top_center.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder; + this.pl_main_top_center.Controls.Add(this.lbTitle); + this.pl_main_top_center.Dock = System.Windows.Forms.DockStyle.Fill; + this.pl_main_top_center.Location = new System.Drawing.Point(162, 2); + this.pl_main_top_center.Name = "pl_main_top_center"; + this.pl_main_top_center.Size = new System.Drawing.Size(315, 34); + this.pl_main_top_center.TabIndex = 3; + // + // lbTitle + // + this.lbTitle.BackColor = System.Drawing.Color.Transparent; + this.lbTitle.Dock = System.Windows.Forms.DockStyle.Fill; + this.lbTitle.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.lbTitle.ForeColor = System.Drawing.Color.Blue; + this.lbTitle.Location = new System.Drawing.Point(0, 0); + this.lbTitle.Name = "lbTitle"; + this.lbTitle.Size = new System.Drawing.Size(315, 34); + this.lbTitle.TabIndex = 1; + this.lbTitle.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // pl_main_top_right + // + this.pl_main_top_right.Appearance.BackColor = System.Drawing.Color.Transparent; + this.pl_main_top_right.Appearance.Options.UseBackColor = true; + this.pl_main_top_right.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder; + this.pl_main_top_right.Controls.Add(this.lblOrderNo); + this.pl_main_top_right.Controls.Add(this.labelControl1); + this.pl_main_top_right.Dock = System.Windows.Forms.DockStyle.Right; + this.pl_main_top_right.Location = new System.Drawing.Point(477, 2); + this.pl_main_top_right.Name = "pl_main_top_right"; + this.pl_main_top_right.Size = new System.Drawing.Size(183, 34); + this.pl_main_top_right.TabIndex = 2; + // + // lblOrderNo + // + this.lblOrderNo.Appearance.BackColor = System.Drawing.Color.Transparent; + this.lblOrderNo.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Underline); + this.lblOrderNo.Appearance.ForeColor = System.Drawing.Color.Blue; + this.lblOrderNo.Location = new System.Drawing.Point(67, 19); + this.lblOrderNo.Name = "lblOrderNo"; + this.lblOrderNo.Size = new System.Drawing.Size(90, 12); + this.lblOrderNo.TabIndex = 1; + this.lblOrderNo.Text = "XTC170112010001"; + // + // labelControl1 + // + this.labelControl1.Appearance.BackColor = System.Drawing.Color.Transparent; + this.labelControl1.Appearance.Font = new System.Drawing.Font("宋体", 9F); + this.labelControl1.Appearance.ForeColor = System.Drawing.Color.Blue; + this.labelControl1.Location = new System.Drawing.Point(7, 19); + this.labelControl1.Name = "labelControl1"; + this.labelControl1.Size = new System.Drawing.Size(54, 12); + this.labelControl1.TabIndex = 0; + this.labelControl1.Text = "单据编号:"; + // + // pl_main_top_left + // + this.pl_main_top_left.Appearance.BackColor = System.Drawing.Color.Transparent; + this.pl_main_top_left.Appearance.Options.UseBackColor = true; + this.pl_main_top_left.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder; + this.pl_main_top_left.Controls.Add(this.pl_red); + this.pl_main_top_left.Controls.Add(this.pl_blue); + this.pl_main_top_left.Dock = System.Windows.Forms.DockStyle.Left; + this.pl_main_top_left.Location = new System.Drawing.Point(2, 2); + this.pl_main_top_left.Name = "pl_main_top_left"; + this.pl_main_top_left.Size = new System.Drawing.Size(160, 34); + this.pl_main_top_left.TabIndex = 1; + // + // pl_red + // + this.pl_red.Appearance.BackColor = System.Drawing.Color.Transparent; + this.pl_red.Appearance.Options.UseBackColor = true; + this.pl_red.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder; + this.pl_red.Controls.Add(this.rdRed); + this.pl_red.Dock = System.Windows.Forms.DockStyle.Left; + this.pl_red.Location = new System.Drawing.Point(80, 0); + this.pl_red.Name = "pl_red"; + this.pl_red.Size = new System.Drawing.Size(80, 34); + this.pl_red.TabIndex = 3; + // + // rdRed + // + this.rdRed.AutoSize = true; + this.rdRed.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.rdRed.ForeColor = System.Drawing.Color.Red; + this.rdRed.Location = new System.Drawing.Point(6, 12); + this.rdRed.Name = "rdRed"; + this.rdRed.Size = new System.Drawing.Size(71, 16); + this.rdRed.TabIndex = 3; + this.rdRed.Text = "红字单据"; + this.rdRed.UseVisualStyleBackColor = true; + // + // pl_blue + // + this.pl_blue.Appearance.BackColor = System.Drawing.Color.Transparent; + this.pl_blue.Appearance.Options.UseBackColor = true; + this.pl_blue.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder; + this.pl_blue.Controls.Add(this.rdBlue); + this.pl_blue.Dock = System.Windows.Forms.DockStyle.Left; + this.pl_blue.Location = new System.Drawing.Point(0, 0); + this.pl_blue.Name = "pl_blue"; + this.pl_blue.Size = new System.Drawing.Size(80, 34); + this.pl_blue.TabIndex = 2; + // + // rdBlue + // + this.rdBlue.AutoSize = true; + this.rdBlue.Checked = true; + this.rdBlue.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.rdBlue.ForeColor = System.Drawing.Color.Blue; + this.rdBlue.Location = new System.Drawing.Point(7, 12); + this.rdBlue.Name = "rdBlue"; + this.rdBlue.Size = new System.Drawing.Size(71, 16); + this.rdBlue.TabIndex = 2; + this.rdBlue.TabStop = true; + this.rdBlue.Text = "蓝字单据"; + this.rdBlue.UseVisualStyleBackColor = true; + // + // FrmBillInfo + // + this.ClientSize = new System.Drawing.Size(666, 518); + this.Controls.Add(this.pl_main); + this.Name = "FrmBillInfo"; + ((System.ComponentModel.ISupportInitialize)(this.pl_main)).EndInit(); + this.pl_main.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.pl_main_center)).EndInit(); + this.pl_main_center.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.pl_main_center_detail)).EndInit(); + this.pl_main_center_detail.ResumeLayout(false); + this.pl_main_center_master.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.pl_treeview_detault_search)).EndInit(); + this.pl_treeview_detault_search.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.panelControl4)).EndInit(); + this.panelControl4.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.textEdit1.Properties)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.panelControl3)).EndInit(); + this.panelControl3.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.pl_main_bottom)).EndInit(); + this.pl_main_bottom.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.pl_templete)).EndInit(); + this.pl_templete.ResumeLayout(false); + this.pl_templete.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.cb_templete.Properties)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pl_input)).EndInit(); + this.pl_input.ResumeLayout(false); + this.pl_input.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.cb_input.Properties)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.txt_input.Properties)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pl_main_top)).EndInit(); + this.pl_main_top.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.pl_main_top_center)).EndInit(); + this.pl_main_top_center.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.pl_main_top_right)).EndInit(); + this.pl_main_top_right.ResumeLayout(false); + this.pl_main_top_right.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pl_main_top_left)).EndInit(); + this.pl_main_top_left.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.pl_red)).EndInit(); + this.pl_red.ResumeLayout(false); + this.pl_red.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pl_blue)).EndInit(); + this.pl_blue.ResumeLayout(false); + this.pl_blue.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private DevExpress.XtraEditors.PanelControl pl_main; + private DevExpress.XtraEditors.PanelControl pl_main_center; + private DevExpress.XtraEditors.PanelControl pl_main_center_detail; + private Control.GridControlEx gcMain; + private DevExpress.XtraEditors.XtraScrollableControl pl_main_center_master; + private DevExpress.XtraEditors.PanelControl pl_treeview_detault_search; + private DevExpress.XtraEditors.PanelControl panelControl4; + private DevExpress.XtraEditors.TextEdit textEdit1; + private Control.LabelComboxEdit lceCombobox; + private DevExpress.XtraEditors.PanelControl panelControl3; + private DevExpress.XtraEditors.SimpleButton btnTreeSearch; + public DevExpress.XtraEditors.PanelControl pl_main_bottom; + private DevExpress.XtraEditors.DropDownButton dbpFP; + private DevExpress.XtraEditors.SimpleButton btnRefresh; + private DevExpress.XtraEditors.SimpleButton btnHiding; + private DevExpress.XtraEditors.SimpleButton btnHelp; + private DevExpress.XtraEditors.PanelControl pl_templete; + private DevExpress.XtraEditors.ComboBoxEdit cb_templete; + private DevExpress.XtraEditors.LabelControl lbl_templete; + private DevExpress.XtraEditors.PanelControl pl_input; + private DevExpress.XtraEditors.ComboBoxEdit cb_input; + private DevExpress.XtraEditors.TextEdit txt_input; + private DevExpress.XtraEditors.LabelControl labelControl2; + private DevExpress.XtraEditors.SimpleButton btn_input; + private DevExpress.XtraEditors.DropDownButton dpbImport; + private DevExpress.XtraEditors.SimpleButton btnBillAdd; + private DevExpress.XtraEditors.SimpleButton btnBillApply; + private D \ No newline at end of file diff --git a/插件库/Lskj.PubBomImport/FrmBillInfo.cs b/插件库/Lskj.PubBomImport/FrmBillInfo.cs new file mode 100644 index 0000000..4032e9b --- /dev/null +++ b/插件库/Lskj.PubBomImport/FrmBillInfo.cs @@ -0,0 +1,331 @@ +using DevExpress.XtraGrid.Columns; +using DevExpress.XtraGrid.Views.Grid; +using DevExpress.XtraTreeList.Columns; +using Lskj.Business; +using Lskj.Business.Impl; +using Lskj.Control; +using Lskj.Control.Model; +using Lskj.Data; +using Lskj.Model; +using Lskj.Util; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Windows.Forms; + +namespace Lskj.PubBomImport +{ + public partial class FrmBillInfo : Form + { + public DynamicBomImport Model; + public DynamicBillModel SysModel; + public BillModel billModel; + public MyControl ControlObj; + /// + /// 单据明细列 + /// + private DataTable _detailColumns; + private string guidField = "xxxxx_guid"; + public GridView GcMainView + { + get { return gcMain.GridView; } + } + public FrmBillInfo() + { + InitializeComponent(); + } + public void OnLoad(DynamicBomImport mainModel) + { + Model = mainModel; + GetControlData(mainModel); + InitControlView(); + SetControlData(); + } + public void GetControlData(DynamicBomImport Model) + { + string[] args = new[] { Model.FormText, Model.UserId, Model.UserName, Model.Privilege, Model.ModuleCode, "", Model.ModuleCode }; + SysModel = new DynamicBillModel(args); + SysModel.BillMasterSql = Model.BillMasterSql; + SysModel.BillDetailSql = ""; + DataRow modelRow = BillImpl.GetBillInfo(SysModel.ModuleCode);//获取单个模块信息 + billModel = new BillModel(modelRow);//初始化类的新实例。 + if (billModel != null) + { + billModel.TypeName = string.IsNullOrEmpty(SysModel.BillMasterSql) ? SysModel.FormText : billModel.TypeName;// 模块名称 + string masterPreFix = BaseImpl.GetColumnPrefix(billModel.MasterTable);// 主表列前缀 + billModel.MasterPreFix = masterPreFix; + string detailPreFix = BaseImpl.GetColumnPrefix(billModel.DetailTable);// 明细表列前缀 + billModel.DetailPreFix = detailPreFix; + billModel.DetailOrderField = billModel.DetailPreFix + "lsidx_id";// 单据来源id + if (SystemInfo.Instance.IsNotBillDetailOrder)//禁用排序 + { + billModel.DetailOrderField = string.Empty; + } + } + DataRow menuRow = BaseImpl.GetMenuConfigTab(SysModel.ModuleId);//获取菜单其他配置 + if (menuRow != null) + { + billModel.BillSourceIds = menuRow.Table.Columns.Contains("BillSourceIds") ? (menuRow["BillSourceIds"] + "").Trim(',') : string.Empty; + billModel.BillFlag = menuRow.Table.Columns.Contains("BillFlag") && !string.IsNullOrEmpty(menuRow["BillFlag"] + "") ? Convert.ToInt32(menuRow["BillFlag"] + "") : -1; + } + DataTable controls = BaseModuleImpl.GetControlLocation(billModel.FormKey, SysModel.ModuleCode); + DataTable groups = BaseModuleImpl.GetAddGroupData(billModel.FormKey);//获取主信息分组数据 + ControlObj = new MyControl() { Model = SysModel };//主表控件 + ControlObj.OtherParams = SysModel.OtherParams(); + ControlObj.InitControl(controls, this.pl_main_center_master, groups); + if (SysModel.GridEnumObj == GridEnum.BandedGridView || billModel.AutoMultiHeader == 1) + { + this.pl_main_center_detail.Controls.Clear(); + this.gcMain = new BandedGridControlEx(); + this.gcMain.Model = SysModel; + this.gcMain.Dock = DockStyle.Fill; + this.pl_main_center_detail.Controls.Add(this.gcMain); + } + _detailColumns = BillImpl.GetDetailColumns(SysModel.ModuleCode);//初始化单据明细列 + if (SysModel.GridEnumObj == GridEnum.BandedGridView || billModel.AutoMultiHeader == 1) + { + //多表头sql要增加一个判断,否则多表头会出错 + _detailColumns = BillImpl.GetDetailColumns(SysModel.ModuleCode, true);//初始化单据明细列 + } + this.gcMain.DisableFieldSources = billModel.DisableFieldSources; + this.gcMain.Model = SysModel; + this.gcMain.ParentControl = ControlObj;//把主表控件赋给 单据主表控件、基础档案查询条件控件等等 + this.gcMain.SetEditColumns(_detailColumns, GridCustomColumnStruct.BillDetailGridView + billModel.FormKey);//设置可编辑列 + } + public void InitControlView() + { + + } + public void SetControlData() + { + + } + public void InitializeHeader(DataRow parentRow) + { + // 新增 + if (!string.IsNullOrEmpty(SysModel.BillMasterSql)) + { + string billMasterSql = SysModel.BillMasterSql; + billMasterSql = ReplaceHelper.ReplaceRowParam(parentRow, billMasterSql); + // 处理单据表头数据 + DataRow row = BillImpl.GetDataRowResult(billMasterSql); + if (row != null) + { + ControlObj.SetAllControlValue(row, true); + } + } + } + public bool BillSave(int comfirm = 0, bool canTipMsg = true) + { + bool saveResult = false; + if (ControlObj.VerifyNull()) + { + // 保存之前先进行表格更新 + if (billModel.DetailTreeTable) + { + (this.gcMain as TreeGridControlEx).TreeListObj.PostEditor(); + } + else + { + this.gcMain.GridView.PostEditor(); + this.gcMain.GridView.UpdateCurrentRow(); + } + try + { + if (this.gcMain.VerifyNull()) + { + if (this.gcMain.RepeatedVerificationNames.Count > 0 && this.gcMain.VerifyDuplicateColumns()) + { + //MessageUtil.Show("表格中数据内容重复,保存失败!"); + return saveResult; + } + string billNo = this.lblOrderNo.Text.Trim(); + string detailGuid = Guid.NewGuid().ToString(); + string masterSql = GetAddRecord(ref billNo); + string detailSql = GetDetailRecord(detailGuid, billNo).ToString(); + // 检查单据头数据合法性 + if (string.IsNullOrEmpty(masterSql)) return false; + // 验证明细合法性 + if (string.IsNullOrEmpty(detailSql) && !billModel.SaveNullDetail) + { + MessageUtil.Show(ResourceKeys.BillDetailIsNotNull); + return false; + } + string tipMsg = string.Empty; + int result = BillImpl.BillSave(masterSql, detailSql, billModel.DetailTable, ref billNo, detailGuid, billModel.BillSeq, billModel.SaveState ? 2 : 1, comfirm, out tipMsg, 0, billModel.NewVer); + if (result == 1) + { + saveResult = true; + } + } + } + catch (Exception ex) + { + MessageUtil.Show(ex.Message); + } + } + return saveResult; + } + private string GetAddRecord(ref string parmaryValue) + { + if (billModel.NewVer == 0) + { + // 检查当前的单据号是否已被占用. + string newBillNo = BillImpl.GetBillNo(billModel.BillSeq); + if (!parmaryValue.Equals(newBillNo)) + { + if (MessageUtil.Show(ResourceKeys.BillRecordRepeat, MessageBoxButtons.YesNo) == DialogResult.No) + { + return string.Empty; + } + else + { + this.lblOrderNo.Text = newBillNo; + parmaryValue = newBillNo; + } + } + } + StringBuilder fieldBuilder = new StringBuilder(); + StringBuilder valueBuilder = new StringBuilder(); + DataTable DetailedProperties = BaseImpl.GetDataTableResult(string.Format("select COLUMN_NAME,DATA_TYPE,CHARACTER_MAXIMUM_LENGTH from information_schema.columns where table_name = '{0}'", billModel.MasterTable)); + string errorMessage = string.Empty;//数据不符合数据库规范的信息 + foreach (ControlModel model in this.ControlObj.ControlModels) + { + if (!model.IsSave || + model.FieldName.Equals(billModel.PrimaryKey, StringComparison.OrdinalIgnoreCase) || + model.FieldName.Equals(billModel.RtagidKey, StringComparison.OrdinalIgnoreCase) || + model.FieldType == ControlType.LabPic || + model.FieldType == ControlType.LabPicEx) + continue; + string fieldValue = this.ControlObj.GetControlValue(model); + if (SystemInfo.Instance.TrimWhiteSpace) + fieldValue = fieldValue.Trim(); + if (fieldValue == "****") continue; + errorMessage = errorMessage + DatabaseFormatJudgment.SaveOrModifyBalidation(DetailedProperties, model, fieldValue); + if (string.IsNullOrEmpty(fieldValue) && model.Isintordecimal) fieldValue = "0";//数值保存时为空的话默认保存为0; + fieldBuilder.Append(model.FieldName + ","); + valueBuilder.Append(string.IsNullOrEmpty(fieldValue) ? this.ControlObj.GetNullValue(model) : string.Format("N'{0}',", fieldValue)); + } + // 增加主键 + fieldBuilder.Append(billModel.PrimaryKey); + valueBuilder.Append("N'" + parmaryValue + "'"); + // 增加红蓝字单标记 + fieldBuilder.Append("," + billModel.RtagidKey); + valueBuilder.Append(",N'" + (rdRed.Checked ? 1 : 0) + "'"); + return string.Format("insert into {0}({1}) values ({2})", billModel.MasterTable, fieldBuilder.ToString().TrimEnd(','), valueBuilder.ToString().TrimEnd(',')); + } + private StringBuilder GetDetailRecord(string guid, string billNo) + { + // 构造明细 + StringBuilder detailBuilder = new StringBuilder(); + DataTable detailTable = this.gcMain.GridControl.DataSourceTable().TrimDeleteRows(); + if (billModel.DetailTreeTable) + { + detailTable = ((this.gcMain as TreeGridControlEx).TreeListObj.DataSource as DataTable).TrimDeleteRows(); + } + DataTable DetailedProperties = BaseImpl.GetDataTableResult(string.Format("select COLUMN_NAME,DATA_TYPE,CHARACTER_MAXIMUM_LENGTH from information_schema.columns where table_name = '{0}'", billModel.DetailTable + "_temp"));//单据明细性表 + if (detailTable.Rows.Count > 0) + { + int lineNumber = 1; + DataTable BillColumns = BaseImpl.GetDataTableResult(string.Format("select * from {0} where 1<>1", billModel.DetailTable)); + DataTable BillTempColumns = BaseImpl.GetDataTableResult(string.Format("select * from {0} where 1<>1", billModel.DetailTable + "_temp")); + foreach (DataRow dataRow in detailTable.Rows) + { + string errorMessage = string.Empty;//数据不符合数据库规范的信息 + StringBuilder fields = new StringBuilder(); + StringBuilder values = new StringBuilder(); + string detailSql = @"insert into " + billModel.DetailTable + "_temp" + "({0}) values({1})"; + fields.Append("sysstr,"); + values.Append("'" + guid + "',"); + foreach (DataColumn item in BillColumns.Columns) + { + if (item.ColumnName.Equals(guidField) || item.ColumnName.Equals(ERPInfo.Instance.isAddRows)) continue; + if (!BillTempColumns.Columns.Contains(item.ColumnName)) + { + string type = "varchar(100)"; + if (item.DataType == typeof(DateTime)) + { + type = "datetime"; + } + BaseImpl.ExecSqlValue(string.Format("alter table {0} add {1} {2}", billModel.DetailTable + "_temp", item.ColumnName, type)); + } + if (billModel.DetailTreeTable) + { + TreeListColumn[] TreeListColumns = (this.gcMain as TreeGridControlEx).TreeListObj.Columns.Cast().Where(x => x.FieldName.Equals(item.Caption, StringComparison.OrdinalIgnoreCase)).ToArray(); + if (TreeListColumns.Count() == 0 && item.Caption.Equals(billModel.PrimaryDetailKey)) + { + string primaryValues = dataRow[billModel.PrimaryDetailKey] + ""; + if (!string.IsNullOrWhiteSpace(primaryValues)) + { + fields.Append(item.ColumnName + ","); + values.Append("N'" + primaryValues.Replace("'", "''") + "',"); + } + } + if (TreeListColumns.Count() == 0) continue; + } + else + { + GridColumn[] gridColumns = gcMain.GridView.Columns.Cast().Where(x => x.FieldName.Equals(item.Caption, StringComparison.OrdinalIgnoreCase)).ToArray(); + if (gridColumns.Count() == 0 && item.Caption.Equals(billModel.PrimaryDetailKey)) + { + string primaryValues = dataRow[billModel.PrimaryDetailKey] + ""; + if (!string.IsNullOrWhiteSpace(primaryValues)) + { + fields.Append(item.ColumnName + ","); + values.Append("N'" + primaryValues.Replace("'", "''") + "',"); + } + } + if (gridColumns.Count() == 0) continue; + } + fields.Append(item.ColumnName + ","); + string fieldValue = dataRow.Table.Columns.Contains(item.ColumnName) ? dataRow[item.ColumnName] + "" : string.Empty; + //if (SystemInfo.Instance.TrimWhiteSpace) + // fieldValue = fieldValue.Trim(); + if (item.ColumnName.Equals(billModel.PrimaryDetailKey, StringComparison.OrdinalIgnoreCase)) + fieldValue = billNo; + if (!string.IsNullOrWhiteSpace(fieldValue)) + { + values.Append(item.DataType == typeof(DateTime) ? "'" + Convert.ToDateTime(fieldValue).ToString("yyyy-MM-dd HH:mm:ss") + "'," : fieldValue.Contains("'") ? "N'" + fieldValue.Replace("'", "''") + "'," : "N'" + fieldValue + "',"); + } + else + { + if (item.DataType == typeof(Decimal) || + item.DataType == typeof(Double) || + item.DataType == typeof(Int16) || + item.DataType == typeof(Int32) || + item.DataType == typeof(Int64)) + values.Append("0,"); + else if (item.DataType == typeof(DateTime)) + { + values.Append("NULL,"); + } + else + { + values.Append("'',"); + } + } + errorMessage = errorMessage + DatabaseFormatJudgment.SaveOrModifyBalidation(_detailColumns, DetailedProperties, dataRow, item, fieldValue); + } + detailBuilder.AppendFormat(detailSql, fields.ToString().Trim(','), values.ToString().Trim(',')); + if (!string.IsNullOrWhiteSpace(errorMessage)) errorMessage = "第" + lineNumber + "行:" + errorMessage; + lineNumber++; + } + } + return detailBuilder; + } + private void SetBillStatus(DataRow rowItem) + { + // 单据为新增状态 + this.dbpFP.Enabled = this.btnDelete.Enabled = this.btnBillSave.Enabled = this.btnBillApply.Enabled = true; + this.lbTitle.Text = billModel.TypeName + "(新增)"; + this.lblOrderNo.Text = BillImpl.GetBillNo(billModel.BillSeq); + this.cb_input.Enabled = this.btn_input.Enabled = this.txt_input.Enabled = true; + this.cb_templete.Enabled = true; + this.billModel.SaveState = false; + this.ControlObj.SetReadOnlyAllControl(false); + this.rdBlue.Enabled = this.rdRed.Enabled = true; + // 通过右键菜单打开单据,假如明细有数据则在初始化时使用传入数据. diff --git a/插件库/Lskj.PubBomImport/FrmBillInfo.resx b/插件库/Lskj.PubBomImport/FrmBillInfo.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/插件库/Lskj.PubBomImport/FrmBillInfo.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.PubBomImport/FrmMain.Designer.cs b/插件库/Lskj.PubBomImport/FrmMain.Designer.cs new file mode 100644 index 0000000..d001375 --- /dev/null +++ b/插件库/Lskj.PubBomImport/FrmMain.Designer.cs @@ -0,0 +1,290 @@ + +namespace Lskj.PubBomImport +{ + 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.btnImport = new DevExpress.XtraEditors.SimpleButton(); + this.btnRead = new DevExpress.XtraEditors.SimpleButton(); + this.pl_bottom = new DevExpress.XtraEditors.PanelControl(); + this.btnCancel = new DevExpress.XtraEditors.SimpleButton(); + this.btnOk = new DevExpress.XtraEditors.SimpleButton(); + this.pl_cond = new DevExpress.XtraEditors.PanelControl(); + this.condTxtEdit = new DevExpress.XtraEditors.TextEdit(); + this.lb_cond = new System.Windows.Forms.Label(); + this.pl_purview = new DevExpress.XtraEditors.PanelControl(); + this.purview_Mulit = new Lskj.Control.LabelMultiAutoTextEdit(); + this.lb_purview = new System.Windows.Forms.Label(); + this.tips = new DevExpress.XtraEditors.PanelControl(); + this.tipsEdit = new DevExpress.XtraEditors.TextEdit(); + this.splitMainContainer = new DevExpress.XtraEditors.SplitContainerControl(); + this.gcMain = new Lskj.Control.GridControlEx(); + this.gc_Right = new Lskj.Control.GridControlEx(); + ((System.ComponentModel.ISupportInitialize)(this.pl_bottom)).BeginInit(); + this.pl_bottom.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pl_cond)).BeginInit(); + this.pl_cond.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.condTxtEdit.Properties)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pl_purview)).BeginInit(); + this.pl_purview.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.tips)).BeginInit(); + this.tips.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.tipsEdit.Properties)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.splitMainContainer)).BeginInit(); + this.splitMainContainer.SuspendLayout(); + this.SuspendLayout(); + // + // btnImport + // + this.btnImport.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btnImport.Location = new System.Drawing.Point(764, 10); + this.btnImport.Margin = new System.Windows.Forms.Padding(4); + this.btnImport.Name = "btnImport"; + this.btnImport.Size = new System.Drawing.Size(97, 31); + this.btnImport.TabIndex = 11; + this.btnImport.Text = "导入数据"; + // + // btnRead + // + this.btnRead.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btnRead.Location = new System.Drawing.Point(656, 10); + this.btnRead.Margin = new System.Windows.Forms.Padding(4); + this.btnRead.Name = "btnRead"; + this.btnRead.Size = new System.Drawing.Size(97, 31); + this.btnRead.TabIndex = 10; + this.btnRead.Text = "读取Excel"; + // + // pl_bottom + // + this.pl_bottom.Appearance.BackColor = System.Drawing.Color.Transparent; + this.pl_bottom.Appearance.Options.UseBackColor = true; + this.pl_bottom.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder; + this.pl_bottom.Controls.Add(this.btnImport); + this.pl_bottom.Controls.Add(this.btnCancel); + this.pl_bottom.Controls.Add(this.btnRead); + this.pl_bottom.Controls.Add(this.btnOk); + this.pl_bottom.Dock = System.Windows.Forms.DockStyle.Bottom; + this.pl_bottom.Location = new System.Drawing.Point(0, 549); + this.pl_bottom.Margin = new System.Windows.Forms.Padding(4); + this.pl_bottom.Name = "pl_bottom"; + this.pl_bottom.Size = new System.Drawing.Size(872, 50); + this.pl_bottom.TabIndex = 2; + // + // btnCancel + // + this.btnCancel.Location = new System.Drawing.Point(120, 10); + this.btnCancel.Margin = new System.Windows.Forms.Padding(4); + this.btnCancel.Name = "btnCancel"; + this.btnCancel.Size = new System.Drawing.Size(97, 31); + this.btnCancel.TabIndex = 11; + this.btnCancel.Text = "清除绑定"; + // + // btnOk + // + this.btnOk.Location = new System.Drawing.Point(12, 10); + this.btnOk.Margin = new System.Windows.Forms.Padding(4); + this.btnOk.Name = "btnOk"; + this.btnOk.Size = new System.Drawing.Size(97, 31); + this.btnOk.TabIndex = 10; + this.btnOk.Text = "保存绑定"; + // + // pl_cond + // + this.pl_cond.Appearance.BackColor = System.Drawing.Color.White; + this.pl_cond.Appearance.Options.UseBackColor = true; + this.pl_cond.Controls.Add(this.condTxtEdit); + this.pl_cond.Controls.Add(this.lb_cond); + this.pl_cond.Dock = System.Windows.Forms.DockStyle.Top; + this.pl_cond.Location = new System.Drawing.Point(0, 0); + this.pl_cond.Margin = new System.Windows.Forms.Padding(4); + this.pl_cond.Name = "pl_cond"; + this.pl_cond.Size = new System.Drawing.Size(872, 42); + this.pl_cond.TabIndex = 12; + // + // condTxtEdit + // + this.condTxtEdit.Dock = System.Windows.Forms.DockStyle.Fill; + this.condTxtEdit.Location = new System.Drawing.Point(87, 2); + this.condTxtEdit.Name = "condTxtEdit"; + this.condTxtEdit.Properties.Appearance.BackColor = System.Drawing.Color.White; + this.condTxtEdit.Properties.Appearance.Options.UseBackColor = true; + this.condTxtEdit.Properties.AutoHeight = false; + this.condTxtEdit.Properties.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder; + this.condTxtEdit.Size = new System.Drawing.Size(783, 38); + this.condTxtEdit.TabIndex = 5; + // + // lb_cond + // + this.lb_cond.BackColor = System.Drawing.Color.White; + this.lb_cond.Dock = System.Windows.Forms.DockStyle.Left; + this.lb_cond.Location = new System.Drawing.Point(2, 2); + this.lb_cond.Name = "lb_cond"; + this.lb_cond.Size = new System.Drawing.Size(85, 38); + this.lb_cond.TabIndex = 3; + this.lb_cond.Text = "筛选条件:"; + this.lb_cond.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // pl_purview + // + this.pl_purview.Appearance.BackColor = System.Drawing.Color.White; + this.pl_purview.Appearance.Options.UseBackColor = true; + this.pl_purview.Controls.Add(this.purview_Mulit); + this.pl_purview.Controls.Add(this.lb_purview); + this.pl_purview.Cursor = System.Windows.Forms.Cursors.Default; + this.pl_purview.Dock = System.Windows.Forms.DockStyle.Top; + this.pl_purview.Location = new System.Drawing.Point(0, 42); + this.pl_purview.Margin = new System.Windows.Forms.Padding(4); + this.pl_purview.Name = "pl_purview"; + this.pl_purview.Size = new System.Drawing.Size(872, 21); + this.pl_purview.TabIndex = 13; + // + // purview_Mulit + // + this.purview_Mulit.BackColor = System.Drawing.Color.White; + this.purview_Mulit.Dock = System.Windows.Forms.DockStyle.Fill; + this.purview_Mulit.EditText = ""; + this.purview_Mulit.FontSize = 0F; + this.purview_Mulit.LabelText = "名称"; + this.purview_Mulit.Location = new System.Drawing.Point(135, 2); + this.purview_Mulit.Margin = new System.Windows.Forms.Padding(4); + this.purview_Mulit.Model = null; + this.purview_Mulit.Name = "purview_Mulit"; + this.purview_Mulit.NullText = ""; + this.purview_Mulit.ReadOnly = false; + this.purview_Mulit.Required = false; + this.purview_Mulit.Size = new System.Drawing.Size(735, 17); + this.purview_Mulit.TabIndex = 4; + this.purview_Mulit.TextBoxProhibition = false; + // + // lb_purview + // + this.lb_purview.BackColor = System.Drawing.Color.White; + this.lb_purview.Dock = System.Windows.Forms.DockStyle.Left; + this.lb_purview.Location = new System.Drawing.Point(2, 2); + this.lb_purview.Name = "lb_purview"; + this.lb_purview.Size = new System.Drawing.Size(133, 17); + this.lb_purview.TabIndex = 3; + this.lb_purview.Text = "条件可编辑人员:"; + this.lb_purview.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // tips + // + this.tips.Appearance.BackColor = System.Drawing.Color.White; + this.tips.Appearance.Options.UseBackColor = true; + this.tips.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.Office2003; + this.tips.Controls.Add(this.tipsEdit); + this.tips.Dock = System.Windows.Forms.DockStyle.Top; + this.tips.Location = new System.Drawing.Point(0, 63); + this.tips.Margin = new System.Windows.Forms.Padding(4); + this.tips.Name = "tips"; + this.tips.Size = new System.Drawing.Size(872, 42); + this.tips.TabIndex = 14; + // + // tipsEdit + // + this.tipsEdit.Dock = System.Windows.Forms.DockStyle.Fill; + this.tipsEdit.EditValue = "请导入Excel模板"; + this.tipsEdit.Location = new System.Drawing.Point(2, 2); + this.tipsEdit.Name = "tipsEdit"; + this.tipsEdit.Properties.Appearance.BackColor = System.Drawing.Color.White; + this.tipsEdit.Properties.Appearance.ForeColor = System.Drawing.Color.Red; + this.tipsEdit.Properties.Appearance.Options.UseBackColor = true; + this.tipsEdit.Properties.Appearance.Options.UseForeColor = true; + this.tipsEdit.Properties.AutoHeight = false; + this.tipsEdit.Properties.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder; + this.tipsEdit.Properties.ReadOnly = true; + this.tipsEdit.Size = new System.Drawing.Size(868, 38); + this.tipsEdit.TabIndex = 6; + // + // splitMainContainer + // + this.splitMainContainer.Appearance.BackColor = System.Drawing.Color.Transparent; + this.splitMainContainer.Appearance.Options.UseBackColor = true; + this.splitMainContainer.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.Default; + this.splitMainContainer.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitMainContainer.Location = new System.Drawing.Point(0, 105); + this.splitMainContainer.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.splitMainContainer.Name = "splitMainContainer"; + this.splitMainContainer.Panel1.Controls.Add(this.gcMain); + this.splitMainContainer.Panel1.Text = "Panel1"; + this.splitMainContainer.Panel2.Controls.Add(this.gc_Right); + this.splitMainContainer.Panel2.Text = "Panel2"; + this.splitMainContainer.Size = new System.Drawing.Size(872, 444); + this.splitMainContainer.SplitterPosition = 500; + this.splitMainContainer.TabIndex = 17; + this.splitMainContainer.Text = "splitContainerControl1"; + // + // gcMain + // + this.gcMain.AdapterObj = null; + this.gcMain.Dock = System.Windows.Forms.DockStyle.Fill; + this.gcMain.Location = new System.Drawing.Point(0, 0); + this.gcMain.Margin = new System.Windows.Forms.Padding(4); + this.gcMain.Name = "gcMain"; + this.gcMain.SiftEnumObj = Lskj.Control.GridControlEx.HeaderSiftEnum.Sum; + this.gcMain.Size = new System.Drawing.Size(500, 444); + this.gcMain.TabIndex = 16; + // + // gc_Right + // + this.gc_Right.AdapterObj = null; + this.gc_Right.Dock = System.Windows.Forms.DockStyle.Fill; + this.gc_Right.Location = new System.Drawing.Point(0, 0); + this.gc_Right.Margin = new System.Windows.Forms.Padding(4); + this.gc_Right.Name = "gc_Right"; + this.gc_Right.SiftEnumObj = Lskj.Control.GridControlEx.HeaderSiftEnum.Sum; + this.gc_Right.Size = new System.Drawing.Size(367, 444); + this.gc_Right.TabIndex = 18; + // + // FrmMain + // + this.Appearance.BackColor = System.Drawing.SystemColors.Control; + this.Appearance.Options.UseBackColor = true; + this.Appearance.Options.UseFont = true; + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; + this.ClientSize = new System.Drawing.Size(872, 599); + this.Controls.Add(this.splitMainContainer); + this.Controls.Add(this.tips); + this.Controls.Add(this.pl_purview); + this.Controls.Add(this.pl_cond); + this.Controls.Add(this.pl_bottom); + this.Name = "FrmMain"; + this.Text = "表格导入"; + ((System.ComponentModel.ISupportInitialize)(this.pl_bottom)).EndInit(); + this.pl_bottom.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.pl_cond)).EndInit(); + this.pl_cond.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.condTxtEdit.Properties)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pl_purview)).EndInit(); + this.pl_purview.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.tips)).EndInit(); + this.tips.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.tipsEdit.Properties)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.splitMainContainer)).EndInit(); + this.splitMainContainer.ResumeLayout(false); + this.ResumeLayout(f \ No newline at end of file diff --git a/插件库/Lskj.PubBomImport/FrmMain.cs b/插件库/Lskj.PubBomImport/FrmMain.cs new file mode 100644 index 0000000..816ad48 --- /dev/null +++ b/插件库/Lskj.PubBomImport/FrmMain.cs @@ -0,0 +1,1668 @@ +using DevExpress.XtraEditors.Repository; +using DevExpress.XtraGrid.Columns; +using DevExpress.XtraGrid.Views.BandedGrid; +using DevExpress.XtraGrid.Views.Grid; +using Lskj.Business; +using Lskj.Business.Impl; +using Lskj.Control; +using Lskj.Control.Model; +using Lskj.Core; +using Lskj.Data; +using Lskj.Model; +using Lskj.PubBomImport; +using Lskj.Util; +using NPOI.HSSF.UserModel; +using NPOI.SS.UserModel; +using NPOI.SS.Util; +using NPOI.XSSF.UserModel; +using System; +using System.Collections.Generic; +using System.Data; +using System.IO; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using System.Windows.Forms; + +namespace Lskj.PubBomImport +{ + public partial class FrmMain : BaseForm + { + public FrmMain() + { + InitializeComponent(); + this.Load += FrmMain_Load; + } + public DynamicBomImport Model; + public int FirstRowIndex = 0; + /// + /// 匹配搜索框列 + /// + private RepositoryItemGridLookUpEdit searchEdit = new RepositoryItemGridLookUpEdit(); + /// + /// 缓存列对象 + /// + private static List ColumnList = new List(); + /// + /// 导入文件名 + /// + private string importFileName = ""; + /// + /// 特殊列值 + /// + private string specialValue = ""; + private static Dictionary ValueGridColumnTable; + private static Dictionary LookupParentKey; + private static List _checkColumns; + private static string _treeColumnName; + #region 事件 + /// + /// 初始化时 + /// + /// + /// + private void FrmMain_Load(object sender, EventArgs e) + { + bool showType = Model != null && Model.ShowType.Equals("1") && !ERPInfo.Instance.UserName.Equals("管理员"); + try + { + if (showType) + { + Opacity = 0; + } + InitlizeSpiltLocation(); + InitEvents(); + InitGridColumns(); + InitMulitControl(); + InitDataSource(); + if (showType) + { + OnBtnImportClick(null, null); + } + } + catch (Exception ex) + { + MessageUtil.Show(ex.Message); + this.Close(); + } + } + /// + /// 导入按钮点击 + /// + /// + /// + private void OnBtnImportClick(object sender, EventArgs e) + { + try + { + //bool showType = Model != null && Model.ShowType.Equals("1") && !ERPInfo.Instance.UserName.Equals("管理员"); + //string fileName = importFileName; + //if (File.Exists(fileName)) + //{ + // this.Hide(); + // WaitForm.ShowForm("正在导入数据..."); + // this.ParentView.GridControl.DataSource = this.ToExcelDataTable(fileName, out int count, out int errorCount, true); + // WaitForm.HideForm(); + // if (!showType) + // { + // MessageUtil.Show(string.Format("成功导入{0}条数据,错误{1}条数据", count, errorCount)); + // } + // this.Close(); + //} + //else + //{ + // MessageUtil.Show("导入Excel文件不存在"); + // tipsEdit.Text = "请导入Excel模板"; + // btnImport.Enabled = false; + //} + //DialogResult dialogResult = frmBillInfo.ShowDialog(); + //if (dialogResult == DialogResult.OK) + //{ + //} + FolderBrowserDialog dialog = new FolderBrowserDialog(); + dialog.Description = "选择导入文件夹"; + DialogResult dialogResult = dialog.ShowDialog(); + if (dialogResult == DialogResult.OK) + { + string dirPath = dialog.SelectedPath; + DirectoryInfo directoryInfo = new DirectoryInfo(dirPath); + FileInfo[] fileInfos = directoryInfo.GetFiles(); + FileInfo parentInfo = fileInfos.Where(n => n.Name.StartsWith("MX") && n.Extension.Equals(".xlsx", StringComparison.OrdinalIgnoreCase)).FirstOrDefault(); + if (parentInfo != null) + { + DataTable parentTable = ExcelToDatatable(parentInfo.FullName, "", 5); + parentTable = parentTable.Rows.Cast().Where(n => int.TryParse(n["序号"] + "", out _) && !string.IsNullOrEmpty(n["图号"] + "")).ToList().CopyToDataTable(); + StringBuilder stringBuilder = new StringBuilder(); + foreach (DataRow dataRow in parentTable.Rows) + { + stringBuilder.AppendLine($"if not exists (select productid from p_ProductTab where productid = '{dataRow["图号"] + ""}')"); + stringBuilder.AppendLine($"begin insert into p_ProductTab (productid,appellation,bak) values ('{(dataRow["图号"] + "").Replace("'", "''")}','{(dataRow["名称"] + "").Replace("'", "''")}','{(dataRow["备注"] + "").Replace("'", "''")}') end;"); + } + if (!string.IsNullOrEmpty(stringBuilder.ToString())) + { + SqlHelper.ExecuteNonQuery(stringBuilder.ToString()); + } + FrmBillInfo frmBillInfo = new FrmBillInfo(); + frmBillInfo.OnLoad(Model); + ParentView = frmBillInfo.GcMainView; + frmBillInfo.ControlObj.OnDataSourceBindCallBack += (s, args) => + { + this.Invoke(new Action(() => + { + try + { + int.TryParse(Model.FirstRowIndex, out int index); + FirstRowIndex = index; + foreach (DataRow dataRow in parentTable.Rows) + { + string code = dataRow["图号"] + ""; + FileInfo childInfo = fileInfos.Where(n => n.Name.Contains(code) && n.Extension.Equals(".xlsx", StringComparison.OrdinalIgnoreCase)).FirstOrDefault(); + if (childInfo != null) + { + ParentView.GridControl.DataSource = this.ToExcelDataTable(childInfo.FullName, out int count, out int errorCount, true); + frmBillInfo.InitializeHeader(dataRow); + frmBillInfo.BillSave(); + frmBillInfo.OnBillAdd(); + } + } + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + finally + { + this.Close(); + } + })); + }; + } + else + { + MessageBox.Show("未包含结构文件"); + } + } + } + catch (Exception ex) + { + WaitForm.HideForm(); + this.Show(); + MessageUtil.Show(string.Format("导入失败,原因:{0}", ex.Message)); + } + } + /// + /// 读取按钮点击 + /// + /// + /// + private void OnBtnReadClick(object sender, EventArgs e) + { + bool showType = false; + try + { + showType = Model != null && Model.ShowType.Equals("1") && !ERPInfo.Instance.UserName.Equals("管理员"); + OpenFileDialog dialog = new OpenFileDialog(); + dialog.Title = "选择导入文件"; + dialog.Filter = SystemInfo.Instance.IsXlsxFirst ? "Excel文件(*.xlsx)|*.xlsx|Excel文件(*.xls)|*.xls" : "Excel文件(*.xls)|*.xls|Excel文件(*.xlsx)|*.xlsx"; + DialogResult result = dialog.ShowDialog(); + DataTable gcData = new DataTable(); + if (result == DialogResult.OK) + { + string fileName = importFileName = dialog.FileName; + tipsEdit.Text = string.Format("当前读取文件:{0},请绑定列后点击导入", Path.GetFileName(fileName)); + string colFields = this.gcMain.GridView.Columns.ToString(','); + string[] indexArray = Model.SpecialValueIndex.Split(','); + if (!string.IsNullOrWhiteSpace(Model.SpecialValueIndex) && indexArray.Length == 2) + { + int rowIndex = int.TryParse(indexArray[0], out rowIndex) ? rowIndex : 0; + int colIndex = int.TryParse(indexArray[1], out colIndex) ? colIndex : 0; + specialValue = GetSpecialCellValue(fileName, "", rowIndex, colIndex); + } + //else + //{ + // MessageUtil.Show("参数配置错误,导入失败"); + // btnImport.Enabled = false; + // tipsEdit.Text = "请导入Excel模板"; + // gc_Right.SetGridViewDataSource(new DataTable()); + // return; + //} + //if (string.IsNullOrEmpty(specialValue)) + //{ + // MessageUtil.Show("当前版本为新版bom/旧版bom导入,请检查导入文件是否匹配正确"); + // btnImport.Enabled = false; + // tipsEdit.Text = "请导入Excel模板"; + // gc_Right.SetGridViewDataSource(new DataTable()); + // return; + //} + string[] firstIndexArray = Model.FirstRowIndex.Split(','); + if (firstIndexArray.Length > 0) + { + bool isTitle = false; + foreach (string firstIndex in firstIndexArray) + { + if (int.TryParse(firstIndex, out int index)) + { + try + { + DataTable dataTable1 = ExcelToDatatable(fileName, Model.SheetName, index); + FirstRowIndex = index; + isTitle = true; + break; + } + catch (IOException ex) + { + throw new Exception(string.Format("读取模板内容失败,原因:{0}", ex.Message)); + } + } + } + if (!isTitle) + { + FirstRowIndex = 0; + } + } + DataTable dataTable = ExcelToDatatable(fileName, Model.SheetName, FirstRowIndex); + DataTable importTable = GetSourceTable(dataTable); + DataTable sourceTable = this.gcMain.GridControl.DataSource as DataTable; + if (dataTable != null) + { + try + { + if (!string.IsNullOrEmpty(Model.ReadTableCond)) + { + DataView view = new DataView(dataTable); + view.RowFilter = Model.ReadTableCond; + dataTable = view.ToTable(); + } + } + catch (Exception) + { + } + this.gc_Right.SetGridViewDataSource(dataTable); + } + if (sourceTable != null && sourceTable.Rows.Count > 0) + { + if (sourceTable.Rows.Count != importTable.Rows.Count) + { + this.gcMain.SetGridViewDataSource(importTable); + this.condTxtEdit.Text = ""; + } + else + { + bool isComplete = true; + int rowCount = importTable.Rows.Count; + if (!string.IsNullOrEmpty(specialValue)) + { + rowCount = importTable.Rows.Count - 1; + } + for (int i = 0; i < rowCount; i++) + { + DataRow row = importTable.Rows[i]; + int count = sourceTable.Rows.Cast().Where(n => (n["excelFieldName"] + "").Equals(row["excelFieldName"] + "")).Count(); + if (count == 0) + { + isComplete = false; + break; + } + } + if (!isComplete) + { + this.gcMain.SetGridViewDataSource(importTable); + this.condTxtEdit.Text = ""; + } + else + { + if (!string.IsNullOrEmpty(specialValue) && sourceTable.Rows.Count > 0) + { + sourceTable.Rows[sourceTable.Rows.Count - 1]["excelFieldName"] = specialValue; + } + } + } + } + else + { + this.gcMain.SetGridViewDataSource(importTable); + this.condTxtEdit.Text = ""; + } + } + } + catch (Exception ex) + { + MessageUtil.Show(ex.Message); + tipsEdit.Text = "请导入Excel模板"; + gc_Right.SetGridViewDataSource(new DataTable()); + this.DialogResult = DialogResult.Cancel; + } + finally + { + if (showType) + { + Close(); + } + } + } + /// + /// 确定按钮点击 + /// + /// + /// + private void OnBtnOkClick(object sender, EventArgs e) + { + try + { + string condFilter = this.condTxtEdit.Text.Trim(); + string condPurview = this.purview_Mulit.EditValue; + string unionColumn = GetUnionColumn(); + string sql = "if exists(select * from P_SpecialImportTab where moduleId = '{0}' and rightMenuName = '{1}') " + + "begin " + + "update P_SpecialImportTab set Ls_CondFilter = '{2}',Ls_UnionColumn = '{3}',Ls_CondPurview = '{4}' where moduleId = '{0}' and rightMenuName = '{1}' " + + "end " + + "else begin " + + "insert into P_SpecialImportTab (moduleId,rightMenuName,Ls_CondFilter,Ls_UnionColumn,Ls_CondPurview) values ('{0}','{1}','{2}','{3}','{4}') " + + "end"; + sql = string.Format(sql, Model.ModuleCode, Model.MenuName, condFilter.Replace("'", "''"), unionColumn.Replace("'", "''"), condPurview.Replace("'", "''")); + SqlHelper.ExecuteNonQuery(sql); + MessageUtil.Show("保存成功"); + } + catch (Exception ex) + { + MessageUtil.Show("保存失败,原因:" + ex.Message); + } + } + /// + /// 取消按钮点击 + /// + /// + /// + private void OnBtnCancelClick(object sender, EventArgs e) + { + try + { + DataTable dataTable = this.gcMain.GridControl.DataSourceTable(); + if (dataTable != null && dataTable.Rows.Count > 0) + { + foreach (DataRow item in dataTable.Rows) + { + item["clientFieldName"] = ""; + } + } + } + catch (Exception ex) + { + MessageUtil.Show(string.Format("取消绑定列失败,原因:{0}", ex.Message)); + } + } + /// + /// 分隔条位置改变时 + /// + /// + /// + private void OnSplitMainContainerPositionChanged(object sender, EventArgs e) + { + try + { + if (this.Model != null) + { + IniHelper.Write(string.Format("PubSpecialImport_SplitMain_{0}", this.Model.ModuleCode), this.splitMainContainer.SplitterPosition + ""); + } + } + catch (Exception ex) + { + MessageUtil.Show(ex.Message); + } + } + #endregion + #region 方法 + /// + /// 初始化事件绑定 + /// + private void InitEvents() + { + this.btnRead.Click += OnBtnReadClick; + this.btnImport.Click += OnBtnImportClick; + this.btnOk.Click += OnBtnOkClick; + this.btnCancel.Click += OnBtnCancelClick; + this.splitMainContainer.SplitterPositionChanged += OnSplitMainContainerPositionChanged; + } + /// + /// 设置分割条位置 + /// + private void InitlizeSpiltLocation() + { + try + { + string splitMainWidth = IniHelper.Read(string.Format("PubSpecialImport_SplitMain_{0}", this.Model.ModuleCode));//通过Key获取Value值 + if (!string.IsNullOrEmpty(splitMainWidth)) + { + this.splitMainContainer.SplitterPosition = Convert.ToInt32(splitMainWidth); + } + } + catch (Exception ex) + { + MessageUtil.Show(ex.Message); + } + } + /// + /// 初始化表格列 + /// + private void InitGridColumns() + { + this.gcMain.AllowClearColumns = false; + GridColumn excelFieldNameColumn = this.gcMain.GridView.Columns.AddVisible("excelFieldName", "Excel列名"); + excelFieldNameColumn.Width = 200; + GridColumn clientFieldNameColumn = this.gcMain.GridView.Columns.AddVisible("clientFieldName", "绑定程序列"); + clientFieldNameColumn.Width = 200; + + //DataTable gridColumnsTab = BaseModuleImpl.GetBaseGridColumns(this.Model.ModuleCode); + DataTable gridColumnsTab = BillImpl.GetDetailColumns(this.Model.ModuleCode); + searchEdit.View.OptionsView.ShowIndicator = false; + searchEdit.View.OptionsView.ColumnAutoWidth = false; + //searchEdit.PopupSizeable = true; + //searchEdit.PopupResizeMode = ResizeMode.Default; + searchEdit.ImmediatePopup = true; + searchEdit.ShowFooter = false; + searchEdit.NullText = ""; + searchEdit.ValueMember = "dm"; + searchEdit.DisplayMember = "mc"; + searchEdit.View.Columns.AddVisible("dm", "dm").Width = 150; + searchEdit.View.Columns.AddVisible("mc", "mc").Width = 200; + searchEdit.View.OptionsView.ShowColumnHeaders = false; + this.gcMain.GridControl.RepositoryItems.Add(searchEdit); + clientFieldNameColumn.ColumnEdit = searchEdit; + searchEdit.DataSource = GetSearchSourceTable(gridColumnsTab); + searchEdit.View.Tag = searchEdit; + } + /// + /// 初始化多选控件 + /// + private void InitMulitControl() + { + if (!ERPInfo.Instance.UserName.Equals("管理员")) + { + pl_purview.Visible = false; + return; + } + purview_Mulit.LabelText = ""; + purview_Mulit.ValueMember = "UserId"; + purview_Mulit.TextField = "UserName"; + purview_Mulit.ValueField = "UserId"; + purview_Mulit.Model = new ControlModel() + { + FieldType = ControlType.LabMultiSelectValue, + }; + string fields = string.Empty; + if (BaseImpl.HasExistsColumn("P_EmployeeTab", "SignBmp")) + fields = ",SignBmp"; + if (BaseImpl.HasExistsColumn("P_EmployeeTab", "Password")) + fields += ",Password"; + if (BaseImpl.HasExistsColumn("P_EmployeeTab", "AD_Id")) + fields += ",AD_Id"; + string sqlValue = string.Format("select EmployeeId UserId,LoginAccount UserCode,EmployeeName UserName {0} from P_EmployeeTab WHERE sign=0 and UseFlag=1 order by loginaccount", fields); + DataTable dataSource = SqlHelper.ExecuteDataTable(sqlValue); + purview_Mulit.SourceSQL = sqlValue; + purview_Mulit.SetDataSource(dataSource); + purview_Mulit.TextEdit.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder; + } + /// + /// 初始化数据 + /// + private void InitDataSource() + { + if (BaseImpl.HasExistsTable("P_SpecialImportTab")) + { + if (!BaseImpl.HasExistsColumn("P_SpecialImportTab", "moduleId")) + { + string addColumnSql = "alter table P_SpecialImportTab add moduleId int"; + SqlHelper.ExecuteNonQuery(addColumnSql); + } + if (!BaseImpl.HasExistsColumn("P_SpecialImportTab", "rightMenuName")) + { + string addColumnSql = "alter table P_SpecialImportTab add rightMenuName varchar(100)"; + SqlHelper.ExecuteNonQuery(addColumnSql); + } + if (!BaseImpl.HasExistsColumn("P_SpecialImportTab", "Ls_CondFilter")) + { + string addColumnSql = "alter table P_SpecialImportTab add Ls_CondFilter varchar(1000)"; + SqlHelper.ExecuteNonQuery(addColumnSql); + } + if (!BaseImpl.HasExistsColumn("P_SpecialImportTab", "Ls_UnionColumn")) + { + string addColumnSql = "alter table P_SpecialImportTab add Ls_UnionColumn varchar(2000)"; + SqlHelper.ExecuteNonQuery(addColumnSql); + } + if (!BaseImpl.HasExistsColumn("P_SpecialImportTab", "Ls_CondPurview")) + { + string addColumnSql = "alter table P_SpecialImportTab add Ls_CondPurview varchar(1000)"; + SqlHelper.ExecuteNonQuery(addColumnSql); + } + DataTable dataTable = new DataTable(); + try + { + string menuName = Model.MenuName; + if (Model.BillDetailSql.StartsWith("*")) + { + string rightid = Model.BillDetailSql.TrimStart('*'); + string sqlValue = "select AllowNullExec,* from p_systempopupmenu "; + sqlValue = $"{sqlValue} where id = '{rightid}'"; + DataRow rowItem = BaseImpl.GetDataRowResult(sqlValue); + if (rowItem != null) + { + menuName = rowItem["menuname"] + ""; + } + } + string searchSql = string.Format("select * from P_SpecialImportTab where moduleId = '{0}' and rightMenuName = '{1}'", Model.ModuleCode, menuName); + dataTable = SqlHelper.ExecuteDataTable(searchSql); + } + catch (Exception) + { + } + if (dataTable != null && dataTable.Rows.Count > 0) + { + DataRow dataRow = dataTable.Rows[0]; + string condFilter = dataRow["Ls_CondFilter"] + ""; + string unionColumn = dataRow["Ls_UnionColumn"] + ""; + string condPurview = dataRow["Ls_CondPurview"] + ""; + + string[] values = condPurview.Trim(',').Split(','); + if (!values.Contains(ERPInfo.Instance.UserId)) + { + condTxtEdit.ReadOnly = true; + } + this.condTxtEdit.Text = condFilter; + this.purview_Mulit.EditText = condPurview; + List unionColumnList = unionColumn.Split(',').ToList(); + DataTable sourceTable = GetSourceTable(unionColumnList); + this.gcMain.GridControl.DataSource = sourceTable; + } + else + { + if (!ERPInfo.Instance.UserName.Equals("管理员")) + { + MessageUtil.Show("未获取到配置数据\r\n请联系管理员配置数据"); + this.Close(); + } + } + } + else + { + string createTableSql = "create table P_SpecialImportTab (moduleId int,rightMenuName varchar(100),Ls_CondFilter varchar(1000),Ls_UnionColumn varchar(2000),Ls_CondPurview varchar(1000))"; + SqlHelper.ExecuteNonQuery(createTableSql); + } + } + /// + /// 判断标题行 + /// + /// + /// + /// + /// + public bool IsTitleRow(string fileName, string sheetName = "", int firstRowIndex = 0) + { + bool isTitle = false; + DataTable data = new DataTable(); + FileStream fs; + IWorkbook workbook = null; + try + { + fs = new FileStream(fileName, FileMode.Open, FileAccess.Read); + if (fileName.IndexOf(".xlsx") > 0) // 2007版本 + { + workbook = new XSSFWorkbook(fs); + } + else if (fileName.IndexOf(".xls") > 0) // 2003版本 + { + workbook = new HSSFWorkbook(fs); + } + ISheet sheet; + if (!string.IsNullOrEmpty(sheetName)) + { + sheet = workbook.GetSheet(sheetName);//根据给定的sheet名称获取数据 + } + else + { + //也可以根据sheet编号来获取数据 + sheet = workbook.GetSheetAt(0);//获取第几个sheet表(此处表示如果没有给定sheet名称,默认是第一个sheet表) + } + if (sheet != null) + { + IRow firstRow = sheet.GetRow(firstRowIndex); + } + } + catch (Exception) + { + } + return isTitle; + } + /// + /// 获取表格数据 + /// + /// + /// + /// + /// + public DataTable ExcelToDatatable(string fileName, string sheetName = "", int firstRowIndex = 0) + { + DataTable data = new DataTable(); + FileStream fs; + IWorkbook workbook = null; + try + { + fs = new FileStream(fileName, FileMode.Open, FileAccess.Read); + if (fileName.IndexOf(".xlsx") > 0) // 2007版本 + { + workbook = new XSSFWorkbook(fs); + } + else if (fileName.IndexOf(".xls") > 0) // 2003版本 + { + workbook = new HSSFWorkbook(fs); + } + ISheet sheet; + if (!string.IsNullOrEmpty(sheetName)) + { + sheet = workbook.GetSheet(sheetName);//根据给定的sheet名称获取数据 + } + else + { + //也可以根据sheet编号来获取数据 + sheet = workbook.GetSheetAt(0);//获取第几个sheet表(此处表示如果没有给定sheet名称,默认是第一个sheet表) + } + if (sheet != null) + { + int startRow = firstRowIndex + 1; + IRow firstRow = sheet.GetRow(firstRowIndex); + IRow bandRow = null; + int cellCount = firstRow.LastCellNum; + for (int i = firstRow.FirstCellNum; i < firstRow.LastCellNum; i++)//第一行列数循环 + { + ICell titleCell = firstRow.GetCell(i); + ICell bandCell = null; + bool isBandTitle = false; + if (titleCell.IsMergedCell) + { + CellRangeAddress mergrRange = FindMergedRegion(sheet, firstRowIndex, i); + startRow = mergrRange.LastRow + 1; + if (mergrRange != null) + { + if (mergrRange.FirstColumn < mergrRange.LastColumn && !Model.CustomerServiceApp) + { + isBandTitle = true; + bandRow = sheet.GetRow(mergrRange.LastRow + 1); + titleCell = firstRow.GetCell(mergrRange.FirstColumn); + bandCell = bandRow.GetCell(i); + CellRangeAddress bandMergrRange = FindMergedRegion(sheet, mergrRange.LastRow + 1, i); + if (bandMergrRange != null) + { + startRow = bandMergrRange.LastRow + 1; + } + else + { + startRow = mergrRange.LastRow + 2; + } + } + else + { + startRow = mergrRange.LastRow + 1; + } + } + } + string fieldName = ""; + if (!isBandTitle || bandRow == null) + { + fieldName = GetCellValue(titleCell); + } + else + { + fieldName = $"{GetCellValue(titleCell)}|{GetCellValue(bandCell)}"; + } + if (string.IsNullOrEmpty(fieldName) && titleCell.IsMergedCell) + { + cellCount -= 1; + continue; + } + DataColumn column = new DataColumn(fieldName);//获取标题 + data.Columns.Add(column);//添加列 + } + //最后一行的标号 + int rowCount = sheet.LastRowNum; + for (int i = startRow; i <= rowCount; i++)//循环遍历所有行 + { + IRow row = sheet.GetRow(i);//第几行 + if (row == null) + { + continue; //没有数据的行默认是null; + } + //将excel表每一行的数据添加到datatable的行中 + DataRow dataRow = data.NewRow(); + for (int j = firstRow.FirstCellNum; j < cellCount; j++) + { + if (row.GetCell(j) != null) //同理,没有数据的单元格都默认是null + { + dataRow[j - firstRow.FirstCellNum] = GetCellValue(row.GetCell(j)); + } + } + data.Rows.Add(dataRow); + } + } + return data; + } + catch (IOException ex) + { + throw new IOException(string.Format("读取模板内容失败,原因:{0}", ex.Message)); + } + catch (Exception ex) + { + throw new Exception(string.Format("读取模板内容失败,原因:{0}", ex.Message)); + } + } + /// + /// 获取特殊单元格的值 + /// + /// + public string GetSpecialCellValue(string fileName, string sheetName = "", int rowIndex = 0, int colIndex = 0) + { + string value = ""; + FileStream fs; + IWorkbook workbook = null; + try + { + fs = new FileStream(fileName, FileMode.Open, FileAccess.Read); + if (fileName.IndexOf(".xlsx") > 0) // 2007版本 + { + workbook = new XSSFWorkbook(fs); + } + else if (fileName.IndexOf(".xls") > 0) // 2003版本 + { + workbook = new HSSFWorkbook(fs); + } + ISheet sheet; + if (!string.IsNullOrEmpty(sheetName)) + { + sheet = workbook.GetSheet(sheetName);//根据给定的sheet名称获取数据 + } + else + { + //也可以根据sheet编号来获取数据 + sheet = workbook.GetSheetAt(0);//获取第几个sheet表(此处表示如果没有给定sheet名称,默认是第一个sheet表) + } + if (sheet != null) + { + IRow firstRow = sheet.GetRow(rowIndex); + value = GetCellValue(firstRow.GetCell(colIndex)); + } + } + catch (Exception ex) + { + Console.WriteLine(ex.Message); + } + return value; + } + /// + /// 获取数据源 + /// + /// + private DataTable GetSourceTable(DataTable dataTable) + { + DataTable sourceTable = new DataTable(); + sourceTable.Columns.Add("excelFieldName"); + sourceTable.Columns.Add("clientFieldName"); + if (dataTable != null) + { + foreach (DataColumn col in dataTable.Columns) + { + DataRow dataRow = sourceTable.NewRow(); + dataRow["excelFieldName"] = col.ColumnName; + sourceTable.Rows.Add(dataRow); + } + } + if (!string.IsNullOrEmpty(specialValue)) + { + DataRow dataRow = sourceTable.NewRow(); + dataRow["excelFieldName"] = specialValue; + sourceTable.Rows.Add(dataRow); + } + return sourceTable; + } + /// + /// 获取数据源 + /// + /// + private DataTable GetSourceTable(List unionColumnList) + { + DataTable sourceTable = new DataTable(); + sourceTable.Columns.Add("excelFieldName"); + sourceTable.Columns.Add("clientFieldName"); + if (unionColumnList != null) + { + foreach (string unionColumn in unionColumnList) + { + string[] unionCilumnArray = unionColumn.Split('^'); + if (unionCilumnArray.Length == 2) + { + DataRow dataRow = sourceTable.NewRow(); + dataRow["excelFieldName"] = unionCilumnArray[0]; + dataRow["clientFieldName"] = unionCilumnArray[1]; + sourceTable.Rows.Add(dataRow); + } + } + } + return sourceTable; + } + /// + /// 获取搜索数据源 + /// + /// + private DataTable GetSearchSourceTable(DataTable dataTable) + { + DataTable sourceTable = new DataTable(); + sourceTable.Columns.Add("dm"); + sourceTable.Columns.Add("mc"); + if (dataTable != null && dataTable.Rows.Count > 0) + { + foreach (DataRow row in dataTable.Rows) + { + GridColumnModel model = new GridColumnModel(row); + if (model.Visible) + { + DataRow dataRow = sourceTable.NewRow(); + dataRow["dm"] = row["fieldname"]; + string username = row["username"] + ""; + if (string.IsNullOrEmpty(username)) + { + username = row["fieldname"] + ""; + } + dataRow["mc"] = username; + sourceTable.Rows.Add(dataRow); + } + } + } + return sourceTable; + } + /// + /// 获取关联列数据 + /// + /// + private string GetUnionColumn() + { + string unionColumn = ""; + DataTable sourceTable = this.gcMain.GridControl.DataSourceTable(); + if (sourceTable != null) + { + foreach (DataRow row in sourceTable.Rows) + { + unionColumn += string.Format("{0}^{1},", row["excelFieldName"], row["clientFieldName"]); + } + } + return unionColumn.TrimEnd(','); + } + /// + /// 导入到表格中 + /// + /// + /// + /// + /// + /// + private DataTable ToExcelDataTable(string fileName, out int count, out int errorCount, bool isDirectImport = false, bool isBillImport = false) + { + count = 0; + errorCount = 0; + GridView gridView = ParentView; + DataTable columnsTable = gcMain.gridControl.DataSourceTable(); + DataTable table = gridView.GridControl.DataSourceTable(); + DataTable sourceDataTable = ExcelToDatatable(fileName, Model.SheetName, FirstRowIndex); + DataView filterDataView = new DataView(sourceDataTable); + try + { + if (!string.IsNullOrEmpty(Model.ReadTableCond)) + { + filterDataView.RowFilter = Model.ReadTableCond; + } + } + catch (Exception) + { + } + List dataRows = columnsTable.Rows.Cast().Where(n => !string.IsNullOrEmpty(n["excelFieldName"] + "") && !string.IsNullOrEmpty(n["clientFieldName"] + "")).ToList(); + int index = gridView is BandedGridView ? FirstRowIndex + 1 : FirstRowIndex; + isBillImport = index == FirstRowIndex ? true : isBillImport; + string fileExt = Path.GetExtension(fileName).ToLower(); + + int CurrentRow = 0;//当前行数 + int CurrentColumn = 0;//当前列数 + string columnName = string.Empty;//当前列名 + bool ToAssignment = false;//是否在给新表赋值 + + try + { + ISheet sheet = ExcelHelper.GetSheet(fileName); + IRow firstRow = sheet.GetRow(index); + IRow bandRow = null; + int startRow = FirstRowIndex + 1; + string bandTitel = string.Empty; + ColumnList.Clear(); + int cellCount = firstRow.LastCellNum; + // 添加列 + for (int i = firstRow.FirstCellNum; i < firstRow.LastCellNum; i++) + { + ICell titleCell = firstRow.GetCell(i); + ICell bandCell = null; + bool isBandTitle = false; + if (titleCell.IsMergedCell) + { + CellRangeAddress mergrRange = FindMergedRegion(sheet, index, i); + startRow = mergrRange.LastRow + 1; + if (mergrRange != null) + { + if (mergrRange.FirstColumn < mergrRange.LastColumn && !Model.CustomerServiceApp) + { + isBandTitle = true; + bandRow = sheet.GetRow(mergrRange.LastRow + 1); + titleCell = firstRow.GetCell(mergrRange.FirstColumn); + bandCell = bandRow.GetCell(i); + CellRangeAddress bandMergrRange = FindMergedRegion(sheet, mergrRange.LastRow + 1, i); + if (bandMergrRange != null) + { + startRow = bandMergrRange.LastRow + 1; + } + else + { + startRow = mergrRange.LastRow + 2; + } + } + else + { + startRow = mergrRange.LastRow + 1; + } + } + } + string headerName = ""; + if (!isBandTitle || bandRow == null) + { + headerName = GetCellValue(titleCell); + } + else if (!string.IsNullOrEmpty(GetCellValue(bandCell))) + { + headerName = $"{GetCellValue(titleCell)}|{GetCellValue(bandCell)}"; + } + if (string.IsNullOrEmpty(headerName)) + { + cellCount -= 1; + continue; + } + DataRow row = columnsTable.Rows.Cast().Where(x => (x["excelFieldName"] + "").Equals(headerName)).FirstOrDefault(); + headerName = row != null ? row["clientFieldName"] + "" : headerName; + if (string.IsNullOrWhiteSpace(headerName)) + { + continue; + } + GridColumn col = gridView.Columns.OfType().FirstOrDefault(x => x.FieldName.Equals(headerName)); + if (col != null) + { + if (!table.Columns.Contains(col.FieldName)) + { + table.Columns.Add(col.FieldName, col.ColumnType); + } + ColumnList.Add(col.Tag as GridColumnModel); + } + else + { + MessageUtil.Show("未找到列->" + headerName + ""); + } + } + InitializeValueGrid(); + bool AutoImportCal = SystemInfo.Instance.AutoImportCal;//是否执行计算公式 + for (int i = startRow; i <= sheet.LastRowNum; i++) + { + ToAssignment = true; + CurrentRow = i; + DataRow rowSource = sourceDataTable.Rows[i - startRow]; + if (!filterDataView.Cast().Any(rowView => rowView.Row == rowSource) || !ValidateCond(condTxtEdit.Text, rowSource)) + { + continue; + } + GridColumn col = new GridColumn(); + IRow row = sheet.GetRow(i); + if (row == null) continue; + bandTitel = string.Empty; + DataRow specialDataRow = dataRows.Where(n => (n["excelFieldName"] + "").Equals(specialValue)).FirstOrDefault(); + string specialFieldName = specialDataRow != null ? specialDataRow["clientFieldName"] + "" : ""; + DataRow dataRow = table.NewRow(); + //if (i == sheet.LastRowNum && fileExt == ".xlsx") break; + for (int j = row.FirstCellNum; j < firstRow.LastCellNum; j++) + { + CurrentColumn = j; + ICell cell = row.GetCell(j); + ICell titleCell = firstRow.GetCell(j); + ICell bandCell = null; + bool isBandTitle = false; + if (titleCell.IsMergedCell) + { + CellRangeAddress mergrRange = FindMergedRegion(sheet, index, j); + startRow = mergrRange.LastRow + 1; + if (mergrRange != null) + { + if (mergrRange.FirstColumn < mergrRange.LastColumn && !Model.CustomerServiceApp) + { + isBandTitle = true; + bandRow = sheet.GetRow(mergrRange.LastRow + 1); + titleCell = firstRow.GetCell(mergrRange.FirstColumn); + bandCell = bandRow.GetCell(j); + CellRangeAddress bandMergrRange = FindMergedRegion(sheet, mergrRange.LastRow + 1, j); + if (bandMergrRange != null) + { + startRow = bandMergrRange.LastRow + 1; + } + else + { + startRow = mergrRange.LastRow + 2; + } + } + else + { + startRow = mergrRange.LastRow + 1; + } + } + } + if (!isBandTitle || bandRow == null) + { + columnName = GetCellValue(titleCell); + } + else if (!string.IsNullOrEmpty(GetCellValue(bandCell))) + { + columnName = $"{GetCellValue(titleCell)}|{GetCellValue(bandCell)}"; + } + if (string.IsNullOrEmpty(columnName)) + { + continue; + } + DataRow colDataRow = dataRows.Where(n => (n["excelFieldName"] + "").Equals(columnName)).FirstOrDefault(); + if (colDataRow == null) + { + continue; + } + columnName = colDataRow["clientFieldName"] + ""; + //if (!bandTitel.Equals(Bandcell + "") && !string.IsNullOrEmpty(Bandcell + "")) bandTitel = Bandcell + ""; + col = gridView.Columns.OfType().FirstOrDefault(x => x.FieldName.Equals(columnName)); + if (col == null) continue; + GridColumnModel model = col.Tag as GridColumnModel; + if (cell != null) + { + try + { + if (cell.CellType == CellType.Blank) + { + continue; + } + if (cell.CellType == CellType.Numeric && (cell + "").StartsWith("-")) + { + dataRow[col.FieldName] = cell.NumericCellValue; + if (AutoImportCal) + { + if (!string.IsNullOrEmpty(model.UnionFields)) + { + SetUnionValue(model, dataRow[col.FieldName] + "", dataRow); + } + SetCalcValue(model, dataRow[col.FieldName] + "", dataRow); + } + } + else + { + if (cell.CellType == CellType.Numeric) + { + + //GridColumnModel model = col.Tag as GridColumnModel; + if (model != null && isDirectImport && (model.FieldType == ControlType.LabDate || + model.FieldType == ControlType.LabDateTime || + model.FieldType == ControlType.LabDateTimeShort || + model.FieldType == ControlType.LabTime || + model.FieldType == ControlType.LabShortTime)) + { + string fieldValue = ToDateTimeValue(cell.NumericCellValue + ""); + if (fieldValue != "") + { + dataRow[col.FieldName] = Convert.ToDateTime(fieldValue); + if (AutoImportCal) + { + if (!string.IsNullOrEmpty(model.UnionFields)) + { + SetUnionValue(model, dataRow[col.FieldName] + "", dataRow); + } + SetCalcValue(model, dataRow[col.FieldName] + "", dataRow); + } + } + } + else + { + dataRow[col.FieldName] = cell.NumericCellValue; + if (AutoImportCal) + { + if (!string.IsNullOrEmpty(model.UnionFields)) + { + SetUnionValue(model, dataRow[col.FieldName] + "", dataRow); + } + SetCalcValue(model, dataRow[col.FieldName] + "", dataRow); + } + } + } + else + { + //GridColumnModel model = col.Tag as GridColumnModel; + if (model != null && isDirectImport && (model.FieldType == ControlType.LabTreeType || + model.FieldType == ControlType.LabComboxValue || + model.FieldType == ControlType.LabComboxValueParam || + model.FieldType == ControlType.LabAutoCompleteValue || + model.FieldType == ControlType.LabAutoCompleteValueParam || + model.FieldType == ControlType.LabMultiSelectValue || + model.FieldType == ControlType.LabMultiSelectValueParam + || model.FieldType == ControlType.LabTreeLookValue + )) + { + bool isEmpty = model.CanNull; + string fieldValue = GetValueByImportText(dataRow, col.FieldName, cell + "", isBillImport); + if ((model.FieldType == ControlType.LabMultiSelectValue || + model.FieldType == ControlType.LabMultiSelectValueParam) && GetCellValue(cell).Contains(",")) + { + string[] cellText = GetCellValue(cell).Split(','); + foreach (string cellValue in cellText) + { + fieldValue += GetValueByImportText(dataRow, col.FieldName, cellValue, isBillImport) + ','; + } + fieldValue = fieldValue.TrimEnd(','); + } + if (string.IsNullOrEmpty(fieldValue)) + { + if (isEmpty) + { + MessageUtil.Show("该列不允许为空->" + col.Caption + ""); + } + else + { + GridColumn column = gridView.Columns[col.FieldName]; + if (column.ColumnType.Name.ToLower().IndexOf("int") >= 0) + if (column.ColumnType.Name.ToLower() == "string") + dataRow[col.FieldName] = ""; + if (column.ColumnType.Name.ToLower().IndexOf("char") >= 0) + dataRow[col.FieldName] = ""; + if (column.ColumnType.Name.ToLower().IndexOf("int") >= 0) + dataRow[col.FieldName] = 0; + if (column.ColumnType.Name.ToLower() == "decimal") + dataRow[col.FieldName] = 0; + if (AutoImportCal) + { + if (!string.IsNullOrEmpty(model.UnionFields)) + { + SetUnionValue(model, dataRow[col.FieldName] + "", dataRow); + } + SetCalcValue(model, dataRow[col.FieldName] + "", dataRow); + } + } + } + else + { + dataRow[col.FieldName] = fieldValue; + if (AutoImportCal) + { + if (!string.IsNullOrEmpty(model.UnionFields)) + { + SetUnionValue(model, dataRow[col.FieldName] + "", dataRow); + } + SetCalcValue(model, dataRow[col.FieldName] + "", dataRow); + } + } + } + else + { + IRichTextString richTextString = (IRichTextString)cell.RichStringCellValue; + if (fileExt == ".xlsx") + { + cell.SetCellValue(richTextString); + } + else if (fileExt == ".xls") + { + string cellValue = string.Empty; + for (int m = 0; m < richTextString.Length; m++) + { + + //string aaa = richTextString.String.Substring(m , 1); + //short aaa = richTextString.GetFontAtIndex(m); + IFont font = sheet.Workbook.GetFontAt(richTextString.GetFontAtIndex(m));//richTextString.GetFontAtIndex(m) + + string str = string.Empty; + string code = richTextString.ToString().Substring(m, 1); + switch (font.TypeOffset) + { + case FontSuperScript.Sub: + str = ChemistryHelper.GetSubChar(code); + break; + + case FontSuperScript.Super: + str = ChemistryHelper.GetSuperChar(code); + break; + default: + str = code; + break; + } + cellValue = cellValue + str; + } + cell.SetCellValue(cellValue); + } + dataRow[col.FieldName] = GetCellValue(cell); + if (AutoImportCal) + { + if (!string.IsNullOrEmpty(model.UnionFields)) + { + SetUnionValue(model, dataRow[col.FieldName] + "", dataRow); + } + SetCalcValue(model, dataRow[col.FieldName] + "", dataRow); + } + } + } + } + } + catch (Exception) + { + throw; + } + } + } + if (!string.IsNullOrEmpty(specialFieldName) && dataRow.Table.Columns.Contains(specialFieldName)) + { + dataRow[specialFieldName] = specialValue; + } + table.Rows.Add(dataRow); + count += 1; + } + ToAssignment = false; + } + catch (InvalidOperationException ex) + { + + if (ToAssignment && (CurrentRow != 0 || CurrentColumn != 0)) + { + string value = string.Format("第{0}行,第{1}列 {2},值出现异常", CurrentRow, CurrentColumn + 1, columnName); + MessageUtil.Show(value); + } + else + { + MessageUtil.Show(ResourceKeys.DeleteLastTotalRow); + } + } + catch (IOException exe) + { + //string Message = ErrorMessage.PromptErrorMessage(exe); + //MessageUtil.Show(Message, exe.Message); + MessageUtil.Show(string.Format(ResourceKeys.UseingFile, Path.GetFileName(fileName))); + } + catch (Exception ex) + { + //MessageUtil.Show(ResourceKeys.ImportFault + ex.Message); + LogUtil.WriteError("读取excel出错!", ex); + string Message = ErrorMessage.PromptErrorMessage(ex); + MessageUtil.Show(Message, ex.Message); + } + return table.TrimEmptyRows(); + } + /// + /// 导入表的时候将下拉框的值存储 + /// + /// + private void InitializeValueGrid() + { + GridView gridView = ParentView; + ValueGridColumnTable = new Dictionary(); + _checkColumns = new List(); + LookupParentKey = new Dictionary(); + foreach (GridColumn col in gridView.Columns) + { + if (col.Tag is GridColumnModel) + { + GridColumnModel model = col.Tag as GridColumnModel; + if (model != null && !ValueGridColumnTable.ContainsKey(model)) + { + if (model.FieldType == ControlType.LabTreeType || + model.FieldType == ControlType.LabComboxValue || + model.FieldType == ControlType.LabComboxValueParam || + model.FieldType == ControlType.LabAutoCompleteValue || + model.FieldType == ControlType.LabAutoCompleteValueParam || + model.FieldType == ControlType.LabMultiSelectValue || + model.FieldType == ControlType.LabMultiSelectValueParam + || model.FieldType == ControlType.LabTreeLookValue + ) + { + string sqlValue = model.SqlSource; + if (sqlValue.Contains(" #")) + { + //sqlValue = sqlValue.Replace("#", ""); + Match m = Regex.Match(sqlValue, @"#([\s\S]*?)#"); + //处理带参数上一级编码过滤问题,需在带参数sql中增加名称的父级字段 + if (m.Success) + { + sqlValue = ReplaceHelper.ReplaceParam(sqlValue); + LookupParentKey.Add(model.FieldName, m.Value.Replace("#", "")); + } + } + ValueGridColumnTable.Add(model, BaseImpl.GetDataTableResult(sqlValue)); + + if (model.FieldType == ControlType.LabTreeType) + { + _treeColumnName = model.FieldName; + } + } + if (model.FieldType == ControlType.LabCheckBox) + { + _checkColumns.Add(col.FieldName.ToLower()); + } + } + } + } + } + /// + /// 计算列关联字段 + /// + /// + /// + /// + private void SetUnionValue(GridColumnModel model, string fieldValue, DataRow rowItem) + { + //DataTable table = gcMain.gridControl.DataSourceTable(); + //DataRow rowItem = this.gridView.GetFocusedDataRow(); + string unionValues = model.UnionValues; + if (rowItem != null && model != null) + { + // if (this.ControlObj != null) + // unionValues = this.ControlObj.ReplaceParentControlValue(unionValues); + unionValues = ReplaceHelper.ReplaceRowParam(rowItem, unionValues.Replace("{" + model.FieldName + "}", fieldValue)); + try + { + string[] fields = model.UnionFields.Trim(',').Split(','); + DataRow rowResult = BaseImpl.GetDataRowResult(unionValues); + if (rowResult != null) + { + for (int i = 0; i < fields.Length; i++) + { + string field = fields[i]; + string value = rowResult.Table.Columns.Contains(field) ? rowResult[field] + "" : null; + rowItem[field] = value; + } + } + else + { + // 设置为空 + for (int i = 0; i < fields.Length; i++) + { + string field = fields[i]; + rowItem[field] = DBNull.Value; + } + } + } + catch (Exception ex) + { + LogHelper.Instance.WriteError(ex); + LogUtil.WriteError("计算列关联字段--错误-->" + unionValues, ex); + } + } + } + /// + /// 计算列计算公式 + /// + /// + /// + /// + private void SetCalcValue(GridColumnModel model, string fieldValue, DataRow rowItem) + { + try + { + if (rowItem != null && model != null) + { + foreach (GridColumn col in this.ParentView.Columns) + { + GridColumnModel colModel = col.Tag as GridColumnModel; + if (colModel == null) continue; + string defultValue = colModel.DefaultValue; + if (colModel.FieldType == 7 && rowItem.Table.Columns.Contains(col.FieldName) && string.IsNullOrEmpty(rowItem[col.FieldName] + "") && !string.IsNullOrEmpty(colModel.DefaultValue)) + { + defultValue = ReplaceHelper.ReplaceUserInfo(colModel.DefaultValue); + if (defultValue.StartsWith("@")) + { + defultValue = BaseImpl.GetDefaultValue(ReplaceHelper.ReplaceRowParam(rowItem, defultValue)); + } + + if (IsNumberic(defultValue)) rowItem[col.FieldName] = defultValue;//colModel.DefaultValue; + + } + } + List calcModels = ColumnList.FindAll(x => !string.IsNullOrEmpty(x.CalcExpr)).OrderBy(y => y.CalcOrder).ToList(); + foreach (GridColumnModel gridModel in calcModels) + { + // 计算顺序小于当前控件则不计算 + if (gridModel.CalcOrder < model.CalcOrder) continue; + + if (!gridModel.FieldName.Equals(model.FieldName, StringComparison.OrdinalIgnoreCase)) + { + bool isTruncate = false; + string calcExpr = gridModel.CalcExpr; + if (calcExpr.StartsWith("@truncate:")) + { + calcExpr = calcExpr.Substring(10); + isTruncate = true; + } + + try + { + string result = string.Empty; + if (calcExpr.StartsWith("@")) + { + result = BaseImpl.GetDefaultValue(ReplaceHelper.ReplaceRowParam(rowItem, calcExpr)); + } + else + { + calcExpr = ReplaceHelper.ReplaceRowParam(rowItem, calcExpr); + result = EvalHelper.Eval2(ReplaceHelper.ReplaceEvalCond(calcExpr)) + ""; + } + if (isTruncate) + { + result += result.Contains(".") ? "0000000000" : ".0000000000"; + rowItem[gridModel.FieldName] = result.Substring(0, result.IndexOf(".")) + result.Substring(result.IndexOf("."), model.Decimals + 1); + //this.gridView.SetRowCellValue(this.gridView.FocusedRowHandle, this.gridView.Columns[gridModel.FieldName], result.Substring(0, result.IndexOf(".")) + result.Substring(result.IndexOf("."), model.Decimals + 1)); + } + else + { + try + { + double d = 0; + if (!string.IsNullOrEmpty(result) && + !"NaN".Equals(result, StringComparison.OrdinalIgnoreCase) && + !"非数字".Equals(result, StringComparison.OrdinalIgnoreCase) && + !"undefined".Equals(result, StringComparison.OrdinalIgnoreCase) && + result != "∞" && result != "-∞" && + !"正无穷大".Equals(result, StringComparison.OrdinalIgnoreCase) && + !"负无穷大".Equals(result, StringComparison.OrdinalIgnoreCase) && + double.TryParse(result, out d)) + { + if (string.IsNullOrEmpty(gridModel.DataFormat)) + { + result = Math.Round(Convert.ToDouble(d), model.Decimals, MidpointRounding.AwayFromZero) + ""; + } + else + { + //计算后先执行保存小数位数 + if (SystemInfo.Instance.ComputeFormatting) result = string.Format("{0:" + gridModel.DataFormat + "}", Convert.ToDecimal(result)); + } + if (model.FieldType == 7 && result.Contains('%')) + { + result = (double.Parse(result.Replace("%", "")) * 0.01).ToString(); + } + rowItem[gridModel.FieldName] = result; + // 判断计算列有无关联值 + GridColumnModel UnionModel = calcModels.FirstOrDefault(x => x.FieldName == gridModel.FieldName); + if (!string.IsNullOrEmpty(UnionModel.UnionFields)) + { + this.SetUnionValue(UnionModel, rowItem[gridModel.FieldName] + "", rowItem); + } + //this.gridView.SetRowCellValue(this.gridView.FocusedRowHandle, this.gridView.Columns[gridModel.FieldName], result); + } + } + catch (Exception) + { + + } + } + } + catch (Exception ex) + { + LogHelper.Instance.WriteError(ex); + LogUtil.WriteError("计算列计算公式--错误-->" + rowItem[gridModel.FieldName], ex); + } + } + } + } + } + catch (Exception ex) + { + Console.WriteLine(ex.Message); + } + } + /// + /// 判断输入的字符串是否可以转换成数值类型 + /// + /// + /// + public static bool IsNumberic(string str) + { + double vsNum; + bool isNum; + isNum = double.TryParse(str, System.Globalization.NumberStyles.Float, + System.Globalization.NumberFormatInfo.InvariantInfo, out vsNum); + return isNum; + } + /// + /// 获取导入到下拉框里的显示值 + /// + /// + /// + /// + /// + /// + public static string GetValueByImportText(DataRow row, string fieldName, string text, bool isBillImport = false) + { + string value = text; + foreach (GridColumnModel model in ValueGridColumnTable.Keys) + { + if (model.FieldName.Equals(fieldName, StringComparison.OrdinalIgnoreCase)) + { + string selWhere = "1=1"; + DataTable table = ValueGridColumnTable[model]; + if (table != null && table.Rows.Count > 0) + { + DataRow rowItemValue = table.Rows.Cast().FirstOrDefault(x => x[model.TextMember] + "" == text); + DataRow rowItemText = table.Rows.Cast().FirstOrDefault(x => x[model.ValueMember] + "" == text); + value = rowItemValue != null ? rowItemValue[isBillImport ? model.ValueMember : model.TextMember] + "" : rowItemText != null ? rowItemText[isBillImport ? model.ValueMember : model.TextMember] + "" : ""; + } + else + value = ""; + } + } + return value; + } + /// + /// 数字转换时间格式 + /// + /// + /// 日期/时间格式 + private static string ToDateTimeValue(string strNumber) + { + string returnData = ""; + if (!string.IsNullOrWhiteSpace(strNumber)) + { + if (!string.IsNullOrWhiteSpace(strNumber)) + { + DateTime dateTime = DateTime.FromOADate(Convert.ToDouble(strNumber)); + returnData = dateTime.ToString("yyyy-MM-dd HH:mm:ss"); + } + } + return returnData; + } + /// + /// 说明:检查可用条件 + /// 创建日期:2024-3-19 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The cond. + /// The data row. + /// true if XXXX, false otherwise. + public bool ValidateCond(string cond, DataRow dataRow) + { + bool result = false; + try + { + cond = ReplaceHelper.ReplaceRowParam(dataRow, cond); + if (cond.StartsWith("@") || cond.StartsWith("!")) + { + result = "1".Equals(BaseImpl.GetDefaultValue(cond)); + } + else if (dataRow == null) + { + result = ReplaceHelper.EvalCond(cond); + } + else + { + result = ReplaceHelper.ReplaceRowParamCond(dataRow, cond); + } + } + catch (Exception) + { + } + return result; + } + /// + /// 获取合并区域 + /// + /// + /// + /// + /// + private CellRangeAddress FindMergedRegion(ISheet sheet, int rowIndex, int columnIndex) + { + int mergedRegionsCount = sheet.NumMergedRegions; + + for (int i = 0; i < mergedRegionsCount; i++) + { + CellRangeAddress mergedRegion = sheet.GetMergedRegion(i); + if (mergedRegion.IsInRange(rowIndex, columnIndex)) + { + return mergedRegion; // 返回合并区域 + } + } + return null; // 未找到合并区域 + } + /// + /// 获取单元格值 + /// + /// + /// + public static string GetCellValue(ICell cell) + { + string cellValue = ""; + try + { + if (cell != null) + { + // 根据单元格类型获取值 + switch (cell.CellType) + { + case CellType.String: + cellValue = cell.StringCellValue; + break; + case CellType.Numeric: + cellValue = cell.NumericCellValue.ToString(); + break; + case CellType.Boolean: + cellValue = cell.BooleanCellValue.ToString(); + break; + case CellType.Formula://单元格中带有公式,根据类型继续判断 + switch (cell.CachedFormulaResultType) + { + case CellType.String: + cellValue = cell.StringCellValue; + \ No newline at end of file diff --git a/插件库/Lskj.PubBomImport/FrmMain.resx b/插件库/Lskj.PubBomImport/FrmMain.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/插件库/Lskj.PubBomImport/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.PubBomImport/Lskj.PubBomImport.csproj b/插件库/Lskj.PubBomImport/Lskj.PubBomImport.csproj new file mode 100644 index 0000000..432feb9 --- /dev/null +++ b/插件库/Lskj.PubBomImport/Lskj.PubBomImport.csproj @@ -0,0 +1,118 @@ + + + + + Debug + AnyCPU + {8C507C31-8C19-46C9-82F8-85DDCAE69190} + Library + Lskj.PubBomImport + Lskj.PubBomImport + v4.0 + 512 + true + + + true + full + false + ..\..\Debug\Lib\ + DEBUG;TRACE + prompt + 4 + x86 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + False + D:\工作\lserp_cs_6.0\引用DLL\Newtonsoft.Json.dll + + + ..\..\..\引用DLL\NPOI.dll + + + ..\..\..\引用DLL\NPOI.OOXML.dll + + + D:\工作\lserp_cs_6.0\引用DLL\NPOI.OpenXml4Net.dll + + + D:\工作\lserp_cs_6.0\引用DLL\NPOI.OpenXmlFormats.dll + + + + + + + + + + + + + + + Form + + + FrmBillInfo.cs + + + Form + + + FrmMain.cs + + + + + + + FrmBillInfo.cs + + + FrmMain.cs + + + + + + {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 + + + {52BC40E0-C0C6-4F78-996B-CAE028D209CA} + Lskj.Model + + + {A51BF642-6543-4DE3-8948-83F558B72BD4} + Lskj.Util + + + + \ No newline at end of file diff --git a/插件库/Lskj.PubBomImport/Properties/AssemblyInfo.cs b/插件库/Lskj.PubBomImport/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..090c46f --- /dev/null +++ b/插件库/Lskj.PubBomImport/Properties/AssemblyInfo.cs @@ -0,0 +1,9 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的一般信息由以下 +// 控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("Lskj.PubBomImport")] +[assembly: AssemblyDe \ No newline at end of file