diff --git a/WindowsFormsApp1/MES_PLC_Control.csproj b/WindowsFormsApp1/MES_PLC_Control.csproj index 1144cc4..8569eb6 100644 --- a/WindowsFormsApp1/MES_PLC_Control.csproj +++ b/WindowsFormsApp1/MES_PLC_Control.csproj @@ -81,17 +81,113 @@ - + Form - - FLOW_Manage.cs + + Line_Insert.cs - + Form - - LINE_Manage.cs + + LinePLC_Insert.cs + + + Form + + + MESUrl_Insert.cs + + + Form + + + Angleaddress_Insert.cs + + + Form + + + Torqueaddress_Insert.cs + + + Form + + + Plc_Insert.cs + + + Form + + + User_Insert.cs + + + Form + + + SerialPort_Insert.cs + + + Form + + + PlcAddress_Insert.cs + + + Form + + + KeyValue_Insert.cs + + + Form + + + Flow_Manage.cs + + + Form + + + FLow_Insert.cs + + + Form + + + LinePLC_Manage.cs + + + Form + + + Line_Manage.cs + + + Form + + + KeyValue.cs + + + Form + + + Angleaddress_Manage.cs + + + Form + + + Torqueaddress_Manage.cs + + + Form + + + ScanForm.cs Form @@ -99,23 +195,23 @@ SerialPort_Manage.cs - + Form - - PLCADDRESS_Manage.cs + + PlcAddress_Manage.cs - + Form - - PLC_Manage.cs + + Plc_Manage.cs - + Form - - USER_ChangeP.cs + + UserChangeP.cs Form @@ -129,15 +225,19 @@ LoginForm.cs - + Form - - MES_URL.cs + + MESUrl.cs + + + + @@ -149,37 +249,87 @@ - + Form - - USER_Manage.cs + + User_Manage.cs + - - FLOW_Manage.cs + + + Line_Insert.cs - - LINE_Manage.cs + + LinePLC_Insert.cs + + + MESUrl_Insert.cs + + + Angleaddress_Insert.cs + + + Torqueaddress_Insert.cs + + + Plc_Insert.cs + + + User_Insert.cs + + + SerialPort_Insert.cs + + + PlcAddress_Insert.cs + + + KeyValue_Insert.cs + + + FLow_Insert.cs + + + Flow_Manage.cs + + + LinePLC_Manage.cs + + + Line_Manage.cs + + + KeyValue.cs + + + Angleaddress_Manage.cs + + + Torqueaddress_Manage.cs + + + ScanForm.cs SerialPort_Manage.cs - - PLCADDRESS_Manage.cs + + PlcAddress_Manage.cs - - PLC_Manage.cs + + Plc_Manage.cs - - USER_ChangeP.cs + + UserChangeP.cs - - USER_Manage.cs + + User_Manage.cs MainForm.cs @@ -187,8 +337,8 @@ LoginForm.cs - - MES_URL.cs + + MESUrl.cs ResXFileCodeGenerator diff --git a/WindowsFormsApp1/MainForm.Designer.cs b/WindowsFormsApp1/MainForm.Designer.cs index fd69b8e..005430f 100644 --- a/WindowsFormsApp1/MainForm.Designer.cs +++ b/WindowsFormsApp1/MainForm.Designer.cs @@ -35,14 +35,19 @@ this.切换用户ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.用户管理ToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); this.产线管理ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.产线基础信息管理ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.产线关联PLC管理ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.pLC管理ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.pLC通讯设置ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.pLC地址设置ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.pLC报警设置ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.流程管理ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.mES接口配置ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.扫码枪配置ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.扫码枪配置ToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); + this.扭力角度扭矩设置ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.扭力曲线配置ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.压力曲线设置ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.系统参数配置ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); this.tableLayoutPanel4 = new System.Windows.Forms.TableLayoutPanel(); @@ -52,10 +57,11 @@ this.Tray盘二维码 = new System.Windows.Forms.Label(); this.原料包装LOT号 = new System.Windows.Forms.GroupBox(); this.tableLayoutPanel5 = new System.Windows.Forms.TableLayoutPanel(); - this.LOT号扫描 = new System.Windows.Forms.Label(); + this.MES提示信息 = new System.Windows.Forms.Label(); + this.MES提示 = new System.Windows.Forms.Label(); this.LOT号显示 = new System.Windows.Forms.Label(); this.LOT号 = new System.Windows.Forms.Label(); - this.请扫描LOT号 = new System.Windows.Forms.Label(); + this.胶水上下线 = new System.Windows.Forms.Button(); this.groupBox2 = new System.Windows.Forms.GroupBox(); this.tableLayoutPanel7 = new System.Windows.Forms.TableLayoutPanel(); this.事件4时间 = new System.Windows.Forms.Label(); @@ -93,6 +99,7 @@ this.底部注释4 = new System.Windows.Forms.Label(); this.底部注释5 = new System.Windows.Forms.Label(); this.timer1 = new System.Windows.Forms.Timer(this.components); + this.螺丝枪扭力设置ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.menuStrip1.SuspendLayout(); this.tableLayoutPanel1.SuspendLayout(); this.tableLayoutPanel4.SuspendLayout(); @@ -162,16 +169,33 @@ // // 产线管理ToolStripMenuItem // + this.产线管理ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.产线基础信息管理ToolStripMenuItem, + this.产线关联PLC管理ToolStripMenuItem}); this.产线管理ToolStripMenuItem.Name = "产线管理ToolStripMenuItem"; this.产线管理ToolStripMenuItem.Size = new System.Drawing.Size(145, 40); this.产线管理ToolStripMenuItem.Text = "产线管理"; - this.产线管理ToolStripMenuItem.Click += new System.EventHandler(this.产线管理ToolStripMenuItem_Click); + // + // 产线基础信息管理ToolStripMenuItem + // + this.产线基础信息管理ToolStripMenuItem.Name = "产线基础信息管理ToolStripMenuItem"; + this.产线基础信息管理ToolStripMenuItem.Size = new System.Drawing.Size(359, 44); + this.产线基础信息管理ToolStripMenuItem.Text = "产线基础信息管理"; + this.产线基础信息管理ToolStripMenuItem.Click += new System.EventHandler(this.产线基础信息管理ToolStripMenuItem_Click); + // + // 产线关联PLC管理ToolStripMenuItem + // + this.产线关联PLC管理ToolStripMenuItem.Name = "产线关联PLC管理ToolStripMenuItem"; + this.产线关联PLC管理ToolStripMenuItem.Size = new System.Drawing.Size(359, 44); + this.产线关联PLC管理ToolStripMenuItem.Text = "产线关联PLC管理"; + this.产线关联PLC管理ToolStripMenuItem.Click += new System.EventHandler(this.产线关联PLC管理ToolStripMenuItem_Click); // // pLC管理ToolStripMenuItem // this.pLC管理ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.pLC通讯设置ToolStripMenuItem, - this.pLC地址设置ToolStripMenuItem}); + this.pLC地址设置ToolStripMenuItem, + this.pLC报警设置ToolStripMenuItem}); this.pLC管理ToolStripMenuItem.Name = "pLC管理ToolStripMenuItem"; this.pLC管理ToolStripMenuItem.Size = new System.Drawing.Size(139, 40); this.pLC管理ToolStripMenuItem.Text = "PLC管理"; @@ -190,6 +214,12 @@ this.pLC地址设置ToolStripMenuItem.Text = "PLC地址设置"; this.pLC地址设置ToolStripMenuItem.Click += new System.EventHandler(this.pLC地址设置ToolStripMenuItem_Click); // + // pLC报警设置ToolStripMenuItem + // + this.pLC报警设置ToolStripMenuItem.Name = "pLC报警设置ToolStripMenuItem"; + this.pLC报警设置ToolStripMenuItem.Size = new System.Drawing.Size(297, 44); + this.pLC报警设置ToolStripMenuItem.Text = "PLC报警设置"; + // // 流程管理ToolStripMenuItem // this.流程管理ToolStripMenuItem.Name = "流程管理ToolStripMenuItem"; @@ -208,7 +238,10 @@ // this.扫码枪配置ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.扫码枪配置ToolStripMenuItem1, - this.扭力曲线配置ToolStripMenuItem}); + this.扭力角度扭矩设置ToolStripMenuItem, + this.螺丝枪扭力设置ToolStripMenuItem, + this.扭力曲线配置ToolStripMenuItem, + this.压力曲线设置ToolStripMenuItem}); this.扫码枪配置ToolStripMenuItem.Name = "扫码枪配置ToolStripMenuItem"; this.扫码枪配置ToolStripMenuItem.Size = new System.Drawing.Size(201, 40); this.扫码枪配置ToolStripMenuItem.Text = "外围设备配置"; @@ -217,20 +250,34 @@ // this.扫码枪配置ToolStripMenuItem1.Name = "扫码枪配置ToolStripMenuItem1"; this.扫码枪配置ToolStripMenuItem1.Size = new System.Drawing.Size(315, 44); - this.扫码枪配置ToolStripMenuItem1.Text = "扫码枪配置"; + this.扫码枪配置ToolStripMenuItem1.Text = "COM口配置"; this.扫码枪配置ToolStripMenuItem1.Click += new System.EventHandler(this.扫码枪配置ToolStripMenuItem1_Click); // + // 扭力角度扭矩设置ToolStripMenuItem + // + this.扭力角度扭矩设置ToolStripMenuItem.Name = "扭力角度扭矩设置ToolStripMenuItem"; + this.扭力角度扭矩设置ToolStripMenuItem.Size = new System.Drawing.Size(331, 44); + this.扭力角度扭矩设置ToolStripMenuItem.Text = "螺丝枪角度设置"; + this.扭力角度扭矩设置ToolStripMenuItem.Click += new System.EventHandler(this.扭力角度扭矩设置ToolStripMenuItem_Click); + // // 扭力曲线配置ToolStripMenuItem // this.扭力曲线配置ToolStripMenuItem.Name = "扭力曲线配置ToolStripMenuItem"; this.扭力曲线配置ToolStripMenuItem.Size = new System.Drawing.Size(315, 44); this.扭力曲线配置ToolStripMenuItem.Text = "扭力曲线配置"; // + // 压力曲线设置ToolStripMenuItem + // + this.压力曲线设置ToolStripMenuItem.Name = "压力曲线设置ToolStripMenuItem"; + this.压力曲线设置ToolStripMenuItem.Size = new System.Drawing.Size(315, 44); + this.压力曲线设置ToolStripMenuItem.Text = "压力曲线设置"; + // // 系统参数配置ToolStripMenuItem // this.系统参数配置ToolStripMenuItem.Name = "系统参数配置ToolStripMenuItem"; this.系统参数配置ToolStripMenuItem.Size = new System.Drawing.Size(201, 40); this.系统参数配置ToolStripMenuItem.Text = "系统参数配置"; + this.系统参数配置ToolStripMenuItem.Click += new System.EventHandler(this.系统参数配置ToolStripMenuItem_Click); // // tableLayoutPanel1 // @@ -337,13 +384,15 @@ // this.tableLayoutPanel5.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; this.tableLayoutPanel5.CellBorderStyle = System.Windows.Forms.TableLayoutPanelCellBorderStyle.Single; - this.tableLayoutPanel5.ColumnCount = 2; - this.tableLayoutPanel5.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); - this.tableLayoutPanel5.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 80F)); - this.tableLayoutPanel5.Controls.Add(this.LOT号扫描, 0, 0); - this.tableLayoutPanel5.Controls.Add(this.LOT号显示, 0, 1); - this.tableLayoutPanel5.Controls.Add(this.LOT号, 1, 1); - this.tableLayoutPanel5.Controls.Add(this.请扫描LOT号, 1, 0); + this.tableLayoutPanel5.ColumnCount = 3; + this.tableLayoutPanel5.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 22.22222F)); + this.tableLayoutPanel5.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 66.66666F)); + this.tableLayoutPanel5.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 11.11111F)); + this.tableLayoutPanel5.Controls.Add(this.MES提示信息, 1, 1); + this.tableLayoutPanel5.Controls.Add(this.MES提示, 0, 1); + this.tableLayoutPanel5.Controls.Add(this.LOT号显示, 0, 0); + this.tableLayoutPanel5.Controls.Add(this.LOT号, 1, 0); + this.tableLayoutPanel5.Controls.Add(this.胶水上下线, 2, 0); this.tableLayoutPanel5.Dock = System.Windows.Forms.DockStyle.Fill; this.tableLayoutPanel5.Location = new System.Drawing.Point(3, 35); this.tableLayoutPanel5.Name = "tableLayoutPanel5"; @@ -353,25 +402,36 @@ this.tableLayoutPanel5.Size = new System.Drawing.Size(1218, 229); this.tableLayoutPanel5.TabIndex = 0; // - // LOT号扫描 + // MES提示信息 // - this.LOT号扫描.Anchor = System.Windows.Forms.AnchorStyles.None; - this.LOT号扫描.AutoSize = true; - this.LOT号扫描.Font = new System.Drawing.Font("宋体", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.LOT号扫描.Location = new System.Drawing.Point(40, 15); - this.LOT号扫描.Name = "LOT号扫描"; - this.LOT号扫描.Size = new System.Drawing.Size(165, 84); - this.LOT号扫描.TabIndex = 3; - this.LOT号扫描.Text = "LOT号扫描:"; + this.MES提示信息.Anchor = System.Windows.Forms.AnchorStyles.None; + this.MES提示信息.AutoSize = true; + this.MES提示信息.Font = new System.Drawing.Font("宋体", 26.14286F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.MES提示信息.Location = new System.Drawing.Point(376, 140); + this.MES提示信息.Name = "MES提示信息"; + this.MES提示信息.Size = new System.Drawing.Size(598, 62); + this.MES提示信息.TabIndex = 5; + this.MES提示信息.Text = "MES提示信息:11111"; + // + // MES提示 + // + this.MES提示.Anchor = System.Windows.Forms.AnchorStyles.None; + this.MES提示.AutoSize = true; + this.MES提示.Font = new System.Drawing.Font("宋体", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.MES提示.Location = new System.Drawing.Point(32, 150); + this.MES提示.Name = "MES提示"; + this.MES提示.Size = new System.Drawing.Size(207, 42); + this.MES提示.TabIndex = 4; + this.MES提示.Text = "MES提示:"; // // LOT号显示 // this.LOT号显示.Anchor = System.Windows.Forms.AnchorStyles.None; this.LOT号显示.AutoSize = true; this.LOT号显示.Font = new System.Drawing.Font("宋体", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.LOT号显示.Location = new System.Drawing.Point(40, 129); + this.LOT号显示.Location = new System.Drawing.Point(11, 36); this.LOT号显示.Name = "LOT号显示"; - this.LOT号显示.Size = new System.Drawing.Size(165, 84); + this.LOT号显示.Size = new System.Drawing.Size(249, 42); this.LOT号显示.TabIndex = 2; this.LOT号显示.Text = "LOT号显示:"; // @@ -380,23 +440,23 @@ this.LOT号.Anchor = System.Windows.Forms.AnchorStyles.None; this.LOT号.AutoSize = true; this.LOT号.Font = new System.Drawing.Font("宋体", 26.14286F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.LOT号.Location = new System.Drawing.Point(270, 140); + this.LOT号.Location = new System.Drawing.Point(327, 26); this.LOT号.Name = "LOT号"; - this.LOT号.Size = new System.Drawing.Size(921, 62); + this.LOT号.Size = new System.Drawing.Size(697, 62); this.LOT号.TabIndex = 0; - this.LOT号.Text = "LOT号:231321919199191919191"; + this.LOT号.Text = "LOT号:23199191919191"; // - // 请扫描LOT号 + // 胶水上下线 // - this.请扫描LOT号.Anchor = System.Windows.Forms.AnchorStyles.None; - this.请扫描LOT号.AutoSize = true; - this.请扫描LOT号.Font = new System.Drawing.Font("宋体", 24F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.请扫描LOT号.ForeColor = System.Drawing.Color.Red; - this.请扫描LOT号.Location = new System.Drawing.Point(476, 29); - this.请扫描LOT号.Name = "请扫描LOT号"; - this.请扫描LOT号.Size = new System.Drawing.Size(510, 56); - this.请扫描LOT号.TabIndex = 1; - this.请扫描LOT号.Text = "请员工扫描LOT号:"; + this.胶水上下线.Dock = System.Windows.Forms.DockStyle.Fill; + this.胶水上下线.Location = new System.Drawing.Point(1084, 4); + this.胶水上下线.Name = "胶水上下线"; + this.tableLayoutPanel5.SetRowSpan(this.胶水上下线, 2); + this.胶水上下线.Size = new System.Drawing.Size(130, 221); + this.胶水上下线.TabIndex = 3; + this.胶水上下线.Text = "胶水/三防漆\r\n上下线"; + this.胶水上下线.UseVisualStyleBackColor = true; + this.胶水上下线.Click += new System.EventHandler(this.胶水上下线_Click); // // groupBox2 // @@ -823,12 +883,17 @@ // // tableLayoutPanel8 // - this.tableLayoutPanel8.ColumnCount = 5; - this.tableLayoutPanel8.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); - this.tableLayoutPanel8.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); - this.tableLayoutPanel8.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); - this.tableLayoutPanel8.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); - this.tableLayoutPanel8.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel8.ColumnCount = 10; + this.tableLayoutPanel8.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel8.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel8.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel8.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel8.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel8.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel8.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel8.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel8.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel8.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10F)); this.tableLayoutPanel8.Controls.Add(this.底部注释1, 0, 0); this.tableLayoutPanel8.Controls.Add(this.底部注释2, 1, 0); this.tableLayoutPanel8.Controls.Add(this.底部注释3, 2, 0); @@ -856,7 +921,7 @@ // this.底部注释2.Anchor = System.Windows.Forms.AnchorStyles.Left; this.底部注释2.AutoSize = true; - this.底部注释2.Location = new System.Drawing.Point(324, 6); + this.底部注释2.Location = new System.Drawing.Point(163, 6); this.底部注释2.Name = "底部注释2"; this.底部注释2.Size = new System.Drawing.Size(105, 21); this.底部注释2.TabIndex = 1; @@ -866,7 +931,7 @@ // this.底部注释3.Anchor = System.Windows.Forms.AnchorStyles.Left; this.底部注释3.AutoSize = true; - this.底部注释3.Location = new System.Drawing.Point(645, 6); + this.底部注释3.Location = new System.Drawing.Point(323, 6); this.底部注释3.Name = "底部注释3"; this.底部注释3.Size = new System.Drawing.Size(105, 21); this.底部注释3.TabIndex = 2; @@ -876,7 +941,7 @@ // this.底部注释4.Anchor = System.Windows.Forms.AnchorStyles.Left; this.底部注释4.AutoSize = true; - this.底部注释4.Location = new System.Drawing.Point(966, 6); + this.底部注释4.Location = new System.Drawing.Point(483, 6); this.底部注释4.Name = "底部注释4"; this.底部注释4.Size = new System.Drawing.Size(105, 21); this.底部注释4.TabIndex = 3; @@ -886,7 +951,7 @@ // this.底部注释5.Anchor = System.Windows.Forms.AnchorStyles.Left; this.底部注释5.AutoSize = true; - this.底部注释5.Location = new System.Drawing.Point(1287, 6); + this.底部注释5.Location = new System.Drawing.Point(643, 6); this.底部注释5.Name = "底部注释5"; this.底部注释5.Size = new System.Drawing.Size(105, 21); this.底部注释5.TabIndex = 4; @@ -898,6 +963,13 @@ this.timer1.Interval = 1000; this.timer1.Tick += new System.EventHandler(this.timer1_Tick); // + // 螺丝枪扭力设置ToolStripMenuItem + // + this.螺丝枪扭力设置ToolStripMenuItem.Name = "螺丝枪扭力设置ToolStripMenuItem"; + this.螺丝枪扭力设置ToolStripMenuItem.Size = new System.Drawing.Size(331, 44); + this.螺丝枪扭力设置ToolStripMenuItem.Text = "螺丝枪扭力设置"; + this.螺丝枪扭力设置ToolStripMenuItem.Click += new System.EventHandler(this.螺丝枪扭力设置ToolStripMenuItem_Click); + // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(11F, 21F); @@ -985,7 +1057,6 @@ private System.Windows.Forms.TableLayoutPanel tableLayoutPanel5; private System.Windows.Forms.Label LOT号显示; private System.Windows.Forms.Label LOT号; - private System.Windows.Forms.Label 请扫描LOT号; private System.Windows.Forms.GroupBox groupBox2; private System.Windows.Forms.TableLayoutPanel tableLayoutPanel7; private System.Windows.Forms.Label 事件4; @@ -997,12 +1068,20 @@ private System.Windows.Forms.Label 事件2结果; private System.Windows.Forms.Label 事件1结果; private System.Windows.Forms.Timer timer1; - private System.Windows.Forms.Label LOT号扫描; private System.Windows.Forms.Label 事件4时间; private System.Windows.Forms.Label 事件3时间; private System.Windows.Forms.Label 事件2时间; private System.Windows.Forms.Label 事件1时间; private System.Windows.Forms.Label 机台状态; + private System.Windows.Forms.Button 胶水上下线; + private System.Windows.Forms.Label MES提示信息; + private System.Windows.Forms.Label MES提示; + private System.Windows.Forms.ToolStripMenuItem 产线基础信息管理ToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem 产线关联PLC管理ToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem pLC报警设置ToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem 扭力角度扭矩设置ToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem 压力曲线设置ToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem 螺丝枪扭力设置ToolStripMenuItem; } } diff --git a/WindowsFormsApp1/MainForm.cs b/WindowsFormsApp1/MainForm.cs index ce53c77..15a3435 100644 --- a/WindowsFormsApp1/MainForm.cs +++ b/WindowsFormsApp1/MainForm.cs @@ -27,23 +27,8 @@ namespace WindowsFormsApp1 { public partial class MainForm : Form { - private Thread thread_plc1; - private Thread thread_plc2; - private SerialPort ScanPort; - /* - * - * COM1 -- COM口名称 - * 9600 波特率 - * 校验位 Parity.None == 无 - * 数据位 :8 - * - * 测试称重 - * 解除注释 - * //port.DataReceived += new SerialDataReceivedEventHandler(port_Receive); - * //port.Open(); - * //port.WriteLine("SI"); - * - */ + //private Thread thread_plc1; + //private Thread thread_plc2; public MainForm() { @@ -57,17 +42,15 @@ namespace WindowsFormsApp1 LogExecute.PlclogNet.BeforeSaveToFile += LogNet_BeforeSaveToFile; LogExecute.ApilogNet.BeforeSaveToFile += LogNet_BeforeSaveToFile; - Formrecover(); - - - - + FormRecover(); 线别.Text = "线别:" + Init.t_Line.linename; - 段别.Text = "段别:" + Init.t_Line.linemode; + 段别.Text = "段别:" + Init.t_Line.linemode; 机台编号.Text = "机台编号:" + Init.t_Line.linecode; 操作人员ID.Text = "操作人员ID:" + Init.t_User.username; } + + public void build(t_plc Plc, CancellationToken token) { while (true) @@ -98,6 +81,10 @@ namespace WindowsFormsApp1 } List plcaddress = Init.t_Plcaddresses.FindAll(a => a.plcid == Plc.id); + List angleaddress = Init.t_Angleaddresses.FindAll(a => a.plcid == Plc.id); + List torqueaddress = Init.t_Torqueaddresses.FindAll(a => a.plcid == Plc.id); + + plcdata PlcData = new plcdata(); var resdresult = siemensHelp.ReadAddress(plcaddress, PlcData); @@ -161,6 +148,9 @@ namespace WindowsFormsApp1 MES链接状态.Text = "MES链接状态:NG"; MES链接状态.BackColor = Color.Red; LogExecute.logNet.WriteError($"MES通讯异常!"); + PlcData.Write_Status = 1002; + var errresult = siemensHelp.WriteAddress(plcaddress, PlcData); + continue; } } //机台报警 @@ -195,6 +185,8 @@ namespace WindowsFormsApp1 MES链接状态.Text = "MES链接状态:NG"; MES链接状态.BackColor = Color.Red; LogExecute.logNet.WriteError($"MES通讯异常!"); + PlcData.Write_Status = 1002; + siemensHelp.WriteAddress(plcaddress, PlcData); } } continue; @@ -238,21 +230,69 @@ namespace WindowsFormsApp1 continue; } #endregion - - if(nowinterface.code == "SN_CheckIN") + #region 根据流程,判断是否需要扫码、气密、扭力等 + if (nowflow.scan) { - 请扫描LOT号.Enabled = true; - //ScanPort.Read(); - - + //扫码 + ScanForm scanForm = new ScanForm(); + DialogResult scan_result = scanForm.ShowDialog(); + if (scan_result == DialogResult.OK) + { + string returnValue = scanForm.ReturnValue; + otherdata.JS_SN = returnValue; + } + else + { + continue; + } } + if (nowflow.finalpressurecurve) + { + //压力曲线 + } + //if (nowflow.finaltorquecurve) + //{ + // //扭力曲线(这里不处理,后端API获取) + //} + if (nowflow.finaltorquevalue) + { + //螺丝枪扭力数据 + var finaltorquevalue_result = siemensHelp.ReadAddress(torqueaddress); + if (!finaltorquevalue_result.Success) + { + PLC链接状态.Text = "PLC链接状态:NG"; + PLC链接状态.BackColor = Color.Red; + LogExecute.logNet.WriteError($"{Plc.plcip}螺丝枪扭力数据地址处理错误:处理停止"); + continue; + } + otherdata.FinalTorqueValue = finaltorquevalue_result.Data; + } + if (nowflow.airtight) + { + //气密参数 + otherdata.FinalAirtightValue = Init.airtight; + } + if (nowflow.finalanglevaluue) + { + //螺丝枪角度 + var finalanglevaluue_result = siemensHelp.ReadAddress(angleaddress); + if (!finalanglevaluue_result.Success) + { + PLC链接状态.Text = "PLC链接状态:NG"; + PLC链接状态.BackColor = Color.Red; + LogExecute.logNet.WriteError($"{Plc.plcip}螺丝枪角度数据地址处理错误:处理停止"); + continue; + } + otherdata.FinalAngleValue = finalanglevaluue_result.Data; + } + if (nowflow.fileupload) + { + //文件上传 + } + #endregion - - - - - - var result = apiClient.CallFunctionByName(nowinterface.code,PlcData, otherdata); + #region 调用后端接口 + var result = apiClient.CallFunctionByName(nowinterface.code, PlcData, otherdata); if (result.Success) { var writeresult = siemensHelp.WriteAddress(plcaddress, PlcData); @@ -281,7 +321,10 @@ namespace WindowsFormsApp1 MES链接状态.Text = "MES链接状态:NG"; MES链接状态.BackColor = Color.Red; LogExecute.logNet.WriteError($"MES通讯异常!"); + PlcData.Write_Status = 1002; + siemensHelp.WriteAddress(plcaddress, PlcData); } + #endregion } catch (Exception e) { @@ -302,22 +345,14 @@ namespace WindowsFormsApp1 { SQLiteHelper sQLiteHelper_plc = new db.SQLiteHelper(); - BllResult plc_result = sQLiteHelper_plc.QuerySingle(a => a.id == Init.t_Line.plcid1); - BllResult plc_result2 = new BllResult(false, "", null); - if (!plc_result.Success) + var plc_sqlresult = sQLiteHelper_plc.QueryAll(); + if (!plc_sqlresult.Success) { - MessageBox.Show("无法初始化PLC1信息,无法开始处理!"); + MessageBox.Show("无法初始化PLC信息,无法开始处理!"); return; } - if (Init.t_Line.plcid2 != 0) - { - plc_result2 = sQLiteHelper_plc.QuerySingle(a => a.id == Init.t_Line.plcid2); - if (!plc_result2.Success) - { - MessageBox.Show("无法初始化PLC2信息,无法开始处理!"); - return; - } - } + var plc_result = plc_sqlresult.Data.FindAll(a => Init.t_Lineplcs.Select(p => p.plcid).Contains(a.id)); + SQLiteHelper sQLiteHelper_flow = new db.SQLiteHelper(); var flow_result = sQLiteHelper_flow.Query(a => a.flowid == Init.t_Line.flowid); @@ -335,6 +370,22 @@ namespace WindowsFormsApp1 return; } + SQLiteHelper sQLiteHelper_torqueaddress = new db.SQLiteHelper(); + var torqueaddress_result = sQLiteHelper_torqueaddress.QueryAll(); + if (!torqueaddress_result.Success) + { + MessageBox.Show("无法初始化螺丝枪扭力信息,无法开始处理!"); + return; + } + + SQLiteHelper sQLiteHelper_angleaddress = new db.SQLiteHelper(); + var angleaddress_result = sQLiteHelper_angleaddress.QueryAll(); + if (!angleaddress_result.Success) + { + MessageBox.Show("无法初始化螺丝枪角度信息,无法开始处理!"); + return; + } + SQLiteHelper sQLiteHelper_interface = new db.SQLiteHelper(); var interface_result = sQLiteHelper_interface.QueryAll(); if (!interface_result.Success) @@ -343,7 +394,6 @@ namespace WindowsFormsApp1 return; } - SQLiteHelper sQLiteHelper_serialport = new db.SQLiteHelper(); var serialport_result = sQLiteHelper_serialport.QueryAll(); if (!serialport_result.Success) @@ -352,61 +402,83 @@ namespace WindowsFormsApp1 return; } + + + #region 初始化全局变量 + + Init.t_Flows = flow_result.Data; + Init.t_Plcaddresses = address_result.Data; + Init.t_Angleaddresses = angleaddress_result.Data; + Init.t_Torqueaddresses = torqueaddress_result.Data; + Init.t_Interfaces = interface_result.Data; + #endregion + #region 初始化COM口服务 try { - var scanport = serialport_result.Data.FirstOrDefault(a=>a.name == "Scan"); + var scanport = serialport_result.Data.FirstOrDefault(a => a.name == "Scan"); if (scanport != null) { if (scanport.enable) { Enum.TryParse(scanport.parity, out Parity parity); - ScanPort = new SerialPort(scanport.portName, scanport.baudRate, parity, scanport.dataBits); - if (!ScanPort.IsOpen) + Init.ScanPort = new SerialPort(scanport.portName, scanport.baudRate, parity, scanport.dataBits); + if (!Init.ScanPort.IsOpen) { - //port?.Open(); + Init.ScanPort?.Open(); 底部注释1.Text = "扫码枪COM-Ready"; 底部注释1.Visible = true; + // 订阅 DataReceived 事件 + 胶水上下线.Enabled = true; } } } - + } - catch(Exception ex) + catch (Exception ex) { - MessageBox.Show("无法开启扫码枪,无法开始处理!" + ex.Message); + MessageBox.Show("无法开启扫码枪COM,无法开始处理!" + ex.Message); return; } - - - - Init.t_Plc1 = plc_result.Data; - Init.t_Plc1.plchelp = new SiemensHelp(Init.t_Plc1.plcip, Init.t_Plc1.timeout); - Init.t_Plc2 = plc_result2.Data; - if (Init.t_Plc2 != null) + try { - Init.t_Plc2.plchelp = new SiemensHelp(Init.t_Plc2.plcip, Init.t_Plc2.timeout); + var scanport = serialport_result.Data.FirstOrDefault(a => a.name == "Airtight"); + if (scanport != null) + { + if (scanport.enable) + { + Enum.TryParse(scanport.parity, out Parity parity); + Init.AirtightPort = new SerialPort(scanport.portName, scanport.baudRate, parity, scanport.dataBits); + if (!Init.AirtightPort.IsOpen) + { + Init.AirtightPort?.Open(); + Init.AirtightPort.DataReceived += AirtightPort_DataReceived; + 底部注释2.Text = "气密仪COM-Ready"; + 底部注释2.Visible = true; + } + } + } } - - Init.t_Flows = flow_result.Data; - - Init.t_Plcaddresses = address_result.Data; - Init.t_Interfaces = interface_result.Data; - - if (!Init.isrunning1) + catch (Exception ex) { - Init.cancellationTokenSource1 = new CancellationTokenSource(); - thread_plc1 = new Thread(() => build(Init.t_Plc1, Init.cancellationTokenSource1.Token)); - thread_plc1.Start(); - Init.isrunning1 = true; + MessageBox.Show("无法开启气密仪COM,无法开始处理!" + ex.Message); + return; } + #endregion - //if (!Init.isrunning2) - //{ - // Init.cancellationTokenSource2 = new CancellationTokenSource(); - // thread_plc2 = new Thread(() => build(Init.t_Plc2, Init.cancellationTokenSource2.Token)); - // thread_plc2.Start(); - // Init.isrunning2 = true; - //} + Init.threadHelps = new List(); + foreach (var plc in plc_result) + { + plc.plchelp = new SiemensHelp(plc.plcip, plc.timeout); + ThreadHelp threadHelp = new ThreadHelp(); + if (!threadHelp.isrunning1) + { + threadHelp.cancellationTokenSource1 = new CancellationTokenSource(); + threadHelp.Thread = new Thread(() => build(plc, threadHelp.cancellationTokenSource1.Token)); + threadHelp.Thread.Start(); + threadHelp.isrunning1 = true; + } + Init.threadHelps.Add(threadHelp); + } 开始处理.Text = "停止处理"; 开始处理.BackColor = Color.Red; @@ -414,57 +486,79 @@ namespace WindowsFormsApp1 } else { - if (thread_plc1 != null && thread_plc1.IsAlive) + foreach (var thread in Init.threadHelps) { - // 请求取消线程 - Init.cancellationTokenSource1?.Cancel(); - thread_plc1.Join(); // 等待线程完成 + if (thread.Thread.IsAlive) + { + // 请求取消线程 + thread.cancellationTokenSource1?.Cancel(); + thread.Thread.Join(); // 等待线程完成 + } + thread.isrunning1 = false; } - Init.isrunning1 = false; - if (thread_plc2 != null && thread_plc2.IsAlive) + if (Init.ScanPort != null && Init.ScanPort.IsOpen) { - // 请求取消线程 - Init.cancellationTokenSource2?.Cancel(); - thread_plc2.Join(); // 等待线程完成 + Init.ScanPort?.Close(); } - Init.isrunning2 = false; - ScanPort?.Close(); + if (Init.AirtightPort != null && Init.AirtightPort.IsOpen) + { + Init.AirtightPort?.Close(); + } - - Thread.Sleep(500); - 开始处理.Text = "开始处理"; - 开始处理.BackColor = Color.Green; - - Formrecover(); + //Thread.Sleep(500); + FormRecover(); LogExecute.logNet.WriteInfo($"用户{Init.t_User.username},停止处理!"); } } #endregion #region 页面按钮-跳转 + private void 扭力角度扭矩设置ToolStripMenuItem_Click(object sender, EventArgs e) + { + Angleaddress_Manage angleaddress_Manage = new Angleaddress_Manage(); + angleaddress_Manage.ShowDialog(); + } + + private void 螺丝枪扭力设置ToolStripMenuItem_Click(object sender, EventArgs e) + { + Torqueaddress_Manage torqueaddress_Manage = new Torqueaddress_Manage(); + torqueaddress_Manage.ShowDialog(); + } private void 流程管理ToolStripMenuItem_Click(object sender, EventArgs e) { - FLOW_Manage fLOW_Mange = new FLOW_Manage(); + Flow_Manage fLOW_Mange = new Flow_Manage(); fLOW_Mange.ShowDialog(); } - private void 产线管理ToolStripMenuItem_Click(object sender, EventArgs e) + private void 产线基础信息管理ToolStripMenuItem_Click(object sender, EventArgs e) { - LINE_Manage lINE_Manage = new LINE_Manage(); + Line_Manage lINE_Manage = new Line_Manage(); lINE_Manage.ShowDialog(); } + private void 产线关联PLC管理ToolStripMenuItem_Click(object sender, EventArgs e) + { + LinePLC_Manage lINEPLC_Manage = new LinePLC_Manage(); + lINEPLC_Manage.ShowDialog(); + } + + private void 系统参数配置ToolStripMenuItem_Click(object sender, EventArgs e) + { + KeyValue keyValue = new KeyValue(); + keyValue.ShowDialog(); + } + private void pLC通讯设置ToolStripMenuItem_Click(object sender, EventArgs e) { - PLC_Manage pLC_Manage = new PLC_Manage(); + Plc_Manage pLC_Manage = new Plc_Manage(); pLC_Manage.ShowDialog(); } private void pLC地址设置ToolStripMenuItem_Click(object sender, EventArgs e) { - PLCADDRESS_Manage pLCADDRESS_Manage = new PLCADDRESS_Manage(); + PlcAddress_Manage pLCADDRESS_Manage = new PlcAddress_Manage(); pLCADDRESS_Manage.ShowDialog(); } private void 切换用户ToolStripMenuItem_Click(object sender, EventArgs e) @@ -474,19 +568,19 @@ namespace WindowsFormsApp1 private void mES接口配置ToolStripMenuItem_Click(object sender, EventArgs e) { - MES_URL mES_URL = new MES_URL(); + MESUrl mES_URL = new MESUrl(); mES_URL.ShowDialog(); } private void 修改密码ToolStripMenuItem_Click(object sender, EventArgs e) { - USER_ChangeP uSER_ChangeP = new USER_ChangeP(); + UserChangeP uSER_ChangeP = new UserChangeP(); uSER_ChangeP.ShowDialog(); } private void 用户管理ToolStripMenuItem1_Click(object sender, EventArgs e) { - USER_Manage uSER_Manage = new USER_Manage(); + User_Manage uSER_Manage = new User_Manage(); uSER_Manage.ShowDialog(); } @@ -543,8 +637,11 @@ namespace WindowsFormsApp1 { 当前时间.Text = "当前时间:" + DateTime.Now.ToString("MM-dd HH:mm:ss"); } - public void Formrecover() + public void FormRecover() { + 开始处理.Text = "开始处理"; + 开始处理.BackColor = Color.Green; + MES链接状态.Text = "MES链接状态:None"; MES链接状态.BackColor = SystemColors.Control; @@ -560,8 +657,9 @@ namespace WindowsFormsApp1 机台状态.Text = "机台状态:None"; 机台状态.BackColor = SystemColors.Control; + 胶水上下线.Enabled = false; - 请扫描LOT号.Enabled = false; + MES提示信息.Visible = false; LOT号.Visible = false; Tray盘二维码.Visible = false; @@ -699,5 +797,93 @@ namespace WindowsFormsApp1 } #endregion + #region 其他业务处理 + private void 胶水上下线_Click(object sender, EventArgs e) + { + ScanForm scanForm = new ScanForm(); + DialogResult result = scanForm.ShowDialog(); + if (result == DialogResult.OK) + { + string returnValue = scanForm.ReturnValue; + MessageBox.Show($"返回值是:{returnValue}"); + //调用三防漆之类的接口 + } + } + public void AirtightPort_DataReceived(object sender, SerialDataReceivedEventArgs e) + { + try + { + if (!Init.AirtightPort.IsOpen) + { + Init.AirtightPort?.Open(); + } + // 读取串口接收到的数据 + string ReturnValue = Init.AirtightPort.ReadExisting(); + + int index1 = 1; + int index2 = 1; + string press = string.Empty; + string leakage = string.Empty; + //pressure选择为yes// export选择为yes(非常重要) + var dataArray = ReturnValue.Trim('\r', '\n').Split('\t'); + float[] sealFloat = new float[2]; + + //充气压力 + if (dataArray[3] == "") + { + sealFloat[0] = 0; + } + else + { + if (dataArray[3].Contains("-")) + { + press = dataArray[3].Remove(0, 1); + index1 = -1; + } + else + { + press = dataArray[3]; + index1 = 1; + } + sealFloat[0] = float.Parse(press); + } + + //测试泄露结果 + if (dataArray[5] == "") + sealFloat[1] = 0; + else + { + if (dataArray[5].Contains("-")) + { + leakage = dataArray[5].Remove(0, 1); + index2 = -1; + } + else + { + leakage = dataArray[5]; + index2 = 1; + } + sealFloat[1] = float.Parse(leakage); + } + + int[] sealInt = new int[2]; + sealInt[0] = Convert.ToInt32(sealFloat[1] * 1000) * (index2); + sealInt[1] = Convert.ToInt32(sealFloat[0] * 1000) * (index1); + Init.airtight.Airtight_Value = sealInt[0].ToString(); + Init.airtight.Leak_Value = sealInt[1].ToString(); + Init.airtight.LastTime = DateTime.Now; + LogExecute.logNet.WriteDebug($"通过气密仪获取到 压力值:{Init.airtight.Airtight_Value},泄露值:{Init.airtight.Leak_Value}"); + + } + catch (Exception ex) + { + LogExecute.logNet.WriteError($"通过气密仪获取到压力参数失败,错误原因{ex.Message}"); + } + } + + + #endregion + + } } diff --git a/WindowsFormsApp1/Program.cs b/WindowsFormsApp1/Program.cs index d649712..50ac108 100644 --- a/WindowsFormsApp1/Program.cs +++ b/WindowsFormsApp1/Program.cs @@ -1,11 +1,13 @@ using System; using System.Collections.Generic; +using System.IO.Ports; using System.Linq; using System.Security.Cryptography.X509Certificates; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; using WindowsFormsApp1.mod; +using WindowsFormsApp1.mod.server; using WindowsFormsApp1.server; namespace WindowsFormsApp1 @@ -36,23 +38,32 @@ namespace WindowsFormsApp1 public static class Init { public static t_user t_User; - public static t_line t_Line; public static List t_Flows; - public static t_plc t_Plc1; - public static t_plc t_Plc2; + public static List t_Interfaces; public static List t_Plcaddresses; - public static bool isrunning1 = false; - public static CancellationTokenSource cancellationTokenSource1; - public static bool isrunning2 = false; - public static CancellationTokenSource cancellationTokenSource2; - public static int errinterface1 = 0; - public static int errinterface2 = 0; + public static List t_Angleaddresses; + public static List t_Torqueaddresses; + public static t_line t_Line; + public static List t_Lineplcs; + public static List threadHelps; + + //PLC状态存储 public static short Plcstatus = -1; + + //PLC最后状态事件(用于计时15秒状态不变回传) public static DateTime Plcstatus_LastTime = DateTime.Now; + //扫码Com + public static SerialPort ScanPort; + + //气密Com + public static SerialPort AirtightPort; + + //其他线程获取的气密参数 + public static Airtight airtight = new Airtight(); } } diff --git a/WindowsFormsApp1/db/SQLiteHelper.cs b/WindowsFormsApp1/db/SQLiteHelper.cs index ced75dc..2508b92 100644 --- a/WindowsFormsApp1/db/SQLiteHelper.cs +++ b/WindowsFormsApp1/db/SQLiteHelper.cs @@ -119,6 +119,10 @@ namespace WindowsFormsApp1.db { return BllResult>.Sucess(result); } + else if (result.Count == 0) + { + return BllResult>.Sucess(new List()); + } else { return BllResult>.Error(); diff --git a/WindowsFormsApp1/form/Angleaddress_Manage.Designer.cs b/WindowsFormsApp1/form/Angleaddress_Manage.Designer.cs new file mode 100644 index 0000000..85ec473 --- /dev/null +++ b/WindowsFormsApp1/form/Angleaddress_Manage.Designer.cs @@ -0,0 +1,312 @@ +namespace WindowsFormsApp1.form +{ + partial class Angleaddress_Manage + { + /// + /// 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() + { + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); + this.关闭 = new System.Windows.Forms.Button(); + this.查询 = new System.Windows.Forms.Button(); + this.dataGridView1 = new System.Windows.Forms.DataGridView(); + this.label1 = new System.Windows.Forms.Label(); + this.comboBox1 = new System.Windows.Forms.ComboBox(); + this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.button1 = new System.Windows.Forms.Button(); + this.id = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.plcname = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.code = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.type = new System.Windows.Forms.DataGridViewComboBoxColumn(); + this.dbaddress = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.addressoffset = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.addresstype = new System.Windows.Forms.DataGridViewComboBoxColumn(); + this.addresstypelegth = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.remark = new System.Windows.Forms.DataGridViewTextBoxColumn(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); + this.tableLayoutPanel1.SuspendLayout(); + this.SuspendLayout(); + // + // 关闭 + // + this.关闭.Anchor = System.Windows.Forms.AnchorStyles.None; + this.关闭.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.关闭.Location = new System.Drawing.Point(1642, 696); + this.关闭.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); + this.关闭.Name = "关闭"; + this.关闭.Size = new System.Drawing.Size(169, 72); + this.关闭.TabIndex = 11; + this.关闭.Text = "关闭"; + this.关闭.UseVisualStyleBackColor = true; + this.关闭.Click += new System.EventHandler(this.关闭_Click); + // + // 查询 + // + this.查询.Anchor = System.Windows.Forms.AnchorStyles.None; + this.查询.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.查询.Location = new System.Drawing.Point(1642, 25); + this.查询.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); + this.查询.Name = "查询"; + this.查询.Size = new System.Drawing.Size(169, 72); + this.查询.TabIndex = 9; + this.查询.Text = "查询"; + this.查询.UseVisualStyleBackColor = true; + this.查询.Click += new System.EventHandler(this.查询_Click); + // + // dataGridView1 + // + this.dataGridView1.AllowUserToAddRows = false; + this.dataGridView1.AllowUserToDeleteRows = false; + dataGridViewCellStyle1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.dataGridView1.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; + this.dataGridView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle2.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle2; + this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.id, + this.plcname, + this.code, + this.type, + this.dbaddress, + this.addressoffset, + this.addresstype, + this.addresstypelegth, + this.remark}); + this.tableLayoutPanel1.SetColumnSpan(this.dataGridView1, 2); + dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Window; + dataGridViewCellStyle3.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle3.ForeColor = System.Drawing.SystemColors.ControlText; + dataGridViewCellStyle3.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle3.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.False; + this.dataGridView1.DefaultCellStyle = dataGridViewCellStyle3; + this.dataGridView1.Location = new System.Drawing.Point(6, 127); + this.dataGridView1.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); + this.dataGridView1.Name = "dataGridView1"; + this.dataGridView1.ReadOnly = true; + this.dataGridView1.RowHeadersWidth = 72; + this.tableLayoutPanel1.SetRowSpan(this.dataGridView1, 3); + this.dataGridView1.RowTemplate.Height = 23; + this.dataGridView1.Size = new System.Drawing.Size(1624, 682); + this.dataGridView1.TabIndex = 8; + // + // label1 + // + this.label1.Anchor = System.Windows.Forms.AnchorStyles.Left; + this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("宋体", 14.14286F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label1.Location = new System.Drawing.Point(4, 27); + this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(253, 68); + this.label1.TabIndex = 12; + this.label1.Text = "选择需要编辑的PLC编号:"; + // + // comboBox1 + // + this.comboBox1.Anchor = System.Windows.Forms.AnchorStyles.Left; + this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBox1.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.comboBox1.FormattingEnabled = true; + this.comboBox1.Location = new System.Drawing.Point(278, 40); + this.comboBox1.Margin = new System.Windows.Forms.Padding(4); + this.comboBox1.Name = "comboBox1"; + this.comboBox1.Size = new System.Drawing.Size(409, 41); + this.comboBox1.TabIndex = 13; + // + // tableLayoutPanel1 + // + this.tableLayoutPanel1.ColumnCount = 3; + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 15.07911F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 74.9177F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10.00319F)); + this.tableLayoutPanel1.Controls.Add(this.button1, 2, 2); + this.tableLayoutPanel1.Controls.Add(this.comboBox1, 1, 0); + this.tableLayoutPanel1.Controls.Add(this.dataGridView1, 0, 1); + this.tableLayoutPanel1.Controls.Add(this.关闭, 2, 3); + this.tableLayoutPanel1.Controls.Add(this.label1, 0, 0); + this.tableLayoutPanel1.Controls.Add(this.查询, 2, 0); + this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanel1.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + this.tableLayoutPanel1.RowCount = 4; + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 15F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 45F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.Size = new System.Drawing.Size(1818, 814); + this.tableLayoutPanel1.TabIndex = 14; + // + // button1 + // + this.button1.Anchor = System.Windows.Forms.AnchorStyles.None; + this.button1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.button1.Location = new System.Drawing.Point(1650, 541); + this.button1.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(153, 56); + this.button1.TabIndex = 15; + this.button1.Text = "新增"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // id + // + this.id.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.id.DataPropertyName = "id"; + this.id.HeaderText = "序号"; + this.id.MinimumWidth = 9; + this.id.Name = "id"; + this.id.ReadOnly = true; + // + // plcname + // + this.plcname.DataPropertyName = "plcname"; + this.plcname.HeaderText = "PLC名称"; + this.plcname.MinimumWidth = 9; + this.plcname.Name = "plcname"; + this.plcname.ReadOnly = true; + this.plcname.Width = 175; + // + // code + // + this.code.DataPropertyName = "code"; + this.code.HeaderText = "数据名称"; + this.code.MinimumWidth = 9; + this.code.Name = "code"; + this.code.ReadOnly = true; + this.code.Width = 175; + // + // type + // + this.type.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.type.DataPropertyName = "type"; + this.type.HeaderText = "读写类型"; + this.type.MinimumWidth = 9; + this.type.Name = "type"; + this.type.ReadOnly = true; + this.type.Resizable = System.Windows.Forms.DataGridViewTriState.True; + this.type.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic; + // + // dbaddress + // + this.dbaddress.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.dbaddress.DataPropertyName = "dbaddress"; + this.dbaddress.HeaderText = "DB块地址"; + this.dbaddress.MinimumWidth = 9; + this.dbaddress.Name = "dbaddress"; + this.dbaddress.ReadOnly = true; + // + // addressoffset + // + this.addressoffset.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.addressoffset.DataPropertyName = "addressoffset"; + this.addressoffset.HeaderText = "DB地址"; + this.addressoffset.MinimumWidth = 9; + this.addressoffset.Name = "addressoffset"; + this.addressoffset.ReadOnly = true; + // + // addresstype + // + this.addresstype.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.addresstype.DataPropertyName = "addresstype"; + this.addresstype.HeaderText = "数据类型"; + this.addresstype.MinimumWidth = 9; + this.addresstype.Name = "addresstype"; + this.addresstype.ReadOnly = true; + this.addresstype.Resizable = System.Windows.Forms.DataGridViewTriState.True; + this.addresstype.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic; + // + // addresstypelegth + // + this.addresstypelegth.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.addresstypelegth.DataPropertyName = "addresstypelegth"; + this.addresstypelegth.HeaderText = "字节长度"; + this.addresstypelegth.MinimumWidth = 9; + this.addresstypelegth.Name = "addresstypelegth"; + this.addresstypelegth.ReadOnly = true; + // + // remark + // + this.remark.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.remark.DataPropertyName = "remark"; + this.remark.HeaderText = "注释"; + this.remark.MinimumWidth = 9; + this.remark.Name = "remark"; + this.remark.ReadOnly = true; + // + // PlcAddress_Manage + // + this.AutoScaleDimensions = new System.Drawing.SizeF(11F, 21F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1818, 814); + this.Controls.Add(this.tableLayoutPanel1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.Margin = new System.Windows.Forms.Padding(4); + this.Name = "PlcAddress_Manage"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "PLCADDRESS_Manage"; + this.WindowState = System.Windows.Forms.FormWindowState.Maximized; + this.Load += new System.EventHandler(this.PLCADDRESS_Manage_Load); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); + this.tableLayoutPanel1.ResumeLayout(false); + this.tableLayoutPanel1.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Button 关闭; + private System.Windows.Forms.Button 查询; + private System.Windows.Forms.DataGridView dataGridView1; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.ComboBox comboBox1; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.DataGridViewTextBoxColumn id; + private System.Windows.Forms.DataGridViewTextBoxColumn plcname; + private System.Windows.Forms.DataGridViewTextBoxColumn code; + private System.Windows.Forms.DataGridViewComboBoxColumn type; + private System.Windows.Forms.DataGridViewTextBoxColumn dbaddress; + private System.Windows.Forms.DataGridViewTextBoxColumn addressoffset; + private System.Windows.Forms.DataGridViewComboBoxColumn addresstype; + private System.Windows.Forms.DataGridViewTextBoxColumn addresstypelegth; + private System.Windows.Forms.DataGridViewTextBoxColumn remark; + } +} \ No newline at end of file diff --git a/WindowsFormsApp1/form/Angleaddress_Manage.cs b/WindowsFormsApp1/form/Angleaddress_Manage.cs new file mode 100644 index 0000000..9a75b35 --- /dev/null +++ b/WindowsFormsApp1/form/Angleaddress_Manage.cs @@ -0,0 +1,209 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using WindowsFormsApp1.db; +using WindowsFormsApp1.mod; + +namespace WindowsFormsApp1.form +{ + public partial class Angleaddress_Manage : Form + { + public Angleaddress_Manage() + { + InitializeComponent(); + } + + private void 查询_Click(object sender, EventArgs e) + { + GetInfo((int)comboBox1.SelectedValue); + } + + private void 保存_Click(object sender, EventArgs e) + { + try + { + SQLiteHelper sQLiteHelper = new db.SQLiteHelper(); + var result = sQLiteHelper.UpdateAll((List)dataGridView1.DataSource); + if (result.Success) + { + MessageBox.Show("更新成功"); + GetInfo((int)comboBox1.SelectedValue); + } + else + { + MessageBox.Show("更新失败"); + } + } + catch (Exception ex) + { + MessageBox.Show($"更新失败,错误原因{ex.Message}"); + } + } + + private void 关闭_Click(object sender, EventArgs e) + { + this.Close(); + } + + private void PLCADDRESS_Manage_Load(object sender, EventArgs e) + { + dataGridView1.AutoGenerateColumns = false; + SQLiteHelper sQLiteHelper1 = new db.SQLiteHelper(); + var result_combox = sQLiteHelper1.QueryAll(); + if (!result_combox.Success) + { + MessageBox.Show("查询失败"); + return; + } + + var list = result_combox.Data.FindAll(a => Init.t_Lineplcs.Select(p => p.plcid).Contains(a.id)); + + // 绑定数据源到 ComboBox + comboBox1.DataSource = list; + comboBox1.DisplayMember = "plcname"; + comboBox1.ValueMember = "id"; + + var result1 = new List + { + new {name = "read",value = "read"}, + new {name = "write",value = "write"} + }; + + var result2 = new List + { + new {name = "real",value = "real"}, + new {name = "string",value = "string"}, + new {name = "uint",value = "uint"}, + }; + + var comboBoxColumn = (DataGridViewComboBoxColumn)dataGridView1.Columns[3]; + // 绑定数据源到 ComboBox + comboBoxColumn.DataSource = result1; + comboBoxColumn.DisplayMember = "name"; + comboBoxColumn.ValueMember = "value"; + + comboBoxColumn.DataPropertyName = "type"; + + var comboBoxColumn1 = (DataGridViewComboBoxColumn)dataGridView1.Columns[6]; + // 绑定数据源到 ComboBox + comboBoxColumn1.DataSource = result2; + comboBoxColumn1.DisplayMember = "name"; + comboBoxColumn1.ValueMember = "value"; + + comboBoxColumn1.DataPropertyName = "addresstype"; + + DataGridViewButtonColumn modifyColumn = new DataGridViewButtonColumn(); + modifyColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + modifyColumn.Name = "ModifyColumn"; + modifyColumn.HeaderText = "修改"; + modifyColumn.Text = "修改"; + modifyColumn.UseColumnTextForButtonValue = true; + dataGridView1.Columns.Add(modifyColumn); + + // 添加删除按钮列 + DataGridViewButtonColumn deleteColumn = new DataGridViewButtonColumn(); + deleteColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + deleteColumn.Name = "DeleteColumn"; + deleteColumn.HeaderText = "删除"; + deleteColumn.Text = "删除"; + deleteColumn.UseColumnTextForButtonValue = true; + + dataGridView1.CellContentClick += DataGridView1_CellContentClick; + + dataGridView1.Columns.Add(deleteColumn); + + } + private void DataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) + { + // 检查点击的是否为按钮列 + if (e.RowIndex >= 0) + { + DataGridView dataGridView = (DataGridView)sender; + DataGridViewRow row = dataGridView.Rows[e.RowIndex]; + + int selectid = int.Parse(row.Cells[0].Value.ToString()); + if (e.ColumnIndex == 9) + { + Angleaddress_Insert fLOW_Insert = new Angleaddress_Insert(); + fLOW_Insert.dataid = selectid; + fLOW_Insert.Operation = OperationType.Edit; + fLOW_Insert.ShowDialog(); + GetInfo((int)comboBox1.SelectedValue); + + } + else if (e.ColumnIndex == 10) + { + DialogResult result = MessageBox.Show("你确定要删除数据吗?", "确认提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); + + if (result == DialogResult.OK) + { + SQLiteHelper sQLiteHelper = new db.SQLiteHelper(); + var delresult = sQLiteHelper.Delete(selectid); + if (delresult.Success) + { + MessageBox.Show("删除成功"); + } + else + { + MessageBox.Show("删除失败"); + } + GetInfo((int)comboBox1.SelectedValue); + } + } + } + } + public void GetInfo(int plcid) + { + try + { + dataGridView1.DataSource = null; + SQLiteHelper sQLiteHelper = new db.SQLiteHelper(); + SQLiteHelper sQLiteHelper1 = new db.SQLiteHelper(); + var result_plc = sQLiteHelper1.QueryAll(); + var result = sQLiteHelper.Query(a=>a.plcid == plcid); + if (result.Success) + { + List list = new List(); + foreach (var plcaddress in result.Data) + { + var plc = result_plc.Data.FirstOrDefault(a => a.id == plcaddress.plcid); + list.Add(new + { + id = plcaddress.id, + plcid = plcaddress.plcid, + code = plcaddress.code, + type = plcaddress.type, + dbaddress = plcaddress.dbaddress, + addresstype = plcaddress.addresstype, + addresstypelegth = plcaddress.addresstypelegth, + addressoffset = plcaddress.addressoffset, + remark = plcaddress.remark, + value = plcaddress.value, + plcname = plc.plcname, + + + }); + } + dataGridView1.DataSource = list; + dataGridView1.Refresh(); + } + } + catch (Exception ex) + { + } + } + + private void button1_Click(object sender, EventArgs e) + { + Angleaddress_Insert fLOW_Insert = new Angleaddress_Insert(); + fLOW_Insert.ShowDialog(); + GetInfo((int)comboBox1.SelectedValue); + } + } +} diff --git a/WindowsFormsApp1/form/Angleaddress_Manage.resx b/WindowsFormsApp1/form/Angleaddress_Manage.resx new file mode 100644 index 0000000..7f316a3 --- /dev/null +++ b/WindowsFormsApp1/form/Angleaddress_Manage.resx @@ -0,0 +1,147 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + \ No newline at end of file diff --git a/WindowsFormsApp1/form/FLOW_Manage.Designer.cs b/WindowsFormsApp1/form/FLOW_Manage.Designer.cs index 4068ca9..6c13765 100644 --- a/WindowsFormsApp1/form/FLOW_Manage.Designer.cs +++ b/WindowsFormsApp1/form/FLOW_Manage.Designer.cs @@ -1,6 +1,6 @@ namespace WindowsFormsApp1.form { - partial class FLOW_Manage + partial class Flow_Manage { /// /// Required designer variable. @@ -33,15 +33,24 @@ System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); this.dataGridView1 = new System.Windows.Forms.DataGridView(); this.关闭 = new System.Windows.Forms.Button(); - this.保存 = new System.Windows.Forms.Button(); this.查询 = new System.Windows.Forms.Button(); this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.button1 = new System.Windows.Forms.Button(); + this.id = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.flowid = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.flowname = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.setp = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.hopestatus = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.hopeinterfaceid = new System.Windows.Forms.DataGridViewComboBoxColumn(); + this.hopeinterfaceid = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.errstatus = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.errinterfaceid = new System.Windows.Forms.DataGridViewComboBoxColumn(); + this.errinterfaceid = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.scan = new System.Windows.Forms.DataGridViewCheckBoxColumn(); + this.fileupload = new System.Windows.Forms.DataGridViewCheckBoxColumn(); + this.finaltorquevalue = new System.Windows.Forms.DataGridViewCheckBoxColumn(); + this.finalanglevaluue = new System.Windows.Forms.DataGridViewCheckBoxColumn(); + this.finaltorquecurve = new System.Windows.Forms.DataGridViewCheckBoxColumn(); + this.finalpressurecurve = new System.Windows.Forms.DataGridViewCheckBoxColumn(); + this.airtight = new System.Windows.Forms.DataGridViewCheckBoxColumn(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); this.tableLayoutPanel1.SuspendLayout(); this.SuspendLayout(); @@ -65,12 +74,21 @@ this.dataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle2; this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.id, this.flowid, + this.flowname, this.setp, this.hopestatus, this.hopeinterfaceid, this.errstatus, - this.errinterfaceid}); + this.errinterfaceid, + this.scan, + this.fileupload, + this.finaltorquevalue, + this.finalanglevaluue, + this.finaltorquecurve, + this.finalpressurecurve, + this.airtight}); dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Window; dataGridViewCellStyle3.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); @@ -82,6 +100,7 @@ this.dataGridView1.Location = new System.Drawing.Point(6, 5); this.dataGridView1.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); this.dataGridView1.Name = "dataGridView1"; + this.dataGridView1.ReadOnly = true; this.dataGridView1.RowHeadersWidth = 72; this.tableLayoutPanel1.SetRowSpan(this.dataGridView1, 4); this.dataGridView1.RowTemplate.Height = 23; @@ -101,19 +120,6 @@ this.关闭.UseVisualStyleBackColor = true; this.关闭.Click += new System.EventHandler(this.关闭_Click); // - // 保存 - // - this.保存.Anchor = System.Windows.Forms.AnchorStyles.None; - this.保存.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.保存.Location = new System.Drawing.Point(1575, 542); - this.保存.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); - this.保存.Name = "保存"; - this.保存.Size = new System.Drawing.Size(163, 72); - this.保存.TabIndex = 5; - this.保存.Text = "保存"; - this.保存.UseVisualStyleBackColor = true; - this.保存.Click += new System.EventHandler(this.保存_Click); - // // 查询 // this.查询.Anchor = System.Windows.Forms.AnchorStyles.None; @@ -135,7 +141,7 @@ this.tableLayoutPanel1.Controls.Add(this.查询, 1, 0); this.tableLayoutPanel1.Controls.Add(this.关闭, 1, 3); this.tableLayoutPanel1.Controls.Add(this.dataGridView1, 0, 0); - this.tableLayoutPanel1.Controls.Add(this.保存, 1, 2); + this.tableLayoutPanel1.Controls.Add(this.button1, 1, 2); this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); this.tableLayoutPanel1.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); @@ -148,6 +154,29 @@ this.tableLayoutPanel1.Size = new System.Drawing.Size(1744, 828); this.tableLayoutPanel1.TabIndex = 7; // + // button1 + // + this.button1.Anchor = System.Windows.Forms.AnchorStyles.None; + this.button1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.button1.Location = new System.Drawing.Point(1575, 542); + this.button1.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(163, 72); + this.button1.TabIndex = 7; + this.button1.Text = "新增"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // id + // + this.id.DataPropertyName = "id"; + this.id.HeaderText = "id"; + this.id.MinimumWidth = 9; + this.id.Name = "id"; + this.id.ReadOnly = true; + this.id.Visible = false; + this.id.Width = 175; + // // flowid // this.flowid.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; @@ -157,6 +186,15 @@ this.flowid.Name = "flowid"; this.flowid.ReadOnly = true; // + // flowname + // + this.flowname.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.flowname.DataPropertyName = "flowname"; + this.flowname.HeaderText = "流程名称"; + this.flowname.MinimumWidth = 9; + this.flowname.Name = "flowname"; + this.flowname.ReadOnly = true; + // // setp // this.setp.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; @@ -164,6 +202,7 @@ this.setp.HeaderText = "步骤"; this.setp.MinimumWidth = 9; this.setp.Name = "setp"; + this.setp.ReadOnly = true; // // hopestatus // @@ -172,6 +211,7 @@ this.hopestatus.HeaderText = "期望PLC值"; this.hopestatus.MinimumWidth = 9; this.hopestatus.Name = "hopestatus"; + this.hopestatus.ReadOnly = true; // // hopeinterfaceid // @@ -180,6 +220,9 @@ this.hopeinterfaceid.HeaderText = "成功调用接口"; this.hopeinterfaceid.MinimumWidth = 9; this.hopeinterfaceid.Name = "hopeinterfaceid"; + this.hopeinterfaceid.ReadOnly = true; + this.hopeinterfaceid.Resizable = System.Windows.Forms.DataGridViewTriState.True; + this.hopeinterfaceid.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; // // errstatus // @@ -188,6 +231,7 @@ this.errstatus.HeaderText = "错误PLC值"; this.errstatus.MinimumWidth = 9; this.errstatus.Name = "errstatus"; + this.errstatus.ReadOnly = true; // // errinterfaceid // @@ -196,7 +240,72 @@ this.errinterfaceid.HeaderText = "错误调用接口"; this.errinterfaceid.MinimumWidth = 9; this.errinterfaceid.Name = "errinterfaceid"; + this.errinterfaceid.ReadOnly = true; this.errinterfaceid.Resizable = System.Windows.Forms.DataGridViewTriState.True; + this.errinterfaceid.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; + // + // scan + // + this.scan.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.scan.DataPropertyName = "scan"; + this.scan.HeaderText = "扫码"; + this.scan.MinimumWidth = 9; + this.scan.Name = "scan"; + this.scan.ReadOnly = true; + // + // fileupload + // + this.fileupload.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.fileupload.DataPropertyName = "fileupload"; + this.fileupload.HeaderText = "文件上传"; + this.fileupload.MinimumWidth = 9; + this.fileupload.Name = "fileupload"; + this.fileupload.ReadOnly = true; + // + // finaltorquevalue + // + this.finaltorquevalue.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.finaltorquevalue.DataPropertyName = "finaltorquevalue"; + this.finaltorquevalue.HeaderText = "螺丝扭力"; + this.finaltorquevalue.MinimumWidth = 9; + this.finaltorquevalue.Name = "finaltorquevalue"; + this.finaltorquevalue.ReadOnly = true; + // + // finalanglevaluue + // + this.finalanglevaluue.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.finalanglevaluue.DataPropertyName = "finalanglevaluue"; + this.finalanglevaluue.HeaderText = "螺丝角度"; + this.finalanglevaluue.MinimumWidth = 9; + this.finalanglevaluue.Name = "finalanglevaluue"; + this.finalanglevaluue.ReadOnly = true; + // + // finaltorquecurve + // + this.finaltorquecurve.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.finaltorquecurve.DataPropertyName = "finaltorquecurve"; + this.finaltorquecurve.HeaderText = "扭力曲线"; + this.finaltorquecurve.MinimumWidth = 9; + this.finaltorquecurve.Name = "finaltorquecurve"; + this.finaltorquecurve.ReadOnly = true; + // + // finalpressurecurve + // + this.finalpressurecurve.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.finalpressurecurve.DataPropertyName = "finalpressurecurve"; + this.finalpressurecurve.HeaderText = "压力曲线"; + this.finalpressurecurve.MinimumWidth = 9; + this.finalpressurecurve.Name = "finalpressurecurve"; + this.finalpressurecurve.ReadOnly = true; + // + // airtight + // + this.airtight.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.airtight.DataPropertyName = "airtight"; + this.airtight.HeaderText = "气密参数"; + this.airtight.MinimumWidth = 9; + this.airtight.Name = "airtight"; + this.airtight.ReadOnly = true; // // FLOW_Manage // @@ -209,6 +318,7 @@ this.Name = "FLOW_Manage"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "FLOW_Mange"; + this.WindowState = System.Windows.Forms.FormWindowState.Maximized; this.Load += new System.EventHandler(this.FLOW_Mange_Load); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); this.tableLayoutPanel1.ResumeLayout(false); @@ -220,14 +330,23 @@ private System.Windows.Forms.DataGridView dataGridView1; private System.Windows.Forms.Button 关闭; - private System.Windows.Forms.Button 保存; private System.Windows.Forms.Button 查询; private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.DataGridViewTextBoxColumn id; private System.Windows.Forms.DataGridViewTextBoxColumn flowid; + private System.Windows.Forms.DataGridViewTextBoxColumn flowname; private System.Windows.Forms.DataGridViewTextBoxColumn setp; private System.Windows.Forms.DataGridViewTextBoxColumn hopestatus; - private System.Windows.Forms.DataGridViewComboBoxColumn hopeinterfaceid; + private System.Windows.Forms.DataGridViewTextBoxColumn hopeinterfaceid; private System.Windows.Forms.DataGridViewTextBoxColumn errstatus; - private System.Windows.Forms.DataGridViewComboBoxColumn errinterfaceid; + private System.Windows.Forms.DataGridViewTextBoxColumn errinterfaceid; + private System.Windows.Forms.DataGridViewCheckBoxColumn scan; + private System.Windows.Forms.DataGridViewCheckBoxColumn fileupload; + private System.Windows.Forms.DataGridViewCheckBoxColumn finaltorquevalue; + private System.Windows.Forms.DataGridViewCheckBoxColumn finalanglevaluue; + private System.Windows.Forms.DataGridViewCheckBoxColumn finaltorquecurve; + private System.Windows.Forms.DataGridViewCheckBoxColumn finalpressurecurve; + private System.Windows.Forms.DataGridViewCheckBoxColumn airtight; } } \ No newline at end of file diff --git a/WindowsFormsApp1/form/FLOW_Manage.cs b/WindowsFormsApp1/form/FLOW_Manage.cs index d129a95..030c5d6 100644 --- a/WindowsFormsApp1/form/FLOW_Manage.cs +++ b/WindowsFormsApp1/form/FLOW_Manage.cs @@ -9,12 +9,13 @@ using System.Threading.Tasks; using System.Windows.Forms; using WindowsFormsApp1.db; using WindowsFormsApp1.mod; +using static SQLite.SQLite3; namespace WindowsFormsApp1.form { - public partial class FLOW_Manage : Form + public partial class Flow_Manage : Form { - public FLOW_Manage() + public Flow_Manage() { InitializeComponent(); } @@ -54,47 +55,108 @@ namespace WindowsFormsApp1.form private void FLOW_Mange_Load(object sender, EventArgs e) { dataGridView1.AutoGenerateColumns = false; + // 添加修改按钮列 + DataGridViewButtonColumn modifyColumn = new DataGridViewButtonColumn(); + modifyColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + modifyColumn.Name = "ModifyColumn"; + modifyColumn.HeaderText = "修改"; + modifyColumn.Text = "修改"; + modifyColumn.UseColumnTextForButtonValue = true; + dataGridView1.Columns.Add(modifyColumn); - SQLiteHelper sQLiteHelper1 = new db.SQLiteHelper(); - var result1 = sQLiteHelper1.QueryAll(); - if (!result1.Success) - { - MessageBox.Show("查询失败"); - return; - } - result1.Data.Insert(0, new t_interface { id = 0, name = "" }); - - var comboBoxColumn = (DataGridViewComboBoxColumn)dataGridView1.Columns[3]; - // 绑定数据源到 ComboBox - comboBoxColumn.DataSource = result1.Data; - comboBoxColumn.DisplayMember = "name"; - comboBoxColumn.ValueMember = "id"; - - // 设置默认值为 Product 的 CategoryId - comboBoxColumn.DataPropertyName = "hopeinterfaceid"; // 绑定数据源中的 CategoryId 字段 - - var comboBoxColumn1 = (DataGridViewComboBoxColumn)dataGridView1.Columns[5]; - // 绑定数据源到 ComboBox - comboBoxColumn1.DataSource = result1.Data; - comboBoxColumn1.DisplayMember = "name"; - comboBoxColumn1.ValueMember = "id"; - - // 设置默认值为 Product 的 CategoryId - comboBoxColumn1.DataPropertyName = "errinterfaceid"; // 绑定数据源中的 CategoryId 字段 + // 添加删除按钮列 + DataGridViewButtonColumn deleteColumn = new DataGridViewButtonColumn(); + deleteColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + deleteColumn.Name = "DeleteColumn"; + deleteColumn.HeaderText = "删除"; + deleteColumn.Text = "删除"; + deleteColumn.UseColumnTextForButtonValue = true; + dataGridView1.Columns.Add(deleteColumn); + dataGridView1.CellContentClick += DataGridView1_CellContentClick; GetInfo(); } + private void DataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) + { + // 检查点击的是否为按钮列 + if (e.RowIndex >= 0) + { + DataGridView dataGridView = (DataGridView)sender; + DataGridViewRow row = dataGridView.Rows[e.RowIndex]; + int selectid = int.Parse(row.Cells[0].Value.ToString()); + if (e.ColumnIndex == 15) + { + FLow_Insert fLOW_Insert = new FLow_Insert(); + fLOW_Insert.dataid = selectid; + fLOW_Insert.Operation = OperationType.Edit; + fLOW_Insert.ShowDialog(); + GetInfo(); + + } + else if (e.ColumnIndex == 16) + { + DialogResult result = MessageBox.Show("你确定要删除数据吗?", "确认提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); + + if (result == DialogResult.OK) + { + SQLiteHelper sQLiteHelper = new db.SQLiteHelper(); + var delresult = sQLiteHelper.Delete(selectid); + if (delresult.Success) + { + MessageBox.Show("删除成功"); + } + else + { + MessageBox.Show("删除失败"); + } + GetInfo(); + } + } + } + } public void GetInfo() { try { SQLiteHelper sQLiteHelper = new db.SQLiteHelper(); - var result = sQLiteHelper.Query(a => a.flowid == Init.t_Line.flowid); - if (result.Success) + SQLiteHelper sQLiteHelper1 = new db.SQLiteHelper(); + var result_inf = sQLiteHelper1.QueryAll(); + var result_flow = sQLiteHelper.Query(a => a.flowid == Init.t_Line.flowid); + if (!result_flow.Success || !result_inf.Success) { + MessageBox.Show("查询失败!"); + return; + } + else + { + List list = new List(); + foreach (var flow in result_flow.Data) + { + var errinterface = result_inf.Data.FirstOrDefault(a => a.id == flow.errinterfaceid); + var hopeinterface = result_inf.Data.FirstOrDefault(a => a.id == flow.hopeinterfaceid); + list.Add(new + { + id = flow.id, + flowname = flow.flowname, + flowid = flow.flowid, + setp = flow.setp, + hopeinterfaceid = hopeinterface?.name, + errinterfaceid = errinterface?.name, + hopestatus = flow.hopestatus, + errstatus = flow.errstatus, + scan = flow.scan, + fileupload = flow.fileupload, + finaltorquevalue = flow.finaltorquevalue, + finalanglevaluue = flow.finalanglevaluue, + finaltorquecurve = flow.finaltorquecurve, + finalpressurecurve = flow.finalpressurecurve, + airtight = flow.airtight, + + }); + } dataGridView1.DataSource = null; - dataGridView1.DataSource = result.Data; + dataGridView1.DataSource = list; dataGridView1.Refresh(); } @@ -103,5 +165,12 @@ namespace WindowsFormsApp1.form { } } + + private void button1_Click(object sender, EventArgs e) + { + FLow_Insert fLOW_Insert = new FLow_Insert(); + fLOW_Insert.ShowDialog(); + GetInfo(); + } } } diff --git a/WindowsFormsApp1/form/FLOW_Manage.resx b/WindowsFormsApp1/form/FLOW_Manage.resx index e80d3d1..0f2360b 100644 --- a/WindowsFormsApp1/form/FLOW_Manage.resx +++ b/WindowsFormsApp1/form/FLOW_Manage.resx @@ -117,9 +117,15 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + True + True + + True + True @@ -135,4 +141,25 @@ True + + True + + + True + + + True + + + True + + + True + + + True + + + True + \ No newline at end of file diff --git a/WindowsFormsApp1/form/KeyValue.Designer.cs b/WindowsFormsApp1/form/KeyValue.Designer.cs new file mode 100644 index 0000000..c6ef1ad --- /dev/null +++ b/WindowsFormsApp1/form/KeyValue.Designer.cs @@ -0,0 +1,212 @@ +namespace WindowsFormsApp1 +{ + partial class KeyValue + { + /// + /// 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() + { + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); + this.查询 = new System.Windows.Forms.Button(); + this.dataGridView1 = new System.Windows.Forms.DataGridView(); + this.关闭 = new System.Windows.Forms.Button(); + this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.id = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.key = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.value = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.remark = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.button1 = new System.Windows.Forms.Button(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); + this.tableLayoutPanel1.SuspendLayout(); + this.SuspendLayout(); + // + // 查询 + // + this.查询.Anchor = System.Windows.Forms.AnchorStyles.None; + this.查询.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.查询.Location = new System.Drawing.Point(1488, 51); + this.查询.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); + this.查询.Name = "查询"; + this.查询.Size = new System.Drawing.Size(153, 56); + this.查询.TabIndex = 3; + this.查询.Text = "查询"; + this.查询.UseVisualStyleBackColor = true; + this.查询.Click += new System.EventHandler(this.查询_Click); + // + // dataGridView1 + // + this.dataGridView1.AllowUserToAddRows = false; + this.dataGridView1.AllowUserToDeleteRows = false; + dataGridViewCellStyle1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.dataGridView1.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle2.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle2; + this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.id, + this.key, + this.value, + this.remark}); + dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Window; + dataGridViewCellStyle3.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle3.ForeColor = System.Drawing.SystemColors.ControlText; + dataGridViewCellStyle3.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle3.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.False; + this.dataGridView1.DefaultCellStyle = dataGridViewCellStyle3; + this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill; + this.dataGridView1.Location = new System.Drawing.Point(6, 5); + this.dataGridView1.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); + this.dataGridView1.Name = "dataGridView1"; + this.dataGridView1.ReadOnly = true; + this.dataGridView1.RowHeadersWidth = 72; + this.tableLayoutPanel1.SetRowSpan(this.dataGridView1, 4); + this.dataGridView1.RowTemplate.Height = 23; + this.dataGridView1.Size = new System.Drawing.Size(1470, 785); + this.dataGridView1.TabIndex = 0; + // + // 关闭 + // + this.关闭.Anchor = System.Windows.Forms.AnchorStyles.None; + this.关闭.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.关闭.Location = new System.Drawing.Point(1488, 687); + this.关闭.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); + this.关闭.Name = "关闭"; + this.关闭.Size = new System.Drawing.Size(153, 56); + this.关闭.TabIndex = 2; + this.关闭.Text = "关闭"; + this.关闭.UseVisualStyleBackColor = true; + this.关闭.Click += new System.EventHandler(this.关闭_Click); + // + // tableLayoutPanel1 + // + this.tableLayoutPanel1.ColumnCount = 2; + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 90F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.Controls.Add(this.dataGridView1, 0, 0); + this.tableLayoutPanel1.Controls.Add(this.查询, 1, 0); + this.tableLayoutPanel1.Controls.Add(this.关闭, 1, 3); + this.tableLayoutPanel1.Controls.Add(this.button1, 1, 2); + this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanel1.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + this.tableLayoutPanel1.RowCount = 4; + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 40F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.Size = new System.Drawing.Size(1647, 795); + this.tableLayoutPanel1.TabIndex = 4; + // + // id + // + this.id.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.id.DataPropertyName = "id"; + this.id.HeaderText = "序号"; + this.id.MinimumWidth = 9; + this.id.Name = "id"; + this.id.ReadOnly = true; + // + // key + // + this.key.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.key.DataPropertyName = "key"; + this.key.HeaderText = "关键字"; + this.key.MinimumWidth = 9; + this.key.Name = "key"; + this.key.ReadOnly = true; + // + // value + // + this.value.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.value.DataPropertyName = "value"; + this.value.HeaderText = "值"; + this.value.MinimumWidth = 9; + this.value.Name = "value"; + this.value.ReadOnly = true; + // + // remark + // + this.remark.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.remark.DataPropertyName = "remark"; + this.remark.HeaderText = "备注"; + this.remark.MinimumWidth = 9; + this.remark.Name = "remark"; + this.remark.ReadOnly = true; + // + // button1 + // + this.button1.Anchor = System.Windows.Forms.AnchorStyles.None; + this.button1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.button1.Location = new System.Drawing.Point(1488, 528); + this.button1.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(153, 56); + this.button1.TabIndex = 4; + this.button1.Text = "新增"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // KeyValue + // + this.AutoScaleDimensions = new System.Drawing.SizeF(11F, 21F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1647, 795); + this.Controls.Add(this.tableLayoutPanel1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); + this.Name = "KeyValue"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "MES_URL"; + this.WindowState = System.Windows.Forms.FormWindowState.Maximized; + this.Load += new System.EventHandler(this.MES_URL_Load); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); + this.tableLayoutPanel1.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + private System.Windows.Forms.Button 查询; + private System.Windows.Forms.DataGridView dataGridView1; + private System.Windows.Forms.Button 关闭; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + private System.Windows.Forms.DataGridViewTextBoxColumn id; + private System.Windows.Forms.DataGridViewTextBoxColumn key; + private System.Windows.Forms.DataGridViewTextBoxColumn value; + private System.Windows.Forms.DataGridViewTextBoxColumn remark; + private System.Windows.Forms.Button button1; + } +} \ No newline at end of file diff --git a/WindowsFormsApp1/form/KeyValue.cs b/WindowsFormsApp1/form/KeyValue.cs new file mode 100644 index 0000000..4247781 --- /dev/null +++ b/WindowsFormsApp1/form/KeyValue.cs @@ -0,0 +1,123 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using WindowsFormsApp1.db; +using WindowsFormsApp1.form; +using WindowsFormsApp1.mod; + +namespace WindowsFormsApp1 +{ + public partial class KeyValue : Form + { + public KeyValue() + { + InitializeComponent(); + } + + private void MES_URL_Load(object sender, EventArgs e) + { + dataGridView1.AutoGenerateColumns = false; + DataGridViewButtonColumn modifyColumn = new DataGridViewButtonColumn(); + modifyColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + modifyColumn.Name = "ModifyColumn"; + modifyColumn.HeaderText = "修改"; + modifyColumn.Text = "修改"; + modifyColumn.UseColumnTextForButtonValue = true; + dataGridView1.Columns.Add(modifyColumn); + + // 添加删除按钮列 + DataGridViewButtonColumn deleteColumn = new DataGridViewButtonColumn(); + deleteColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + deleteColumn.Name = "DeleteColumn"; + deleteColumn.HeaderText = "删除"; + deleteColumn.Text = "删除"; + deleteColumn.UseColumnTextForButtonValue = true; + dataGridView1.Columns.Add(deleteColumn); + + dataGridView1.CellContentClick += DataGridView1_CellContentClick; + + GetInfo(); + } + + private void DataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) + { + // 检查点击的是否为按钮列 + if (e.RowIndex >= 0) + { + DataGridView dataGridView = (DataGridView)sender; + DataGridViewRow row = dataGridView.Rows[e.RowIndex]; + + int selectid = int.Parse(row.Cells[0].Value.ToString()); + if (e.ColumnIndex == 4) + { + KeyValue_Insert fLOW_Insert = new KeyValue_Insert(); + fLOW_Insert.dataid = selectid; + fLOW_Insert.Operation = OperationType.Edit; + fLOW_Insert.ShowDialog(); + GetInfo(); + + } + else if (e.ColumnIndex == 5) + { + DialogResult result = MessageBox.Show("你确定要删除数据吗?", "确认提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); + + if (result == DialogResult.OK) + { + SQLiteHelper sQLiteHelper = new db.SQLiteHelper(); + var delresult = sQLiteHelper.Delete(selectid); + if (delresult.Success) + { + MessageBox.Show("删除成功"); + } + else + { + MessageBox.Show("删除失败"); + } + GetInfo(); + } + } + } + } + + private void 关闭_Click(object sender, EventArgs e) + { + this.Close(); + } + + private void 查询_Click(object sender, EventArgs e) + { + GetInfo(); + } + + public void GetInfo() + { + try + { + SQLiteHelper sQLiteHelper = new db.SQLiteHelper(); + var result = sQLiteHelper.QueryAll(); + if (result.Success) + { + dataGridView1.DataSource = null; + dataGridView1.DataSource = result.Data; + dataGridView1.Refresh(); + } + } + catch (Exception ex) + { + } + } + + private void button1_Click(object sender, EventArgs e) + { + KeyValue_Insert fLOW_Insert = new KeyValue_Insert(); + fLOW_Insert.ShowDialog(); + GetInfo(); + } + } +} diff --git a/WindowsFormsApp1/form/KeyValue.resx b/WindowsFormsApp1/form/KeyValue.resx new file mode 100644 index 0000000..c00fe38 --- /dev/null +++ b/WindowsFormsApp1/form/KeyValue.resx @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + True + + + True + + + True + + + True + + \ No newline at end of file diff --git a/WindowsFormsApp1/form/LINE_Manage.Designer.cs b/WindowsFormsApp1/form/LINE_Manage.Designer.cs index 584c126..b50b3ed 100644 --- a/WindowsFormsApp1/form/LINE_Manage.Designer.cs +++ b/WindowsFormsApp1/form/LINE_Manage.Designer.cs @@ -1,6 +1,6 @@ namespace WindowsFormsApp1.form { - partial class LINE_Manage + partial class Line_Manage { /// /// Required designer variable. @@ -32,18 +32,16 @@ System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); this.关闭 = new System.Windows.Forms.Button(); - this.保存 = new System.Windows.Forms.Button(); this.查询 = new System.Windows.Forms.Button(); this.dataGridView1 = new System.Windows.Forms.DataGridView(); - this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); this.id = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.linename = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.linecode = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.linetype = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.linemode = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.plcid1 = new System.Windows.Forms.DataGridViewComboBoxColumn(); - this.plcid2 = new System.Windows.Forms.DataGridViewComboBoxColumn(); - this.flowid = new System.Windows.Forms.DataGridViewComboBoxColumn(); + this.flowname = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.新增 = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); this.tableLayoutPanel1.SuspendLayout(); this.SuspendLayout(); @@ -61,19 +59,6 @@ this.关闭.UseVisualStyleBackColor = true; this.关闭.Click += new System.EventHandler(this.关闭_Click); // - // 保存 - // - this.保存.Anchor = System.Windows.Forms.AnchorStyles.None; - this.保存.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.保存.Location = new System.Drawing.Point(1604, 542); - this.保存.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); - this.保存.Name = "保存"; - this.保存.Size = new System.Drawing.Size(162, 72); - this.保存.TabIndex = 9; - this.保存.Text = "保存"; - this.保存.UseVisualStyleBackColor = true; - this.保存.Click += new System.EventHandler(this.保存_Click); - // // 查询 // this.查询.Anchor = System.Windows.Forms.AnchorStyles.None; @@ -111,9 +96,7 @@ this.linecode, this.linetype, this.linemode, - this.plcid1, - this.plcid2, - this.flowid}); + this.flowname}); dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Window; dataGridViewCellStyle3.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); @@ -125,33 +108,13 @@ this.dataGridView1.Location = new System.Drawing.Point(6, 5); this.dataGridView1.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); this.dataGridView1.Name = "dataGridView1"; + this.dataGridView1.ReadOnly = true; this.dataGridView1.RowHeadersWidth = 72; this.tableLayoutPanel1.SetRowSpan(this.dataGridView1, 4); this.dataGridView1.RowTemplate.Height = 23; this.dataGridView1.Size = new System.Drawing.Size(1584, 819); this.dataGridView1.TabIndex = 7; // - // tableLayoutPanel1 - // - this.tableLayoutPanel1.ColumnCount = 2; - this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 90F)); - this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10F)); - this.tableLayoutPanel1.Controls.Add(this.关闭, 1, 3); - this.tableLayoutPanel1.Controls.Add(this.dataGridView1, 0, 0); - this.tableLayoutPanel1.Controls.Add(this.查询, 1, 0); - this.tableLayoutPanel1.Controls.Add(this.保存, 1, 2); - this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; - this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); - this.tableLayoutPanel1.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); - this.tableLayoutPanel1.Name = "tableLayoutPanel1"; - this.tableLayoutPanel1.RowCount = 4; - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 40F)); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); - this.tableLayoutPanel1.Size = new System.Drawing.Size(1774, 829); - this.tableLayoutPanel1.TabIndex = 11; - // // id // this.id.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; @@ -168,6 +131,7 @@ this.linename.HeaderText = "名称"; this.linename.MinimumWidth = 9; this.linename.Name = "linename"; + this.linename.ReadOnly = true; // // linecode // @@ -176,6 +140,7 @@ this.linecode.HeaderText = "产线编码"; this.linecode.MinimumWidth = 9; this.linecode.Name = "linecode"; + this.linecode.ReadOnly = true; // // linetype // @@ -184,6 +149,7 @@ this.linetype.HeaderText = "产线类型"; this.linetype.MinimumWidth = 9; this.linetype.Name = "linetype"; + this.linetype.ReadOnly = true; // // linemode // @@ -192,31 +158,53 @@ this.linemode.HeaderText = "模组"; this.linemode.MinimumWidth = 9; this.linemode.Name = "linemode"; + this.linemode.ReadOnly = true; // - // plcid1 + // flowname // - this.plcid1.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; - this.plcid1.DataPropertyName = "plcid1"; - this.plcid1.HeaderText = "关联PLC1"; - this.plcid1.MinimumWidth = 9; - this.plcid1.Name = "plcid1"; + this.flowname.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.flowname.DataPropertyName = "flowname"; + this.flowname.HeaderText = "关联流程"; + this.flowname.MinimumWidth = 9; + this.flowname.Name = "flowname"; + this.flowname.ReadOnly = true; + this.flowname.Resizable = System.Windows.Forms.DataGridViewTriState.True; + this.flowname.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; + this.flowname.ToolTipText = "flowname"; // - // plcid2 + // tableLayoutPanel1 // - this.plcid2.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; - this.plcid2.DataPropertyName = "plcid2"; - this.plcid2.HeaderText = "关联PLC2"; - this.plcid2.MinimumWidth = 9; - this.plcid2.Name = "plcid2"; + this.tableLayoutPanel1.ColumnCount = 2; + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 90F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.Controls.Add(this.关闭, 1, 3); + this.tableLayoutPanel1.Controls.Add(this.dataGridView1, 0, 0); + this.tableLayoutPanel1.Controls.Add(this.查询, 1, 0); + this.tableLayoutPanel1.Controls.Add(this.新增, 1, 2); + this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanel1.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + this.tableLayoutPanel1.RowCount = 4; + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 40F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.Size = new System.Drawing.Size(1774, 829); + this.tableLayoutPanel1.TabIndex = 11; // - // flowid + // 新增 // - this.flowid.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; - this.flowid.DataPropertyName = "flowid"; - this.flowid.HeaderText = "关联流程"; - this.flowid.MinimumWidth = 9; - this.flowid.Name = "flowid"; - this.flowid.Resizable = System.Windows.Forms.DataGridViewTriState.True; + this.新增.Anchor = System.Windows.Forms.AnchorStyles.None; + this.新增.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.新增.Location = new System.Drawing.Point(1604, 542); + this.新增.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); + this.新增.Name = "新增"; + this.新增.Size = new System.Drawing.Size(162, 72); + this.新增.TabIndex = 11; + this.新增.Text = "新增"; + this.新增.UseVisualStyleBackColor = true; + this.新增.Click += new System.EventHandler(this.新增_Click); // // LINE_Manage // @@ -229,6 +217,7 @@ this.Name = "LINE_Manage"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "LINE_Mange"; + this.WindowState = System.Windows.Forms.FormWindowState.Maximized; this.Load += new System.EventHandler(this.LINE_Manage_Load); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); this.tableLayoutPanel1.ResumeLayout(false); @@ -239,17 +228,15 @@ #endregion private System.Windows.Forms.Button 关闭; - private System.Windows.Forms.Button 保存; private System.Windows.Forms.Button 查询; private System.Windows.Forms.DataGridView dataGridView1; private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + private System.Windows.Forms.Button 新增; private System.Windows.Forms.DataGridViewTextBoxColumn id; private System.Windows.Forms.DataGridViewTextBoxColumn linename; private System.Windows.Forms.DataGridViewTextBoxColumn linecode; private System.Windows.Forms.DataGridViewTextBoxColumn linetype; private System.Windows.Forms.DataGridViewTextBoxColumn linemode; - private System.Windows.Forms.DataGridViewComboBoxColumn plcid1; - private System.Windows.Forms.DataGridViewComboBoxColumn plcid2; - private System.Windows.Forms.DataGridViewComboBoxColumn flowid; + private System.Windows.Forms.DataGridViewTextBoxColumn flowname; } } \ No newline at end of file diff --git a/WindowsFormsApp1/form/LINE_Manage.cs b/WindowsFormsApp1/form/LINE_Manage.cs index d9321c8..04c20ec 100644 --- a/WindowsFormsApp1/form/LINE_Manage.cs +++ b/WindowsFormsApp1/form/LINE_Manage.cs @@ -13,9 +13,9 @@ using static System.Windows.Forms.VisualStyles.VisualStyleElement; namespace WindowsFormsApp1.form { - public partial class LINE_Manage : Form + public partial class Line_Manage : Form { - public LINE_Manage() + public Line_Manage() { InitializeComponent(); } @@ -25,39 +25,6 @@ namespace WindowsFormsApp1.form GetInfo(); } - private void 保存_Click(object sender, EventArgs e) - { - try - { - SQLiteHelper sQLiteHelper = new db.SQLiteHelper(); - var result = sQLiteHelper.UpdateAll((List)dataGridView1.DataSource); - if (result.Success) - { - MessageBox.Show("更新成功"); - SQLiteHelper sQLiteHelper1 = new db.SQLiteHelper(); - var result_combox = sQLiteHelper1.QuerySingle(a => a.id == Init.t_Line.id); - if (!result_combox.Success) - { - MessageBox.Show("更新产线配置失败!"); - return; - } - else - { - Init.t_Line = result_combox.Data; - GetInfo(); - } - } - else - { - MessageBox.Show("更新失败"); - } - } - catch (Exception ex) - { - MessageBox.Show($"更新失败,错误原因{ex.Message}"); - } - } - private void 关闭_Click(object sender, EventArgs e) { this.Close(); @@ -67,64 +34,71 @@ namespace WindowsFormsApp1.form { dataGridView1.AutoGenerateColumns = false; - SQLiteHelper sQLiteHelper1 = new db.SQLiteHelper(); - var result = sQLiteHelper1.QueryAll(); - if (!result.Success) - { - MessageBox.Show("查询失败!"); - return; - } - var result1 = result.Data.GroupBy(a => a.flowid).ToList(); - - SQLiteHelper sQLiteHelper2 = new db.SQLiteHelper(); - var result2 = sQLiteHelper2.QueryAll(); - if (!result2.Success) - { - MessageBox.Show("查询失败!"); - return; - } - result2.Data.Insert(0, new t_plc { id = 0, plcip = "" }); - - var comboBoxColumn = (DataGridViewComboBoxColumn)dataGridView1.Columns[5]; - // 绑定数据源到 ComboBox - comboBoxColumn.DataSource = result2.Data; - comboBoxColumn.DisplayMember = "plcip"; - comboBoxColumn.ValueMember = "id"; - - //// 设置默认值为 Product 的 CategoryId - comboBoxColumn.DataPropertyName = "plcid1"; // 绑定数据源中的 CategoryId 字段 - - var comboBoxColumn1 = (DataGridViewComboBoxColumn)dataGridView1.Columns[6]; - // 绑定数据源到 ComboBox - comboBoxColumn1.DataSource = result2.Data; - comboBoxColumn1.DisplayMember = "plcip"; - comboBoxColumn1.ValueMember = "id"; - - // 设置默认值为 Product 的 CategoryId - comboBoxColumn1.DataPropertyName = "plcid2"; // 绑定数据源中的 CategoryId 字段 - - - var comboBoxColumn2 = (DataGridViewComboBoxColumn)dataGridView1.Columns[7]; - // 绑定数据源到 ComboBox - comboBoxColumn2.DataSource = result1; - comboBoxColumn2.DisplayMember = "key"; - comboBoxColumn2.ValueMember = "key"; - - // 设置默认值为 Product 的 CategoryId - comboBoxColumn2.DataPropertyName = "flowid"; // 绑定数据源中的 CategoryId 字段 + // 添加修改按钮列 + DataGridViewButtonColumn modifyColumn = new DataGridViewButtonColumn(); + modifyColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + modifyColumn.Name = "ModifyColumn"; + modifyColumn.HeaderText = "修改"; + modifyColumn.Text = "修改"; + modifyColumn.UseColumnTextForButtonValue = true; + dataGridView1.Columns.Add(modifyColumn); + dataGridView1.CellContentClick += DataGridView1_CellContentClick; GetInfo(); } + private void DataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) + { + // 检查点击的是否为按钮列 + if (e.RowIndex >= 0) + { + DataGridView dataGridView = (DataGridView)sender; + DataGridViewRow row = dataGridView.Rows[e.RowIndex]; + + int selectid = int.Parse(row.Cells[0].Value.ToString()); + if (e.ColumnIndex == 6) + { + Line_Insert fLOW_Insert = new Line_Insert(); + fLOW_Insert.dataid = selectid; + fLOW_Insert.Operation = OperationType.Edit; + fLOW_Insert.ShowDialog(); + GetInfo(); + + } + } + } public void GetInfo() { try { SQLiteHelper sQLiteHelper = new db.SQLiteHelper(); - var result = sQLiteHelper.Query(a=>a.id == Init.t_Line.id); - if (result.Success) + SQLiteHelper sQLiteHelper1 = new db.SQLiteHelper(); + var result_flow = sQLiteHelper1.QueryAll(); + var result_line = sQLiteHelper.Query(a=>a.id == Init.t_Line.id); + if (!result_line.Success || !result_flow.Success) { + MessageBox.Show("查询失败!"); + return; + } + else + { + List list = new List(); + foreach (var line in result_line.Data) + { + var flowname = result_flow.Data.FirstOrDefault(a=>a.flowid == line.flowid); + list.Add( new + { + id = line.id, + flowid = line.flowid, + linename = line.linename, + linecode = line.linecode, + linetype = line.linetype, + linemode = line.linemode, + flowname = flowname.flowname, + }); + } + dataGridView1.DataSource = null; - dataGridView1.DataSource = result.Data; + dataGridView1.DataSource = list; dataGridView1.Refresh(); } } @@ -132,5 +106,12 @@ namespace WindowsFormsApp1.form { } } + + private void 新增_Click(object sender, EventArgs e) + { + Line_Insert fLOW_Insert = new Line_Insert(); + fLOW_Insert.ShowDialog(); + GetInfo(); + } } } diff --git a/WindowsFormsApp1/form/LINE_Manage.resx b/WindowsFormsApp1/form/LINE_Manage.resx index c6e5615..17100db 100644 --- a/WindowsFormsApp1/form/LINE_Manage.resx +++ b/WindowsFormsApp1/form/LINE_Manage.resx @@ -132,13 +132,7 @@ True - - True - - - True - - + True \ No newline at end of file diff --git a/WindowsFormsApp1/form/LinePLC_Manage.Designer.cs b/WindowsFormsApp1/form/LinePLC_Manage.Designer.cs new file mode 100644 index 0000000..02091d3 --- /dev/null +++ b/WindowsFormsApp1/form/LinePLC_Manage.Designer.cs @@ -0,0 +1,206 @@ +namespace WindowsFormsApp1.form +{ + partial class LinePLC_Manage + { + /// + /// 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() + { + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); + this.关闭 = new System.Windows.Forms.Button(); + this.查询 = new System.Windows.Forms.Button(); + this.dataGridView1 = new System.Windows.Forms.DataGridView(); + this.id = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.linename = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.flowname = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.新增 = new System.Windows.Forms.Button(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); + this.tableLayoutPanel1.SuspendLayout(); + this.SuspendLayout(); + // + // 关闭 + // + this.关闭.Anchor = System.Windows.Forms.AnchorStyles.None; + this.关闭.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.关闭.Location = new System.Drawing.Point(1604, 709); + this.关闭.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); + this.关闭.Name = "关闭"; + this.关闭.Size = new System.Drawing.Size(162, 72); + this.关闭.TabIndex = 10; + this.关闭.Text = "关闭"; + this.关闭.UseVisualStyleBackColor = true; + this.关闭.Click += new System.EventHandler(this.关闭_Click); + // + // 查询 + // + this.查询.Anchor = System.Windows.Forms.AnchorStyles.None; + this.查询.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.查询.Location = new System.Drawing.Point(1604, 46); + this.查询.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); + this.查询.Name = "查询"; + this.查询.Size = new System.Drawing.Size(162, 72); + this.查询.TabIndex = 8; + this.查询.Text = "查询"; + this.查询.UseVisualStyleBackColor = true; + this.查询.Click += new System.EventHandler(this.查询_Click); + // + // dataGridView1 + // + this.dataGridView1.AllowUserToAddRows = false; + this.dataGridView1.AllowUserToDeleteRows = false; + dataGridViewCellStyle1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.dataGridView1.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; + this.dataGridView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle2.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle2; + this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.id, + this.linename, + this.flowname}); + dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Window; + dataGridViewCellStyle3.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle3.ForeColor = System.Drawing.SystemColors.ControlText; + dataGridViewCellStyle3.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle3.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.False; + this.dataGridView1.DefaultCellStyle = dataGridViewCellStyle3; + this.dataGridView1.Location = new System.Drawing.Point(6, 5); + this.dataGridView1.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); + this.dataGridView1.Name = "dataGridView1"; + this.dataGridView1.ReadOnly = true; + this.dataGridView1.RowHeadersWidth = 72; + this.tableLayoutPanel1.SetRowSpan(this.dataGridView1, 4); + this.dataGridView1.RowTemplate.Height = 23; + this.dataGridView1.Size = new System.Drawing.Size(1584, 819); + this.dataGridView1.TabIndex = 7; + // + // id + // + this.id.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.id.DataPropertyName = "id"; + this.id.HeaderText = "序号"; + this.id.MinimumWidth = 9; + this.id.Name = "id"; + this.id.ReadOnly = true; + // + // linename + // + this.linename.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.linename.DataPropertyName = "linename"; + this.linename.HeaderText = "产线名称"; + this.linename.MinimumWidth = 9; + this.linename.Name = "linename"; + this.linename.ReadOnly = true; + // + // flowname + // + this.flowname.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.flowname.DataPropertyName = "plcname"; + this.flowname.HeaderText = "关联PLC"; + this.flowname.MinimumWidth = 9; + this.flowname.Name = "flowname"; + this.flowname.ReadOnly = true; + this.flowname.Resizable = System.Windows.Forms.DataGridViewTriState.True; + this.flowname.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; + this.flowname.ToolTipText = "plcname"; + // + // tableLayoutPanel1 + // + this.tableLayoutPanel1.ColumnCount = 2; + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 90F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.Controls.Add(this.关闭, 1, 3); + this.tableLayoutPanel1.Controls.Add(this.dataGridView1, 0, 0); + this.tableLayoutPanel1.Controls.Add(this.查询, 1, 0); + this.tableLayoutPanel1.Controls.Add(this.新增, 1, 2); + this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanel1.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + this.tableLayoutPanel1.RowCount = 4; + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 40F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.Size = new System.Drawing.Size(1774, 829); + this.tableLayoutPanel1.TabIndex = 11; + // + // 新增 + // + this.新增.Anchor = System.Windows.Forms.AnchorStyles.None; + this.新增.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.新增.Location = new System.Drawing.Point(1604, 542); + this.新增.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); + this.新增.Name = "新增"; + this.新增.Size = new System.Drawing.Size(162, 72); + this.新增.TabIndex = 11; + this.新增.Text = "新增"; + this.新增.UseVisualStyleBackColor = true; + this.新增.Click += new System.EventHandler(this.新增_Click); + // + // LINEPLC_Manage + // + this.AutoScaleDimensions = new System.Drawing.SizeF(11F, 21F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1774, 829); + this.Controls.Add(this.tableLayoutPanel1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.Margin = new System.Windows.Forms.Padding(4); + this.Name = "LINEPLC_Manage"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "LINE_Mange"; + this.WindowState = System.Windows.Forms.FormWindowState.Maximized; + this.Load += new System.EventHandler(this.LINE_Manage_Load); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); + this.tableLayoutPanel1.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Button 关闭; + private System.Windows.Forms.Button 查询; + private System.Windows.Forms.DataGridView dataGridView1; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + private System.Windows.Forms.Button 新增; + private System.Windows.Forms.DataGridViewTextBoxColumn id; + private System.Windows.Forms.DataGridViewTextBoxColumn linename; + private System.Windows.Forms.DataGridViewTextBoxColumn flowname; + } +} \ No newline at end of file diff --git a/WindowsFormsApp1/form/LinePLC_Manage.cs b/WindowsFormsApp1/form/LinePLC_Manage.cs new file mode 100644 index 0000000..709b14a --- /dev/null +++ b/WindowsFormsApp1/form/LinePLC_Manage.cs @@ -0,0 +1,148 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using WindowsFormsApp1.db; +using WindowsFormsApp1.mod; +using static System.Windows.Forms.VisualStyles.VisualStyleElement; + +namespace WindowsFormsApp1.form +{ + public partial class LinePLC_Manage : Form + { + public LinePLC_Manage() + { + InitializeComponent(); + } + + private void 查询_Click(object sender, EventArgs e) + { + GetInfo(); + } + + private void 关闭_Click(object sender, EventArgs e) + { + this.Close(); + } + + private void LINE_Manage_Load(object sender, EventArgs e) + { + dataGridView1.AutoGenerateColumns = false; + + // 添加修改按钮列 + DataGridViewButtonColumn modifyColumn = new DataGridViewButtonColumn(); + modifyColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + modifyColumn.Name = "ModifyColumn"; + modifyColumn.HeaderText = "修改"; + modifyColumn.Text = "修改"; + modifyColumn.UseColumnTextForButtonValue = true; + dataGridView1.Columns.Add(modifyColumn); + + // 添加删除按钮列 + DataGridViewButtonColumn deleteColumn = new DataGridViewButtonColumn(); + deleteColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + deleteColumn.Name = "DeleteColumn"; + deleteColumn.HeaderText = "删除"; + deleteColumn.Text = "删除"; + deleteColumn.UseColumnTextForButtonValue = true; + dataGridView1.Columns.Add(deleteColumn); + + dataGridView1.CellContentClick += DataGridView1_CellContentClick; + GetInfo(); + } + private void DataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) + { + // 检查点击的是否为按钮列 + if (e.RowIndex >= 0) + { + DataGridView dataGridView = (DataGridView)sender; + DataGridViewRow row = dataGridView.Rows[e.RowIndex]; + + int selectid = int.Parse(row.Cells[0].Value.ToString()); + if (e.ColumnIndex == 3) + { + LinePLC_Insert fLOW_Insert = new LinePLC_Insert(); + fLOW_Insert.dataid = selectid; + fLOW_Insert.Operation = OperationType.Edit; + fLOW_Insert.ShowDialog(); + GetInfo(); + + } + else if (e.ColumnIndex == 4) + { + DialogResult result = MessageBox.Show("你确定要删除数据吗?", "确认提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); + + if (result == DialogResult.OK) + { + SQLiteHelper sQLiteHelper = new db.SQLiteHelper(); + var delresult = sQLiteHelper.Delete(selectid); + if (delresult.Success) + { + MessageBox.Show("删除成功"); + } + else + { + MessageBox.Show("删除失败"); + } + GetInfo(); + } + } + } + } + public void GetInfo() + { + try + { + SQLiteHelper sQLiteHelper = new db.SQLiteHelper(); + SQLiteHelper sQLiteHelper1 = new db.SQLiteHelper(); + SQLiteHelper sQLiteHelper2 = new db.SQLiteHelper(); + var result_plc = sQLiteHelper.QueryAll(); + var result_line = sQLiteHelper1.QueryAll(); + var result_lineplc = sQLiteHelper2.QueryAll(); + + + if (!result_line.Success || !result_plc.Success || !result_lineplc.Success) + { + MessageBox.Show("查询失败!"); + return; + } + else + { + List list = new List(); + foreach (var line in result_lineplc.Data) + { + var linename = result_line.Data.FirstOrDefault(a=>a.id == line.lineid); + var plcname = result_plc.Data.FirstOrDefault(a => a.id == line.plcid); + list.Add( new + { + id = line.id, + lineid = line.lineid, + plcid = line.plcid, + linename = linename.linename, + plcname = plcname.plcname, + }); + } + + dataGridView1.DataSource = null; + dataGridView1.DataSource = list; + dataGridView1.Refresh(); + } + } + catch (Exception ex) + { + } + } + + private void 新增_Click(object sender, EventArgs e) + { + LinePLC_Insert fLOW_Insert = new LinePLC_Insert(); + fLOW_Insert.ShowDialog(); + GetInfo(); + } + } +} diff --git a/WindowsFormsApp1/form/LinePLC_Manage.resx b/WindowsFormsApp1/form/LinePLC_Manage.resx new file mode 100644 index 0000000..03c7fe3 --- /dev/null +++ b/WindowsFormsApp1/form/LinePLC_Manage.resx @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + True + + + True + + + True + + \ No newline at end of file diff --git a/WindowsFormsApp1/form/LoginForm.cs b/WindowsFormsApp1/form/LoginForm.cs index 684ab34..1119101 100644 --- a/WindowsFormsApp1/form/LoginForm.cs +++ b/WindowsFormsApp1/form/LoginForm.cs @@ -34,6 +34,7 @@ namespace WindowsFormsApp1 SQLiteHelper sQLiteHelper1 = new db.SQLiteHelper(); var result_combox = sQLiteHelper1.QuerySingle(a=>a.id == (int)comboBox1.SelectedValue); + if (!result.Success || !result_combox.Success) { MessageBox.Show("账号/密码/产线错误!"); @@ -41,8 +42,17 @@ namespace WindowsFormsApp1 } else { + SQLiteHelper sQLiteHelper_lineplc = new db.SQLiteHelper(); + var lineplc_result = sQLiteHelper_lineplc.Query(a => a.lineid == result_combox.Data.id); + if (!lineplc_result.Success) + { + MessageBox.Show("无法初始化PLC-产线关联信息!"); + return; + } + Init.t_User = result.Data; Init.t_Line = result_combox.Data; + Init.t_Lineplcs = lineplc_result.Data; DialogResult = DialogResult.OK; this.Close(); } diff --git a/WindowsFormsApp1/form/MES_URL.Designer.cs b/WindowsFormsApp1/form/MESUrl.Designer.cs similarity index 90% rename from WindowsFormsApp1/form/MES_URL.Designer.cs rename to WindowsFormsApp1/form/MESUrl.Designer.cs index 9ef4ea2..338039c 100644 --- a/WindowsFormsApp1/form/MES_URL.Designer.cs +++ b/WindowsFormsApp1/form/MESUrl.Designer.cs @@ -1,6 +1,6 @@ namespace WindowsFormsApp1 { - partial class MES_URL + partial class MESUrl { /// /// Required designer variable. @@ -31,32 +31,19 @@ System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); - this.保存 = new System.Windows.Forms.Button(); this.查询 = new System.Windows.Forms.Button(); this.dataGridView1 = new System.Windows.Forms.DataGridView(); - this.关闭 = new System.Windows.Forms.Button(); - this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); this.id = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.name = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.code = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.url = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.关闭 = new System.Windows.Forms.Button(); + this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.button1 = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); this.tableLayoutPanel1.SuspendLayout(); this.SuspendLayout(); // - // 保存 - // - this.保存.Anchor = System.Windows.Forms.AnchorStyles.None; - this.保存.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.保存.Location = new System.Drawing.Point(1488, 528); - this.保存.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); - this.保存.Name = "保存"; - this.保存.Size = new System.Drawing.Size(153, 56); - this.保存.TabIndex = 1; - this.保存.Text = "保存"; - this.保存.UseVisualStyleBackColor = true; - this.保存.Click += new System.EventHandler(this.保存_Click); - // // 查询 // this.查询.Anchor = System.Windows.Forms.AnchorStyles.None; @@ -102,46 +89,13 @@ this.dataGridView1.Location = new System.Drawing.Point(6, 5); this.dataGridView1.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); this.dataGridView1.Name = "dataGridView1"; + this.dataGridView1.ReadOnly = true; this.dataGridView1.RowHeadersWidth = 72; this.tableLayoutPanel1.SetRowSpan(this.dataGridView1, 4); this.dataGridView1.RowTemplate.Height = 23; this.dataGridView1.Size = new System.Drawing.Size(1470, 785); this.dataGridView1.TabIndex = 0; // - // 关闭 - // - this.关闭.Anchor = System.Windows.Forms.AnchorStyles.None; - this.关闭.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.关闭.Location = new System.Drawing.Point(1488, 687); - this.关闭.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); - this.关闭.Name = "关闭"; - this.关闭.Size = new System.Drawing.Size(153, 56); - this.关闭.TabIndex = 2; - this.关闭.Text = "关闭"; - this.关闭.UseVisualStyleBackColor = true; - this.关闭.Click += new System.EventHandler(this.关闭_Click); - // - // tableLayoutPanel1 - // - this.tableLayoutPanel1.ColumnCount = 2; - this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 90F)); - this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10F)); - this.tableLayoutPanel1.Controls.Add(this.dataGridView1, 0, 0); - this.tableLayoutPanel1.Controls.Add(this.查询, 1, 0); - this.tableLayoutPanel1.Controls.Add(this.关闭, 1, 3); - this.tableLayoutPanel1.Controls.Add(this.保存, 1, 2); - this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; - this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); - this.tableLayoutPanel1.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); - this.tableLayoutPanel1.Name = "tableLayoutPanel1"; - this.tableLayoutPanel1.RowCount = 4; - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 40F)); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); - this.tableLayoutPanel1.Size = new System.Drawing.Size(1647, 795); - this.tableLayoutPanel1.TabIndex = 4; - // // id // this.id.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; @@ -176,6 +130,54 @@ this.url.HeaderText = "网址"; this.url.MinimumWidth = 9; this.url.Name = "url"; + this.url.ReadOnly = true; + // + // 关闭 + // + this.关闭.Anchor = System.Windows.Forms.AnchorStyles.None; + this.关闭.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.关闭.Location = new System.Drawing.Point(1488, 687); + this.关闭.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); + this.关闭.Name = "关闭"; + this.关闭.Size = new System.Drawing.Size(153, 56); + this.关闭.TabIndex = 2; + this.关闭.Text = "关闭"; + this.关闭.UseVisualStyleBackColor = true; + this.关闭.Click += new System.EventHandler(this.关闭_Click); + // + // tableLayoutPanel1 + // + this.tableLayoutPanel1.ColumnCount = 2; + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 90F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.Controls.Add(this.dataGridView1, 0, 0); + this.tableLayoutPanel1.Controls.Add(this.查询, 1, 0); + this.tableLayoutPanel1.Controls.Add(this.关闭, 1, 3); + this.tableLayoutPanel1.Controls.Add(this.button1, 1, 2); + this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanel1.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + this.tableLayoutPanel1.RowCount = 4; + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 40F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.Size = new System.Drawing.Size(1647, 795); + this.tableLayoutPanel1.TabIndex = 4; + // + // button1 + // + this.button1.Anchor = System.Windows.Forms.AnchorStyles.None; + this.button1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.button1.Location = new System.Drawing.Point(1488, 528); + this.button1.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(153, 56); + this.button1.TabIndex = 4; + this.button1.Text = "新增"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); // // MES_URL // @@ -188,6 +190,7 @@ this.Name = "MES_URL"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "MES_URL"; + this.WindowState = System.Windows.Forms.FormWindowState.Maximized; this.Load += new System.EventHandler(this.MES_URL_Load); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); this.tableLayoutPanel1.ResumeLayout(false); @@ -196,7 +199,6 @@ } #endregion - private System.Windows.Forms.Button 保存; private System.Windows.Forms.Button 查询; private System.Windows.Forms.DataGridView dataGridView1; private System.Windows.Forms.Button 关闭; @@ -205,5 +207,6 @@ private System.Windows.Forms.DataGridViewTextBoxColumn name; private System.Windows.Forms.DataGridViewTextBoxColumn code; private System.Windows.Forms.DataGridViewTextBoxColumn url; + private System.Windows.Forms.Button button1; } } \ No newline at end of file diff --git a/WindowsFormsApp1/form/MESUrl.cs b/WindowsFormsApp1/form/MESUrl.cs new file mode 100644 index 0000000..a2b1469 --- /dev/null +++ b/WindowsFormsApp1/form/MESUrl.cs @@ -0,0 +1,144 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using WindowsFormsApp1.db; +using WindowsFormsApp1.form; +using WindowsFormsApp1.mod; + +namespace WindowsFormsApp1 +{ + public partial class MESUrl : Form + { + public MESUrl() + { + InitializeComponent(); + } + + private void MES_URL_Load(object sender, EventArgs e) + { + dataGridView1.AutoGenerateColumns = false; + DataGridViewButtonColumn modifyColumn = new DataGridViewButtonColumn(); + modifyColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + modifyColumn.Name = "ModifyColumn"; + modifyColumn.HeaderText = "修改"; + modifyColumn.Text = "修改"; + modifyColumn.UseColumnTextForButtonValue = true; + dataGridView1.Columns.Add(modifyColumn); + + // 添加删除按钮列 + DataGridViewButtonColumn deleteColumn = new DataGridViewButtonColumn(); + deleteColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + deleteColumn.Name = "DeleteColumn"; + deleteColumn.HeaderText = "删除"; + deleteColumn.Text = "删除"; + deleteColumn.UseColumnTextForButtonValue = true; + dataGridView1.Columns.Add(deleteColumn); + + dataGridView1.CellContentClick += DataGridView1_CellContentClick; + GetInfo(); + } + + private void DataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) + { + // 检查点击的是否为按钮列 + if (e.RowIndex >= 0) + { + DataGridView dataGridView = (DataGridView)sender; + DataGridViewRow row = dataGridView.Rows[e.RowIndex]; + + int selectid = int.Parse(row.Cells[0].Value.ToString()); + if (e.ColumnIndex == 4) + { + MESUrl_Insert fLOW_Insert = new MESUrl_Insert(); + fLOW_Insert.dataid = selectid; + fLOW_Insert.Operation = OperationType.Edit; + fLOW_Insert.ShowDialog(); + GetInfo(); + + } + else if (e.ColumnIndex == 5) + { + DialogResult result = MessageBox.Show("你确定要删除数据吗?", "确认提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); + + if (result == DialogResult.OK) + { + SQLiteHelper sQLiteHelper = new db.SQLiteHelper(); + var delresult = sQLiteHelper.Delete(selectid); + if (delresult.Success) + { + MessageBox.Show("删除成功"); + } + else + { + MessageBox.Show("删除失败"); + } + GetInfo(); + } + } + } + } + + private void 保存_Click(object sender, EventArgs e) + { + try + { + SQLiteHelper sQLiteHelper = new db.SQLiteHelper(); + var result = sQLiteHelper.UpdateAll((List)dataGridView1.DataSource); + if (result.Success) + { + MessageBox.Show("更新成功"); + GetInfo(); + } + else + { + MessageBox.Show("更新失败"); + } + } + catch (Exception ex) + { + MessageBox.Show($"更新失败,错误原因{ex.Message}"); + } + } + + private void 关闭_Click(object sender, EventArgs e) + { + this.Close(); + } + + private void 查询_Click(object sender, EventArgs e) + { + GetInfo(); + } + + public void GetInfo() + { + try + { + SQLiteHelper sQLiteHelper = new db.SQLiteHelper(); + var result = sQLiteHelper.QueryAll(); + if (result.Success) + { + dataGridView1.DataSource = null; + dataGridView1.DataSource = result.Data; + dataGridView1.Refresh(); + } + } + catch (Exception ex) + { + } + } + + private void button1_Click(object sender, EventArgs e) + { + MESUrl_Insert fLOW_Insert = new MESUrl_Insert(); + fLOW_Insert.ShowDialog(); + GetInfo(); + } + } +} diff --git a/WindowsFormsApp1/form/MES_URL.resx b/WindowsFormsApp1/form/MESUrl.resx similarity index 100% rename from WindowsFormsApp1/form/MES_URL.resx rename to WindowsFormsApp1/form/MESUrl.resx diff --git a/WindowsFormsApp1/form/MES_URL.cs b/WindowsFormsApp1/form/MES_URL.cs deleted file mode 100644 index d79e432..0000000 --- a/WindowsFormsApp1/form/MES_URL.cs +++ /dev/null @@ -1,78 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; -using WindowsFormsApp1.db; -using WindowsFormsApp1.mod; - -namespace WindowsFormsApp1 -{ - public partial class MES_URL : Form - { - public MES_URL() - { - InitializeComponent(); - } - - private void MES_URL_Load(object sender, EventArgs e) - { - dataGridView1.AutoGenerateColumns = false; - GetInfo(); - } - - private void 保存_Click(object sender, EventArgs e) - { - try - { - SQLiteHelper sQLiteHelper = new db.SQLiteHelper(); - var result = sQLiteHelper.UpdateAll((List)dataGridView1.DataSource); - if (result.Success) - { - MessageBox.Show("更新成功"); - GetInfo(); - } - else - { - MessageBox.Show("更新失败"); - } - } - catch (Exception ex) - { - MessageBox.Show($"更新失败,错误原因{ex.Message}"); - } - } - - private void 关闭_Click(object sender, EventArgs e) - { - this.Close(); - } - - private void 查询_Click(object sender, EventArgs e) - { - GetInfo(); - } - - public void GetInfo() - { - try - { - SQLiteHelper sQLiteHelper = new db.SQLiteHelper(); - var result = sQLiteHelper.QueryAll(); - if (result.Success) - { - dataGridView1.DataSource = null; - dataGridView1.DataSource = result.Data; - dataGridView1.Refresh(); - } - } - catch (Exception ex) - { - } - } - } -} diff --git a/WindowsFormsApp1/form/PLCADDRESS_Manage.Designer.cs b/WindowsFormsApp1/form/PLCADDRESS_Manage.Designer.cs index 1665e6e..df64993 100644 --- a/WindowsFormsApp1/form/PLCADDRESS_Manage.Designer.cs +++ b/WindowsFormsApp1/form/PLCADDRESS_Manage.Designer.cs @@ -1,6 +1,6 @@ namespace WindowsFormsApp1.form { - partial class PLCADDRESS_Manage + partial class PlcAddress_Manage { /// /// Required designer variable. @@ -32,14 +32,15 @@ System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); this.关闭 = new System.Windows.Forms.Button(); - this.保存 = new System.Windows.Forms.Button(); this.查询 = new System.Windows.Forms.Button(); this.dataGridView1 = new System.Windows.Forms.DataGridView(); this.label1 = new System.Windows.Forms.Label(); this.comboBox1 = new System.Windows.Forms.ComboBox(); this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.button1 = new System.Windows.Forms.Button(); this.id = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.plcid = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.plcname = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.code = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.type = new System.Windows.Forms.DataGridViewComboBoxColumn(); this.dbaddress = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.addressoffset = new System.Windows.Forms.DataGridViewTextBoxColumn(); @@ -54,7 +55,7 @@ // this.关闭.Anchor = System.Windows.Forms.AnchorStyles.None; this.关闭.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.关闭.Location = new System.Drawing.Point(1642, 695); + this.关闭.Location = new System.Drawing.Point(1642, 696); this.关闭.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); this.关闭.Name = "关闭"; this.关闭.Size = new System.Drawing.Size(169, 72); @@ -63,24 +64,11 @@ this.关闭.UseVisualStyleBackColor = true; this.关闭.Click += new System.EventHandler(this.关闭_Click); // - // 保存 - // - this.保存.Anchor = System.Windows.Forms.AnchorStyles.None; - this.保存.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.保存.Location = new System.Drawing.Point(1642, 532); - this.保存.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); - this.保存.Name = "保存"; - this.保存.Size = new System.Drawing.Size(169, 72); - this.保存.TabIndex = 10; - this.保存.Text = "保存"; - this.保存.UseVisualStyleBackColor = true; - this.保存.Click += new System.EventHandler(this.保存_Click); - // // 查询 // this.查询.Anchor = System.Windows.Forms.AnchorStyles.None; this.查询.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.查询.Location = new System.Drawing.Point(1642, 45); + this.查询.Location = new System.Drawing.Point(1642, 25); this.查询.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); this.查询.Name = "查询"; this.查询.Size = new System.Drawing.Size(169, 72); @@ -109,7 +97,8 @@ this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.id, - this.plcid, + this.plcname, + this.code, this.type, this.dbaddress, this.addressoffset, @@ -125,13 +114,14 @@ dataGridViewCellStyle3.SelectionForeColor = System.Drawing.SystemColors.HighlightText; dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.False; this.dataGridView1.DefaultCellStyle = dataGridViewCellStyle3; - this.dataGridView1.Location = new System.Drawing.Point(6, 167); + this.dataGridView1.Location = new System.Drawing.Point(6, 127); this.dataGridView1.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); this.dataGridView1.Name = "dataGridView1"; + this.dataGridView1.ReadOnly = true; this.dataGridView1.RowHeadersWidth = 72; this.tableLayoutPanel1.SetRowSpan(this.dataGridView1, 3); this.dataGridView1.RowTemplate.Height = 23; - this.dataGridView1.Size = new System.Drawing.Size(1624, 642); + this.dataGridView1.Size = new System.Drawing.Size(1624, 682); this.dataGridView1.TabIndex = 8; // // label1 @@ -139,7 +129,7 @@ this.label1.Anchor = System.Windows.Forms.AnchorStyles.Left; this.label1.AutoSize = true; this.label1.Font = new System.Drawing.Font("宋体", 14.14286F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.label1.Location = new System.Drawing.Point(4, 47); + this.label1.Location = new System.Drawing.Point(4, 27); this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(253, 68); @@ -149,9 +139,10 @@ // comboBox1 // this.comboBox1.Anchor = System.Windows.Forms.AnchorStyles.Left; + this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.comboBox1.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.comboBox1.FormattingEnabled = true; - this.comboBox1.Location = new System.Drawing.Point(278, 60); + this.comboBox1.Location = new System.Drawing.Point(278, 40); this.comboBox1.Margin = new System.Windows.Forms.Padding(4); this.comboBox1.Name = "comboBox1"; this.comboBox1.Size = new System.Drawing.Size(409, 41); @@ -163,24 +154,37 @@ this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 15.07911F)); this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 74.9177F)); this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10.00319F)); + this.tableLayoutPanel1.Controls.Add(this.button1, 2, 2); this.tableLayoutPanel1.Controls.Add(this.comboBox1, 1, 0); this.tableLayoutPanel1.Controls.Add(this.dataGridView1, 0, 1); this.tableLayoutPanel1.Controls.Add(this.关闭, 2, 3); this.tableLayoutPanel1.Controls.Add(this.label1, 0, 0); - this.tableLayoutPanel1.Controls.Add(this.保存, 2, 2); this.tableLayoutPanel1.Controls.Add(this.查询, 2, 0); this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); this.tableLayoutPanel1.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); this.tableLayoutPanel1.Name = "tableLayoutPanel1"; this.tableLayoutPanel1.RowCount = 4; - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 40F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 15F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 45F)); this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); this.tableLayoutPanel1.Size = new System.Drawing.Size(1818, 814); this.tableLayoutPanel1.TabIndex = 14; // + // button1 + // + this.button1.Anchor = System.Windows.Forms.AnchorStyles.None; + this.button1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.button1.Location = new System.Drawing.Point(1650, 541); + this.button1.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(153, 56); + this.button1.TabIndex = 15; + this.button1.Text = "新增"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // // id // this.id.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; @@ -190,14 +194,23 @@ this.id.Name = "id"; this.id.ReadOnly = true; // - // plcid + // plcname // - this.plcid.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; - this.plcid.DataPropertyName = "plcid"; - this.plcid.HeaderText = "所属PLC"; - this.plcid.MinimumWidth = 9; - this.plcid.Name = "plcid"; - this.plcid.ReadOnly = true; + this.plcname.DataPropertyName = "plcname"; + this.plcname.HeaderText = "PLC名称"; + this.plcname.MinimumWidth = 9; + this.plcname.Name = "plcname"; + this.plcname.ReadOnly = true; + this.plcname.Width = 175; + // + // code + // + this.code.DataPropertyName = "code"; + this.code.HeaderText = "数据名称"; + this.code.MinimumWidth = 9; + this.code.Name = "code"; + this.code.ReadOnly = true; + this.code.Width = 175; // // type // @@ -206,6 +219,7 @@ this.type.HeaderText = "读写类型"; this.type.MinimumWidth = 9; this.type.Name = "type"; + this.type.ReadOnly = true; this.type.Resizable = System.Windows.Forms.DataGridViewTriState.True; this.type.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic; // @@ -216,6 +230,7 @@ this.dbaddress.HeaderText = "DB块地址"; this.dbaddress.MinimumWidth = 9; this.dbaddress.Name = "dbaddress"; + this.dbaddress.ReadOnly = true; // // addressoffset // @@ -224,6 +239,7 @@ this.addressoffset.HeaderText = "DB地址"; this.addressoffset.MinimumWidth = 9; this.addressoffset.Name = "addressoffset"; + this.addressoffset.ReadOnly = true; // // addresstype // @@ -232,6 +248,7 @@ this.addresstype.HeaderText = "数据类型"; this.addresstype.MinimumWidth = 9; this.addresstype.Name = "addresstype"; + this.addresstype.ReadOnly = true; this.addresstype.Resizable = System.Windows.Forms.DataGridViewTriState.True; this.addresstype.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic; // @@ -242,6 +259,7 @@ this.addresstypelegth.HeaderText = "字节长度"; this.addresstypelegth.MinimumWidth = 9; this.addresstypelegth.Name = "addresstypelegth"; + this.addresstypelegth.ReadOnly = true; // // remark // @@ -252,7 +270,7 @@ this.remark.Name = "remark"; this.remark.ReadOnly = true; // - // PLCADDRESS_Manage + // PlcAddress_Manage // this.AutoScaleDimensions = new System.Drawing.SizeF(11F, 21F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; @@ -260,9 +278,10 @@ this.Controls.Add(this.tableLayoutPanel1); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.Margin = new System.Windows.Forms.Padding(4); - this.Name = "PLCADDRESS_Manage"; + this.Name = "PlcAddress_Manage"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "PLCADDRESS_Manage"; + this.WindowState = System.Windows.Forms.FormWindowState.Maximized; this.Load += new System.EventHandler(this.PLCADDRESS_Manage_Load); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); this.tableLayoutPanel1.ResumeLayout(false); @@ -274,14 +293,15 @@ #endregion private System.Windows.Forms.Button 关闭; - private System.Windows.Forms.Button 保存; private System.Windows.Forms.Button 查询; private System.Windows.Forms.DataGridView dataGridView1; private System.Windows.Forms.Label label1; private System.Windows.Forms.ComboBox comboBox1; private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + private System.Windows.Forms.Button button1; private System.Windows.Forms.DataGridViewTextBoxColumn id; - private System.Windows.Forms.DataGridViewTextBoxColumn plcid; + private System.Windows.Forms.DataGridViewTextBoxColumn plcname; + private System.Windows.Forms.DataGridViewTextBoxColumn code; private System.Windows.Forms.DataGridViewComboBoxColumn type; private System.Windows.Forms.DataGridViewTextBoxColumn dbaddress; private System.Windows.Forms.DataGridViewTextBoxColumn addressoffset; diff --git a/WindowsFormsApp1/form/PLCADDRESS_Manage.cs b/WindowsFormsApp1/form/PLCADDRESS_Manage.cs index 26c3a84..20c997b 100644 --- a/WindowsFormsApp1/form/PLCADDRESS_Manage.cs +++ b/WindowsFormsApp1/form/PLCADDRESS_Manage.cs @@ -12,9 +12,9 @@ using WindowsFormsApp1.mod; namespace WindowsFormsApp1.form { - public partial class PLCADDRESS_Manage : Form + public partial class PlcAddress_Manage : Form { - public PLCADDRESS_Manage() + public PlcAddress_Manage() { InitializeComponent(); } @@ -55,16 +55,18 @@ namespace WindowsFormsApp1.form { dataGridView1.AutoGenerateColumns = false; SQLiteHelper sQLiteHelper1 = new db.SQLiteHelper(); - var result_combox = sQLiteHelper1.Query(a => a.id == Init.t_Line.plcid1 || a.id == Init.t_Line.plcid2); + var result_combox = sQLiteHelper1.QueryAll(); if (!result_combox.Success) { MessageBox.Show("查询失败"); return; } + var list = result_combox.Data.FindAll(a => Init.t_Lineplcs.Select(p => p.plcid).Contains(a.id)); + // 绑定数据源到 ComboBox - comboBox1.DataSource = result_combox.Data; - comboBox1.DisplayMember = "name"; + comboBox1.DataSource = list; + comboBox1.DisplayMember = "plcname"; comboBox1.ValueMember = "id"; var result1 = new List @@ -80,7 +82,7 @@ namespace WindowsFormsApp1.form new {name = "uint",value = "uint"}, }; - var comboBoxColumn = (DataGridViewComboBoxColumn)dataGridView1.Columns[2]; + var comboBoxColumn = (DataGridViewComboBoxColumn)dataGridView1.Columns[3]; // 绑定数据源到 ComboBox comboBoxColumn.DataSource = result1; comboBoxColumn.DisplayMember = "name"; @@ -88,26 +90,107 @@ namespace WindowsFormsApp1.form comboBoxColumn.DataPropertyName = "type"; - var comboBoxColumn1 = (DataGridViewComboBoxColumn)dataGridView1.Columns[5]; + var comboBoxColumn1 = (DataGridViewComboBoxColumn)dataGridView1.Columns[6]; // 绑定数据源到 ComboBox comboBoxColumn1.DataSource = result2; comboBoxColumn1.DisplayMember = "name"; comboBoxColumn1.ValueMember = "value"; - comboBoxColumn1.DataPropertyName = "addresstype"; + comboBoxColumn1.DataPropertyName = "addresstype"; + + DataGridViewButtonColumn modifyColumn = new DataGridViewButtonColumn(); + modifyColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + modifyColumn.Name = "ModifyColumn"; + modifyColumn.HeaderText = "修改"; + modifyColumn.Text = "修改"; + modifyColumn.UseColumnTextForButtonValue = true; + dataGridView1.Columns.Add(modifyColumn); + + // 添加删除按钮列 + DataGridViewButtonColumn deleteColumn = new DataGridViewButtonColumn(); + deleteColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + deleteColumn.Name = "DeleteColumn"; + deleteColumn.HeaderText = "删除"; + deleteColumn.Text = "删除"; + deleteColumn.UseColumnTextForButtonValue = true; + + dataGridView1.CellContentClick += DataGridView1_CellContentClick; + + dataGridView1.Columns.Add(deleteColumn); } + private void DataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) + { + // 检查点击的是否为按钮列 + if (e.RowIndex >= 0) + { + DataGridView dataGridView = (DataGridView)sender; + DataGridViewRow row = dataGridView.Rows[e.RowIndex]; + int selectid = int.Parse(row.Cells[0].Value.ToString()); + if (e.ColumnIndex == 9) + { + PlcAddress_Insert fLOW_Insert = new PlcAddress_Insert(); + fLOW_Insert.dataid = selectid; + fLOW_Insert.Operation = OperationType.Edit; + fLOW_Insert.ShowDialog(); + GetInfo((int)comboBox1.SelectedValue); + + } + else if (e.ColumnIndex == 10) + { + DialogResult result = MessageBox.Show("你确定要删除数据吗?", "确认提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); + + if (result == DialogResult.OK) + { + SQLiteHelper sQLiteHelper = new db.SQLiteHelper(); + var delresult = sQLiteHelper.Delete(selectid); + if (delresult.Success) + { + MessageBox.Show("删除成功"); + } + else + { + MessageBox.Show("删除失败"); + } + GetInfo((int)comboBox1.SelectedValue); + } + } + } + } public void GetInfo(int plcid) { try { + dataGridView1.DataSource = null; SQLiteHelper sQLiteHelper = new db.SQLiteHelper(); + SQLiteHelper sQLiteHelper1 = new db.SQLiteHelper(); + var result_plc = sQLiteHelper1.QueryAll(); var result = sQLiteHelper.Query(a=>a.plcid == plcid); if (result.Success) { - dataGridView1.DataSource = null; - dataGridView1.DataSource = result.Data; + List list = new List(); + foreach (var plcaddress in result.Data) + { + var plc = result_plc.Data.FirstOrDefault(a => a.id == plcaddress.plcid); + list.Add(new + { + id = plcaddress.id, + plcid = plcaddress.plcid, + code = plcaddress.code, + type = plcaddress.type, + dbaddress = plcaddress.dbaddress, + addresstype = plcaddress.addresstype, + addresstypelegth = plcaddress.addresstypelegth, + addressoffset = plcaddress.addressoffset, + remark = plcaddress.remark, + value = plcaddress.value, + plcname = plc.plcname, + + + }); + } + dataGridView1.DataSource = list; dataGridView1.Refresh(); } } @@ -115,5 +198,12 @@ namespace WindowsFormsApp1.form { } } + + private void button1_Click(object sender, EventArgs e) + { + PlcAddress_Insert fLOW_Insert = new PlcAddress_Insert(); + fLOW_Insert.ShowDialog(); + GetInfo((int)comboBox1.SelectedValue); + } } } diff --git a/WindowsFormsApp1/form/PLCADDRESS_Manage.resx b/WindowsFormsApp1/form/PLCADDRESS_Manage.resx index 480aacc..7f316a3 100644 --- a/WindowsFormsApp1/form/PLCADDRESS_Manage.resx +++ b/WindowsFormsApp1/form/PLCADDRESS_Manage.resx @@ -120,7 +120,10 @@ True - + + True + + True diff --git a/WindowsFormsApp1/form/PLC_Manage.Designer.cs b/WindowsFormsApp1/form/PLC_Manage.Designer.cs index 427d491..0d27122 100644 --- a/WindowsFormsApp1/form/PLC_Manage.Designer.cs +++ b/WindowsFormsApp1/form/PLC_Manage.Designer.cs @@ -1,6 +1,6 @@ namespace WindowsFormsApp1.form { - partial class PLC_Manage + partial class Plc_Manage { /// /// Required designer variable. @@ -32,13 +32,16 @@ System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); this.关闭 = new System.Windows.Forms.Button(); - this.保存 = new System.Windows.Forms.Button(); this.查询 = new System.Windows.Forms.Button(); this.dataGridView1 = new System.Windows.Forms.DataGridView(); this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.button1 = new System.Windows.Forms.Button(); this.id = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.plcname = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.plcip = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.timeout = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.statues = new System.Windows.Forms.DataGridViewCheckBoxColumn(); + this.alarm = new System.Windows.Forms.DataGridViewCheckBoxColumn(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); this.tableLayoutPanel1.SuspendLayout(); this.SuspendLayout(); @@ -56,19 +59,6 @@ this.关闭.UseVisualStyleBackColor = true; this.关闭.Click += new System.EventHandler(this.关闭_Click); // - // 保存 - // - this.保存.Anchor = System.Windows.Forms.AnchorStyles.None; - this.保存.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.保存.Location = new System.Drawing.Point(1380, 517); - this.保存.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); - this.保存.Name = "保存"; - this.保存.Size = new System.Drawing.Size(141, 72); - this.保存.TabIndex = 6; - this.保存.Text = "保存"; - this.保存.UseVisualStyleBackColor = true; - this.保存.Click += new System.EventHandler(this.保存_Click); - // // 查询 // this.查询.Anchor = System.Windows.Forms.AnchorStyles.None; @@ -102,8 +92,11 @@ this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.id, + this.plcname, this.plcip, - this.timeout}); + this.timeout, + this.statues, + this.alarm}); dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Window; dataGridViewCellStyle3.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); @@ -115,6 +108,7 @@ this.dataGridView1.Location = new System.Drawing.Point(6, 5); this.dataGridView1.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); this.dataGridView1.Name = "dataGridView1"; + this.dataGridView1.ReadOnly = true; this.dataGridView1.RowHeadersWidth = 72; this.tableLayoutPanel1.SetRowSpan(this.dataGridView1, 4); this.dataGridView1.RowTemplate.Height = 23; @@ -126,9 +120,9 @@ this.tableLayoutPanel1.ColumnCount = 2; this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 90F)); this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.Controls.Add(this.button1, 1, 2); this.tableLayoutPanel1.Controls.Add(this.关闭, 1, 3); this.tableLayoutPanel1.Controls.Add(this.dataGridView1, 0, 0); - this.tableLayoutPanel1.Controls.Add(this.保存, 1, 2); this.tableLayoutPanel1.Controls.Add(this.查询, 1, 0); this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); @@ -142,6 +136,19 @@ this.tableLayoutPanel1.Size = new System.Drawing.Size(1527, 790); this.tableLayoutPanel1.TabIndex = 8; // + // button1 + // + this.button1.Anchor = System.Windows.Forms.AnchorStyles.None; + this.button1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.button1.Location = new System.Drawing.Point(1380, 525); + this.button1.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(141, 56); + this.button1.TabIndex = 9; + this.button1.Text = "新增"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // // id // this.id.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; @@ -151,6 +158,15 @@ this.id.Name = "id"; this.id.ReadOnly = true; // + // plcname + // + this.plcname.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.plcname.DataPropertyName = "plcname"; + this.plcname.HeaderText = "PLC名称"; + this.plcname.MinimumWidth = 9; + this.plcname.Name = "plcname"; + this.plcname.ReadOnly = true; + // // plcip // this.plcip.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; @@ -158,6 +174,7 @@ this.plcip.HeaderText = "IP地址"; this.plcip.MinimumWidth = 9; this.plcip.Name = "plcip"; + this.plcip.ReadOnly = true; // // timeout // @@ -166,20 +183,44 @@ this.timeout.HeaderText = "超时时间"; this.timeout.MinimumWidth = 9; this.timeout.Name = "timeout"; + this.timeout.ReadOnly = true; this.timeout.Resizable = System.Windows.Forms.DataGridViewTriState.True; this.timeout.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; // - // PLC_Manage + // statues + // + this.statues.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.statues.DataPropertyName = "statues"; + this.statues.HeaderText = "是否上传状态"; + this.statues.MinimumWidth = 9; + this.statues.Name = "statues"; + this.statues.ReadOnly = true; + this.statues.Resizable = System.Windows.Forms.DataGridViewTriState.True; + this.statues.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic; + // + // alarm + // + this.alarm.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.alarm.DataPropertyName = "alarm"; + this.alarm.HeaderText = "是否上传报警"; + this.alarm.MinimumWidth = 9; + this.alarm.Name = "alarm"; + this.alarm.ReadOnly = true; + this.alarm.Resizable = System.Windows.Forms.DataGridViewTriState.True; + this.alarm.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic; + // + // Plc_Manage // this.AutoScaleDimensions = new System.Drawing.SizeF(11F, 21F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(1527, 790); this.Controls.Add(this.tableLayoutPanel1); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; - this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); - this.Name = "PLC_Manage"; + this.Margin = new System.Windows.Forms.Padding(4); + this.Name = "Plc_Manage"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "PLC_Manage"; + this.WindowState = System.Windows.Forms.FormWindowState.Maximized; this.Load += new System.EventHandler(this.PLC_Manage_Load); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); this.tableLayoutPanel1.ResumeLayout(false); @@ -190,12 +231,15 @@ #endregion private System.Windows.Forms.Button 关闭; - private System.Windows.Forms.Button 保存; private System.Windows.Forms.Button 查询; private System.Windows.Forms.DataGridView dataGridView1; private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + private System.Windows.Forms.Button button1; private System.Windows.Forms.DataGridViewTextBoxColumn id; + private System.Windows.Forms.DataGridViewTextBoxColumn plcname; private System.Windows.Forms.DataGridViewTextBoxColumn plcip; private System.Windows.Forms.DataGridViewTextBoxColumn timeout; + private System.Windows.Forms.DataGridViewCheckBoxColumn statues; + private System.Windows.Forms.DataGridViewCheckBoxColumn alarm; } } \ No newline at end of file diff --git a/WindowsFormsApp1/form/PLC_Manage.cs b/WindowsFormsApp1/form/PLC_Manage.cs index 795d8ff..af97e9f 100644 --- a/WindowsFormsApp1/form/PLC_Manage.cs +++ b/WindowsFormsApp1/form/PLC_Manage.cs @@ -12,9 +12,9 @@ using WindowsFormsApp1.mod; namespace WindowsFormsApp1.form { - public partial class PLC_Manage : Form + public partial class Plc_Manage : Form { - public PLC_Manage() + public Plc_Manage() { InitializeComponent(); } @@ -54,19 +54,77 @@ namespace WindowsFormsApp1.form private void PLC_Manage_Load(object sender, EventArgs e) { dataGridView1.AutoGenerateColumns = false; + DataGridViewButtonColumn modifyColumn = new DataGridViewButtonColumn(); + modifyColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + modifyColumn.Name = "ModifyColumn"; + modifyColumn.HeaderText = "修改"; + modifyColumn.Text = "修改"; + modifyColumn.UseColumnTextForButtonValue = true; + dataGridView1.Columns.Add(modifyColumn); + + // 添加删除按钮列 + DataGridViewButtonColumn deleteColumn = new DataGridViewButtonColumn(); + deleteColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + deleteColumn.Name = "DeleteColumn"; + deleteColumn.HeaderText = "删除"; + deleteColumn.Text = "删除"; + deleteColumn.UseColumnTextForButtonValue = true; + dataGridView1.Columns.Add(deleteColumn); + dataGridView1.CellContentClick += DataGridView1_CellContentClick; + GetInfo(); } + private void DataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) + { + // 检查点击的是否为按钮列 + if (e.RowIndex >= 0) + { + DataGridView dataGridView = (DataGridView)sender; + DataGridViewRow row = dataGridView.Rows[e.RowIndex]; + int selectid = int.Parse(row.Cells[0].Value.ToString()); + if (e.ColumnIndex == 6) + { + Plc_Insert fLOW_Insert = new Plc_Insert(); + fLOW_Insert.dataid = selectid; + fLOW_Insert.Operation = OperationType.Edit; + fLOW_Insert.ShowDialog(); + GetInfo(); + + } + else if (e.ColumnIndex == 7) + { + DialogResult result = MessageBox.Show("你确定要删除数据吗?", "确认提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); + + if (result == DialogResult.OK) + { + SQLiteHelper sQLiteHelper = new db.SQLiteHelper(); + var delresult = sQLiteHelper.Delete(selectid); + if (delresult.Success) + { + MessageBox.Show("删除成功"); + } + else + { + MessageBox.Show("删除失败"); + } + GetInfo(); + } + } + } + } public void GetInfo() { try { SQLiteHelper sQLiteHelper = new db.SQLiteHelper(); - var result = sQLiteHelper.Query(a=> a.id == Init.t_Line.plcid1 || a.id == Init.t_Line.plcid2); + var result = sQLiteHelper.QueryAll(); if (result.Success) { + var list = result.Data.FindAll(a=>Init.t_Lineplcs.Select(p=>p.plcid).Contains(a.id)); + dataGridView1.DataSource = null; - dataGridView1.DataSource = result.Data; + dataGridView1.DataSource = list; dataGridView1.Refresh(); } } @@ -74,5 +132,12 @@ namespace WindowsFormsApp1.form { } } + + private void button1_Click(object sender, EventArgs e) + { + Plc_Insert fLOW_Insert = new Plc_Insert(); + fLOW_Insert.ShowDialog(); + GetInfo(); + } } } diff --git a/WindowsFormsApp1/form/PLC_Manage.resx b/WindowsFormsApp1/form/PLC_Manage.resx index b121660..b099188 100644 --- a/WindowsFormsApp1/form/PLC_Manage.resx +++ b/WindowsFormsApp1/form/PLC_Manage.resx @@ -120,10 +120,19 @@ True + + True + True True + + True + + + True + \ No newline at end of file diff --git a/WindowsFormsApp1/form/ScanForm.Designer.cs b/WindowsFormsApp1/form/ScanForm.Designer.cs new file mode 100644 index 0000000..7684244 --- /dev/null +++ b/WindowsFormsApp1/form/ScanForm.Designer.cs @@ -0,0 +1,165 @@ +namespace WindowsFormsApp1 +{ + partial class ScanForm + { + /// + /// 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.components = new System.ComponentModel.Container(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.请扫描条码 = new System.Windows.Forms.Label(); + this.LOt号 = new System.Windows.Forms.Label(); + this.确认 = new System.Windows.Forms.Button(); + this.取消 = new System.Windows.Forms.Button(); + this.timer1 = new System.Windows.Forms.Timer(this.components); + this.groupBox1.SuspendLayout(); + this.tableLayoutPanel1.SuspendLayout(); + this.SuspendLayout(); + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.tableLayoutPanel1); + this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill; + this.groupBox1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.groupBox1.Location = new System.Drawing.Point(0, 0); + this.groupBox1.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Padding = new System.Windows.Forms.Padding(6, 5, 6, 5); + this.groupBox1.Size = new System.Drawing.Size(1647, 704); + this.groupBox1.TabIndex = 5; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "用户扫码"; + // + // tableLayoutPanel1 + // + this.tableLayoutPanel1.ColumnCount = 5; + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 11.11111F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 11.11111F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 11.11111F)); + this.tableLayoutPanel1.Controls.Add(this.请扫描条码, 1, 1); + this.tableLayoutPanel1.Controls.Add(this.LOt号, 1, 2); + this.tableLayoutPanel1.Controls.Add(this.确认, 1, 4); + this.tableLayoutPanel1.Controls.Add(this.取消, 3, 4); + this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel1.Location = new System.Drawing.Point(6, 37); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + this.tableLayoutPanel1.RowCount = 6; + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 23F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 77F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 192F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 82F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 126F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 69F)); + this.tableLayoutPanel1.Size = new System.Drawing.Size(1635, 662); + this.tableLayoutPanel1.TabIndex = 0; + // + // 请扫描条码 + // + this.请扫描条码.Anchor = System.Windows.Forms.AnchorStyles.None; + this.请扫描条码.AutoSize = true; + this.tableLayoutPanel1.SetColumnSpan(this.请扫描条码, 3); + this.请扫描条码.Font = new System.Drawing.Font("宋体", 24F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.请扫描条码.ForeColor = System.Drawing.Color.Red; + this.请扫描条码.Location = new System.Drawing.Point(647, 90); + this.请扫描条码.Name = "请扫描条码"; + this.请扫描条码.Size = new System.Drawing.Size(338, 56); + this.请扫描条码.TabIndex = 0; + this.请扫描条码.Text = "请扫描条码:"; + // + // LOt号 + // + this.LOt号.Anchor = System.Windows.Forms.AnchorStyles.None; + this.LOt号.AutoSize = true; + this.tableLayoutPanel1.SetColumnSpan(this.LOt号, 3); + this.LOt号.Font = new System.Drawing.Font("宋体", 24F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.LOt号.Location = new System.Drawing.Point(544, 260); + this.LOt号.Name = "LOt号"; + this.LOt号.Size = new System.Drawing.Size(544, 56); + this.LOt号.TabIndex = 1; + this.LOt号.Text = "LOt号:12112312312"; + // + // 确认 + // + this.确认.Dock = System.Windows.Forms.DockStyle.Fill; + this.确认.Font = new System.Drawing.Font("宋体", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.确认.Location = new System.Drawing.Point(184, 469); + this.确认.Name = "确认"; + this.确认.Size = new System.Drawing.Size(539, 120); + this.确认.TabIndex = 2; + this.确认.Text = "确认"; + this.确认.UseVisualStyleBackColor = true; + this.确认.Click += new System.EventHandler(this.button1_Click); + // + // 取消 + // + this.取消.Dock = System.Windows.Forms.DockStyle.Fill; + this.取消.Font = new System.Drawing.Font("宋体", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.取消.Location = new System.Drawing.Point(910, 469); + this.取消.Name = "取消"; + this.取消.Size = new System.Drawing.Size(539, 120); + this.取消.TabIndex = 3; + this.取消.Text = "取消"; + this.取消.UseVisualStyleBackColor = true; + this.取消.Click += new System.EventHandler(this.button2_Click); + // + // timer1 + // + this.timer1.Enabled = true; + this.timer1.Interval = 800; + this.timer1.Tick += new System.EventHandler(this.timer1_Tick); + // + // ScanForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(11F, 21F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1647, 704); + this.Controls.Add(this.groupBox1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.Margin = new System.Windows.Forms.Padding(4); + this.Name = "ScanForm"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "扫码界面"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ScanForm_FormClosing); + this.groupBox1.ResumeLayout(false); + this.tableLayoutPanel1.ResumeLayout(false); + this.tableLayoutPanel1.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + private System.Windows.Forms.GroupBox groupBox1; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + private System.Windows.Forms.Label 请扫描条码; + private System.Windows.Forms.Label LOt号; + private System.Windows.Forms.Button 确认; + private System.Windows.Forms.Button 取消; + private System.Windows.Forms.Timer timer1; + } +} \ No newline at end of file diff --git a/WindowsFormsApp1/form/ScanForm.cs b/WindowsFormsApp1/form/ScanForm.cs new file mode 100644 index 0000000..e8a6694 --- /dev/null +++ b/WindowsFormsApp1/form/ScanForm.cs @@ -0,0 +1,95 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.IO.Ports; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using WindowsFormsApp1.db; +using WindowsFormsApp1.mod; +using WindowsFormsApp1.mod.database; +using WindowsFormsApp1.server; +using static System.Windows.Forms.VisualStyles.VisualStyleElement; + +namespace WindowsFormsApp1 +{ + public partial class ScanForm : Form + { + // 自定义属性,用于存储返回值 + public string ReturnValue { get; set; } + public ScanForm() + { + InitializeComponent(); + Init.ScanPort.DataReceived += SerialPort_DataReceived; + LOt号.Visible = false; + + } + private void button1_Click(object sender, EventArgs e) + { + if (string.IsNullOrWhiteSpace(ReturnValue)) + { + MessageBox.Show("扫码为空,请确认!"); + return; + } + this.DialogResult = DialogResult.OK; + this.Close(); + } + + private void button2_Click(object sender, EventArgs e) + { + this.DialogResult = DialogResult.Cancel; + this.Close(); + } + + private void timer1_Tick(object sender, EventArgs e) + { + if (请扫描条码.ForeColor == Color.Red) + { + 请扫描条码.ForeColor = Color.RosyBrown; + } + else + { + 请扫描条码.ForeColor = Color.Red; + } + } + + public void SerialPort_DataReceived(object sender, SerialDataReceivedEventArgs e) + { + try + { + if (!Init.ScanPort.IsOpen) + { + Init.ScanPort?.Open(); + } + // 读取串口接收到的数据 + ReturnValue = Init.ScanPort.ReadExisting(); + if (this.InvokeRequired) + { + this.Invoke(new Action(() => + { + LOt号.Text = ReturnValue; + LOt号.Visible = true; + })); + } + else + { + LOt号.Text = ReturnValue; + LOt号.Visible = true; + } + } + catch (Exception ex) + { + MessageBox.Show($"读取数据时出错: {ex.Message}"); + } + } + + private void ScanForm_FormClosing(object sender, FormClosingEventArgs e) + { + FormHelp.RemoveAllEventHandlers(Init.ScanPort, "DataReceived"); + } + } +} diff --git a/WindowsFormsApp1/form/ScanForm.resx b/WindowsFormsApp1/form/ScanForm.resx new file mode 100644 index 0000000..1f666f2 --- /dev/null +++ b/WindowsFormsApp1/form/ScanForm.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + 17, 17 + + \ No newline at end of file diff --git a/WindowsFormsApp1/form/SerialPort_Manage.Designer.cs b/WindowsFormsApp1/form/SerialPort_Manage.Designer.cs index 00aca2a..9a091d2 100644 --- a/WindowsFormsApp1/form/SerialPort_Manage.Designer.cs +++ b/WindowsFormsApp1/form/SerialPort_Manage.Designer.cs @@ -31,36 +31,23 @@ System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); - this.保存 = new System.Windows.Forms.Button(); this.查询 = new System.Windows.Forms.Button(); this.dataGridView1 = new System.Windows.Forms.DataGridView(); this.关闭 = new System.Windows.Forms.Button(); this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.button1 = new System.Windows.Forms.Button(); this.id = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.name = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.portName = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.baudRate = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.parity = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.dataBits = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.enable = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.enable = new System.Windows.Forms.DataGridViewCheckBoxColumn(); this.reamrk = new System.Windows.Forms.DataGridViewTextBoxColumn(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); this.tableLayoutPanel1.SuspendLayout(); this.SuspendLayout(); // - // 保存 - // - this.保存.Anchor = System.Windows.Forms.AnchorStyles.None; - this.保存.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.保存.Location = new System.Drawing.Point(1488, 528); - this.保存.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); - this.保存.Name = "保存"; - this.保存.Size = new System.Drawing.Size(153, 56); - this.保存.TabIndex = 1; - this.保存.Text = "保存"; - this.保存.UseVisualStyleBackColor = true; - this.保存.Click += new System.EventHandler(this.保存_Click); - // // 查询 // this.查询.Anchor = System.Windows.Forms.AnchorStyles.None; @@ -110,6 +97,7 @@ this.dataGridView1.Location = new System.Drawing.Point(6, 5); this.dataGridView1.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); this.dataGridView1.Name = "dataGridView1"; + this.dataGridView1.ReadOnly = true; this.dataGridView1.RowHeadersWidth = 72; this.tableLayoutPanel1.SetRowSpan(this.dataGridView1, 4); this.dataGridView1.RowTemplate.Height = 23; @@ -134,10 +122,10 @@ this.tableLayoutPanel1.ColumnCount = 2; this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 90F)); this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.Controls.Add(this.button1, 1, 2); this.tableLayoutPanel1.Controls.Add(this.dataGridView1, 0, 0); this.tableLayoutPanel1.Controls.Add(this.查询, 1, 0); this.tableLayoutPanel1.Controls.Add(this.关闭, 1, 3); - this.tableLayoutPanel1.Controls.Add(this.保存, 1, 2); this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); this.tableLayoutPanel1.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); @@ -150,6 +138,19 @@ this.tableLayoutPanel1.Size = new System.Drawing.Size(1647, 795); this.tableLayoutPanel1.TabIndex = 4; // + // button1 + // + this.button1.Anchor = System.Windows.Forms.AnchorStyles.None; + this.button1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.button1.Location = new System.Drawing.Point(1488, 528); + this.button1.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(153, 56); + this.button1.TabIndex = 5; + this.button1.Text = "新增"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // // id // this.id.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; @@ -175,6 +176,7 @@ this.portName.HeaderText = "COM口"; this.portName.MinimumWidth = 9; this.portName.Name = "portName"; + this.portName.ReadOnly = true; // // baudRate // @@ -183,6 +185,7 @@ this.baudRate.HeaderText = "波特率"; this.baudRate.MinimumWidth = 9; this.baudRate.Name = "baudRate"; + this.baudRate.ReadOnly = true; // // parity // @@ -191,6 +194,7 @@ this.parity.HeaderText = "奇偶校验位"; this.parity.MinimumWidth = 9; this.parity.Name = "parity"; + this.parity.ReadOnly = true; // // dataBits // @@ -199,6 +203,7 @@ this.dataBits.HeaderText = "数据位"; this.dataBits.MinimumWidth = 9; this.dataBits.Name = "dataBits"; + this.dataBits.ReadOnly = true; // // enable // @@ -207,7 +212,9 @@ this.enable.HeaderText = "是否启用"; this.enable.MinimumWidth = 9; this.enable.Name = "enable"; + this.enable.ReadOnly = true; this.enable.Resizable = System.Windows.Forms.DataGridViewTriState.True; + this.enable.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic; // // reamrk // @@ -229,6 +236,7 @@ this.Name = "SerialPort_Manage"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "SerialPort_Manage"; + this.WindowState = System.Windows.Forms.FormWindowState.Maximized; this.Load += new System.EventHandler(this.MES_URL_Load); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); this.tableLayoutPanel1.ResumeLayout(false); @@ -237,18 +245,18 @@ } #endregion - private System.Windows.Forms.Button 保存; private System.Windows.Forms.Button 查询; private System.Windows.Forms.DataGridView dataGridView1; private System.Windows.Forms.Button 关闭; private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + private System.Windows.Forms.Button button1; private System.Windows.Forms.DataGridViewTextBoxColumn id; private System.Windows.Forms.DataGridViewTextBoxColumn name; private System.Windows.Forms.DataGridViewTextBoxColumn portName; private System.Windows.Forms.DataGridViewTextBoxColumn baudRate; private System.Windows.Forms.DataGridViewTextBoxColumn parity; private System.Windows.Forms.DataGridViewTextBoxColumn dataBits; - private System.Windows.Forms.DataGridViewTextBoxColumn enable; + private System.Windows.Forms.DataGridViewCheckBoxColumn enable; private System.Windows.Forms.DataGridViewTextBoxColumn reamrk; } } \ No newline at end of file diff --git a/WindowsFormsApp1/form/SerialPort_Manage.cs b/WindowsFormsApp1/form/SerialPort_Manage.cs index a80396e..57a0393 100644 --- a/WindowsFormsApp1/form/SerialPort_Manage.cs +++ b/WindowsFormsApp1/form/SerialPort_Manage.cs @@ -8,6 +8,7 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using WindowsFormsApp1.db; +using WindowsFormsApp1.form; using WindowsFormsApp1.mod; using WindowsFormsApp1.mod.database; @@ -23,9 +24,65 @@ namespace WindowsFormsApp1 private void MES_URL_Load(object sender, EventArgs e) { dataGridView1.AutoGenerateColumns = false; + DataGridViewButtonColumn modifyColumn = new DataGridViewButtonColumn(); + modifyColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + modifyColumn.Name = "ModifyColumn"; + modifyColumn.HeaderText = "修改"; + modifyColumn.Text = "修改"; + modifyColumn.UseColumnTextForButtonValue = true; + dataGridView1.Columns.Add(modifyColumn); + + // 添加删除按钮列 + DataGridViewButtonColumn deleteColumn = new DataGridViewButtonColumn(); + deleteColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + deleteColumn.Name = "DeleteColumn"; + deleteColumn.HeaderText = "删除"; + deleteColumn.Text = "删除"; + deleteColumn.UseColumnTextForButtonValue = true; + dataGridView1.Columns.Add(deleteColumn); + + dataGridView1.CellContentClick += DataGridView1_CellContentClick; GetInfo(); } + private void DataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) + { + // 检查点击的是否为按钮列 + if (e.RowIndex >= 0) + { + DataGridView dataGridView = (DataGridView)sender; + DataGridViewRow row = dataGridView.Rows[e.RowIndex]; + int selectid = int.Parse(row.Cells[0].Value.ToString()); + if (e.ColumnIndex == 8) + { + SerialPort_Insert fLOW_Insert = new SerialPort_Insert(); + fLOW_Insert.dataid = selectid; + fLOW_Insert.Operation = OperationType.Edit; + fLOW_Insert.ShowDialog(); + GetInfo(); + + } + else if (e.ColumnIndex == 9) + { + DialogResult result = MessageBox.Show("你确定要删除数据吗?", "确认提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); + + if (result == DialogResult.OK) + { + SQLiteHelper sQLiteHelper = new db.SQLiteHelper(); + var delresult = sQLiteHelper.Delete(selectid); + if (delresult.Success) + { + MessageBox.Show("删除成功"); + } + else + { + MessageBox.Show("删除失败"); + } + GetInfo(); + } + } + } + } private void 保存_Click(object sender, EventArgs e) { try @@ -75,5 +132,12 @@ namespace WindowsFormsApp1 { } } + + private void button1_Click(object sender, EventArgs e) + { + SerialPort_Insert fLOW_Insert = new SerialPort_Insert(); + fLOW_Insert.ShowDialog(); + GetInfo(); + } } } diff --git a/WindowsFormsApp1/form/Torqueaddress_Manage.Designer.cs b/WindowsFormsApp1/form/Torqueaddress_Manage.Designer.cs new file mode 100644 index 0000000..70dbc52 --- /dev/null +++ b/WindowsFormsApp1/form/Torqueaddress_Manage.Designer.cs @@ -0,0 +1,312 @@ +namespace WindowsFormsApp1.form +{ + partial class Torqueaddress_Manage + { + /// + /// 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() + { + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); + this.关闭 = new System.Windows.Forms.Button(); + this.查询 = new System.Windows.Forms.Button(); + this.dataGridView1 = new System.Windows.Forms.DataGridView(); + this.label1 = new System.Windows.Forms.Label(); + this.comboBox1 = new System.Windows.Forms.ComboBox(); + this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.button1 = new System.Windows.Forms.Button(); + this.id = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.plcname = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.code = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.type = new System.Windows.Forms.DataGridViewComboBoxColumn(); + this.dbaddress = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.addressoffset = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.addresstype = new System.Windows.Forms.DataGridViewComboBoxColumn(); + this.addresstypelegth = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.remark = new System.Windows.Forms.DataGridViewTextBoxColumn(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); + this.tableLayoutPanel1.SuspendLayout(); + this.SuspendLayout(); + // + // 关闭 + // + this.关闭.Anchor = System.Windows.Forms.AnchorStyles.None; + this.关闭.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.关闭.Location = new System.Drawing.Point(1642, 696); + this.关闭.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); + this.关闭.Name = "关闭"; + this.关闭.Size = new System.Drawing.Size(169, 72); + this.关闭.TabIndex = 11; + this.关闭.Text = "关闭"; + this.关闭.UseVisualStyleBackColor = true; + this.关闭.Click += new System.EventHandler(this.关闭_Click); + // + // 查询 + // + this.查询.Anchor = System.Windows.Forms.AnchorStyles.None; + this.查询.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.查询.Location = new System.Drawing.Point(1642, 25); + this.查询.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); + this.查询.Name = "查询"; + this.查询.Size = new System.Drawing.Size(169, 72); + this.查询.TabIndex = 9; + this.查询.Text = "查询"; + this.查询.UseVisualStyleBackColor = true; + this.查询.Click += new System.EventHandler(this.查询_Click); + // + // dataGridView1 + // + this.dataGridView1.AllowUserToAddRows = false; + this.dataGridView1.AllowUserToDeleteRows = false; + dataGridViewCellStyle1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.dataGridView1.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; + this.dataGridView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle2.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle2; + this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.id, + this.plcname, + this.code, + this.type, + this.dbaddress, + this.addressoffset, + this.addresstype, + this.addresstypelegth, + this.remark}); + this.tableLayoutPanel1.SetColumnSpan(this.dataGridView1, 2); + dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Window; + dataGridViewCellStyle3.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle3.ForeColor = System.Drawing.SystemColors.ControlText; + dataGridViewCellStyle3.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle3.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.False; + this.dataGridView1.DefaultCellStyle = dataGridViewCellStyle3; + this.dataGridView1.Location = new System.Drawing.Point(6, 127); + this.dataGridView1.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); + this.dataGridView1.Name = "dataGridView1"; + this.dataGridView1.ReadOnly = true; + this.dataGridView1.RowHeadersWidth = 72; + this.tableLayoutPanel1.SetRowSpan(this.dataGridView1, 3); + this.dataGridView1.RowTemplate.Height = 23; + this.dataGridView1.Size = new System.Drawing.Size(1624, 682); + this.dataGridView1.TabIndex = 8; + // + // label1 + // + this.label1.Anchor = System.Windows.Forms.AnchorStyles.Left; + this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("宋体", 14.14286F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label1.Location = new System.Drawing.Point(4, 27); + this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(253, 68); + this.label1.TabIndex = 12; + this.label1.Text = "选择需要编辑的PLC编号:"; + // + // comboBox1 + // + this.comboBox1.Anchor = System.Windows.Forms.AnchorStyles.Left; + this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBox1.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.comboBox1.FormattingEnabled = true; + this.comboBox1.Location = new System.Drawing.Point(278, 40); + this.comboBox1.Margin = new System.Windows.Forms.Padding(4); + this.comboBox1.Name = "comboBox1"; + this.comboBox1.Size = new System.Drawing.Size(409, 41); + this.comboBox1.TabIndex = 13; + // + // tableLayoutPanel1 + // + this.tableLayoutPanel1.ColumnCount = 3; + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 15.07911F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 74.9177F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10.00319F)); + this.tableLayoutPanel1.Controls.Add(this.button1, 2, 2); + this.tableLayoutPanel1.Controls.Add(this.comboBox1, 1, 0); + this.tableLayoutPanel1.Controls.Add(this.dataGridView1, 0, 1); + this.tableLayoutPanel1.Controls.Add(this.关闭, 2, 3); + this.tableLayoutPanel1.Controls.Add(this.label1, 0, 0); + this.tableLayoutPanel1.Controls.Add(this.查询, 2, 0); + this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanel1.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + this.tableLayoutPanel1.RowCount = 4; + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 15F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 45F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.Size = new System.Drawing.Size(1818, 814); + this.tableLayoutPanel1.TabIndex = 14; + // + // button1 + // + this.button1.Anchor = System.Windows.Forms.AnchorStyles.None; + this.button1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.button1.Location = new System.Drawing.Point(1650, 541); + this.button1.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(153, 56); + this.button1.TabIndex = 15; + this.button1.Text = "新增"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // id + // + this.id.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.id.DataPropertyName = "id"; + this.id.HeaderText = "序号"; + this.id.MinimumWidth = 9; + this.id.Name = "id"; + this.id.ReadOnly = true; + // + // plcname + // + this.plcname.DataPropertyName = "plcname"; + this.plcname.HeaderText = "PLC名称"; + this.plcname.MinimumWidth = 9; + this.plcname.Name = "plcname"; + this.plcname.ReadOnly = true; + this.plcname.Width = 175; + // + // code + // + this.code.DataPropertyName = "code"; + this.code.HeaderText = "数据名称"; + this.code.MinimumWidth = 9; + this.code.Name = "code"; + this.code.ReadOnly = true; + this.code.Width = 175; + // + // type + // + this.type.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.type.DataPropertyName = "type"; + this.type.HeaderText = "读写类型"; + this.type.MinimumWidth = 9; + this.type.Name = "type"; + this.type.ReadOnly = true; + this.type.Resizable = System.Windows.Forms.DataGridViewTriState.True; + this.type.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic; + // + // dbaddress + // + this.dbaddress.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.dbaddress.DataPropertyName = "dbaddress"; + this.dbaddress.HeaderText = "DB块地址"; + this.dbaddress.MinimumWidth = 9; + this.dbaddress.Name = "dbaddress"; + this.dbaddress.ReadOnly = true; + // + // addressoffset + // + this.addressoffset.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.addressoffset.DataPropertyName = "addressoffset"; + this.addressoffset.HeaderText = "DB地址"; + this.addressoffset.MinimumWidth = 9; + this.addressoffset.Name = "addressoffset"; + this.addressoffset.ReadOnly = true; + // + // addresstype + // + this.addresstype.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.addresstype.DataPropertyName = "addresstype"; + this.addresstype.HeaderText = "数据类型"; + this.addresstype.MinimumWidth = 9; + this.addresstype.Name = "addresstype"; + this.addresstype.ReadOnly = true; + this.addresstype.Resizable = System.Windows.Forms.DataGridViewTriState.True; + this.addresstype.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic; + // + // addresstypelegth + // + this.addresstypelegth.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.addresstypelegth.DataPropertyName = "addresstypelegth"; + this.addresstypelegth.HeaderText = "字节长度"; + this.addresstypelegth.MinimumWidth = 9; + this.addresstypelegth.Name = "addresstypelegth"; + this.addresstypelegth.ReadOnly = true; + // + // remark + // + this.remark.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.remark.DataPropertyName = "remark"; + this.remark.HeaderText = "注释"; + this.remark.MinimumWidth = 9; + this.remark.Name = "remark"; + this.remark.ReadOnly = true; + // + // PlcAddress_Manage + // + this.AutoScaleDimensions = new System.Drawing.SizeF(11F, 21F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1818, 814); + this.Controls.Add(this.tableLayoutPanel1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.Margin = new System.Windows.Forms.Padding(4); + this.Name = "PlcAddress_Manage"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "PLCADDRESS_Manage"; + this.WindowState = System.Windows.Forms.FormWindowState.Maximized; + this.Load += new System.EventHandler(this.PLCADDRESS_Manage_Load); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); + this.tableLayoutPanel1.ResumeLayout(false); + this.tableLayoutPanel1.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Button 关闭; + private System.Windows.Forms.Button 查询; + private System.Windows.Forms.DataGridView dataGridView1; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.ComboBox comboBox1; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.DataGridViewTextBoxColumn id; + private System.Windows.Forms.DataGridViewTextBoxColumn plcname; + private System.Windows.Forms.DataGridViewTextBoxColumn code; + private System.Windows.Forms.DataGridViewComboBoxColumn type; + private System.Windows.Forms.DataGridViewTextBoxColumn dbaddress; + private System.Windows.Forms.DataGridViewTextBoxColumn addressoffset; + private System.Windows.Forms.DataGridViewComboBoxColumn addresstype; + private System.Windows.Forms.DataGridViewTextBoxColumn addresstypelegth; + private System.Windows.Forms.DataGridViewTextBoxColumn remark; + } +} \ No newline at end of file diff --git a/WindowsFormsApp1/form/Torqueaddress_Manage.cs b/WindowsFormsApp1/form/Torqueaddress_Manage.cs new file mode 100644 index 0000000..e7eb8a3 --- /dev/null +++ b/WindowsFormsApp1/form/Torqueaddress_Manage.cs @@ -0,0 +1,209 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using WindowsFormsApp1.db; +using WindowsFormsApp1.mod; + +namespace WindowsFormsApp1.form +{ + public partial class Torqueaddress_Manage : Form + { + public Torqueaddress_Manage() + { + InitializeComponent(); + } + + private void 查询_Click(object sender, EventArgs e) + { + GetInfo((int)comboBox1.SelectedValue); + } + + private void 保存_Click(object sender, EventArgs e) + { + try + { + SQLiteHelper sQLiteHelper = new db.SQLiteHelper(); + var result = sQLiteHelper.UpdateAll((List)dataGridView1.DataSource); + if (result.Success) + { + MessageBox.Show("更新成功"); + GetInfo((int)comboBox1.SelectedValue); + } + else + { + MessageBox.Show("更新失败"); + } + } + catch (Exception ex) + { + MessageBox.Show($"更新失败,错误原因{ex.Message}"); + } + } + + private void 关闭_Click(object sender, EventArgs e) + { + this.Close(); + } + + private void PLCADDRESS_Manage_Load(object sender, EventArgs e) + { + dataGridView1.AutoGenerateColumns = false; + SQLiteHelper sQLiteHelper1 = new db.SQLiteHelper(); + var result_combox = sQLiteHelper1.QueryAll(); + if (!result_combox.Success) + { + MessageBox.Show("查询失败"); + return; + } + + var list = result_combox.Data.FindAll(a => Init.t_Lineplcs.Select(p => p.plcid).Contains(a.id)); + + // 绑定数据源到 ComboBox + comboBox1.DataSource = list; + comboBox1.DisplayMember = "plcname"; + comboBox1.ValueMember = "id"; + + var result1 = new List + { + new {name = "read",value = "read"}, + new {name = "write",value = "write"} + }; + + var result2 = new List + { + new {name = "real",value = "real"}, + new {name = "string",value = "string"}, + new {name = "uint",value = "uint"}, + }; + + var comboBoxColumn = (DataGridViewComboBoxColumn)dataGridView1.Columns[3]; + // 绑定数据源到 ComboBox + comboBoxColumn.DataSource = result1; + comboBoxColumn.DisplayMember = "name"; + comboBoxColumn.ValueMember = "value"; + + comboBoxColumn.DataPropertyName = "type"; + + var comboBoxColumn1 = (DataGridViewComboBoxColumn)dataGridView1.Columns[6]; + // 绑定数据源到 ComboBox + comboBoxColumn1.DataSource = result2; + comboBoxColumn1.DisplayMember = "name"; + comboBoxColumn1.ValueMember = "value"; + + comboBoxColumn1.DataPropertyName = "addresstype"; + + DataGridViewButtonColumn modifyColumn = new DataGridViewButtonColumn(); + modifyColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + modifyColumn.Name = "ModifyColumn"; + modifyColumn.HeaderText = "修改"; + modifyColumn.Text = "修改"; + modifyColumn.UseColumnTextForButtonValue = true; + dataGridView1.Columns.Add(modifyColumn); + + // 添加删除按钮列 + DataGridViewButtonColumn deleteColumn = new DataGridViewButtonColumn(); + deleteColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + deleteColumn.Name = "DeleteColumn"; + deleteColumn.HeaderText = "删除"; + deleteColumn.Text = "删除"; + deleteColumn.UseColumnTextForButtonValue = true; + + dataGridView1.CellContentClick += DataGridView1_CellContentClick; + + dataGridView1.Columns.Add(deleteColumn); + + } + private void DataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) + { + // 检查点击的是否为按钮列 + if (e.RowIndex >= 0) + { + DataGridView dataGridView = (DataGridView)sender; + DataGridViewRow row = dataGridView.Rows[e.RowIndex]; + + int selectid = int.Parse(row.Cells[0].Value.ToString()); + if (e.ColumnIndex == 9) + { + Torqueaddress_Insert fLOW_Insert = new Torqueaddress_Insert(); + fLOW_Insert.dataid = selectid; + fLOW_Insert.Operation = OperationType.Edit; + fLOW_Insert.ShowDialog(); + GetInfo((int)comboBox1.SelectedValue); + + } + else if (e.ColumnIndex == 10) + { + DialogResult result = MessageBox.Show("你确定要删除数据吗?", "确认提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); + + if (result == DialogResult.OK) + { + SQLiteHelper sQLiteHelper = new db.SQLiteHelper(); + var delresult = sQLiteHelper.Delete(selectid); + if (delresult.Success) + { + MessageBox.Show("删除成功"); + } + else + { + MessageBox.Show("删除失败"); + } + GetInfo((int)comboBox1.SelectedValue); + } + } + } + } + public void GetInfo(int plcid) + { + try + { + dataGridView1.DataSource = null; + SQLiteHelper sQLiteHelper = new db.SQLiteHelper(); + SQLiteHelper sQLiteHelper1 = new db.SQLiteHelper(); + var result_plc = sQLiteHelper1.QueryAll(); + var result = sQLiteHelper.Query(a=>a.plcid == plcid); + if (result.Success) + { + List list = new List(); + foreach (var plcaddress in result.Data) + { + var plc = result_plc.Data.FirstOrDefault(a => a.id == plcaddress.plcid); + list.Add(new + { + id = plcaddress.id, + plcid = plcaddress.plcid, + code = plcaddress.code, + type = plcaddress.type, + dbaddress = plcaddress.dbaddress, + addresstype = plcaddress.addresstype, + addresstypelegth = plcaddress.addresstypelegth, + addressoffset = plcaddress.addressoffset, + remark = plcaddress.remark, + value = plcaddress.value, + plcname = plc.plcname, + + + }); + } + dataGridView1.DataSource = list; + dataGridView1.Refresh(); + } + } + catch (Exception ex) + { + } + } + + private void button1_Click(object sender, EventArgs e) + { + Torqueaddress_Insert fLOW_Insert = new Torqueaddress_Insert(); + fLOW_Insert.ShowDialog(); + GetInfo((int)comboBox1.SelectedValue); + } + } +} diff --git a/WindowsFormsApp1/form/Torqueaddress_Manage.resx b/WindowsFormsApp1/form/Torqueaddress_Manage.resx new file mode 100644 index 0000000..7f316a3 --- /dev/null +++ b/WindowsFormsApp1/form/Torqueaddress_Manage.resx @@ -0,0 +1,147 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + \ No newline at end of file diff --git a/WindowsFormsApp1/form/USER_Manage.Designer.cs b/WindowsFormsApp1/form/USER_Manage.Designer.cs index fbfea84..4670e18 100644 --- a/WindowsFormsApp1/form/USER_Manage.Designer.cs +++ b/WindowsFormsApp1/form/USER_Manage.Designer.cs @@ -1,6 +1,6 @@ namespace WindowsFormsApp1 { - partial class USER_Manage + partial class User_Manage { /// /// Required designer variable. @@ -32,13 +32,13 @@ System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); this.dataGridView1 = new System.Windows.Forms.DataGridView(); - this.查询 = new System.Windows.Forms.Button(); - this.保存 = new System.Windows.Forms.Button(); - this.关闭 = new System.Windows.Forms.Button(); - this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); this.id = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.username = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.password = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.查询 = new System.Windows.Forms.Button(); + this.关闭 = new System.Windows.Forms.Button(); + this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.button1 = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); this.tableLayoutPanel1.SuspendLayout(); this.SuspendLayout(); @@ -78,66 +78,6 @@ this.dataGridView1.Size = new System.Drawing.Size(1475, 711); this.dataGridView1.TabIndex = 0; // - // 查询 - // - this.查询.Anchor = System.Windows.Forms.AnchorStyles.None; - this.查询.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.查询.Location = new System.Drawing.Point(1493, 36); - this.查询.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); - this.查询.Name = "查询"; - this.查询.Size = new System.Drawing.Size(154, 72); - this.查询.TabIndex = 1; - this.查询.Text = "查询"; - this.查询.UseVisualStyleBackColor = true; - this.查询.Click += new System.EventHandler(this.查询_Click); - // - // 保存 - // - this.保存.Anchor = System.Windows.Forms.AnchorStyles.None; - this.保存.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.保存.Location = new System.Drawing.Point(1493, 468); - this.保存.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); - this.保存.Name = "保存"; - this.保存.Size = new System.Drawing.Size(154, 72); - this.保存.TabIndex = 2; - this.保存.Text = "保存"; - this.保存.UseVisualStyleBackColor = true; - this.保存.Click += new System.EventHandler(this.保存_Click); - // - // 关闭 - // - this.关闭.Anchor = System.Windows.Forms.AnchorStyles.None; - this.关闭.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.关闭.Location = new System.Drawing.Point(1493, 612); - this.关闭.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); - this.关闭.Name = "关闭"; - this.关闭.Size = new System.Drawing.Size(154, 72); - this.关闭.TabIndex = 3; - this.关闭.Text = "关闭"; - this.关闭.UseVisualStyleBackColor = true; - this.关闭.Click += new System.EventHandler(this.关闭_Click); - // - // tableLayoutPanel1 - // - this.tableLayoutPanel1.ColumnCount = 2; - this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 90F)); - this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10F)); - this.tableLayoutPanel1.Controls.Add(this.关闭, 1, 3); - this.tableLayoutPanel1.Controls.Add(this.dataGridView1, 0, 0); - this.tableLayoutPanel1.Controls.Add(this.保存, 1, 2); - this.tableLayoutPanel1.Controls.Add(this.查询, 1, 0); - this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; - this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); - this.tableLayoutPanel1.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); - this.tableLayoutPanel1.Name = "tableLayoutPanel1"; - this.tableLayoutPanel1.RowCount = 4; - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 40F)); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); - this.tableLayoutPanel1.Size = new System.Drawing.Size(1653, 721); - this.tableLayoutPanel1.TabIndex = 4; - // // id // this.id.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; @@ -163,6 +103,66 @@ this.password.MinimumWidth = 9; this.password.Name = "password"; // + // 查询 + // + this.查询.Anchor = System.Windows.Forms.AnchorStyles.None; + this.查询.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.查询.Location = new System.Drawing.Point(1493, 36); + this.查询.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); + this.查询.Name = "查询"; + this.查询.Size = new System.Drawing.Size(154, 72); + this.查询.TabIndex = 1; + this.查询.Text = "查询"; + this.查询.UseVisualStyleBackColor = true; + this.查询.Click += new System.EventHandler(this.查询_Click); + // + // 关闭 + // + this.关闭.Anchor = System.Windows.Forms.AnchorStyles.None; + this.关闭.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.关闭.Location = new System.Drawing.Point(1493, 612); + this.关闭.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); + this.关闭.Name = "关闭"; + this.关闭.Size = new System.Drawing.Size(154, 72); + this.关闭.TabIndex = 3; + this.关闭.Text = "关闭"; + this.关闭.UseVisualStyleBackColor = true; + this.关闭.Click += new System.EventHandler(this.关闭_Click); + // + // tableLayoutPanel1 + // + this.tableLayoutPanel1.ColumnCount = 2; + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 90F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.Controls.Add(this.button1, 1, 2); + this.tableLayoutPanel1.Controls.Add(this.关闭, 1, 3); + this.tableLayoutPanel1.Controls.Add(this.dataGridView1, 0, 0); + this.tableLayoutPanel1.Controls.Add(this.查询, 1, 0); + this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanel1.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + this.tableLayoutPanel1.RowCount = 4; + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 40F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.Size = new System.Drawing.Size(1653, 721); + this.tableLayoutPanel1.TabIndex = 4; + // + // button1 + // + this.button1.Anchor = System.Windows.Forms.AnchorStyles.None; + this.button1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.button1.Location = new System.Drawing.Point(1493, 476); + this.button1.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(153, 56); + this.button1.TabIndex = 5; + this.button1.Text = "新增"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // // USER_Manage // this.AutoScaleDimensions = new System.Drawing.SizeF(11F, 21F); @@ -174,6 +174,7 @@ this.Name = "USER_Manage"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "USER_Manage"; + this.WindowState = System.Windows.Forms.FormWindowState.Maximized; this.Load += new System.EventHandler(this.USER_Manage_Load); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); this.tableLayoutPanel1.ResumeLayout(false); @@ -185,11 +186,11 @@ private System.Windows.Forms.DataGridView dataGridView1; private System.Windows.Forms.Button 查询; - private System.Windows.Forms.Button 保存; private System.Windows.Forms.Button 关闭; private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; private System.Windows.Forms.DataGridViewTextBoxColumn id; private System.Windows.Forms.DataGridViewTextBoxColumn username; private System.Windows.Forms.DataGridViewTextBoxColumn password; + private System.Windows.Forms.Button button1; } } \ No newline at end of file diff --git a/WindowsFormsApp1/form/USER_Manage.cs b/WindowsFormsApp1/form/USER_Manage.cs index 9523c50..1b2b6b1 100644 --- a/WindowsFormsApp1/form/USER_Manage.cs +++ b/WindowsFormsApp1/form/USER_Manage.cs @@ -8,13 +8,14 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using WindowsFormsApp1.db; +using WindowsFormsApp1.form; using WindowsFormsApp1.mod; namespace WindowsFormsApp1 { - public partial class USER_Manage : Form + public partial class User_Manage : Form { - public USER_Manage() + public User_Manage() { InitializeComponent(); } @@ -83,6 +84,71 @@ namespace WindowsFormsApp1 private void USER_Manage_Load(object sender, EventArgs e) { dataGridView1.AutoGenerateColumns = false; + DataGridViewButtonColumn modifyColumn = new DataGridViewButtonColumn(); + modifyColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + modifyColumn.Name = "ModifyColumn"; + modifyColumn.HeaderText = "修改"; + modifyColumn.Text = "修改"; + modifyColumn.UseColumnTextForButtonValue = true; + dataGridView1.Columns.Add(modifyColumn); + + // 添加删除按钮列 + DataGridViewButtonColumn deleteColumn = new DataGridViewButtonColumn(); + deleteColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + deleteColumn.Name = "DeleteColumn"; + deleteColumn.HeaderText = "删除"; + deleteColumn.Text = "删除"; + deleteColumn.UseColumnTextForButtonValue = true; + dataGridView1.Columns.Add(deleteColumn); + + dataGridView1.CellContentClick += DataGridView1_CellContentClick; + GetInfo(); + } + + private void DataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) + { + // 检查点击的是否为按钮列 + if (e.RowIndex >= 0) + { + DataGridView dataGridView = (DataGridView)sender; + DataGridViewRow row = dataGridView.Rows[e.RowIndex]; + + int selectid = int.Parse(row.Cells[0].Value.ToString()); + if (e.ColumnIndex == 3) + { + User_Insert fLOW_Insert = new User_Insert(); + fLOW_Insert.dataid = selectid; + fLOW_Insert.Operation = OperationType.Edit; + fLOW_Insert.ShowDialog(); + GetInfo(); + + } + else if (e.ColumnIndex == 4) + { + DialogResult result = MessageBox.Show("你确定要删除数据吗?", "确认提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); + + if (result == DialogResult.OK) + { + SQLiteHelper sQLiteHelper = new db.SQLiteHelper(); + var delresult = sQLiteHelper.Delete(selectid); + if (delresult.Success) + { + MessageBox.Show("删除成功"); + } + else + { + MessageBox.Show("删除失败"); + } + GetInfo(); + } + } + } + } + + private void button1_Click(object sender, EventArgs e) + { + User_Insert fLOW_Insert = new User_Insert(); + fLOW_Insert.ShowDialog(); GetInfo(); } } diff --git a/WindowsFormsApp1/form/USER_ChangeP.Designer.cs b/WindowsFormsApp1/form/UserChangeP.Designer.cs similarity index 99% rename from WindowsFormsApp1/form/USER_ChangeP.Designer.cs rename to WindowsFormsApp1/form/UserChangeP.Designer.cs index fc25646..dddaf5d 100644 --- a/WindowsFormsApp1/form/USER_ChangeP.Designer.cs +++ b/WindowsFormsApp1/form/UserChangeP.Designer.cs @@ -1,6 +1,6 @@ namespace WindowsFormsApp1.form { - partial class USER_ChangeP + partial class UserChangeP { /// /// Required designer variable. diff --git a/WindowsFormsApp1/form/USER_ChangeP.cs b/WindowsFormsApp1/form/UserChangeP.cs similarity index 87% rename from WindowsFormsApp1/form/USER_ChangeP.cs rename to WindowsFormsApp1/form/UserChangeP.cs index c414afc..8362aed 100644 --- a/WindowsFormsApp1/form/USER_ChangeP.cs +++ b/WindowsFormsApp1/form/UserChangeP.cs @@ -10,9 +10,9 @@ using System.Windows.Forms; namespace WindowsFormsApp1.form { - public partial class USER_ChangeP : Form + public partial class UserChangeP : Form { - public USER_ChangeP() + public UserChangeP() { InitializeComponent(); } diff --git a/WindowsFormsApp1/form/USER_ChangeP.resx b/WindowsFormsApp1/form/UserChangeP.resx similarity index 100% rename from WindowsFormsApp1/form/USER_ChangeP.resx rename to WindowsFormsApp1/form/UserChangeP.resx diff --git a/WindowsFormsApp1/form/editForm/Angleaddress_Insert.Designer.cs b/WindowsFormsApp1/form/editForm/Angleaddress_Insert.Designer.cs new file mode 100644 index 0000000..7494671 --- /dev/null +++ b/WindowsFormsApp1/form/editForm/Angleaddress_Insert.Designer.cs @@ -0,0 +1,333 @@ +namespace WindowsFormsApp1.form +{ + partial class Angleaddress_Insert + { + /// + /// 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.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.数据名称 = new System.Windows.Forms.TextBox(); + this.button1 = new System.Windows.Forms.Button(); + this.button2 = new System.Windows.Forms.Button(); + this.label4 = new System.Windows.Forms.Label(); + this.db地址 = new System.Windows.Forms.TextBox(); + this.label7 = new System.Windows.Forms.Label(); + this.长度 = new System.Windows.Forms.TextBox(); + this.读写 = new System.Windows.Forms.ComboBox(); + this.db块 = new System.Windows.Forms.TextBox(); + this.备注 = new System.Windows.Forms.TextBox(); + this.类型 = new System.Windows.Forms.ComboBox(); + this.label2 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.label5 = new System.Windows.Forms.Label(); + this.label6 = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.PLC名称 = new System.Windows.Forms.ComboBox(); + this.label8 = new System.Windows.Forms.Label(); + this.tableLayoutPanel1.SuspendLayout(); + this.SuspendLayout(); + // + // tableLayoutPanel1 + // + this.tableLayoutPanel1.ColumnCount = 6; + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.Controls.Add(this.数据名称, 2, 1); + this.tableLayoutPanel1.Controls.Add(this.button1, 1, 8); + this.tableLayoutPanel1.Controls.Add(this.button2, 3, 8); + this.tableLayoutPanel1.Controls.Add(this.label4, 1, 5); + this.tableLayoutPanel1.Controls.Add(this.db地址, 2, 4); + this.tableLayoutPanel1.Controls.Add(this.label7, 1, 2); + this.tableLayoutPanel1.Controls.Add(this.长度, 2, 6); + this.tableLayoutPanel1.Controls.Add(this.读写, 2, 2); + this.tableLayoutPanel1.Controls.Add(this.db块, 2, 3); + this.tableLayoutPanel1.Controls.Add(this.备注, 2, 7); + this.tableLayoutPanel1.Controls.Add(this.类型, 2, 5); + this.tableLayoutPanel1.Controls.Add(this.label2, 1, 3); + this.tableLayoutPanel1.Controls.Add(this.label3, 1, 4); + this.tableLayoutPanel1.Controls.Add(this.label5, 1, 6); + this.tableLayoutPanel1.Controls.Add(this.label6, 1, 7); + this.tableLayoutPanel1.Controls.Add(this.label1, 1, 0); + this.tableLayoutPanel1.Controls.Add(this.PLC名称, 2, 0); + this.tableLayoutPanel1.Controls.Add(this.label8, 1, 1); + this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + this.tableLayoutPanel1.RowCount = 10; + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.Size = new System.Drawing.Size(931, 732); + this.tableLayoutPanel1.TabIndex = 0; + // + // 数据名称 + // + this.数据名称.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.数据名称, 3); + this.数据名称.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.数据名称.Location = new System.Drawing.Point(282, 90); + this.数据名称.Name = "数据名称"; + this.数据名称.Size = new System.Drawing.Size(552, 39); + this.数据名称.TabIndex = 35; + // + // button1 + // + this.button1.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.button1, 2); + this.button1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.button1.Location = new System.Drawing.Point(182, 587); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(194, 67); + this.button1.TabIndex = 14; + this.button1.Text = "保存"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // button2 + // + this.button2.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.button2, 2); + this.button2.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.button2.Location = new System.Drawing.Point(556, 587); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(190, 67); + this.button2.TabIndex = 15; + this.button2.Text = "取消"; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.button2_Click); + // + // label4 + // + this.label4.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label4.AutoSize = true; + this.label4.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label4.Location = new System.Drawing.Point(124, 387); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(124, 28); + this.label4.TabIndex = 3; + this.label4.Text = "数据类型"; + // + // db地址 + // + this.db地址.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.db地址, 3); + this.db地址.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.db地址.Location = new System.Drawing.Point(282, 309); + this.db地址.Name = "db地址"; + this.db地址.Size = new System.Drawing.Size(552, 39); + this.db地址.TabIndex = 20; + // + // label7 + // + this.label7.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label7.AutoSize = true; + this.label7.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label7.Location = new System.Drawing.Point(124, 168); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(124, 28); + this.label7.TabIndex = 29; + this.label7.Text = "读写类型"; + // + // 长度 + // + this.长度.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.长度, 3); + this.长度.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.长度.Location = new System.Drawing.Point(282, 455); + this.长度.Name = "长度"; + this.长度.Size = new System.Drawing.Size(552, 39); + this.长度.TabIndex = 18; + // + // 读写 + // + this.读写.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.读写, 3); + this.读写.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.读写.FormattingEnabled = true; + this.读写.Location = new System.Drawing.Point(282, 168); + this.读写.Name = "读写"; + this.读写.Size = new System.Drawing.Size(552, 36); + this.读写.TabIndex = 31; + // + // db块 + // + this.db块.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.db块, 3); + this.db块.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.db块.Location = new System.Drawing.Point(282, 236); + this.db块.Name = "db块"; + this.db块.Size = new System.Drawing.Size(552, 39); + this.db块.TabIndex = 30; + // + // 备注 + // + this.备注.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.备注, 3); + this.备注.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.备注.Location = new System.Drawing.Point(282, 528); + this.备注.Name = "备注"; + this.备注.Size = new System.Drawing.Size(552, 39); + this.备注.TabIndex = 17; + // + // 类型 + // + this.类型.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.类型, 3); + this.类型.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.类型.FormattingEnabled = true; + this.类型.Location = new System.Drawing.Point(282, 387); + this.类型.Name = "类型"; + this.类型.Size = new System.Drawing.Size(552, 36); + this.类型.TabIndex = 32; + // + // label2 + // + this.label2.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label2.AutoSize = true; + this.label2.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label2.Location = new System.Drawing.Point(124, 241); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(124, 28); + this.label2.TabIndex = 1; + this.label2.Text = "DB块地址"; + // + // label3 + // + this.label3.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label3.AutoSize = true; + this.label3.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label3.Location = new System.Drawing.Point(138, 314); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(96, 28); + this.label3.TabIndex = 2; + this.label3.Text = "DB地址"; + // + // label5 + // + this.label5.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label5.AutoSize = true; + this.label5.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label5.Location = new System.Drawing.Point(124, 460); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(124, 28); + this.label5.TabIndex = 4; + this.label5.Text = "字节长度"; + // + // label6 + // + this.label6.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label6.AutoSize = true; + this.label6.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label6.Location = new System.Drawing.Point(152, 533); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(68, 28); + this.label6.TabIndex = 5; + this.label6.Text = "备注"; + // + // label1 + // + this.label1.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label1.Location = new System.Drawing.Point(131, 22); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(110, 28); + this.label1.TabIndex = 0; + this.label1.Text = "PLC名称"; + // + // PLC名称 + // + this.PLC名称.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.PLC名称, 3); + this.PLC名称.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.PLC名称.FormattingEnabled = true; + this.PLC名称.Location = new System.Drawing.Point(282, 22); + this.PLC名称.Name = "PLC名称"; + this.PLC名称.Size = new System.Drawing.Size(552, 36); + this.PLC名称.TabIndex = 33; + // + // label8 + // + this.label8.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label8.AutoSize = true; + this.label8.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label8.Location = new System.Drawing.Point(124, 95); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(124, 28); + this.label8.TabIndex = 34; + this.label8.Text = "数据名称"; + // + // PlcAddress_Insert + // + this.AutoScaleDimensions = new System.Drawing.SizeF(11F, 21F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(931, 732); + this.Controls.Add(this.tableLayoutPanel1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.Name = "PlcAddress_Insert"; + this.Text = "Form_Insert"; + this.Load += new System.EventHandler(this.FLOW_Insert_Load); + this.tableLayoutPanel1.ResumeLayout(false); + this.tableLayoutPanel1.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.Button button2; + private System.Windows.Forms.TextBox 备注; + private System.Windows.Forms.TextBox db地址; + private System.Windows.Forms.TextBox 长度; + private System.Windows.Forms.Label label7; + private System.Windows.Forms.TextBox db块; + private System.Windows.Forms.ComboBox 读写; + private System.Windows.Forms.ComboBox 类型; + private System.Windows.Forms.ComboBox PLC名称; + private System.Windows.Forms.TextBox 数据名称; + private System.Windows.Forms.Label label8; + } +} \ No newline at end of file diff --git a/WindowsFormsApp1/form/editForm/Angleaddress_Insert.cs b/WindowsFormsApp1/form/editForm/Angleaddress_Insert.cs new file mode 100644 index 0000000..bb9e42d --- /dev/null +++ b/WindowsFormsApp1/form/editForm/Angleaddress_Insert.cs @@ -0,0 +1,181 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using WindowsFormsApp1.db; +using WindowsFormsApp1.mod; + +namespace WindowsFormsApp1.form +{ + public partial class Angleaddress_Insert : Form + { + public OperationType Operation { get; set; } + public int dataid { get; set; } + + public Angleaddress_Insert() + { + InitializeComponent(); + } + + private void button1_Click(object sender, EventArgs e) + { + //保存 + int _db; + int _legth; + if (!int.TryParse(db地址.Text, out _db)) + { + MessageBox.Show("db地址不是数字类型"); + return; + } + if (!int.TryParse(长度.Text, out _legth)) + { + MessageBox.Show("长度不是数字类型"); + return; + } + if (string.IsNullOrWhiteSpace(备注.Text)) + { + MessageBox.Show("备注不能为空"); + return; + } + if (string.IsNullOrWhiteSpace(数据名称.Text)) + { + MessageBox.Show("数据名称不能为空"); + return; + } + if (string.IsNullOrWhiteSpace(db块.Text)) + { + MessageBox.Show("db块地址不能为空"); + return; + } + if (类型.SelectedValue == null) + { + MessageBox.Show("类型不能为空"); + return; + } + if (读写.SelectedValue == null) + { + MessageBox.Show("读写类型不能为空"); + return; + } + + + + t_angleaddress t_Flow = new t_angleaddress(); + t_Flow.plcid = (int)PLC名称.SelectedValue; + t_Flow.code = 数据名称.Text; + t_Flow.type = (string)读写.SelectedValue; + t_Flow.dbaddress = db块.Text; + t_Flow.remark = 备注.Text; + t_Flow.addresstypelegth = _legth; + t_Flow.addressoffset = _db; + t_Flow.addresstype = (string)类型.SelectedValue; + + SQLiteHelper sQLiteHelper1 = new db.SQLiteHelper(); + if (Operation == OperationType.Edit) + { + t_Flow.id = dataid; + sQLiteHelper1.Update(t_Flow); + } + else + { + sQLiteHelper1.Insert(t_Flow); + } + MessageBox.Show("保存成功"); + this.Close(); + } + + private void button2_Click(object sender, EventArgs e) + { + //取消 + this.Close(); + } + + private void FLOW_Insert_Load(object sender, EventArgs e) + { + var result1 = new List<_KeyV> + { + new _KeyV{name = "read",value = "read"}, + new _KeyV{name = "write",value = "write"} + }; + + var result2 = new List<_KeyV> + { + new _KeyV{name = "real",value = "real"}, + new _KeyV{name = "string",value = "string"}, + new _KeyV{name = "uint",value = "uint"}, + }; + + // 绑定数据源到 ComboBox + 读写.DataSource = result1; + 读写.DisplayMember = "name"; + 读写.ValueMember = "value"; + + + 类型.DataSource = result2; + 类型.DisplayMember = "name"; + 类型.ValueMember = "value"; + + SQLiteHelper sQLiteHelper1 = new db.SQLiteHelper(); + var result_combox1 = sQLiteHelper1.QueryAll(); + if (!result_combox1.Success) + { + MessageBox.Show("查询失败"); + return; + } + + // 绑定数据源到 ComboBox + PLC名称.DataSource = result_combox1.Data; + PLC名称.DisplayMember = "plcname"; + PLC名称.ValueMember = "id"; + + + if (Operation == OperationType.Edit) + { + SQLiteHelper sQLiteHelper = new db.SQLiteHelper(); + var result = sQLiteHelper.QuerySingle(a=>a.id == dataid); + if (!result.Success) + { + MessageBox.Show("查询失败"); + return; + } + var DataToEdit = result.Data; + 数据名称.Text = DataToEdit.code; + db块.Text = DataToEdit.dbaddress; + db地址.Text = DataToEdit.addressoffset.ToString(); + 长度.Text = DataToEdit.addresstypelegth.ToString(); + 备注.Text = DataToEdit.remark; + SelectItemByValue1(PLC名称, DataToEdit.plcid.ToString()); + SelectItemByValue(读写, DataToEdit.type.ToString()); + SelectItemByValue(类型, DataToEdit.addresstypelegth.ToString()); + } + } + + private void SelectItemByValue(ComboBox comboBox1, string value) + { + foreach (_KeyV item in comboBox1.Items) + { + if (item.value.ToString() == value) + { + comboBox1.SelectedItem = item; + break; + } + } + } + private void SelectItemByValue1(ComboBox comboBox1, string value) + { + foreach (t_plc item in comboBox1.Items) + { + if (item.id.ToString() == value) + { + comboBox1.SelectedItem = item; + break; + } + } + } + } +} diff --git a/WindowsFormsApp1/form/editForm/Angleaddress_Insert.resx b/WindowsFormsApp1/form/editForm/Angleaddress_Insert.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/WindowsFormsApp1/form/editForm/Angleaddress_Insert.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/WindowsFormsApp1/form/editForm/FLow_Insert.Designer.cs b/WindowsFormsApp1/form/editForm/FLow_Insert.Designer.cs new file mode 100644 index 0000000..a3736e7 --- /dev/null +++ b/WindowsFormsApp1/form/editForm/FLow_Insert.Designer.cs @@ -0,0 +1,494 @@ +namespace WindowsFormsApp1.form +{ + partial class FLow_Insert + { + /// + /// 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.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.label1 = new System.Windows.Forms.Label(); + this.label8 = new System.Windows.Forms.Label(); + this.label9 = new System.Windows.Forms.Label(); + this.label10 = new System.Windows.Forms.Label(); + this.button1 = new System.Windows.Forms.Button(); + this.button2 = new System.Windows.Forms.Button(); + this.压力曲线 = new System.Windows.Forms.CheckBox(); + this.螺丝扭力 = new System.Windows.Forms.CheckBox(); + this.文件上传 = new System.Windows.Forms.CheckBox(); + this.流程名称 = new System.Windows.Forms.TextBox(); + this.气密参数 = new System.Windows.Forms.CheckBox(); + this.label6 = new System.Windows.Forms.Label(); + this.label5 = new System.Windows.Forms.Label(); + this.label4 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.期望PLC值 = new System.Windows.Forms.TextBox(); + this.步骤 = new System.Windows.Forms.TextBox(); + this.label7 = new System.Windows.Forms.Label(); + this.流程编号 = new System.Windows.Forms.TextBox(); + this.label11 = new System.Windows.Forms.Label(); + this.螺丝角度 = new System.Windows.Forms.CheckBox(); + this.label12 = new System.Windows.Forms.Label(); + this.扭力曲线 = new System.Windows.Forms.CheckBox(); + this.label13 = new System.Windows.Forms.Label(); + this.label14 = new System.Windows.Forms.Label(); + this.扫码 = new System.Windows.Forms.CheckBox(); + this.错误PLC值 = new System.Windows.Forms.TextBox(); + this.成功接口 = new System.Windows.Forms.ComboBox(); + this.错误接口 = new System.Windows.Forms.ComboBox(); + this.tableLayoutPanel1.SuspendLayout(); + this.SuspendLayout(); + // + // tableLayoutPanel1 + // + this.tableLayoutPanel1.ColumnCount = 6; + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.Controls.Add(this.label1, 1, 1); + this.tableLayoutPanel1.Controls.Add(this.label8, 3, 1); + this.tableLayoutPanel1.Controls.Add(this.label9, 3, 2); + this.tableLayoutPanel1.Controls.Add(this.label10, 3, 3); + this.tableLayoutPanel1.Controls.Add(this.button1, 1, 8); + this.tableLayoutPanel1.Controls.Add(this.button2, 3, 8); + this.tableLayoutPanel1.Controls.Add(this.压力曲线, 4, 6); + this.tableLayoutPanel1.Controls.Add(this.螺丝扭力, 4, 3); + this.tableLayoutPanel1.Controls.Add(this.文件上传, 4, 2); + this.tableLayoutPanel1.Controls.Add(this.流程名称, 2, 1); + this.tableLayoutPanel1.Controls.Add(this.气密参数, 4, 7); + this.tableLayoutPanel1.Controls.Add(this.label6, 1, 7); + this.tableLayoutPanel1.Controls.Add(this.label5, 1, 6); + this.tableLayoutPanel1.Controls.Add(this.label4, 1, 5); + this.tableLayoutPanel1.Controls.Add(this.label3, 1, 4); + this.tableLayoutPanel1.Controls.Add(this.label2, 1, 3); + this.tableLayoutPanel1.Controls.Add(this.期望PLC值, 2, 4); + this.tableLayoutPanel1.Controls.Add(this.步骤, 2, 3); + this.tableLayoutPanel1.Controls.Add(this.label7, 1, 2); + this.tableLayoutPanel1.Controls.Add(this.流程编号, 2, 2); + this.tableLayoutPanel1.Controls.Add(this.label11, 3, 4); + this.tableLayoutPanel1.Controls.Add(this.螺丝角度, 4, 4); + this.tableLayoutPanel1.Controls.Add(this.label12, 3, 5); + this.tableLayoutPanel1.Controls.Add(this.扭力曲线, 4, 5); + this.tableLayoutPanel1.Controls.Add(this.label13, 3, 6); + this.tableLayoutPanel1.Controls.Add(this.label14, 3, 7); + this.tableLayoutPanel1.Controls.Add(this.扫码, 4, 1); + this.tableLayoutPanel1.Controls.Add(this.错误PLC值, 2, 6); + this.tableLayoutPanel1.Controls.Add(this.成功接口, 2, 5); + this.tableLayoutPanel1.Controls.Add(this.错误接口, 2, 7); + this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + this.tableLayoutPanel1.RowCount = 10; + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.Size = new System.Drawing.Size(1087, 854); + this.tableLayoutPanel1.TabIndex = 0; + // + // label1 + // + this.label1.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label1.Location = new System.Drawing.Point(154, 113); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(124, 28); + this.label1.TabIndex = 0; + this.label1.Text = "流程名称"; + // + // label8 + // + this.label8.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label8.AutoSize = true; + this.label8.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label8.Location = new System.Drawing.Point(616, 113); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(68, 28); + this.label8.TabIndex = 7; + this.label8.Text = "扫码"; + // + // label9 + // + this.label9.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label9.AutoSize = true; + this.label9.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label9.Location = new System.Drawing.Point(588, 198); + this.label9.Name = "label9"; + this.label9.Size = new System.Drawing.Size(124, 28); + this.label9.TabIndex = 8; + this.label9.Text = "文件上传"; + // + // label10 + // + this.label10.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label10.AutoSize = true; + this.label10.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label10.Location = new System.Drawing.Point(588, 283); + this.label10.Name = "label10"; + this.label10.Size = new System.Drawing.Size(124, 28); + this.label10.TabIndex = 9; + this.label10.Text = "螺丝扭力"; + // + // button1 + // + this.button1.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.button1, 2); + this.button1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.button1.Location = new System.Drawing.Point(228, 683); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(194, 79); + this.button1.TabIndex = 14; + this.button1.Text = "保存"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // button2 + // + this.button2.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.button2, 2); + this.button2.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.button2.Location = new System.Drawing.Point(664, 683); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(190, 79); + this.button2.TabIndex = 15; + this.button2.Text = "取消"; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.button2_Click); + // + // 压力曲线 + // + this.压力曲线.Anchor = System.Windows.Forms.AnchorStyles.None; + this.压力曲线.AutoSize = true; + this.压力曲线.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.压力曲线.Location = new System.Drawing.Point(856, 542); + this.压力曲线.Name = "压力曲线"; + this.压力曲线.Size = new System.Drawing.Size(22, 21); + this.压力曲线.TabIndex = 23; + this.压力曲线.UseVisualStyleBackColor = true; + // + // 螺丝扭力 + // + this.螺丝扭力.Anchor = System.Windows.Forms.AnchorStyles.None; + this.螺丝扭力.AutoSize = true; + this.螺丝扭力.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.螺丝扭力.Location = new System.Drawing.Point(856, 287); + this.螺丝扭力.Name = "螺丝扭力"; + this.螺丝扭力.Size = new System.Drawing.Size(22, 21); + this.螺丝扭力.TabIndex = 26; + this.螺丝扭力.UseVisualStyleBackColor = true; + // + // 文件上传 + // + this.文件上传.Anchor = System.Windows.Forms.AnchorStyles.None; + this.文件上传.AutoSize = true; + this.文件上传.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.文件上传.Location = new System.Drawing.Point(856, 202); + this.文件上传.Name = "文件上传"; + this.文件上传.Size = new System.Drawing.Size(22, 21); + this.文件上传.TabIndex = 27; + this.文件上传.UseVisualStyleBackColor = true; + // + // 流程名称 + // + this.流程名称.Anchor = System.Windows.Forms.AnchorStyles.None; + this.流程名称.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.流程名称.Location = new System.Drawing.Point(328, 108); + this.流程名称.Name = "流程名称"; + this.流程名称.Size = new System.Drawing.Size(211, 39); + this.流程名称.TabIndex = 16; + // + // 气密参数 + // + this.气密参数.Anchor = System.Windows.Forms.AnchorStyles.None; + this.气密参数.AutoSize = true; + this.气密参数.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.气密参数.Location = new System.Drawing.Point(856, 627); + this.气密参数.Name = "气密参数"; + this.气密参数.Size = new System.Drawing.Size(22, 21); + this.气密参数.TabIndex = 22; + this.气密参数.UseVisualStyleBackColor = true; + // + // label6 + // + this.label6.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label6.AutoSize = true; + this.label6.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label6.Location = new System.Drawing.Point(126, 623); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(180, 28); + this.label6.TabIndex = 5; + this.label6.Text = "错误调用接口"; + // + // label5 + // + this.label5.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label5.AutoSize = true; + this.label5.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label5.Location = new System.Drawing.Point(147, 538); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(138, 28); + this.label5.TabIndex = 4; + this.label5.Text = "错误PLC值"; + // + // label4 + // + this.label4.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label4.AutoSize = true; + this.label4.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label4.Location = new System.Drawing.Point(126, 453); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(180, 28); + this.label4.TabIndex = 3; + this.label4.Text = "成功调用接口"; + // + // label3 + // + this.label3.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label3.AutoSize = true; + this.label3.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label3.Location = new System.Drawing.Point(147, 368); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(138, 28); + this.label3.TabIndex = 2; + this.label3.Text = "期望PLC值"; + // + // label2 + // + this.label2.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label2.AutoSize = true; + this.label2.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label2.Location = new System.Drawing.Point(182, 283); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(68, 28); + this.label2.TabIndex = 1; + this.label2.Text = "步骤"; + // + // 期望PLC值 + // + this.期望PLC值.Anchor = System.Windows.Forms.AnchorStyles.None; + this.期望PLC值.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.期望PLC值.Location = new System.Drawing.Point(328, 363); + this.期望PLC值.Name = "期望PLC值"; + this.期望PLC值.Size = new System.Drawing.Size(211, 39); + this.期望PLC值.TabIndex = 20; + // + // 步骤 + // + this.步骤.Anchor = System.Windows.Forms.AnchorStyles.None; + this.步骤.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.步骤.Location = new System.Drawing.Point(328, 278); + this.步骤.Name = "步骤"; + this.步骤.Size = new System.Drawing.Size(211, 39); + this.步骤.TabIndex = 17; + // + // label7 + // + this.label7.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label7.AutoSize = true; + this.label7.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label7.Location = new System.Drawing.Point(154, 198); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(124, 28); + this.label7.TabIndex = 29; + this.label7.Text = "流程编号"; + // + // 流程编号 + // + this.流程编号.Anchor = System.Windows.Forms.AnchorStyles.None; + this.流程编号.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.流程编号.Location = new System.Drawing.Point(328, 193); + this.流程编号.Name = "流程编号"; + this.流程编号.Size = new System.Drawing.Size(211, 39); + this.流程编号.TabIndex = 30; + // + // label11 + // + this.label11.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label11.AutoSize = true; + this.label11.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label11.Location = new System.Drawing.Point(588, 368); + this.label11.Name = "label11"; + this.label11.Size = new System.Drawing.Size(124, 28); + this.label11.TabIndex = 10; + this.label11.Text = "螺丝角度"; + // + // 螺丝角度 + // + this.螺丝角度.Anchor = System.Windows.Forms.AnchorStyles.None; + this.螺丝角度.AutoSize = true; + this.螺丝角度.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.螺丝角度.Location = new System.Drawing.Point(856, 372); + this.螺丝角度.Name = "螺丝角度"; + this.螺丝角度.Size = new System.Drawing.Size(22, 21); + this.螺丝角度.TabIndex = 24; + this.螺丝角度.UseVisualStyleBackColor = true; + // + // label12 + // + this.label12.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label12.AutoSize = true; + this.label12.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label12.Location = new System.Drawing.Point(588, 453); + this.label12.Name = "label12"; + this.label12.Size = new System.Drawing.Size(124, 28); + this.label12.TabIndex = 11; + this.label12.Text = "扭力曲线"; + // + // 扭力曲线 + // + this.扭力曲线.Anchor = System.Windows.Forms.AnchorStyles.None; + this.扭力曲线.AutoSize = true; + this.扭力曲线.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.扭力曲线.Location = new System.Drawing.Point(856, 457); + this.扭力曲线.Name = "扭力曲线"; + this.扭力曲线.Size = new System.Drawing.Size(22, 21); + this.扭力曲线.TabIndex = 25; + this.扭力曲线.UseVisualStyleBackColor = true; + // + // label13 + // + this.label13.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label13.AutoSize = true; + this.label13.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label13.Location = new System.Drawing.Point(588, 538); + this.label13.Name = "label13"; + this.label13.Size = new System.Drawing.Size(124, 28); + this.label13.TabIndex = 12; + this.label13.Text = "压力曲线"; + // + // label14 + // + this.label14.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label14.AutoSize = true; + this.label14.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label14.Location = new System.Drawing.Point(588, 623); + this.label14.Name = "label14"; + this.label14.Size = new System.Drawing.Size(124, 28); + this.label14.TabIndex = 13; + this.label14.Text = "气密参数"; + // + // 扫码 + // + this.扫码.Anchor = System.Windows.Forms.AnchorStyles.None; + this.扫码.AutoSize = true; + this.扫码.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.扫码.Location = new System.Drawing.Point(856, 117); + this.扫码.Name = "扫码"; + this.扫码.Size = new System.Drawing.Size(22, 21); + this.扫码.TabIndex = 28; + this.扫码.UseVisualStyleBackColor = true; + // + // 错误PLC值 + // + this.错误PLC值.Anchor = System.Windows.Forms.AnchorStyles.None; + this.错误PLC值.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.错误PLC值.Location = new System.Drawing.Point(328, 533); + this.错误PLC值.Name = "错误PLC值"; + this.错误PLC值.Size = new System.Drawing.Size(211, 39); + this.错误PLC值.TabIndex = 18; + // + // 成功接口 + // + this.成功接口.Anchor = System.Windows.Forms.AnchorStyles.None; + this.成功接口.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.成功接口.FormattingEnabled = true; + this.成功接口.Location = new System.Drawing.Point(328, 453); + this.成功接口.Name = "成功接口"; + this.成功接口.Size = new System.Drawing.Size(211, 36); + this.成功接口.TabIndex = 31; + // + // 错误接口 + // + this.错误接口.Anchor = System.Windows.Forms.AnchorStyles.None; + this.错误接口.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.错误接口.FormattingEnabled = true; + this.错误接口.Location = new System.Drawing.Point(328, 623); + this.错误接口.Name = "错误接口"; + this.错误接口.Size = new System.Drawing.Size(211, 36); + this.错误接口.TabIndex = 32; + // + // FLOW_Insert + // + this.AutoScaleDimensions = new System.Drawing.SizeF(11F, 21F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1087, 854); + this.Controls.Add(this.tableLayoutPanel1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.Name = "FLOW_Insert"; + this.Text = "Form_Insert"; + this.Load += new System.EventHandler(this.FLOW_Insert_Load); + this.tableLayoutPanel1.ResumeLayout(false); + this.tableLayoutPanel1.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.Label label8; + private System.Windows.Forms.Label label9; + private System.Windows.Forms.Label label10; + private System.Windows.Forms.Label label11; + private System.Windows.Forms.Label label12; + private System.Windows.Forms.Label label13; + private System.Windows.Forms.Label label14; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.Button button2; + private System.Windows.Forms.TextBox 步骤; + private System.Windows.Forms.TextBox 流程名称; + private System.Windows.Forms.TextBox 期望PLC值; + private System.Windows.Forms.TextBox 错误PLC值; + private System.Windows.Forms.CheckBox 气密参数; + private System.Windows.Forms.CheckBox 压力曲线; + private System.Windows.Forms.CheckBox 螺丝角度; + private System.Windows.Forms.CheckBox 扭力曲线; + private System.Windows.Forms.CheckBox 螺丝扭力; + private System.Windows.Forms.CheckBox 文件上传; + private System.Windows.Forms.CheckBox 扫码; + private System.Windows.Forms.Label label7; + private System.Windows.Forms.TextBox 流程编号; + private System.Windows.Forms.ComboBox 成功接口; + private System.Windows.Forms.ComboBox 错误接口; + } +} \ No newline at end of file diff --git a/WindowsFormsApp1/form/editForm/FLow_Insert.cs b/WindowsFormsApp1/form/editForm/FLow_Insert.cs new file mode 100644 index 0000000..912a07b --- /dev/null +++ b/WindowsFormsApp1/form/editForm/FLow_Insert.cs @@ -0,0 +1,169 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using WindowsFormsApp1.db; +using WindowsFormsApp1.mod; + +namespace WindowsFormsApp1.form +{ + public partial class FLow_Insert : Form + { + public OperationType Operation { get; set; } + public int dataid { get; set; } + + public FLow_Insert() + { + InitializeComponent(); + } + + private void button1_Click(object sender, EventArgs e) + { + //保存 + int _流程编号; + int _步骤; + int _期望PLC值; + int _错误PLC值; + if (!int.TryParse(流程编号.Text,out _流程编号)){ + MessageBox.Show("流程编号不是数字类型"); + return; + } + if (!int.TryParse(步骤.Text, out _步骤)) + { + MessageBox.Show("步骤不是数字类型"); + return; + } + if (!int.TryParse(期望PLC值.Text, out _期望PLC值)) + { + MessageBox.Show("期望PLC值不是数字类型"); + return; + } + if (!int.TryParse(错误PLC值.Text, out _错误PLC值)) + { + MessageBox.Show("错误PLC值不是数字类型"); + return; + } + if (string.IsNullOrWhiteSpace(流程名称.Text)) + { + MessageBox.Show("流程名称不能为空"); + return; + } + + t_flow t_Flow = new t_flow(); + t_Flow.flowname = 流程名称.Text; + t_Flow.flowid = _流程编号; + t_Flow.setp = _步骤; + t_Flow.hopestatus = _期望PLC值; + t_Flow.hopeinterfaceid = (int)成功接口.SelectedValue; + t_Flow.errstatus = _错误PLC值; + t_Flow.errinterfaceid = (int)错误接口.SelectedValue; + t_Flow.scan = 扫码.Checked; + t_Flow.fileupload = 文件上传.Checked; + t_Flow.finaltorquevalue = 螺丝扭力.Checked; + t_Flow.finalanglevaluue = 螺丝角度.Checked; + t_Flow.finaltorquecurve = 扭力曲线.Checked; + t_Flow.finalpressurecurve = 压力曲线.Checked; + t_Flow.airtight = 气密参数.Checked; + + SQLiteHelper sQLiteHelper1 = new db.SQLiteHelper(); + if (Operation == OperationType.Edit) + { + t_Flow.id = dataid; + sQLiteHelper1.Update(t_Flow); + } + else + { + sQLiteHelper1.Insert(t_Flow); + } + MessageBox.Show("保存成功"); + this.Close(); + } + + private void button2_Click(object sender, EventArgs e) + { + //取消 + this.Close(); + } + + private void FLOW_Insert_Load(object sender, EventArgs e) + { + SQLiteHelper sQLiteHelper1 = new db.SQLiteHelper(); + var result_combox1 = sQLiteHelper1.QueryAll(); + if (!result_combox1.Success) + { + MessageBox.Show("查询失败"); + return; + } + result_combox1.Data.Insert(0,new t_interface + { + id = 0, + name = "" + }); + + // 绑定数据源到 ComboBox + 成功接口.DataSource = result_combox1.Data; + 成功接口.DisplayMember = "name"; + 成功接口.ValueMember = "id"; + + + SQLiteHelper sQLiteHelper2 = new db.SQLiteHelper(); + var result_combox2 = sQLiteHelper2.QueryAll(); + if (!result_combox2.Success) + { + MessageBox.Show("查询失败"); + return; + } + result_combox2.Data.Insert(0, new t_interface + { + id = 0, + name = "" + }); + 错误接口.DataSource = result_combox2.Data; + 错误接口.DisplayMember = "name"; + 错误接口.ValueMember = "id"; + + if (Operation == OperationType.Edit) + { + SQLiteHelper sQLiteHelper = new db.SQLiteHelper(); + var result = sQLiteHelper.QuerySingle(a=>a.id == dataid); + if (!result.Success) + { + MessageBox.Show("查询失败"); + return; + } + var DataToEdit = result.Data; + 流程名称.Text = DataToEdit.flowname; + 流程编号.Text = DataToEdit.flowid.ToString(); + 步骤.Text = DataToEdit.setp.ToString(); + 期望PLC值.Text = DataToEdit.hopestatus.ToString(); + SelectItemByValue(成功接口, DataToEdit.hopeinterfaceid.ToString()); + 错误PLC值.Text = DataToEdit.errstatus.ToString(); + SelectItemByValue(错误接口, DataToEdit.errinterfaceid.ToString()); + 扫码.Checked = DataToEdit.scan; + 文件上传.Checked = DataToEdit.fileupload; + 螺丝扭力.Checked = DataToEdit.finaltorquevalue; + 螺丝角度.Checked = DataToEdit.finalanglevaluue; + 扭力曲线.Checked = DataToEdit.finaltorquecurve; + 压力曲线.Checked = DataToEdit.finalpressurecurve; + 气密参数.Checked = DataToEdit.airtight; + } + } + + private void SelectItemByValue(ComboBox comboBox1, string value) + { + foreach (t_interface item in comboBox1.Items) + { + if (item.id.ToString() == value) + { + comboBox1.SelectedItem = item; + break; + } + } + } + } +} diff --git a/WindowsFormsApp1/form/editForm/FLow_Insert.resx b/WindowsFormsApp1/form/editForm/FLow_Insert.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/WindowsFormsApp1/form/editForm/FLow_Insert.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/WindowsFormsApp1/form/editForm/KeyValue_Insert.Designer.cs b/WindowsFormsApp1/form/editForm/KeyValue_Insert.Designer.cs new file mode 100644 index 0000000..388a505 --- /dev/null +++ b/WindowsFormsApp1/form/editForm/KeyValue_Insert.Designer.cs @@ -0,0 +1,195 @@ +namespace WindowsFormsApp1.form +{ + partial class KeyValue_Insert + { + /// + /// 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.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.label1 = new System.Windows.Forms.Label(); + this.button1 = new System.Windows.Forms.Button(); + this.button2 = new System.Windows.Forms.Button(); + this.关键字 = new System.Windows.Forms.TextBox(); + this.label2 = new System.Windows.Forms.Label(); + this.备注 = new System.Windows.Forms.TextBox(); + this.label7 = new System.Windows.Forms.Label(); + this.值 = new System.Windows.Forms.TextBox(); + this.tableLayoutPanel1.SuspendLayout(); + this.SuspendLayout(); + // + // tableLayoutPanel1 + // + this.tableLayoutPanel1.ColumnCount = 6; + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.Controls.Add(this.label1, 1, 1); + this.tableLayoutPanel1.Controls.Add(this.button1, 1, 8); + this.tableLayoutPanel1.Controls.Add(this.button2, 3, 8); + this.tableLayoutPanel1.Controls.Add(this.label2, 1, 3); + this.tableLayoutPanel1.Controls.Add(this.label7, 1, 2); + this.tableLayoutPanel1.Controls.Add(this.关键字, 2, 1); + this.tableLayoutPanel1.Controls.Add(this.值, 2, 2); + this.tableLayoutPanel1.Controls.Add(this.备注, 2, 3); + this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + this.tableLayoutPanel1.RowCount = 10; + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.Size = new System.Drawing.Size(1087, 854); + this.tableLayoutPanel1.TabIndex = 0; + // + // label1 + // + this.label1.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label1.Location = new System.Drawing.Point(168, 113); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(96, 28); + this.label1.TabIndex = 0; + this.label1.Text = "关键字"; + // + // button1 + // + this.button1.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.button1, 2); + this.button1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.button1.Location = new System.Drawing.Point(228, 683); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(194, 79); + this.button1.TabIndex = 14; + this.button1.Text = "保存"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // button2 + // + this.button2.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.button2, 2); + this.button2.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.button2.Location = new System.Drawing.Point(664, 683); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(190, 79); + this.button2.TabIndex = 15; + this.button2.Text = "取消"; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.button2_Click); + // + // 关键字 + // + this.关键字.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.关键字, 3); + this.关键字.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.关键字.Location = new System.Drawing.Point(367, 108); + this.关键字.Name = "关键字"; + this.关键字.Size = new System.Drawing.Size(566, 39); + this.关键字.TabIndex = 16; + // + // label2 + // + this.label2.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label2.AutoSize = true; + this.label2.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label2.Location = new System.Drawing.Point(182, 283); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(68, 28); + this.label2.TabIndex = 1; + this.label2.Text = "备注"; + // + // 备注 + // + this.备注.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.备注, 3); + this.备注.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.备注.Location = new System.Drawing.Point(367, 278); + this.备注.Name = "备注"; + this.备注.Size = new System.Drawing.Size(566, 39); + this.备注.TabIndex = 17; + // + // label7 + // + this.label7.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label7.AutoSize = true; + this.label7.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label7.Location = new System.Drawing.Point(196, 198); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(40, 28); + this.label7.TabIndex = 29; + this.label7.Text = "值"; + // + // 值 + // + this.值.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.值, 3); + this.值.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.值.Location = new System.Drawing.Point(367, 193); + this.值.Name = "值"; + this.值.Size = new System.Drawing.Size(566, 39); + this.值.TabIndex = 30; + // + // KeyValue_Insert + // + this.AutoScaleDimensions = new System.Drawing.SizeF(11F, 21F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1087, 854); + this.Controls.Add(this.tableLayoutPanel1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.Name = "KeyValue_Insert"; + this.Text = "Form_Insert"; + this.Load += new System.EventHandler(this.FLOW_Insert_Load); + this.tableLayoutPanel1.ResumeLayout(false); + this.tableLayoutPanel1.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.Button button2; + private System.Windows.Forms.TextBox 备注; + private System.Windows.Forms.TextBox 关键字; + private System.Windows.Forms.Label label7; + private System.Windows.Forms.TextBox 值; + } +} \ No newline at end of file diff --git a/WindowsFormsApp1/form/editForm/KeyValue_Insert.cs b/WindowsFormsApp1/form/editForm/KeyValue_Insert.cs new file mode 100644 index 0000000..e903af9 --- /dev/null +++ b/WindowsFormsApp1/form/editForm/KeyValue_Insert.cs @@ -0,0 +1,87 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using WindowsFormsApp1.db; +using WindowsFormsApp1.mod; + +namespace WindowsFormsApp1.form +{ + public partial class KeyValue_Insert : Form + { + public OperationType Operation { get; set; } + public int dataid { get; set; } + + public KeyValue_Insert() + { + InitializeComponent(); + } + + private void button1_Click(object sender, EventArgs e) + { + //保存 + if (string.IsNullOrWhiteSpace(关键字.Text)) + { + MessageBox.Show("关键字不能为空"); + return; + } + if (string.IsNullOrWhiteSpace(值.Text)) + { + MessageBox.Show("值不能为空"); + return; + } + if (string.IsNullOrWhiteSpace(备注.Text)) + { + MessageBox.Show("备注不能为空"); + return; + } + + t_keyvalue t_Flow = new t_keyvalue(); + t_Flow.key = 关键字.Text; + t_Flow.value = 值.Text; + t_Flow.remark = 备注.Text; + + SQLiteHelper sQLiteHelper1 = new db.SQLiteHelper(); + if (Operation == OperationType.Edit) + { + t_Flow.id = dataid; + sQLiteHelper1.Update(t_Flow); + } + else + { + sQLiteHelper1.Insert(t_Flow); + } + MessageBox.Show("保存成功"); + this.Close(); + } + + private void button2_Click(object sender, EventArgs e) + { + //取消 + this.Close(); + } + + private void FLOW_Insert_Load(object sender, EventArgs e) + { + if (Operation == OperationType.Edit) + { + SQLiteHelper sQLiteHelper = new db.SQLiteHelper(); + var result = sQLiteHelper.QuerySingle(a=>a.id == dataid); + if (!result.Success) + { + MessageBox.Show("查询失败"); + return; + } + var DataToEdit = result.Data; + 关键字.Text = DataToEdit.key; + 值.Text = DataToEdit.value ; + 备注.Text = DataToEdit.remark; + } + } + } +} diff --git a/WindowsFormsApp1/form/editForm/KeyValue_Insert.resx b/WindowsFormsApp1/form/editForm/KeyValue_Insert.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/WindowsFormsApp1/form/editForm/KeyValue_Insert.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/WindowsFormsApp1/form/editForm/LinePLC_Insert.Designer.cs b/WindowsFormsApp1/form/editForm/LinePLC_Insert.Designer.cs new file mode 100644 index 0000000..fcc143f --- /dev/null +++ b/WindowsFormsApp1/form/editForm/LinePLC_Insert.Designer.cs @@ -0,0 +1,170 @@ +namespace WindowsFormsApp1.form +{ + partial class LinePLC_Insert + { + /// + /// 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.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.button1 = new System.Windows.Forms.Button(); + this.button2 = new System.Windows.Forms.Button(); + this.label4 = new System.Windows.Forms.Label(); + this.label6 = new System.Windows.Forms.Label(); + this.产线 = new System.Windows.Forms.ComboBox(); + this.PLC = new System.Windows.Forms.ComboBox(); + this.tableLayoutPanel1.SuspendLayout(); + this.SuspendLayout(); + // + // tableLayoutPanel1 + // + this.tableLayoutPanel1.ColumnCount = 6; + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.Controls.Add(this.button1, 1, 8); + this.tableLayoutPanel1.Controls.Add(this.button2, 3, 8); + this.tableLayoutPanel1.Controls.Add(this.label4, 1, 1); + this.tableLayoutPanel1.Controls.Add(this.label6, 1, 3); + this.tableLayoutPanel1.Controls.Add(this.产线, 2, 1); + this.tableLayoutPanel1.Controls.Add(this.PLC, 2, 3); + this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + this.tableLayoutPanel1.RowCount = 10; + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.Size = new System.Drawing.Size(1087, 854); + this.tableLayoutPanel1.TabIndex = 0; + // + // button1 + // + this.button1.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.button1, 2); + this.button1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.button1.Location = new System.Drawing.Point(228, 683); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(194, 79); + this.button1.TabIndex = 14; + this.button1.Text = "保存"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // button2 + // + this.button2.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.button2, 2); + this.button2.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.button2.Location = new System.Drawing.Point(664, 683); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(190, 79); + this.button2.TabIndex = 15; + this.button2.Text = "取消"; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.button2_Click); + // + // label4 + // + this.label4.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label4.AutoSize = true; + this.label4.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label4.Location = new System.Drawing.Point(154, 113); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(124, 28); + this.label4.TabIndex = 3; + this.label4.Text = "产线名称"; + // + // label6 + // + this.label6.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label6.AutoSize = true; + this.label6.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label6.Location = new System.Drawing.Point(161, 283); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(110, 28); + this.label6.TabIndex = 5; + this.label6.Text = "关联PLC"; + // + // 产线 + // + this.产线.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.产线, 3); + this.产线.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.产线.FormattingEnabled = true; + this.产线.Location = new System.Drawing.Point(341, 113); + this.产线.Name = "产线"; + this.产线.Size = new System.Drawing.Size(619, 36); + this.产线.TabIndex = 31; + // + // PLC + // + this.PLC.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.PLC, 3); + this.PLC.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.PLC.FormattingEnabled = true; + this.PLC.Location = new System.Drawing.Point(341, 283); + this.PLC.Name = "PLC"; + this.PLC.Size = new System.Drawing.Size(619, 36); + this.PLC.TabIndex = 32; + // + // LinePLC_Insert + // + this.AutoScaleDimensions = new System.Drawing.SizeF(11F, 21F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1087, 854); + this.Controls.Add(this.tableLayoutPanel1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.Name = "LinePLC_Insert"; + this.Text = "Form_Insert"; + this.Load += new System.EventHandler(this.FLOW_Insert_Load); + this.tableLayoutPanel1.ResumeLayout(false); + this.tableLayoutPanel1.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.Button button2; + private System.Windows.Forms.ComboBox 产线; + private System.Windows.Forms.ComboBox PLC; + } +} \ No newline at end of file diff --git a/WindowsFormsApp1/form/editForm/LinePLC_Insert.cs b/WindowsFormsApp1/form/editForm/LinePLC_Insert.cs new file mode 100644 index 0000000..a920a84 --- /dev/null +++ b/WindowsFormsApp1/form/editForm/LinePLC_Insert.cs @@ -0,0 +1,130 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using WindowsFormsApp1.db; +using WindowsFormsApp1.mod; + +namespace WindowsFormsApp1.form +{ + public partial class LinePLC_Insert : Form + { + public OperationType Operation { get; set; } + public int dataid { get; set; } + + public LinePLC_Insert() + { + InitializeComponent(); + } + + private void button1_Click(object sender, EventArgs e) + { + //保存 + if (产线.SelectedValue == null) + { + MessageBox.Show("产线不可为空"); + } + if (PLC.SelectedValue == null) + { + MessageBox.Show("PLC不可为空"); + } + + t_lineplc t_Flow = new t_lineplc(); + t_Flow.lineid = (int)产线.SelectedValue; + t_Flow.plcid = (int)PLC.SelectedValue; + + + SQLiteHelper sQLiteHelper1 = new db.SQLiteHelper(); + if (Operation == OperationType.Edit) + { + t_Flow.id = dataid; + sQLiteHelper1.Update(t_Flow); + } + else + { + sQLiteHelper1.Insert(t_Flow); + } + MessageBox.Show("保存成功"); + this.Close(); + } + + private void button2_Click(object sender, EventArgs e) + { + //取消 + this.Close(); + } + + private void FLOW_Insert_Load(object sender, EventArgs e) + { + SQLiteHelper sQLiteHelper1 = new db.SQLiteHelper(); + var result_combox1 = sQLiteHelper1.QueryAll(); + if (!result_combox1.Success) + { + MessageBox.Show("查询失败"); + return; + } + + + // 绑定数据源到 ComboBox + 产线.DataSource = result_combox1.Data; + 产线.DisplayMember = "linename"; + 产线.ValueMember = "id"; + + + SQLiteHelper sQLiteHelper2 = new db.SQLiteHelper(); + var result_combox2 = sQLiteHelper2.QueryAll(); + if (!result_combox2.Success) + { + MessageBox.Show("查询失败"); + return; + } + + PLC.DataSource = result_combox2.Data; + PLC.DisplayMember = "plcname"; + PLC.ValueMember = "id"; + + if (Operation == OperationType.Edit) + { + SQLiteHelper sQLiteHelper = new db.SQLiteHelper(); + var result = sQLiteHelper.QuerySingle(a=>a.id == dataid); + if (!result.Success) + { + MessageBox.Show("查询失败"); + return; + } + var DataToEdit = result.Data; + SelectItemByValue1(产线, DataToEdit.lineid.ToString()); + SelectItemByValue2(PLC, DataToEdit.plcid.ToString()); + } + } + + private void SelectItemByValue1(ComboBox comboBox1, string value) + { + foreach (t_line item in comboBox1.Items) + { + if (item.id.ToString() == value) + { + comboBox1.SelectedItem = item; + break; + } + } + } + + private void SelectItemByValue2(ComboBox comboBox1, string value) + { + foreach (t_plc item in comboBox1.Items) + { + if (item.id.ToString() == value) + { + comboBox1.SelectedItem = item; + break; + } + } + } + } +} diff --git a/WindowsFormsApp1/form/editForm/LinePLC_Insert.resx b/WindowsFormsApp1/form/editForm/LinePLC_Insert.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/WindowsFormsApp1/form/editForm/LinePLC_Insert.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/WindowsFormsApp1/form/editForm/Line_Insert.Designer.cs b/WindowsFormsApp1/form/editForm/Line_Insert.Designer.cs new file mode 100644 index 0000000..74c653d --- /dev/null +++ b/WindowsFormsApp1/form/editForm/Line_Insert.Designer.cs @@ -0,0 +1,250 @@ +namespace WindowsFormsApp1.form +{ + partial class Line_Insert + { + /// + /// 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.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.label1 = new System.Windows.Forms.Label(); + this.button1 = new System.Windows.Forms.Button(); + this.button2 = new System.Windows.Forms.Button(); + this.名称 = new System.Windows.Forms.TextBox(); + this.label4 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.模组 = new System.Windows.Forms.TextBox(); + this.产线类型 = new System.Windows.Forms.TextBox(); + this.label7 = new System.Windows.Forms.Label(); + this.产线编号 = new System.Windows.Forms.TextBox(); + this.关联流程 = new System.Windows.Forms.ComboBox(); + this.tableLayoutPanel1.SuspendLayout(); + this.SuspendLayout(); + // + // tableLayoutPanel1 + // + this.tableLayoutPanel1.ColumnCount = 6; + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.Controls.Add(this.label1, 1, 1); + this.tableLayoutPanel1.Controls.Add(this.button1, 1, 8); + this.tableLayoutPanel1.Controls.Add(this.button2, 3, 8); + this.tableLayoutPanel1.Controls.Add(this.名称, 2, 1); + this.tableLayoutPanel1.Controls.Add(this.label4, 1, 5); + this.tableLayoutPanel1.Controls.Add(this.label3, 1, 4); + this.tableLayoutPanel1.Controls.Add(this.label2, 1, 3); + this.tableLayoutPanel1.Controls.Add(this.模组, 2, 4); + this.tableLayoutPanel1.Controls.Add(this.产线类型, 2, 3); + this.tableLayoutPanel1.Controls.Add(this.label7, 1, 2); + this.tableLayoutPanel1.Controls.Add(this.产线编号, 2, 2); + this.tableLayoutPanel1.Controls.Add(this.关联流程, 2, 5); + this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + this.tableLayoutPanel1.RowCount = 10; + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.Size = new System.Drawing.Size(1087, 854); + this.tableLayoutPanel1.TabIndex = 0; + // + // label1 + // + this.label1.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label1.Location = new System.Drawing.Point(182, 113); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(68, 28); + this.label1.TabIndex = 0; + this.label1.Text = "名称"; + // + // button1 + // + this.button1.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.button1, 2); + this.button1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.button1.Location = new System.Drawing.Point(228, 683); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(194, 79); + this.button1.TabIndex = 14; + this.button1.Text = "保存"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // button2 + // + this.button2.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.button2, 2); + this.button2.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.button2.Location = new System.Drawing.Point(664, 683); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(190, 79); + this.button2.TabIndex = 15; + this.button2.Text = "取消"; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.button2_Click); + // + // 名称 + // + this.名称.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.名称, 3); + this.名称.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.名称.Location = new System.Drawing.Point(364, 108); + this.名称.Name = "名称"; + this.名称.Size = new System.Drawing.Size(573, 39); + this.名称.TabIndex = 16; + // + // label4 + // + this.label4.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label4.AutoSize = true; + this.label4.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label4.Location = new System.Drawing.Point(154, 453); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(124, 28); + this.label4.TabIndex = 3; + this.label4.Text = "关联流程"; + // + // label3 + // + this.label3.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label3.AutoSize = true; + this.label3.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label3.Location = new System.Drawing.Point(182, 368); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(68, 28); + this.label3.TabIndex = 2; + this.label3.Text = "模组"; + // + // label2 + // + this.label2.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label2.AutoSize = true; + this.label2.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label2.Location = new System.Drawing.Point(154, 283); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(124, 28); + this.label2.TabIndex = 1; + this.label2.Text = "产线类型"; + // + // 模组 + // + this.模组.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.模组, 3); + this.模组.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.模组.Location = new System.Drawing.Point(364, 363); + this.模组.Name = "模组"; + this.模组.Size = new System.Drawing.Size(573, 39); + this.模组.TabIndex = 20; + // + // 产线类型 + // + this.产线类型.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.产线类型, 3); + this.产线类型.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.产线类型.Location = new System.Drawing.Point(364, 278); + this.产线类型.Name = "产线类型"; + this.产线类型.Size = new System.Drawing.Size(573, 39); + this.产线类型.TabIndex = 17; + // + // label7 + // + this.label7.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label7.AutoSize = true; + this.label7.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label7.Location = new System.Drawing.Point(154, 198); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(124, 28); + this.label7.TabIndex = 29; + this.label7.Text = "产线编号"; + // + // 产线编号 + // + this.产线编号.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.产线编号, 3); + this.产线编号.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.产线编号.Location = new System.Drawing.Point(364, 193); + this.产线编号.Name = "产线编号"; + this.产线编号.Size = new System.Drawing.Size(573, 39); + this.产线编号.TabIndex = 30; + // + // 关联流程 + // + this.关联流程.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.关联流程, 3); + this.关联流程.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.关联流程.FormattingEnabled = true; + this.关联流程.Location = new System.Drawing.Point(364, 453); + this.关联流程.Name = "关联流程"; + this.关联流程.Size = new System.Drawing.Size(573, 36); + this.关联流程.TabIndex = 31; + // + // Line_Insert + // + this.AutoScaleDimensions = new System.Drawing.SizeF(11F, 21F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1087, 854); + this.Controls.Add(this.tableLayoutPanel1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.Name = "Line_Insert"; + this.Text = "Form_Insert"; + this.Load += new System.EventHandler(this.FLOW_Insert_Load); + this.tableLayoutPanel1.ResumeLayout(false); + this.tableLayoutPanel1.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.Button button2; + private System.Windows.Forms.TextBox 产线类型; + private System.Windows.Forms.TextBox 名称; + private System.Windows.Forms.TextBox 模组; + private System.Windows.Forms.Label label7; + private System.Windows.Forms.TextBox 产线编号; + private System.Windows.Forms.ComboBox 关联流程; + } +} \ No newline at end of file diff --git a/WindowsFormsApp1/form/editForm/Line_Insert.cs b/WindowsFormsApp1/form/editForm/Line_Insert.cs new file mode 100644 index 0000000..aeba319 --- /dev/null +++ b/WindowsFormsApp1/form/editForm/Line_Insert.cs @@ -0,0 +1,142 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using WindowsFormsApp1.db; +using WindowsFormsApp1.mod; + +namespace WindowsFormsApp1.form +{ + public partial class Line_Insert : Form + { + public OperationType Operation { get; set; } + public int dataid { get; set; } + + public Line_Insert() + { + InitializeComponent(); + } + + private void button1_Click(object sender, EventArgs e) + { + //保存 + + if (string.IsNullOrWhiteSpace(名称.Text)) + { + MessageBox.Show("名称不能为空"); + return; + } + if (string.IsNullOrWhiteSpace(产线类型.Text)) + { + MessageBox.Show("产线类型不能为空"); + return; + } + if (string.IsNullOrWhiteSpace(产线编号.Text)) + { + MessageBox.Show("产线编号不能为空"); + return; + } + if (string.IsNullOrWhiteSpace(模组.Text)) + { + MessageBox.Show("模组不能为空"); + return; + } + if (关联流程.SelectedValue == null || (int)关联流程.SelectedValue == 0) + { + MessageBox.Show("关联流程不能为空"); + return; + } + + t_line t_Flow = new t_line(); + t_Flow.linename = 名称.Text; + t_Flow.linetype = 产线类型.Text; + t_Flow.linecode = 产线编号.Text; + t_Flow.linemode = 模组.Text; + t_Flow.flowid = (int)关联流程.SelectedValue; + + SQLiteHelper sQLiteHelper1 = new db.SQLiteHelper(); + if (Operation == OperationType.Edit) + { + t_Flow.id = dataid; + sQLiteHelper1.Update(t_Flow); + } + else + { + sQLiteHelper1.Insert(t_Flow); + } + MessageBox.Show("保存成功"); + this.Close(); + } + + private void button2_Click(object sender, EventArgs e) + { + //取消 + this.Close(); + } + + private void FLOW_Insert_Load(object sender, EventArgs e) + { + SQLiteHelper sQLiteHelper1 = new db.SQLiteHelper(); + var result_combox1 = sQLiteHelper1.QueryAll(); + if (!result_combox1.Success) + { + MessageBox.Show("查询失败"); + return; + } + List list = new List(); + var groupre = result_combox1.Data.GroupBy(a=>a.flowid); + foreach (var group in groupre) { + list.Add(new flow_combox + { + id = group.Key, + flowname = group.First().flowname + }); + } + + // 绑定数据源到 ComboBox + 关联流程.DataSource = list; + 关联流程.DisplayMember = "flowname"; + 关联流程.ValueMember = "id"; + + if (Operation == OperationType.Edit) + { + SQLiteHelper sQLiteHelper = new db.SQLiteHelper(); + var result = sQLiteHelper.QuerySingle(a=>a.id == dataid); + if (!result.Success) + { + MessageBox.Show("查询失败"); + return; + } + var DataToEdit = result.Data; + 名称.Text = DataToEdit.linename; + 产线编号.Text = DataToEdit.linecode; + 产线类型.Text = DataToEdit.linetype; + 模组.Text = DataToEdit.linemode; + SelectItemByValue(关联流程, DataToEdit.flowid.ToString()); + } + } + + private void SelectItemByValue(ComboBox comboBox1, string value) + { + foreach (flow_combox item in comboBox1.Items) + { + if (item.id.ToString() == value) + { + comboBox1.SelectedItem = item; + break; + } + } + } + } + + public class flow_combox + { + public int id { get; set; } + public string flowname{ get; set; } + } +} diff --git a/WindowsFormsApp1/form/editForm/Line_Insert.resx b/WindowsFormsApp1/form/editForm/Line_Insert.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/WindowsFormsApp1/form/editForm/Line_Insert.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/WindowsFormsApp1/form/editForm/MESUrl_Insert.Designer.cs b/WindowsFormsApp1/form/editForm/MESUrl_Insert.Designer.cs new file mode 100644 index 0000000..04c580f --- /dev/null +++ b/WindowsFormsApp1/form/editForm/MESUrl_Insert.Designer.cs @@ -0,0 +1,195 @@ +namespace WindowsFormsApp1.form +{ + partial class MESUrl_Insert + { + /// + /// 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.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.label1 = new System.Windows.Forms.Label(); + this.button1 = new System.Windows.Forms.Button(); + this.button2 = new System.Windows.Forms.Button(); + this.名称 = new System.Windows.Forms.TextBox(); + this.label2 = new System.Windows.Forms.Label(); + this.网址 = new System.Windows.Forms.TextBox(); + this.label7 = new System.Windows.Forms.Label(); + this.接口 = new System.Windows.Forms.TextBox(); + this.tableLayoutPanel1.SuspendLayout(); + this.SuspendLayout(); + // + // tableLayoutPanel1 + // + this.tableLayoutPanel1.ColumnCount = 6; + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.Controls.Add(this.label1, 1, 1); + this.tableLayoutPanel1.Controls.Add(this.button1, 1, 8); + this.tableLayoutPanel1.Controls.Add(this.button2, 3, 8); + this.tableLayoutPanel1.Controls.Add(this.label2, 1, 3); + this.tableLayoutPanel1.Controls.Add(this.网址, 2, 3); + this.tableLayoutPanel1.Controls.Add(this.label7, 1, 2); + this.tableLayoutPanel1.Controls.Add(this.接口, 2, 2); + this.tableLayoutPanel1.Controls.Add(this.名称, 2, 1); + this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + this.tableLayoutPanel1.RowCount = 10; + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.Size = new System.Drawing.Size(1087, 854); + this.tableLayoutPanel1.TabIndex = 0; + // + // label1 + // + this.label1.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label1.Location = new System.Drawing.Point(182, 113); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(68, 28); + this.label1.TabIndex = 0; + this.label1.Text = "名称"; + // + // button1 + // + this.button1.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.button1, 2); + this.button1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.button1.Location = new System.Drawing.Point(228, 683); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(194, 79); + this.button1.TabIndex = 14; + this.button1.Text = "保存"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // button2 + // + this.button2.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.button2, 2); + this.button2.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.button2.Location = new System.Drawing.Point(664, 683); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(190, 79); + this.button2.TabIndex = 15; + this.button2.Text = "取消"; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.button2_Click); + // + // 名称 + // + this.名称.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.名称, 3); + this.名称.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.名称.Location = new System.Drawing.Point(340, 108); + this.名称.Name = "名称"; + this.名称.Size = new System.Drawing.Size(620, 39); + this.名称.TabIndex = 16; + // + // label2 + // + this.label2.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label2.AutoSize = true; + this.label2.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label2.Location = new System.Drawing.Point(182, 283); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(68, 28); + this.label2.TabIndex = 1; + this.label2.Text = "网址"; + // + // 网址 + // + this.网址.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.网址, 3); + this.网址.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.网址.Location = new System.Drawing.Point(340, 278); + this.网址.Name = "网址"; + this.网址.Size = new System.Drawing.Size(620, 39); + this.网址.TabIndex = 17; + // + // label7 + // + this.label7.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label7.AutoSize = true; + this.label7.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label7.Location = new System.Drawing.Point(182, 198); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(68, 28); + this.label7.TabIndex = 29; + this.label7.Text = "接口"; + // + // 接口 + // + this.接口.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.接口, 3); + this.接口.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.接口.Location = new System.Drawing.Point(340, 193); + this.接口.Name = "接口"; + this.接口.Size = new System.Drawing.Size(620, 39); + this.接口.TabIndex = 30; + // + // MESUrl_Insert + // + this.AutoScaleDimensions = new System.Drawing.SizeF(11F, 21F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1087, 854); + this.Controls.Add(this.tableLayoutPanel1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.Name = "MESUrl_Insert"; + this.Text = "Form_Insert"; + this.Load += new System.EventHandler(this.FLOW_Insert_Load); + this.tableLayoutPanel1.ResumeLayout(false); + this.tableLayoutPanel1.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.Button button2; + private System.Windows.Forms.TextBox 网址; + private System.Windows.Forms.TextBox 名称; + private System.Windows.Forms.Label label7; + private System.Windows.Forms.TextBox 接口; + } +} \ No newline at end of file diff --git a/WindowsFormsApp1/form/editForm/MESUrl_Insert.cs b/WindowsFormsApp1/form/editForm/MESUrl_Insert.cs new file mode 100644 index 0000000..4e8415a --- /dev/null +++ b/WindowsFormsApp1/form/editForm/MESUrl_Insert.cs @@ -0,0 +1,87 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using WindowsFormsApp1.db; +using WindowsFormsApp1.mod; + +namespace WindowsFormsApp1.form +{ + public partial class MESUrl_Insert : Form + { + public OperationType Operation { get; set; } + public int dataid { get; set; } + + public MESUrl_Insert() + { + InitializeComponent(); + } + + private void button1_Click(object sender, EventArgs e) + { + + if (string.IsNullOrWhiteSpace(名称.Text)) + { + MessageBox.Show("名称不能为空"); + return; + } + if (string.IsNullOrWhiteSpace(接口.Text)) + { + MessageBox.Show("接口不能为空"); + return; + } + if (string.IsNullOrWhiteSpace(网址.Text)) + { + MessageBox.Show("网址不能为空"); + return; + } + + t_interface t_Flow = new t_interface(); + t_Flow.name = 名称.Text; + t_Flow.code = 接口.Text; + t_Flow.url = 网址.Text; + + SQLiteHelper sQLiteHelper1 = new db.SQLiteHelper(); + if (Operation == OperationType.Edit) + { + t_Flow.id = dataid; + sQLiteHelper1.Update(t_Flow); + } + else + { + sQLiteHelper1.Insert(t_Flow); + } + MessageBox.Show("保存成功"); + this.Close(); + } + + private void button2_Click(object sender, EventArgs e) + { + //取消 + this.Close(); + } + + private void FLOW_Insert_Load(object sender, EventArgs e) + { + if (Operation == OperationType.Edit) + { + SQLiteHelper sQLiteHelper = new db.SQLiteHelper(); + var result = sQLiteHelper.QuerySingle(a=>a.id == dataid); + if (!result.Success) + { + MessageBox.Show("查询失败"); + return; + } + var DataToEdit = result.Data; + 名称.Text = DataToEdit.name; + 接口.Text = DataToEdit.code; + 网址.Text = DataToEdit.url; + } + } + } +} diff --git a/WindowsFormsApp1/form/editForm/MESUrl_Insert.resx b/WindowsFormsApp1/form/editForm/MESUrl_Insert.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/WindowsFormsApp1/form/editForm/MESUrl_Insert.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/WindowsFormsApp1/form/editForm/PlcAddress_Insert.Designer.cs b/WindowsFormsApp1/form/editForm/PlcAddress_Insert.Designer.cs new file mode 100644 index 0000000..c5122df --- /dev/null +++ b/WindowsFormsApp1/form/editForm/PlcAddress_Insert.Designer.cs @@ -0,0 +1,333 @@ +namespace WindowsFormsApp1.form +{ + partial class PlcAddress_Insert + { + /// + /// 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.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.数据名称 = new System.Windows.Forms.TextBox(); + this.button1 = new System.Windows.Forms.Button(); + this.button2 = new System.Windows.Forms.Button(); + this.label4 = new System.Windows.Forms.Label(); + this.db地址 = new System.Windows.Forms.TextBox(); + this.label7 = new System.Windows.Forms.Label(); + this.长度 = new System.Windows.Forms.TextBox(); + this.读写 = new System.Windows.Forms.ComboBox(); + this.db块 = new System.Windows.Forms.TextBox(); + this.备注 = new System.Windows.Forms.TextBox(); + this.类型 = new System.Windows.Forms.ComboBox(); + this.label2 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.label5 = new System.Windows.Forms.Label(); + this.label6 = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.PLC名称 = new System.Windows.Forms.ComboBox(); + this.label8 = new System.Windows.Forms.Label(); + this.tableLayoutPanel1.SuspendLayout(); + this.SuspendLayout(); + // + // tableLayoutPanel1 + // + this.tableLayoutPanel1.ColumnCount = 6; + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.Controls.Add(this.数据名称, 2, 1); + this.tableLayoutPanel1.Controls.Add(this.button1, 1, 8); + this.tableLayoutPanel1.Controls.Add(this.button2, 3, 8); + this.tableLayoutPanel1.Controls.Add(this.label4, 1, 5); + this.tableLayoutPanel1.Controls.Add(this.db地址, 2, 4); + this.tableLayoutPanel1.Controls.Add(this.label7, 1, 2); + this.tableLayoutPanel1.Controls.Add(this.长度, 2, 6); + this.tableLayoutPanel1.Controls.Add(this.读写, 2, 2); + this.tableLayoutPanel1.Controls.Add(this.db块, 2, 3); + this.tableLayoutPanel1.Controls.Add(this.备注, 2, 7); + this.tableLayoutPanel1.Controls.Add(this.类型, 2, 5); + this.tableLayoutPanel1.Controls.Add(this.label2, 1, 3); + this.tableLayoutPanel1.Controls.Add(this.label3, 1, 4); + this.tableLayoutPanel1.Controls.Add(this.label5, 1, 6); + this.tableLayoutPanel1.Controls.Add(this.label6, 1, 7); + this.tableLayoutPanel1.Controls.Add(this.label1, 1, 0); + this.tableLayoutPanel1.Controls.Add(this.PLC名称, 2, 0); + this.tableLayoutPanel1.Controls.Add(this.label8, 1, 1); + this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + this.tableLayoutPanel1.RowCount = 10; + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.Size = new System.Drawing.Size(931, 732); + this.tableLayoutPanel1.TabIndex = 0; + // + // 数据名称 + // + this.数据名称.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.数据名称, 3); + this.数据名称.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.数据名称.Location = new System.Drawing.Point(282, 90); + this.数据名称.Name = "数据名称"; + this.数据名称.Size = new System.Drawing.Size(552, 39); + this.数据名称.TabIndex = 35; + // + // button1 + // + this.button1.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.button1, 2); + this.button1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.button1.Location = new System.Drawing.Point(182, 587); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(194, 67); + this.button1.TabIndex = 14; + this.button1.Text = "保存"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // button2 + // + this.button2.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.button2, 2); + this.button2.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.button2.Location = new System.Drawing.Point(556, 587); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(190, 67); + this.button2.TabIndex = 15; + this.button2.Text = "取消"; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.button2_Click); + // + // label4 + // + this.label4.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label4.AutoSize = true; + this.label4.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label4.Location = new System.Drawing.Point(124, 387); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(124, 28); + this.label4.TabIndex = 3; + this.label4.Text = "数据类型"; + // + // db地址 + // + this.db地址.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.db地址, 3); + this.db地址.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.db地址.Location = new System.Drawing.Point(282, 309); + this.db地址.Name = "db地址"; + this.db地址.Size = new System.Drawing.Size(552, 39); + this.db地址.TabIndex = 20; + // + // label7 + // + this.label7.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label7.AutoSize = true; + this.label7.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label7.Location = new System.Drawing.Point(124, 168); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(124, 28); + this.label7.TabIndex = 29; + this.label7.Text = "读写类型"; + // + // 长度 + // + this.长度.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.长度, 3); + this.长度.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.长度.Location = new System.Drawing.Point(282, 455); + this.长度.Name = "长度"; + this.长度.Size = new System.Drawing.Size(552, 39); + this.长度.TabIndex = 18; + // + // 读写 + // + this.读写.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.读写, 3); + this.读写.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.读写.FormattingEnabled = true; + this.读写.Location = new System.Drawing.Point(282, 168); + this.读写.Name = "读写"; + this.读写.Size = new System.Drawing.Size(552, 36); + this.读写.TabIndex = 31; + // + // db块 + // + this.db块.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.db块, 3); + this.db块.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.db块.Location = new System.Drawing.Point(282, 236); + this.db块.Name = "db块"; + this.db块.Size = new System.Drawing.Size(552, 39); + this.db块.TabIndex = 30; + // + // 备注 + // + this.备注.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.备注, 3); + this.备注.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.备注.Location = new System.Drawing.Point(282, 528); + this.备注.Name = "备注"; + this.备注.Size = new System.Drawing.Size(552, 39); + this.备注.TabIndex = 17; + // + // 类型 + // + this.类型.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.类型, 3); + this.类型.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.类型.FormattingEnabled = true; + this.类型.Location = new System.Drawing.Point(282, 387); + this.类型.Name = "类型"; + this.类型.Size = new System.Drawing.Size(552, 36); + this.类型.TabIndex = 32; + // + // label2 + // + this.label2.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label2.AutoSize = true; + this.label2.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label2.Location = new System.Drawing.Point(124, 241); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(124, 28); + this.label2.TabIndex = 1; + this.label2.Text = "DB块地址"; + // + // label3 + // + this.label3.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label3.AutoSize = true; + this.label3.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label3.Location = new System.Drawing.Point(138, 314); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(96, 28); + this.label3.TabIndex = 2; + this.label3.Text = "DB地址"; + // + // label5 + // + this.label5.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label5.AutoSize = true; + this.label5.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label5.Location = new System.Drawing.Point(124, 460); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(124, 28); + this.label5.TabIndex = 4; + this.label5.Text = "字节长度"; + // + // label6 + // + this.label6.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label6.AutoSize = true; + this.label6.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label6.Location = new System.Drawing.Point(152, 533); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(68, 28); + this.label6.TabIndex = 5; + this.label6.Text = "备注"; + // + // label1 + // + this.label1.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label1.Location = new System.Drawing.Point(131, 22); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(110, 28); + this.label1.TabIndex = 0; + this.label1.Text = "PLC名称"; + // + // PLC名称 + // + this.PLC名称.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.PLC名称, 3); + this.PLC名称.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.PLC名称.FormattingEnabled = true; + this.PLC名称.Location = new System.Drawing.Point(282, 22); + this.PLC名称.Name = "PLC名称"; + this.PLC名称.Size = new System.Drawing.Size(552, 36); + this.PLC名称.TabIndex = 33; + // + // label8 + // + this.label8.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label8.AutoSize = true; + this.label8.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label8.Location = new System.Drawing.Point(124, 95); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(124, 28); + this.label8.TabIndex = 34; + this.label8.Text = "数据名称"; + // + // PlcAddress_Insert + // + this.AutoScaleDimensions = new System.Drawing.SizeF(11F, 21F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(931, 732); + this.Controls.Add(this.tableLayoutPanel1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.Name = "PlcAddress_Insert"; + this.Text = "Form_Insert"; + this.Load += new System.EventHandler(this.FLOW_Insert_Load); + this.tableLayoutPanel1.ResumeLayout(false); + this.tableLayoutPanel1.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.Button button2; + private System.Windows.Forms.TextBox 备注; + private System.Windows.Forms.TextBox db地址; + private System.Windows.Forms.TextBox 长度; + private System.Windows.Forms.Label label7; + private System.Windows.Forms.TextBox db块; + private System.Windows.Forms.ComboBox 读写; + private System.Windows.Forms.ComboBox 类型; + private System.Windows.Forms.ComboBox PLC名称; + private System.Windows.Forms.TextBox 数据名称; + private System.Windows.Forms.Label label8; + } +} \ No newline at end of file diff --git a/WindowsFormsApp1/form/editForm/PlcAddress_Insert.cs b/WindowsFormsApp1/form/editForm/PlcAddress_Insert.cs new file mode 100644 index 0000000..7598fa6 --- /dev/null +++ b/WindowsFormsApp1/form/editForm/PlcAddress_Insert.cs @@ -0,0 +1,186 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using WindowsFormsApp1.db; +using WindowsFormsApp1.mod; + +namespace WindowsFormsApp1.form +{ + public partial class PlcAddress_Insert : Form + { + public OperationType Operation { get; set; } + public int dataid { get; set; } + + public PlcAddress_Insert() + { + InitializeComponent(); + } + + private void button1_Click(object sender, EventArgs e) + { + //保存 + int _db; + int _legth; + if (!int.TryParse(db地址.Text, out _db)) + { + MessageBox.Show("db地址不是数字类型"); + return; + } + if (!int.TryParse(长度.Text, out _legth)) + { + MessageBox.Show("长度不是数字类型"); + return; + } + if (string.IsNullOrWhiteSpace(备注.Text)) + { + MessageBox.Show("备注不能为空"); + return; + } + if (string.IsNullOrWhiteSpace(数据名称.Text)) + { + MessageBox.Show("数据名称不能为空"); + return; + } + if (string.IsNullOrWhiteSpace(db块.Text)) + { + MessageBox.Show("db块地址不能为空"); + return; + } + if (类型.SelectedValue == null) + { + MessageBox.Show("类型不能为空"); + return; + } + if (读写.SelectedValue == null) + { + MessageBox.Show("读写类型不能为空"); + return; + } + + + + t_plcaddress t_Flow = new t_plcaddress(); + t_Flow.plcid = (int)PLC名称.SelectedValue; + t_Flow.code = 数据名称.Text; + t_Flow.type = (string)读写.SelectedValue; + t_Flow.dbaddress = db块.Text; + t_Flow.remark = 备注.Text; + t_Flow.addresstypelegth = _legth; + t_Flow.addressoffset = _db; + t_Flow.addresstype = (string)类型.SelectedValue; + + SQLiteHelper sQLiteHelper1 = new db.SQLiteHelper(); + if (Operation == OperationType.Edit) + { + t_Flow.id = dataid; + sQLiteHelper1.Update(t_Flow); + } + else + { + sQLiteHelper1.Insert(t_Flow); + } + MessageBox.Show("保存成功"); + this.Close(); + } + + private void button2_Click(object sender, EventArgs e) + { + //取消 + this.Close(); + } + + private void FLOW_Insert_Load(object sender, EventArgs e) + { + var result1 = new List<_KeyV> + { + new _KeyV{name = "read",value = "read"}, + new _KeyV{name = "write",value = "write"} + }; + + var result2 = new List<_KeyV> + { + new _KeyV{name = "real",value = "real"}, + new _KeyV{name = "string",value = "string"}, + new _KeyV{name = "uint",value = "uint"}, + }; + + // 绑定数据源到 ComboBox + 读写.DataSource = result1; + 读写.DisplayMember = "name"; + 读写.ValueMember = "value"; + + + 类型.DataSource = result2; + 类型.DisplayMember = "name"; + 类型.ValueMember = "value"; + + SQLiteHelper sQLiteHelper1 = new db.SQLiteHelper(); + var result_combox1 = sQLiteHelper1.QueryAll(); + if (!result_combox1.Success) + { + MessageBox.Show("查询失败"); + return; + } + + // 绑定数据源到 ComboBox + PLC名称.DataSource = result_combox1.Data; + PLC名称.DisplayMember = "plcname"; + PLC名称.ValueMember = "id"; + + + if (Operation == OperationType.Edit) + { + SQLiteHelper sQLiteHelper = new db.SQLiteHelper(); + var result = sQLiteHelper.QuerySingle(a=>a.id == dataid); + if (!result.Success) + { + MessageBox.Show("查询失败"); + return; + } + var DataToEdit = result.Data; + 数据名称.Text = DataToEdit.code; + db块.Text = DataToEdit.dbaddress; + db地址.Text = DataToEdit.addressoffset.ToString(); + 长度.Text = DataToEdit.addresstypelegth.ToString(); + 备注.Text = DataToEdit.remark; + SelectItemByValue1(PLC名称, DataToEdit.plcid.ToString()); + SelectItemByValue(读写, DataToEdit.type.ToString()); + SelectItemByValue(类型, DataToEdit.addresstypelegth.ToString()); + } + } + + private void SelectItemByValue(ComboBox comboBox1, string value) + { + foreach (_KeyV item in comboBox1.Items) + { + if (item.value.ToString() == value) + { + comboBox1.SelectedItem = item; + break; + } + } + } + private void SelectItemByValue1(ComboBox comboBox1, string value) + { + foreach (t_plc item in comboBox1.Items) + { + if (item.id.ToString() == value) + { + comboBox1.SelectedItem = item; + break; + } + } + } + } + public class _KeyV + { + public string name { get; set; } + public string value { get; set; } + } +} diff --git a/WindowsFormsApp1/form/editForm/PlcAddress_Insert.resx b/WindowsFormsApp1/form/editForm/PlcAddress_Insert.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/WindowsFormsApp1/form/editForm/PlcAddress_Insert.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/WindowsFormsApp1/form/editForm/Plc_Insert.Designer.cs b/WindowsFormsApp1/form/editForm/Plc_Insert.Designer.cs new file mode 100644 index 0000000..4bfaad4 --- /dev/null +++ b/WindowsFormsApp1/form/editForm/Plc_Insert.Designer.cs @@ -0,0 +1,253 @@ +namespace WindowsFormsApp1.form +{ + partial class Plc_Insert + { + /// + /// 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.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.label1 = new System.Windows.Forms.Label(); + this.button1 = new System.Windows.Forms.Button(); + this.button2 = new System.Windows.Forms.Button(); + this.状态 = new System.Windows.Forms.CheckBox(); + this.名称 = new System.Windows.Forms.TextBox(); + this.报警 = new System.Windows.Forms.CheckBox(); + this.label2 = new System.Windows.Forms.Label(); + this.time = new System.Windows.Forms.TextBox(); + this.label7 = new System.Windows.Forms.Label(); + this.IP = new System.Windows.Forms.TextBox(); + this.label13 = new System.Windows.Forms.Label(); + this.label14 = new System.Windows.Forms.Label(); + this.tableLayoutPanel1.SuspendLayout(); + this.SuspendLayout(); + // + // tableLayoutPanel1 + // + this.tableLayoutPanel1.ColumnCount = 6; + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.Controls.Add(this.label1, 1, 1); + this.tableLayoutPanel1.Controls.Add(this.button1, 1, 8); + this.tableLayoutPanel1.Controls.Add(this.button2, 3, 8); + this.tableLayoutPanel1.Controls.Add(this.名称, 2, 1); + this.tableLayoutPanel1.Controls.Add(this.label2, 1, 3); + this.tableLayoutPanel1.Controls.Add(this.time, 2, 3); + this.tableLayoutPanel1.Controls.Add(this.label7, 1, 2); + this.tableLayoutPanel1.Controls.Add(this.IP, 2, 2); + this.tableLayoutPanel1.Controls.Add(this.label13, 1, 4); + this.tableLayoutPanel1.Controls.Add(this.状态, 2, 4); + this.tableLayoutPanel1.Controls.Add(this.报警, 2, 5); + this.tableLayoutPanel1.Controls.Add(this.label14, 1, 5); + this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + this.tableLayoutPanel1.RowCount = 10; + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.Size = new System.Drawing.Size(1087, 854); + this.tableLayoutPanel1.TabIndex = 0; + // + // label1 + // + this.label1.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label1.Location = new System.Drawing.Point(161, 113); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(110, 28); + this.label1.TabIndex = 0; + this.label1.Text = "PLC名称"; + // + // button1 + // + this.button1.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.button1, 2); + this.button1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.button1.Location = new System.Drawing.Point(228, 683); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(194, 79); + this.button1.TabIndex = 14; + this.button1.Text = "保存"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // button2 + // + this.button2.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.button2, 2); + this.button2.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.button2.Location = new System.Drawing.Point(664, 683); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(190, 79); + this.button2.TabIndex = 15; + this.button2.Text = "取消"; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.button2_Click); + // + // 状态 + // + this.状态.Anchor = System.Windows.Forms.AnchorStyles.None; + this.状态.AutoSize = true; + this.tableLayoutPanel1.SetColumnSpan(this.状态, 3); + this.状态.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.状态.Location = new System.Drawing.Point(639, 372); + this.状态.Name = "状态"; + this.状态.Size = new System.Drawing.Size(22, 21); + this.状态.TabIndex = 23; + this.状态.UseVisualStyleBackColor = true; + // + // 名称 + // + this.名称.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.名称, 3); + this.名称.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.名称.Location = new System.Drawing.Point(343, 108); + this.名称.Name = "名称"; + this.名称.Size = new System.Drawing.Size(615, 39); + this.名称.TabIndex = 16; + // + // 报警 + // + this.报警.Anchor = System.Windows.Forms.AnchorStyles.None; + this.报警.AutoSize = true; + this.tableLayoutPanel1.SetColumnSpan(this.报警, 3); + this.报警.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.报警.Location = new System.Drawing.Point(639, 457); + this.报警.Name = "报警"; + this.报警.Size = new System.Drawing.Size(22, 21); + this.报警.TabIndex = 22; + this.报警.UseVisualStyleBackColor = true; + // + // label2 + // + this.label2.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label2.AutoSize = true; + this.label2.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label2.Location = new System.Drawing.Point(154, 283); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(124, 28); + this.label2.TabIndex = 1; + this.label2.Text = "超时时间"; + // + // time + // + this.time.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.time, 3); + this.time.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.time.Location = new System.Drawing.Point(343, 278); + this.time.Name = "time"; + this.time.Size = new System.Drawing.Size(615, 39); + this.time.TabIndex = 17; + // + // label7 + // + this.label7.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label7.AutoSize = true; + this.label7.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label7.Location = new System.Drawing.Point(168, 198); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(96, 28); + this.label7.TabIndex = 29; + this.label7.Text = "IP地址"; + // + // IP + // + this.IP.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.IP, 3); + this.IP.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.IP.Location = new System.Drawing.Point(343, 193); + this.IP.Name = "IP"; + this.IP.Size = new System.Drawing.Size(615, 39); + this.IP.TabIndex = 30; + // + // label13 + // + this.label13.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label13.AutoSize = true; + this.label13.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label13.Location = new System.Drawing.Point(182, 368); + this.label13.Name = "label13"; + this.label13.Size = new System.Drawing.Size(68, 28); + this.label13.TabIndex = 12; + this.label13.Text = "状态"; + // + // label14 + // + this.label14.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label14.AutoSize = true; + this.label14.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label14.Location = new System.Drawing.Point(182, 453); + this.label14.Name = "label14"; + this.label14.Size = new System.Drawing.Size(68, 28); + this.label14.TabIndex = 13; + this.label14.Text = "报警"; + // + // Plc_Insert + // + this.AutoScaleDimensions = new System.Drawing.SizeF(11F, 21F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1087, 854); + this.Controls.Add(this.tableLayoutPanel1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.Name = "Plc_Insert"; + this.Text = "Form_Insert"; + this.Load += new System.EventHandler(this.FLOW_Insert_Load); + this.tableLayoutPanel1.ResumeLayout(false); + this.tableLayoutPanel1.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label13; + private System.Windows.Forms.Label label14; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.Button button2; + private System.Windows.Forms.TextBox time; + private System.Windows.Forms.TextBox 名称; + private System.Windows.Forms.CheckBox 报警; + private System.Windows.Forms.CheckBox 状态; + private System.Windows.Forms.Label label7; + private System.Windows.Forms.TextBox IP; + } +} \ No newline at end of file diff --git a/WindowsFormsApp1/form/editForm/Plc_Insert.cs b/WindowsFormsApp1/form/editForm/Plc_Insert.cs new file mode 100644 index 0000000..cc041c5 --- /dev/null +++ b/WindowsFormsApp1/form/editForm/Plc_Insert.cs @@ -0,0 +1,92 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using WindowsFormsApp1.db; +using WindowsFormsApp1.mod; + +namespace WindowsFormsApp1.form +{ + public partial class Plc_Insert : Form + { + public OperationType Operation { get; set; } + public int dataid { get; set; } + + public Plc_Insert() + { + InitializeComponent(); + } + + private void button1_Click(object sender, EventArgs e) + { + //保存 + int 超时时间; + + if (!int.TryParse(time.Text,out 超时时间)){ + MessageBox.Show("超时时间不是数字类型"); + return; + } + if (string.IsNullOrWhiteSpace(名称.Text)) + { + MessageBox.Show("流程名称不能为空"); + return; + } + if (string.IsNullOrWhiteSpace(IP.Text)) + { + MessageBox.Show("IP地址不能为空"); + return; + } + + t_plc t_Flow = new t_plc(); + t_Flow.plcname = 名称.Text; + t_Flow.plcip = IP.Text; + t_Flow.timeout = 超时时间; + t_Flow.statues = 状态.Checked; + t_Flow.alarm = 报警.Checked; + + SQLiteHelper sQLiteHelper1 = new db.SQLiteHelper(); + if (Operation == OperationType.Edit) + { + t_Flow.id = dataid; + sQLiteHelper1.Update(t_Flow); + } + else + { + sQLiteHelper1.Insert(t_Flow); + } + MessageBox.Show("保存成功"); + this.Close(); + } + + private void button2_Click(object sender, EventArgs e) + { + //取消 + this.Close(); + } + + private void FLOW_Insert_Load(object sender, EventArgs e) + { + if (Operation == OperationType.Edit) + { + SQLiteHelper sQLiteHelper = new db.SQLiteHelper(); + var result = sQLiteHelper.QuerySingle(a=>a.id == dataid); + if (!result.Success) + { + MessageBox.Show("查询失败"); + return; + } + var DataToEdit = result.Data; + 名称.Text = DataToEdit.plcname; + IP.Text = DataToEdit.plcip; + time.Text = DataToEdit.timeout.ToString(); + 状态.Checked = DataToEdit.statues; + 报警.Checked = DataToEdit.alarm; + } + } + } +} diff --git a/WindowsFormsApp1/form/editForm/Plc_Insert.resx b/WindowsFormsApp1/form/editForm/Plc_Insert.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/WindowsFormsApp1/form/editForm/Plc_Insert.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/WindowsFormsApp1/form/editForm/SerialPort_Insert.Designer.cs b/WindowsFormsApp1/form/editForm/SerialPort_Insert.Designer.cs new file mode 100644 index 0000000..1ce411c --- /dev/null +++ b/WindowsFormsApp1/form/editForm/SerialPort_Insert.Designer.cs @@ -0,0 +1,306 @@ +namespace WindowsFormsApp1.form +{ + partial class SerialPort_Insert + { + /// + /// 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.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.label1 = new System.Windows.Forms.Label(); + this.button1 = new System.Windows.Forms.Button(); + this.button2 = new System.Windows.Forms.Button(); + this.名称 = new System.Windows.Forms.TextBox(); + this.启用 = new System.Windows.Forms.CheckBox(); + this.label5 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.波特率 = new System.Windows.Forms.TextBox(); + this.label7 = new System.Windows.Forms.Label(); + this.com = new System.Windows.Forms.TextBox(); + this.label14 = new System.Windows.Forms.Label(); + this.数据位 = new System.Windows.Forms.TextBox(); + this.奇偶 = new System.Windows.Forms.ComboBox(); + this.label4 = new System.Windows.Forms.Label(); + this.备注 = new System.Windows.Forms.TextBox(); + this.tableLayoutPanel1.SuspendLayout(); + this.SuspendLayout(); + // + // tableLayoutPanel1 + // + this.tableLayoutPanel1.ColumnCount = 6; + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.Controls.Add(this.label1, 1, 1); + this.tableLayoutPanel1.Controls.Add(this.button1, 1, 8); + this.tableLayoutPanel1.Controls.Add(this.button2, 3, 8); + this.tableLayoutPanel1.Controls.Add(this.名称, 2, 1); + this.tableLayoutPanel1.Controls.Add(this.label2, 1, 3); + this.tableLayoutPanel1.Controls.Add(this.波特率, 2, 3); + this.tableLayoutPanel1.Controls.Add(this.label7, 1, 2); + this.tableLayoutPanel1.Controls.Add(this.com, 2, 2); + this.tableLayoutPanel1.Controls.Add(this.数据位, 2, 5); + this.tableLayoutPanel1.Controls.Add(this.启用, 2, 6); + this.tableLayoutPanel1.Controls.Add(this.label3, 1, 4); + this.tableLayoutPanel1.Controls.Add(this.label5, 1, 5); + this.tableLayoutPanel1.Controls.Add(this.label14, 1, 6); + this.tableLayoutPanel1.Controls.Add(this.奇偶, 2, 4); + this.tableLayoutPanel1.Controls.Add(this.label4, 1, 7); + this.tableLayoutPanel1.Controls.Add(this.备注, 2, 7); + this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + this.tableLayoutPanel1.RowCount = 10; + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.Size = new System.Drawing.Size(1087, 854); + this.tableLayoutPanel1.TabIndex = 0; + // + // label1 + // + this.label1.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label1.Location = new System.Drawing.Point(182, 113); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(68, 28); + this.label1.TabIndex = 0; + this.label1.Text = "名称"; + // + // button1 + // + this.button1.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.button1, 2); + this.button1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.button1.Location = new System.Drawing.Point(228, 683); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(194, 79); + this.button1.TabIndex = 14; + this.button1.Text = "保存"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // button2 + // + this.button2.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.button2, 2); + this.button2.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.button2.Location = new System.Drawing.Point(664, 683); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(190, 79); + this.button2.TabIndex = 15; + this.button2.Text = "取消"; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.button2_Click); + // + // 名称 + // + this.名称.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.名称, 3); + this.名称.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.名称.Location = new System.Drawing.Point(359, 108); + this.名称.Name = "名称"; + this.名称.Size = new System.Drawing.Size(583, 39); + this.名称.TabIndex = 16; + // + // 启用 + // + this.启用.Anchor = System.Windows.Forms.AnchorStyles.None; + this.启用.AutoSize = true; + this.tableLayoutPanel1.SetColumnSpan(this.启用, 3); + this.启用.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.启用.Location = new System.Drawing.Point(639, 542); + this.启用.Name = "启用"; + this.启用.Size = new System.Drawing.Size(22, 21); + this.启用.TabIndex = 22; + this.启用.UseVisualStyleBackColor = true; + // + // label5 + // + this.label5.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label5.AutoSize = true; + this.label5.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label5.Location = new System.Drawing.Point(168, 453); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(96, 28); + this.label5.TabIndex = 4; + this.label5.Text = "数据位"; + // + // label3 + // + this.label3.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label3.AutoSize = true; + this.label3.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label3.Location = new System.Drawing.Point(154, 368); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(124, 28); + this.label3.TabIndex = 2; + this.label3.Text = "奇偶校验"; + // + // label2 + // + this.label2.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label2.AutoSize = true; + this.label2.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label2.Location = new System.Drawing.Point(168, 283); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(96, 28); + this.label2.TabIndex = 1; + this.label2.Text = "波特率"; + // + // 波特率 + // + this.波特率.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.波特率, 3); + this.波特率.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.波特率.Location = new System.Drawing.Point(359, 278); + this.波特率.Name = "波特率"; + this.波特率.Size = new System.Drawing.Size(583, 39); + this.波特率.TabIndex = 17; + // + // label7 + // + this.label7.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label7.AutoSize = true; + this.label7.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label7.Location = new System.Drawing.Point(175, 198); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(82, 28); + this.label7.TabIndex = 29; + this.label7.Text = "CPM口"; + // + // com + // + this.com.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.com, 3); + this.com.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.com.Location = new System.Drawing.Point(359, 193); + this.com.Name = "com"; + this.com.Size = new System.Drawing.Size(583, 39); + this.com.TabIndex = 30; + // + // label14 + // + this.label14.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label14.AutoSize = true; + this.label14.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label14.Location = new System.Drawing.Point(154, 538); + this.label14.Name = "label14"; + this.label14.Size = new System.Drawing.Size(124, 28); + this.label14.TabIndex = 13; + this.label14.Text = "是否启用"; + // + // 数据位 + // + this.数据位.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.数据位, 3); + this.数据位.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.数据位.Location = new System.Drawing.Point(359, 448); + this.数据位.Name = "数据位"; + this.数据位.Size = new System.Drawing.Size(583, 39); + this.数据位.TabIndex = 18; + // + // 奇偶 + // + this.奇偶.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.奇偶, 3); + this.奇偶.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.奇偶.FormattingEnabled = true; + this.奇偶.Location = new System.Drawing.Point(362, 364); + this.奇偶.Name = "奇偶"; + this.奇偶.Size = new System.Drawing.Size(577, 36); + this.奇偶.TabIndex = 32; + // + // label4 + // + this.label4.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label4.AutoSize = true; + this.label4.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label4.Location = new System.Drawing.Point(182, 623); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(68, 28); + this.label4.TabIndex = 33; + this.label4.Text = "备注"; + // + // 备注 + // + this.备注.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.备注, 3); + this.备注.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.备注.Location = new System.Drawing.Point(359, 618); + this.备注.Name = "备注"; + this.备注.Size = new System.Drawing.Size(583, 39); + this.备注.TabIndex = 34; + // + // SerialPort_Insert + // + this.AutoScaleDimensions = new System.Drawing.SizeF(11F, 21F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1087, 854); + this.Controls.Add(this.tableLayoutPanel1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.Name = "SerialPort_Insert"; + this.Text = "Form_Insert"; + this.Load += new System.EventHandler(this.FLOW_Insert_Load); + this.tableLayoutPanel1.ResumeLayout(false); + this.tableLayoutPanel1.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.Label label14; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.Button button2; + private System.Windows.Forms.TextBox 波特率; + private System.Windows.Forms.TextBox 名称; + private System.Windows.Forms.TextBox 数据位; + private System.Windows.Forms.CheckBox 启用; + private System.Windows.Forms.Label label7; + private System.Windows.Forms.TextBox com; + private System.Windows.Forms.ComboBox 奇偶; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.TextBox 备注; + } +} \ No newline at end of file diff --git a/WindowsFormsApp1/form/editForm/SerialPort_Insert.cs b/WindowsFormsApp1/form/editForm/SerialPort_Insert.cs new file mode 100644 index 0000000..3141869 --- /dev/null +++ b/WindowsFormsApp1/form/editForm/SerialPort_Insert.cs @@ -0,0 +1,141 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using WindowsFormsApp1.db; +using WindowsFormsApp1.mod; +using WindowsFormsApp1.mod.database; + +namespace WindowsFormsApp1.form +{ + public partial class SerialPort_Insert : Form + { + public OperationType Operation { get; set; } + public int dataid { get; set; } + + public SerialPort_Insert() + { + InitializeComponent(); + } + + private void button1_Click(object sender, EventArgs e) + { + //保存 + int _波特率; + int _数据位; + if (!int.TryParse(波特率.Text, out _波特率)) + { + MessageBox.Show("波特率不是数字类型"); + return; + } + if (!int.TryParse(数据位.Text, out _数据位)) + { + MessageBox.Show("数据位不是数字类型"); + return; + } + if (string.IsNullOrWhiteSpace(名称.Text)) + { + MessageBox.Show("名称不能为空"); + return; + } + if (string.IsNullOrWhiteSpace(com.Text)) + { + MessageBox.Show("COM名称不能为空"); + return; + } + if (奇偶.SelectedValue == null) + { + MessageBox.Show("奇偶校验不能为空"); + return; + } + + t_serialport t_Flow = new t_serialport(); + t_Flow.name = 名称.Text; + t_Flow.portName = com.Text; + t_Flow.reamrk = 备注.Text; + t_Flow.baudRate = _波特率; + t_Flow.dataBits = _数据位; + t_Flow.parity = (string)奇偶.SelectedValue; + + t_Flow.enable = 启用.Checked; + + SQLiteHelper sQLiteHelper1 = new db.SQLiteHelper(); + if (Operation == OperationType.Edit) + { + t_Flow.id = dataid; + sQLiteHelper1.Update(t_Flow); + } + else + { + sQLiteHelper1.Insert(t_Flow); + } + MessageBox.Show("保存成功"); + this.Close(); + } + + private void button2_Click(object sender, EventArgs e) + { + //取消 + this.Close(); + } + + private void FLOW_Insert_Load(object sender, EventArgs e) + { + /* + None, + Odd, + Even, + Mark, + Space + + */ + var result1 = new List<_KeyV> + { + new _KeyV{name = "None",value = "None"}, + new _KeyV{name = "Odd",value = "Odd"}, + new _KeyV{name = "Even",value = "Even"}, + new _KeyV{name = "Mark",value = "Mark"}, + new _KeyV{name = "Space",value = "Space"} + }; + 奇偶.DataSource = result1; + 奇偶.DisplayMember = "name"; + 奇偶.ValueMember = "value"; + + if (Operation == OperationType.Edit) + { + SQLiteHelper sQLiteHelper = new db.SQLiteHelper(); + var result = sQLiteHelper.QuerySingle(a=>a.id == dataid); + if (!result.Success) + { + MessageBox.Show("查询失败"); + return; + } + var DataToEdit = result.Data; + 名称.Text = DataToEdit.name; + com.Text = DataToEdit.portName; + 波特率.Text = DataToEdit.baudRate.ToString(); + 数据位.Text = DataToEdit.dataBits.ToString(); + 启用.Checked = DataToEdit.enable; + 备注.Text = DataToEdit.reamrk; + SelectItemByValue(奇偶, DataToEdit.parity.ToString()); + } + } + + private void SelectItemByValue(ComboBox comboBox1, string value) + { + foreach (_KeyV item in comboBox1.Items) + { + if (item.value.ToString() == value) + { + comboBox1.SelectedItem = item; + break; + } + } + } + } +} diff --git a/WindowsFormsApp1/form/editForm/SerialPort_Insert.resx b/WindowsFormsApp1/form/editForm/SerialPort_Insert.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/WindowsFormsApp1/form/editForm/SerialPort_Insert.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/WindowsFormsApp1/form/editForm/Torqueaddress_Insert.Designer.cs b/WindowsFormsApp1/form/editForm/Torqueaddress_Insert.Designer.cs new file mode 100644 index 0000000..46c65cd --- /dev/null +++ b/WindowsFormsApp1/form/editForm/Torqueaddress_Insert.Designer.cs @@ -0,0 +1,333 @@ +namespace WindowsFormsApp1.form +{ + partial class Torqueaddress_Insert + { + /// + /// 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.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.数据名称 = new System.Windows.Forms.TextBox(); + this.button1 = new System.Windows.Forms.Button(); + this.button2 = new System.Windows.Forms.Button(); + this.label4 = new System.Windows.Forms.Label(); + this.db地址 = new System.Windows.Forms.TextBox(); + this.label7 = new System.Windows.Forms.Label(); + this.长度 = new System.Windows.Forms.TextBox(); + this.读写 = new System.Windows.Forms.ComboBox(); + this.db块 = new System.Windows.Forms.TextBox(); + this.备注 = new System.Windows.Forms.TextBox(); + this.类型 = new System.Windows.Forms.ComboBox(); + this.label2 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.label5 = new System.Windows.Forms.Label(); + this.label6 = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.PLC名称 = new System.Windows.Forms.ComboBox(); + this.label8 = new System.Windows.Forms.Label(); + this.tableLayoutPanel1.SuspendLayout(); + this.SuspendLayout(); + // + // tableLayoutPanel1 + // + this.tableLayoutPanel1.ColumnCount = 6; + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.Controls.Add(this.数据名称, 2, 1); + this.tableLayoutPanel1.Controls.Add(this.button1, 1, 8); + this.tableLayoutPanel1.Controls.Add(this.button2, 3, 8); + this.tableLayoutPanel1.Controls.Add(this.label4, 1, 5); + this.tableLayoutPanel1.Controls.Add(this.db地址, 2, 4); + this.tableLayoutPanel1.Controls.Add(this.label7, 1, 2); + this.tableLayoutPanel1.Controls.Add(this.长度, 2, 6); + this.tableLayoutPanel1.Controls.Add(this.读写, 2, 2); + this.tableLayoutPanel1.Controls.Add(this.db块, 2, 3); + this.tableLayoutPanel1.Controls.Add(this.备注, 2, 7); + this.tableLayoutPanel1.Controls.Add(this.类型, 2, 5); + this.tableLayoutPanel1.Controls.Add(this.label2, 1, 3); + this.tableLayoutPanel1.Controls.Add(this.label3, 1, 4); + this.tableLayoutPanel1.Controls.Add(this.label5, 1, 6); + this.tableLayoutPanel1.Controls.Add(this.label6, 1, 7); + this.tableLayoutPanel1.Controls.Add(this.label1, 1, 0); + this.tableLayoutPanel1.Controls.Add(this.PLC名称, 2, 0); + this.tableLayoutPanel1.Controls.Add(this.label8, 1, 1); + this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + this.tableLayoutPanel1.RowCount = 10; + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.Size = new System.Drawing.Size(931, 732); + this.tableLayoutPanel1.TabIndex = 0; + // + // 数据名称 + // + this.数据名称.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.数据名称, 3); + this.数据名称.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.数据名称.Location = new System.Drawing.Point(282, 90); + this.数据名称.Name = "数据名称"; + this.数据名称.Size = new System.Drawing.Size(552, 39); + this.数据名称.TabIndex = 35; + // + // button1 + // + this.button1.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.button1, 2); + this.button1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.button1.Location = new System.Drawing.Point(182, 587); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(194, 67); + this.button1.TabIndex = 14; + this.button1.Text = "保存"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // button2 + // + this.button2.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.button2, 2); + this.button2.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.button2.Location = new System.Drawing.Point(556, 587); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(190, 67); + this.button2.TabIndex = 15; + this.button2.Text = "取消"; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.button2_Click); + // + // label4 + // + this.label4.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label4.AutoSize = true; + this.label4.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label4.Location = new System.Drawing.Point(124, 387); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(124, 28); + this.label4.TabIndex = 3; + this.label4.Text = "数据类型"; + // + // db地址 + // + this.db地址.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.db地址, 3); + this.db地址.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.db地址.Location = new System.Drawing.Point(282, 309); + this.db地址.Name = "db地址"; + this.db地址.Size = new System.Drawing.Size(552, 39); + this.db地址.TabIndex = 20; + // + // label7 + // + this.label7.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label7.AutoSize = true; + this.label7.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label7.Location = new System.Drawing.Point(124, 168); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(124, 28); + this.label7.TabIndex = 29; + this.label7.Text = "读写类型"; + // + // 长度 + // + this.长度.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.长度, 3); + this.长度.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.长度.Location = new System.Drawing.Point(282, 455); + this.长度.Name = "长度"; + this.长度.Size = new System.Drawing.Size(552, 39); + this.长度.TabIndex = 18; + // + // 读写 + // + this.读写.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.读写, 3); + this.读写.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.读写.FormattingEnabled = true; + this.读写.Location = new System.Drawing.Point(282, 168); + this.读写.Name = "读写"; + this.读写.Size = new System.Drawing.Size(552, 36); + this.读写.TabIndex = 31; + // + // db块 + // + this.db块.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.db块, 3); + this.db块.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.db块.Location = new System.Drawing.Point(282, 236); + this.db块.Name = "db块"; + this.db块.Size = new System.Drawing.Size(552, 39); + this.db块.TabIndex = 30; + // + // 备注 + // + this.备注.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.备注, 3); + this.备注.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.备注.Location = new System.Drawing.Point(282, 528); + this.备注.Name = "备注"; + this.备注.Size = new System.Drawing.Size(552, 39); + this.备注.TabIndex = 17; + // + // 类型 + // + this.类型.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.类型, 3); + this.类型.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.类型.FormattingEnabled = true; + this.类型.Location = new System.Drawing.Point(282, 387); + this.类型.Name = "类型"; + this.类型.Size = new System.Drawing.Size(552, 36); + this.类型.TabIndex = 32; + // + // label2 + // + this.label2.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label2.AutoSize = true; + this.label2.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label2.Location = new System.Drawing.Point(124, 241); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(124, 28); + this.label2.TabIndex = 1; + this.label2.Text = "DB块地址"; + // + // label3 + // + this.label3.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label3.AutoSize = true; + this.label3.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label3.Location = new System.Drawing.Point(138, 314); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(96, 28); + this.label3.TabIndex = 2; + this.label3.Text = "DB地址"; + // + // label5 + // + this.label5.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label5.AutoSize = true; + this.label5.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label5.Location = new System.Drawing.Point(124, 460); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(124, 28); + this.label5.TabIndex = 4; + this.label5.Text = "字节长度"; + // + // label6 + // + this.label6.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label6.AutoSize = true; + this.label6.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label6.Location = new System.Drawing.Point(152, 533); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(68, 28); + this.label6.TabIndex = 5; + this.label6.Text = "备注"; + // + // label1 + // + this.label1.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label1.Location = new System.Drawing.Point(131, 22); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(110, 28); + this.label1.TabIndex = 0; + this.label1.Text = "PLC名称"; + // + // PLC名称 + // + this.PLC名称.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.PLC名称, 3); + this.PLC名称.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.PLC名称.FormattingEnabled = true; + this.PLC名称.Location = new System.Drawing.Point(282, 22); + this.PLC名称.Name = "PLC名称"; + this.PLC名称.Size = new System.Drawing.Size(552, 36); + this.PLC名称.TabIndex = 33; + // + // label8 + // + this.label8.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label8.AutoSize = true; + this.label8.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label8.Location = new System.Drawing.Point(124, 95); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(124, 28); + this.label8.TabIndex = 34; + this.label8.Text = "数据名称"; + // + // PlcAddress_Insert + // + this.AutoScaleDimensions = new System.Drawing.SizeF(11F, 21F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(931, 732); + this.Controls.Add(this.tableLayoutPanel1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.Name = "PlcAddress_Insert"; + this.Text = "Form_Insert"; + this.Load += new System.EventHandler(this.FLOW_Insert_Load); + this.tableLayoutPanel1.ResumeLayout(false); + this.tableLayoutPanel1.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.Button button2; + private System.Windows.Forms.TextBox 备注; + private System.Windows.Forms.TextBox db地址; + private System.Windows.Forms.TextBox 长度; + private System.Windows.Forms.Label label7; + private System.Windows.Forms.TextBox db块; + private System.Windows.Forms.ComboBox 读写; + private System.Windows.Forms.ComboBox 类型; + private System.Windows.Forms.ComboBox PLC名称; + private System.Windows.Forms.TextBox 数据名称; + private System.Windows.Forms.Label label8; + } +} \ No newline at end of file diff --git a/WindowsFormsApp1/form/editForm/Torqueaddress_Insert.cs b/WindowsFormsApp1/form/editForm/Torqueaddress_Insert.cs new file mode 100644 index 0000000..a6f6dae --- /dev/null +++ b/WindowsFormsApp1/form/editForm/Torqueaddress_Insert.cs @@ -0,0 +1,181 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using WindowsFormsApp1.db; +using WindowsFormsApp1.mod; + +namespace WindowsFormsApp1.form +{ + public partial class Torqueaddress_Insert : Form + { + public OperationType Operation { get; set; } + public int dataid { get; set; } + + public Torqueaddress_Insert() + { + InitializeComponent(); + } + + private void button1_Click(object sender, EventArgs e) + { + //保存 + int _db; + int _legth; + if (!int.TryParse(db地址.Text, out _db)) + { + MessageBox.Show("db地址不是数字类型"); + return; + } + if (!int.TryParse(长度.Text, out _legth)) + { + MessageBox.Show("长度不是数字类型"); + return; + } + if (string.IsNullOrWhiteSpace(备注.Text)) + { + MessageBox.Show("备注不能为空"); + return; + } + if (string.IsNullOrWhiteSpace(数据名称.Text)) + { + MessageBox.Show("数据名称不能为空"); + return; + } + if (string.IsNullOrWhiteSpace(db块.Text)) + { + MessageBox.Show("db块地址不能为空"); + return; + } + if (类型.SelectedValue == null) + { + MessageBox.Show("类型不能为空"); + return; + } + if (读写.SelectedValue == null) + { + MessageBox.Show("读写类型不能为空"); + return; + } + + + + t_torqueaddress t_Flow = new t_torqueaddress(); + t_Flow.plcid = (int)PLC名称.SelectedValue; + t_Flow.code = 数据名称.Text; + t_Flow.type = (string)读写.SelectedValue; + t_Flow.dbaddress = db块.Text; + t_Flow.remark = 备注.Text; + t_Flow.addresstypelegth = _legth; + t_Flow.addressoffset = _db; + t_Flow.addresstype = (string)类型.SelectedValue; + + SQLiteHelper sQLiteHelper1 = new db.SQLiteHelper(); + if (Operation == OperationType.Edit) + { + t_Flow.id = dataid; + sQLiteHelper1.Update(t_Flow); + } + else + { + sQLiteHelper1.Insert(t_Flow); + } + MessageBox.Show("保存成功"); + this.Close(); + } + + private void button2_Click(object sender, EventArgs e) + { + //取消 + this.Close(); + } + + private void FLOW_Insert_Load(object sender, EventArgs e) + { + var result1 = new List<_KeyV> + { + new _KeyV{name = "read",value = "read"}, + new _KeyV{name = "write",value = "write"} + }; + + var result2 = new List<_KeyV> + { + new _KeyV{name = "real",value = "real"}, + new _KeyV{name = "string",value = "string"}, + new _KeyV{name = "uint",value = "uint"}, + }; + + // 绑定数据源到 ComboBox + 读写.DataSource = result1; + 读写.DisplayMember = "name"; + 读写.ValueMember = "value"; + + + 类型.DataSource = result2; + 类型.DisplayMember = "name"; + 类型.ValueMember = "value"; + + SQLiteHelper sQLiteHelper1 = new db.SQLiteHelper(); + var result_combox1 = sQLiteHelper1.QueryAll(); + if (!result_combox1.Success) + { + MessageBox.Show("查询失败"); + return; + } + + // 绑定数据源到 ComboBox + PLC名称.DataSource = result_combox1.Data; + PLC名称.DisplayMember = "plcname"; + PLC名称.ValueMember = "id"; + + + if (Operation == OperationType.Edit) + { + SQLiteHelper sQLiteHelper = new db.SQLiteHelper(); + var result = sQLiteHelper.QuerySingle(a=>a.id == dataid); + if (!result.Success) + { + MessageBox.Show("查询失败"); + return; + } + var DataToEdit = result.Data; + 数据名称.Text = DataToEdit.code; + db块.Text = DataToEdit.dbaddress; + db地址.Text = DataToEdit.addressoffset.ToString(); + 长度.Text = DataToEdit.addresstypelegth.ToString(); + 备注.Text = DataToEdit.remark; + SelectItemByValue1(PLC名称, DataToEdit.plcid.ToString()); + SelectItemByValue(读写, DataToEdit.type.ToString()); + SelectItemByValue(类型, DataToEdit.addresstypelegth.ToString()); + } + } + + private void SelectItemByValue(ComboBox comboBox1, string value) + { + foreach (_KeyV item in comboBox1.Items) + { + if (item.value.ToString() == value) + { + comboBox1.SelectedItem = item; + break; + } + } + } + private void SelectItemByValue1(ComboBox comboBox1, string value) + { + foreach (t_plc item in comboBox1.Items) + { + if (item.id.ToString() == value) + { + comboBox1.SelectedItem = item; + break; + } + } + } + } +} diff --git a/WindowsFormsApp1/form/editForm/Torqueaddress_Insert.resx b/WindowsFormsApp1/form/editForm/Torqueaddress_Insert.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/WindowsFormsApp1/form/editForm/Torqueaddress_Insert.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/WindowsFormsApp1/form/editForm/User_Insert.Designer.cs b/WindowsFormsApp1/form/editForm/User_Insert.Designer.cs new file mode 100644 index 0000000..54f57b8 --- /dev/null +++ b/WindowsFormsApp1/form/editForm/User_Insert.Designer.cs @@ -0,0 +1,168 @@ +namespace WindowsFormsApp1.form +{ + partial class User_Insert + { + /// + /// 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.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.label1 = new System.Windows.Forms.Label(); + this.button1 = new System.Windows.Forms.Button(); + this.button2 = new System.Windows.Forms.Button(); + this.用户名 = new System.Windows.Forms.TextBox(); + this.label7 = new System.Windows.Forms.Label(); + this.密码 = new System.Windows.Forms.TextBox(); + this.tableLayoutPanel1.SuspendLayout(); + this.SuspendLayout(); + // + // tableLayoutPanel1 + // + this.tableLayoutPanel1.ColumnCount = 6; + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.Controls.Add(this.label1, 1, 1); + this.tableLayoutPanel1.Controls.Add(this.button1, 1, 8); + this.tableLayoutPanel1.Controls.Add(this.button2, 3, 8); + this.tableLayoutPanel1.Controls.Add(this.用户名, 2, 1); + this.tableLayoutPanel1.Controls.Add(this.密码, 2, 3); + this.tableLayoutPanel1.Controls.Add(this.label7, 1, 3); + this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + this.tableLayoutPanel1.RowCount = 10; + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel1.Size = new System.Drawing.Size(1087, 854); + this.tableLayoutPanel1.TabIndex = 0; + // + // label1 + // + this.label1.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label1.Location = new System.Drawing.Point(168, 113); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(96, 28); + this.label1.TabIndex = 0; + this.label1.Text = "用户名"; + // + // button1 + // + this.button1.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.button1, 2); + this.button1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.button1.Location = new System.Drawing.Point(228, 683); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(194, 79); + this.button1.TabIndex = 14; + this.button1.Text = "保存"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // button2 + // + this.button2.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.button2, 2); + this.button2.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.button2.Location = new System.Drawing.Point(664, 683); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(190, 79); + this.button2.TabIndex = 15; + this.button2.Text = "取消"; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.button2_Click); + // + // 用户名 + // + this.用户名.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.用户名, 3); + this.用户名.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.用户名.Location = new System.Drawing.Point(359, 108); + this.用户名.Name = "用户名"; + this.用户名.Size = new System.Drawing.Size(583, 39); + this.用户名.TabIndex = 16; + // + // label7 + // + this.label7.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label7.AutoSize = true; + this.label7.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label7.Location = new System.Drawing.Point(182, 283); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(68, 28); + this.label7.TabIndex = 29; + this.label7.Text = "密码"; + // + // 密码 + // + this.密码.Anchor = System.Windows.Forms.AnchorStyles.None; + this.tableLayoutPanel1.SetColumnSpan(this.密码, 3); + this.密码.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.密码.Location = new System.Drawing.Point(359, 278); + this.密码.Name = "密码"; + this.密码.Size = new System.Drawing.Size(583, 39); + this.密码.TabIndex = 30; + // + // User_Insert + // + this.AutoScaleDimensions = new System.Drawing.SizeF(11F, 21F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1087, 854); + this.Controls.Add(this.tableLayoutPanel1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.Name = "User_Insert"; + this.Text = "Form_Insert"; + this.Load += new System.EventHandler(this.FLOW_Insert_Load); + this.tableLayoutPanel1.ResumeLayout(false); + this.tableLayoutPanel1.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.Button button2; + private System.Windows.Forms.TextBox 用户名; + private System.Windows.Forms.Label label7; + private System.Windows.Forms.TextBox 密码; + } +} \ No newline at end of file diff --git a/WindowsFormsApp1/form/editForm/User_Insert.cs b/WindowsFormsApp1/form/editForm/User_Insert.cs new file mode 100644 index 0000000..ebe660a --- /dev/null +++ b/WindowsFormsApp1/form/editForm/User_Insert.cs @@ -0,0 +1,81 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using WindowsFormsApp1.db; +using WindowsFormsApp1.mod; + +namespace WindowsFormsApp1.form +{ + public partial class User_Insert : Form + { + public OperationType Operation { get; set; } + public int dataid { get; set; } + + public User_Insert() + { + InitializeComponent(); + } + + private void button1_Click(object sender, EventArgs e) + { + //保存 + if (string.IsNullOrWhiteSpace(用户名.Text)) + { + MessageBox.Show("用户名不能为空"); + return; + } + if (string.IsNullOrWhiteSpace(密码.Text)) + { + MessageBox.Show("密码不能为空"); + return; + } + + t_user t_Flow = new t_user(); + t_Flow.username = 用户名.Text; + t_Flow.password = 密码.Text; + + + SQLiteHelper sQLiteHelper1 = new db.SQLiteHelper(); + if (Operation == OperationType.Edit) + { + t_Flow.id = dataid; + sQLiteHelper1.Update(t_Flow); + } + else + { + sQLiteHelper1.Insert(t_Flow); + } + MessageBox.Show("保存成功"); + this.Close(); + } + + private void button2_Click(object sender, EventArgs e) + { + //取消 + this.Close(); + } + + private void FLOW_Insert_Load(object sender, EventArgs e) + { + if (Operation == OperationType.Edit) + { + SQLiteHelper sQLiteHelper = new db.SQLiteHelper(); + var result = sQLiteHelper.QuerySingle(a=>a.id == dataid); + if (!result.Success) + { + MessageBox.Show("查询失败"); + return; + } + var DataToEdit = result.Data; + 用户名.Text = DataToEdit.username; + 密码.Text = DataToEdit.password; + } + } + } +} diff --git a/WindowsFormsApp1/form/editForm/User_Insert.resx b/WindowsFormsApp1/form/editForm/User_Insert.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/WindowsFormsApp1/form/editForm/User_Insert.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/WindowsFormsApp1/mod/database/t_angleaddress.cs b/WindowsFormsApp1/mod/database/t_angleaddress.cs new file mode 100644 index 0000000..79ac477 --- /dev/null +++ b/WindowsFormsApp1/mod/database/t_angleaddress.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SQLite; + +namespace WindowsFormsApp1.mod +{ + [Table("angleaddress")] + public class t_angleaddress + { + [PrimaryKey, AutoIncrement] + public int id { get; set; } + public int plcid { get; set; } + + public string code { get; set; } + public string type { get; set; } + public string dbaddress { get; set; } + public string addresstype { get; set; } + public int addresstypelegth { get; set; } + public int addressoffset { get; set; } + public string remark { get; set; } + public string value { get; set; } + + + } +} diff --git a/WindowsFormsApp1/mod/database/t_flow.cs b/WindowsFormsApp1/mod/database/t_flow.cs index b5daa6f..72aa6b3 100644 --- a/WindowsFormsApp1/mod/database/t_flow.cs +++ b/WindowsFormsApp1/mod/database/t_flow.cs @@ -10,14 +10,66 @@ namespace WindowsFormsApp1.mod [Table("flow")] public class t_flow { + /// + /// 唯一id + /// [PrimaryKey, AutoIncrement] public int id { get; set; } + /// + /// 名称 + /// + public string flowname { get; set; } + /// + /// 流程id + /// public int flowid { get; set; } + /// + /// 步骤 + /// public int setp { get; set; } + /// + /// 期望的接口id + /// public int hopeinterfaceid { get; set; } + /// + /// 错误的接口id + /// public int errinterfaceid { get; set; } + /// + /// 期望的状态 + /// public int hopestatus { get; set; } + /// + /// MES返回错误的状态 + /// public int errstatus { get; set; } - + /// + /// 是否需要扫码 + /// + public bool scan { get; set; } + /// + /// 是否需要文件上传 + /// + public bool fileupload { get; set; } + /// + /// 螺丝枪扭力数据 + /// + public bool finaltorquevalue { get; set; } + /// + /// 螺丝枪角度数据 + /// + public bool finalanglevaluue { get; set; } + /// + /// 扭力曲线 + /// + public bool finaltorquecurve { get; set; } + /// + /// 压力曲线 + /// + public bool finalpressurecurve { get; set; } + /// + /// 气密参数 + /// + public bool airtight { get; set; } } } diff --git a/WindowsFormsApp1/mod/database/t_keyvalue.cs b/WindowsFormsApp1/mod/database/t_keyvalue.cs new file mode 100644 index 0000000..ca574a2 --- /dev/null +++ b/WindowsFormsApp1/mod/database/t_keyvalue.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Newtonsoft.Json.Linq; +using SQLite; + +namespace WindowsFormsApp1.mod +{ + [Table("keyvalue")] + public class t_keyvalue + { + [PrimaryKey, AutoIncrement] + public int id { get; set; } + + public string key { get; set; } + public string value { get; set; } + public string remark { get; set; } + + + + } +} diff --git a/WindowsFormsApp1/mod/database/t_line.cs b/WindowsFormsApp1/mod/database/t_line.cs index dd7e4a3..3f793b7 100644 --- a/WindowsFormsApp1/mod/database/t_line.cs +++ b/WindowsFormsApp1/mod/database/t_line.cs @@ -16,10 +16,6 @@ namespace WindowsFormsApp1.mod public string linecode { get; set; } public string linetype { get; set; } public string linemode { get; set; } - public int plcid1 { get; set; } - public int plcid2 { get; set; } public int flowid { get; set; } - - } } diff --git a/WindowsFormsApp1/mod/database/t_lineplc.cs b/WindowsFormsApp1/mod/database/t_lineplc.cs new file mode 100644 index 0000000..0539961 --- /dev/null +++ b/WindowsFormsApp1/mod/database/t_lineplc.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SQLite; + +namespace WindowsFormsApp1.mod +{ + [Table("lineplc")] + public class t_lineplc + { + [PrimaryKey, AutoIncrement] + public int id { get; set; } + public int lineid { get; set; } + public int plcid { get; set; } + } +} diff --git a/WindowsFormsApp1/mod/database/t_plc.cs b/WindowsFormsApp1/mod/database/t_plc.cs index fc49c10..d0065f1 100644 --- a/WindowsFormsApp1/mod/database/t_plc.cs +++ b/WindowsFormsApp1/mod/database/t_plc.cs @@ -13,11 +13,18 @@ namespace WindowsFormsApp1.mod { [PrimaryKey, AutoIncrement] public int id { get; set; } + public string plcname { get; set; } public string plcip { get; set; } public int timeout { get; set; } - //[Ignore] - //public DateTime dateTime { get; set; } + /// + /// 需要上传状态 + /// + public bool statues { get; set; } + /// + /// 需要上传报警 + /// + public bool alarm { get; set; } [Ignore] public SiemensHelp plchelp { get; set; } } diff --git a/WindowsFormsApp1/mod/database/t_torqueaddress.cs b/WindowsFormsApp1/mod/database/t_torqueaddress.cs new file mode 100644 index 0000000..bee7124 --- /dev/null +++ b/WindowsFormsApp1/mod/database/t_torqueaddress.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SQLite; + +namespace WindowsFormsApp1.mod +{ + [Table("torqueaddress")] + public class t_torqueaddress + { + [PrimaryKey, AutoIncrement] + public int id { get; set; } + public int plcid { get; set; } + + public string code { get; set; } + public string type { get; set; } + public string dbaddress { get; set; } + public string addresstype { get; set; } + public int addresstypelegth { get; set; } + public int addressoffset { get; set; } + public string remark { get; set; } + public string value { get; set; } + + + } +} diff --git a/WindowsFormsApp1/mod/enum/plc_emum.cs b/WindowsFormsApp1/mod/enum/plc_emum.cs index c983efd..ed3ad18 100644 --- a/WindowsFormsApp1/mod/enum/plc_emum.cs +++ b/WindowsFormsApp1/mod/enum/plc_emum.cs @@ -28,4 +28,10 @@ namespace WindowsFormsApp1.mod 换料 = (short)11, 未知 = (short)0, }; + + public enum OperationType + { + Add, + Edit + } } diff --git a/WindowsFormsApp1/mod/server/otherdata.cs b/WindowsFormsApp1/mod/server/otherdata.cs index 0df6af4..02750db 100644 --- a/WindowsFormsApp1/mod/server/otherdata.cs +++ b/WindowsFormsApp1/mod/server/otherdata.cs @@ -61,25 +61,27 @@ namespace WindowsFormsApp1.mod.server /// 压力值 /// public string Airtight_Value { get; set; } - /// - /// 压力单位 - /// - public string Airtight_Unit { get; set; } + ///// + ///// 压力单位 + ///// + //public string Airtight_Unit { get; set; } /// /// 泄露值 /// public string Leak_Value { get; set; } - /// - /// 泄露单位 - /// - public string Leak_Unit { get; set; } - /// - /// 小泄露值 - /// - public string LLeak_Value { get; set; } - /// - /// 小泄露单位 - /// - public string LLeak_Unit { get; set; } + ///// + ///// 泄露单位 + ///// + //public string Leak_Unit { get; set; } + ///// + ///// 小泄露值 + ///// + //public string LLeak_Value { get; set; } + ///// + ///// 小泄露单位 + ///// + //public string LLeak_Unit { get; set; } + + public DateTime LastTime { get; set; } } } diff --git a/WindowsFormsApp1/server/FormHelp.cs b/WindowsFormsApp1/server/FormHelp.cs new file mode 100644 index 0000000..46fc180 --- /dev/null +++ b/WindowsFormsApp1/server/FormHelp.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; + +namespace WindowsFormsApp1.server +{ + public static class FormHelp + { + public static void RemoveAllEventHandlers(object obj, string eventName) + { + Type type = obj.GetType(); + EventInfo eventInfo = type.GetEvent(eventName); + if (eventInfo != null) + { + FieldInfo fieldInfo = type.GetField(eventName, BindingFlags.Instance | BindingFlags.NonPublic); + if (fieldInfo != null) + { + fieldInfo.SetValue(obj, null); + } + } + } + } +} diff --git a/WindowsFormsApp1/server/SiemensHelp.cs b/WindowsFormsApp1/server/SiemensHelp.cs index a214768..5cb0584 100644 --- a/WindowsFormsApp1/server/SiemensHelp.cs +++ b/WindowsFormsApp1/server/SiemensHelp.cs @@ -148,7 +148,7 @@ namespace WindowsFormsApp1.server PlcData.Read_Time = DateTime.Now; return BllResult.Sucess(address, "成功"); } - + private BllResult WriteOneDB(List address) { address = address.OrderBy(a => a.addressoffset).ToList(); @@ -343,5 +343,215 @@ namespace WindowsFormsApp1.server return BllResult.Error($"转换WCS数据失败{ex.Message}"); } } + + #region 读取扭力 + public BllResult> ReadAddress(List address) + { + var ulist = address.GroupBy(a => a.dbaddress).ToList(); + foreach (var u in ulist) + { + var readresult = ReadOneDB(u.ToList()); + if (!readresult.Success) + { + return BllResult>.Error(readresult.Msg); + } + } + List list = new List(); + foreach (var add in address.OrderBy(a => a.addressoffset)) + { + list.Add(float.Parse(add.value)); + } + return BllResult>.Sucess(list, "成功"); + } + private BllResult ReadOneDB(List address) + { + address = address.OrderBy(a => a.addressoffset).ToList(); + OperateResult read; + if (address.Count == 1) + { + string startaddress = address[0].dbaddress + "." + address[0].addressoffset.ToString(); + read = siemensS7Net.Read(startaddress, Convert.ToUInt16(address[0].addresstypelegth)); + } + else + { + double admax = address.Select(a => a.addressoffset).Max(); + double admin = address.Select(a => a.addressoffset).Min(); + ushort length = (ushort)(Math.Floor(admax - admin) + address.Last().addresstypelegth); + string startaddress = address[0].dbaddress + "." + admin.ToString(); + read = siemensS7Net.Read(startaddress, length); + } + if (read.IsSuccess) + { + if (TransforWCSDataToAddressData(address, read).Success) + { + return BllResult.Sucess(address, "成功"); + } + else + { + return BllResult.Error(address, "成功"); + } + } + else + { + return BllResult.Error(read.Message); + } + } + private BllResult TransforWCSDataToAddressData(List address, OperateResult read) + { + try + { + //按偏移量排序 + address = address.OrderBy(a => a.addressoffset).ToList(); + int startindex = address[0].addressoffset; + for (int i = 0; i < address.Count; i++) + { + int index = address[i].addressoffset - startindex; + switch (address[i].addresstype) + { + case "byte": + address[i].value = ByteTransform.TransByte(read.Content, index).ToString(); + break; + + case "real": + address[i].value = ByteTransform.TransSingle(read.Content, index).ToString(); + break; + + case "lword": + address[i].value = Convert.ToString(ByteTransform.TransInt64(read.Content, index), 16); ; + break; + + case "int": + address[i].value = ByteTransform.TransInt16(read.Content, index).ToString(); + break; + + case "uint": + address[i].value = ByteTransform.TransInt16(read.Content, index).ToString(); + break; + + case "dint": + address[i].value = Convert.ToString(ByteTransform.TransInt32(read.Content, index), 10); + break; + + case "string": + address[i].value = Encoding.ASCII.GetString(read.Content, index, address[i].addresstypelegth); + break; + + default: + return BllResult.Error("找不到未知的数据类型"); + } + } + return BllResult.Sucess(address); + } + catch (Exception ex) + { + return BllResult.Error($"转换WCS数据失败{ex.Message}"); + } + } + #endregion + + #region 读取角度 + public BllResult> ReadAddress(List address) + { + var ulist = address.GroupBy(a => a.dbaddress).ToList(); + foreach (var u in ulist) + { + var readresult = ReadOneDB(u.ToList()); + if (!readresult.Success) + { + return BllResult>.Error(readresult.Msg); + } + } + List list = new List(); + foreach (var add in address.OrderBy(a => a.addressoffset)) + { + list.Add(float.Parse(add.value)); + } + return BllResult>.Sucess(list, "成功"); + } + private BllResult ReadOneDB(List address) + { + address = address.OrderBy(a => a.addressoffset).ToList(); + OperateResult read; + if (address.Count == 1) + { + string startaddress = address[0].dbaddress + "." + address[0].addressoffset.ToString(); + read = siemensS7Net.Read(startaddress, Convert.ToUInt16(address[0].addresstypelegth)); + } + else + { + double admax = address.Select(a => a.addressoffset).Max(); + double admin = address.Select(a => a.addressoffset).Min(); + ushort length = (ushort)(Math.Floor(admax - admin) + address.Last().addresstypelegth); + string startaddress = address[0].dbaddress + "." + admin.ToString(); + read = siemensS7Net.Read(startaddress, length); + } + if (read.IsSuccess) + { + if (TransforWCSDataToAddressData(address, read).Success) + { + return BllResult.Sucess(address, "成功"); + } + else + { + return BllResult.Error(address, "成功"); + } + } + else + { + return BllResult.Error(read.Message); + } + } + private BllResult TransforWCSDataToAddressData(List address, OperateResult read) + { + try + { + //按偏移量排序 + address = address.OrderBy(a => a.addressoffset).ToList(); + int startindex = address[0].addressoffset; + for (int i = 0; i < address.Count; i++) + { + int index = address[i].addressoffset - startindex; + switch (address[i].addresstype) + { + case "byte": + address[i].value = ByteTransform.TransByte(read.Content, index).ToString(); + break; + + case "real": + address[i].value = ByteTransform.TransSingle(read.Content, index).ToString(); + break; + + case "lword": + address[i].value = Convert.ToString(ByteTransform.TransInt64(read.Content, index), 16); ; + break; + + case "int": + address[i].value = ByteTransform.TransInt16(read.Content, index).ToString(); + break; + + case "uint": + address[i].value = ByteTransform.TransInt16(read.Content, index).ToString(); + break; + + case "dint": + address[i].value = Convert.ToString(ByteTransform.TransInt32(read.Content, index), 10); + break; + + case "string": + address[i].value = Encoding.ASCII.GetString(read.Content, index, address[i].addresstypelegth); + break; + + default: + return BllResult.Error("找不到未知的数据类型"); + } + } + return BllResult.Sucess(address); + } + catch (Exception ex) + { + return BllResult.Error($"转换WCS数据失败{ex.Message}"); + } + } + #endregion } } diff --git a/WindowsFormsApp1/server/ThreadHelp.cs b/WindowsFormsApp1/server/ThreadHelp.cs new file mode 100644 index 0000000..013d3aa --- /dev/null +++ b/WindowsFormsApp1/server/ThreadHelp.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; + +namespace WindowsFormsApp1.server +{ + public class ThreadHelp + { + public Thread Thread { get; set; } + public bool isrunning1 = false; + public CancellationTokenSource cancellationTokenSource1; + } +}