diff --git a/HighWayIot.Repository/HighWayIot.Repository.csproj b/HighWayIot.Repository/HighWayIot.Repository.csproj index 42a4b15..d380f02 100644 --- a/HighWayIot.Repository/HighWayIot.Repository.csproj +++ b/HighWayIot.Repository/HighWayIot.Repository.csproj @@ -65,8 +65,10 @@ + + diff --git a/HighWayIot.Repository/domain/Zx_rfid_setting.cs b/HighWayIot.Repository/domain/Zx_rfid_setting.cs new file mode 100644 index 0000000..0529751 --- /dev/null +++ b/HighWayIot.Repository/domain/Zx_rfid_setting.cs @@ -0,0 +1,50 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Security.Principal; +using System.Text; +using System.Threading.Tasks; + +namespace HighWayIot.Repository.domain +{ + /// + /// + /// + [SugarTable("zx_rfid_setting")] + public class Zx_rfid_setting + { + + + /// + /// 备 注: + /// 默认值: + /// + [SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsIdentity = true)] + public int Id { get; set; } + + /// + /// 备 注:读写器IP + /// 默认值: + /// + [SugarColumn(ColumnName = "rfid_ip")] + public string RfidIp { get; set; } + + /// + /// 备 注:RFID编号 + /// 默认值: + /// + [SugarColumn(ColumnName = "rfid_epc")] + public string RfidEpc { get; set; } + + /// + /// 备 注:工位编号 + /// 默认值: + /// + [SugarColumn(ColumnName = "workstate_no")] + public int? WorkstateNo { get; set; } + + + } + +} diff --git a/HighWayIot.Repository/service/Zx_rfid_settingService.cs b/HighWayIot.Repository/service/Zx_rfid_settingService.cs new file mode 100644 index 0000000..ca82ba1 --- /dev/null +++ b/HighWayIot.Repository/service/Zx_rfid_settingService.cs @@ -0,0 +1,91 @@ +using HighWayIot.Log4net; +using HighWayIot.Repository.domain; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using System.Text; +using System.Threading.Tasks; + +namespace HighWayIot.Repository.service +{ + public class Zx_rfid_settingService + { + private static readonly Lazy lazy = new Lazy(() => new Zx_rfid_settingService()); + + public static Zx_rfid_settingService Instance + { + get + { + return lazy.Value; + } + } + + private LogHelper log = LogHelper.Instance; + Repository _repository => new Repository("sqlserver"); + + /// + /// 查询所有RFID设备信息 + /// + /// + public List GetRfidInfos(Expression> expression = null) + { + try + { + List entity; + if (expression != null) + { + entity = _repository.GetList(expression); + } + else + { + entity = _repository.GetList(); + } + return entity; + } + catch (Exception ex) + { + log.Error("RFID设备信息获取异常", ex); + return null; + } + } + + /// + /// 查询指定RFID设备信息 + /// + /// + public Zx_rfid_setting GetRfidInfoById(int id) + { + try + { + Zx_rfid_setting entity; + entity = _repository.GetById(id); + + return entity; + } + catch (Exception ex) + { + log.Error("RFID设备信息获取异常", ex); + return null; + } + } + + /// + /// 修改信息 + /// + /// + /// + public bool UpdateRfidInfo(Zx_rfid_setting entity) + { + try + { + return _repository.Update(entity); + } + catch (Exception ex) + { + log.Error("RFID信息修改异常", ex); + return false; + } + } + } +} diff --git a/HighWayIot.Winform/HighWayIot.Winform.csproj b/HighWayIot.Winform/HighWayIot.Winform.csproj index 26e17fa..578a4de 100644 --- a/HighWayIot.Winform/HighWayIot.Winform.csproj +++ b/HighWayIot.Winform/HighWayIot.Winform.csproj @@ -118,6 +118,12 @@ MonitorMainPage.cs + + Form + + + UpdateRfidWindow.cs + Form @@ -248,6 +254,9 @@ MonitorMainPage.cs + + UpdateRfidWindow.cs + AddRecipeForm.cs diff --git a/HighWayIot.Winform/UserControlPages/ParamConfigPages/RFIDParamSettingPage.Designer.cs b/HighWayIot.Winform/UserControlPages/ParamConfigPages/RFIDParamSettingPage.Designer.cs index 9f93b13..b31f126 100644 --- a/HighWayIot.Winform/UserControlPages/ParamConfigPages/RFIDParamSettingPage.Designer.cs +++ b/HighWayIot.Winform/UserControlPages/ParamConfigPages/RFIDParamSettingPage.Designer.cs @@ -31,68 +31,105 @@ namespace HighWayIot.Winform.UserControlPages.ParamConfigPages /// private void InitializeComponent() { - this.RoleDataGridView = new System.Windows.Forms.DataGridView(); - this.AddRole = new System.Windows.Forms.Button(); + this.GetRfidButton = new System.Windows.Forms.Button(); this.ButtonPanel = new System.Windows.Forms.Panel(); - ((System.ComponentModel.ISupportInitialize)(this.RoleDataGridView)).BeginInit(); + this.rfidDataGridView = new System.Windows.Forms.DataGridView(); + this.Id = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.RfidIp = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.RfidEpc = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.WorkstateNo = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.ButtonPanel.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.rfidDataGridView)).BeginInit(); this.SuspendLayout(); // - // RoleDataGridView + // GetRfidButton // - this.RoleDataGridView.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))); - this.RoleDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.RoleDataGridView.Location = new System.Drawing.Point(0, 65); - this.RoleDataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.RoleDataGridView.Name = "RoleDataGridView"; - this.RoleDataGridView.RowTemplate.Height = 25; - this.RoleDataGridView.Size = new System.Drawing.Size(1171, 742); - this.RoleDataGridView.TabIndex = 0; - this.RoleDataGridView.Tag = ""; - // - // AddRole - // - this.AddRole.Location = new System.Drawing.Point(11, 11); - this.AddRole.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.AddRole.Name = "AddRole"; - this.AddRole.Size = new System.Drawing.Size(103, 39); - this.AddRole.TabIndex = 1; - this.AddRole.Text = "查询操作信息"; - this.AddRole.UseVisualStyleBackColor = true; + this.GetRfidButton.Location = new System.Drawing.Point(3, 2); + this.GetRfidButton.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.GetRfidButton.Name = "GetRfidButton"; + this.GetRfidButton.Size = new System.Drawing.Size(103, 39); + this.GetRfidButton.TabIndex = 1; + this.GetRfidButton.Text = "查 询"; + this.GetRfidButton.UseVisualStyleBackColor = true; + this.GetRfidButton.Click += new System.EventHandler(this.GetRfidButton_Click); // // ButtonPanel // this.ButtonPanel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.ButtonPanel.Controls.Add(this.AddRole); + this.ButtonPanel.Controls.Add(this.GetRfidButton); this.ButtonPanel.Location = new System.Drawing.Point(0, 0); this.ButtonPanel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.ButtonPanel.Name = "ButtonPanel"; this.ButtonPanel.Size = new System.Drawing.Size(1171, 61); this.ButtonPanel.TabIndex = 4; // + // rfidDataGridView + // + this.rfidDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.rfidDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.Id, + this.RfidIp, + this.RfidEpc, + this.WorkstateNo}); + this.rfidDataGridView.Location = new System.Drawing.Point(20, 66); + this.rfidDataGridView.Name = "rfidDataGridView"; + this.rfidDataGridView.RowTemplate.Height = 23; + this.rfidDataGridView.Size = new System.Drawing.Size(1135, 724); + this.rfidDataGridView.TabIndex = 5; + this.rfidDataGridView.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.rfidDataGridView_CellDoubleClick); + // + // Id + // + this.Id.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.Id.FillWeight = 10F; + this.Id.HeaderText = "ID"; + this.Id.Name = "Id"; + // + // RfidIp + // + this.RfidIp.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.RfidIp.FillWeight = 20F; + this.RfidIp.HeaderText = "设备ip"; + this.RfidIp.Name = "RfidIp"; + // + // RfidEpc + // + this.RfidEpc.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.RfidEpc.FillWeight = 20F; + this.RfidEpc.HeaderText = "RFID编号"; + this.RfidEpc.Name = "RfidEpc"; + // + // WorkstateNo + // + this.WorkstateNo.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.WorkstateNo.FillWeight = 20F; + this.WorkstateNo.HeaderText = "工位编号"; + this.WorkstateNo.Name = "WorkstateNo"; + // // RFIDParamSettingPage // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.SystemColors.ControlLight; + this.Controls.Add(this.rfidDataGridView); this.Controls.Add(this.ButtonPanel); - this.Controls.Add(this.RoleDataGridView); this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.Name = "RFIDParamSettingPage"; this.Size = new System.Drawing.Size(1171, 807); - ((System.ComponentModel.ISupportInitialize)(this.RoleDataGridView)).EndInit(); this.ButtonPanel.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.rfidDataGridView)).EndInit(); this.ResumeLayout(false); } #endregion - - private DataGridView RoleDataGridView; - private Button AddRole; + private Button GetRfidButton; private Panel ButtonPanel; + private DataGridView rfidDataGridView; + private DataGridViewTextBoxColumn Id; + private DataGridViewTextBoxColumn RfidIp; + private DataGridViewTextBoxColumn RfidEpc; + private DataGridViewTextBoxColumn WorkstateNo; } } diff --git a/HighWayIot.Winform/UserControlPages/ParamConfigPages/RFIDParamSettingPage.cs b/HighWayIot.Winform/UserControlPages/ParamConfigPages/RFIDParamSettingPage.cs index 1126abb..13b1dee 100644 --- a/HighWayIot.Winform/UserControlPages/ParamConfigPages/RFIDParamSettingPage.cs +++ b/HighWayIot.Winform/UserControlPages/ParamConfigPages/RFIDParamSettingPage.cs @@ -1,4 +1,6 @@ -using System; +using HighWayIot.Repository.domain; +using HighWayIot.Repository.service; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; @@ -12,14 +14,45 @@ namespace HighWayIot.Winform.UserControlPages.ParamConfigPages { public partial class RFIDParamSettingPage : UserControl { + private Zx_rfid_settingService zx_rfid_settingService = Zx_rfid_settingService.Instance; public RFIDParamSettingPage() { InitializeComponent(); } - private void UpdateRole_Click(object sender, EventArgs e) + + + private void GetRfidButton_Click(object sender, EventArgs e) + { + this.rfidDataGridView.Rows.Clear(); + List list = zx_rfid_settingService.GetRfidInfos(); + foreach (var item in list) + { + this.rfidDataGridView.Rows.Add(item.Id, item.RfidIp, item.RfidEpc, item.WorkstateNo); + } + + } + + private void rfidDataGridView_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { + // 检查是否双击了有效的行(排除列头) + if (e.RowIndex >= 0) + { + // 获取双击的行 + DataGridViewRow row = rfidDataGridView.Rows[e.RowIndex]; + // 获取该行的数据 + int id = (int)row.Cells["Id"].Value; + string RfidIp = (string)row.Cells["RfidIp"].Value; + string RfidEpc = (string)row.Cells["RfidEpc"].Value; + string WorkstateNo = (string)row.Cells["WorkstateNo"].Value; + UpdateRfidWindow window = new UpdateRfidWindow(id, RfidIp,RfidEpc, WorkstateNo); + window.Show(); + + + } } + + } } diff --git a/HighWayIot.Winform/UserControlPages/ParamConfigPages/RFIDParamSettingPage.resx b/HighWayIot.Winform/UserControlPages/ParamConfigPages/RFIDParamSettingPage.resx index 1af7de1..ed88a1c 100644 --- a/HighWayIot.Winform/UserControlPages/ParamConfigPages/RFIDParamSettingPage.resx +++ b/HighWayIot.Winform/UserControlPages/ParamConfigPages/RFIDParamSettingPage.resx @@ -117,4 +117,16 @@ 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/HighWayIot.Winform/UserControlPages/ParamConfigPages/UpdateRfidWindow.Designer.cs b/HighWayIot.Winform/UserControlPages/ParamConfigPages/UpdateRfidWindow.Designer.cs new file mode 100644 index 0000000..826336c --- /dev/null +++ b/HighWayIot.Winform/UserControlPages/ParamConfigPages/UpdateRfidWindow.Designer.cs @@ -0,0 +1,127 @@ +namespace HighWayIot.Winform.UserControlPages.ParamConfigPages +{ + partial class UpdateRfidWindow + { + /// + /// 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.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.RfidIptextBox = new System.Windows.Forms.TextBox(); + this.RfidEpctextBox = new System.Windows.Forms.TextBox(); + this.WorkstateNotextBox = new System.Windows.Forms.TextBox(); + this.saveButton = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(174, 56); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(65, 12); + this.label1.TabIndex = 0; + this.label1.Text = "读写器IP:"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(174, 135); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(65, 12); + this.label2.TabIndex = 1; + this.label2.Text = "RFID编号:"; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(174, 211); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(65, 12); + this.label3.TabIndex = 2; + this.label3.Text = "工位编号:"; + // + // RfidIptextBox + // + this.RfidIptextBox.Location = new System.Drawing.Point(241, 53); + this.RfidIptextBox.Name = "RfidIptextBox"; + this.RfidIptextBox.Size = new System.Drawing.Size(159, 21); + this.RfidIptextBox.TabIndex = 3; + // + // RfidEpctextBox + // + this.RfidEpctextBox.Location = new System.Drawing.Point(241, 135); + this.RfidEpctextBox.Name = "RfidEpctextBox"; + this.RfidEpctextBox.Size = new System.Drawing.Size(159, 21); + this.RfidEpctextBox.TabIndex = 4; + // + // WorkstateNotextBox + // + this.WorkstateNotextBox.Location = new System.Drawing.Point(241, 211); + this.WorkstateNotextBox.Name = "WorkstateNotextBox"; + this.WorkstateNotextBox.Size = new System.Drawing.Size(159, 21); + this.WorkstateNotextBox.TabIndex = 5; + // + // saveButton + // + this.saveButton.Location = new System.Drawing.Point(271, 315); + this.saveButton.Name = "saveButton"; + this.saveButton.Size = new System.Drawing.Size(75, 23); + this.saveButton.TabIndex = 6; + this.saveButton.Text = "修改"; + this.saveButton.UseVisualStyleBackColor = true; + this.saveButton.Click += new System.EventHandler(this.saveButton_Click); + // + // UpdateRfidWindow + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(674, 450); + this.Controls.Add(this.saveButton); + this.Controls.Add(this.WorkstateNotextBox); + this.Controls.Add(this.RfidEpctextBox); + this.Controls.Add(this.RfidIptextBox); + this.Controls.Add(this.label3); + this.Controls.Add(this.label2); + this.Controls.Add(this.label1); + this.Name = "UpdateRfidWindow"; + this.Text = "UpdateRfidWindow"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.TextBox RfidIptextBox; + private System.Windows.Forms.TextBox RfidEpctextBox; + private System.Windows.Forms.TextBox WorkstateNotextBox; + private System.Windows.Forms.Button saveButton; + } +} \ No newline at end of file diff --git a/HighWayIot.Winform/UserControlPages/ParamConfigPages/UpdateRfidWindow.cs b/HighWayIot.Winform/UserControlPages/ParamConfigPages/UpdateRfidWindow.cs new file mode 100644 index 0000000..b935882 --- /dev/null +++ b/HighWayIot.Winform/UserControlPages/ParamConfigPages/UpdateRfidWindow.cs @@ -0,0 +1,43 @@ +using HighWayIot.Repository.domain; +using HighWayIot.Repository.service; +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; + +namespace HighWayIot.Winform.UserControlPages.ParamConfigPages +{ + public partial class UpdateRfidWindow : Form + { + private Zx_rfid_settingService zx_rfid_settingService = Zx_rfid_settingService.Instance; + private int _id; + public UpdateRfidWindow(int id,string ip,string epc,string no) + { + _id = id; + InitializeComponent(); + RfidIptextBox.Text = ip; + RfidEpctextBox.Text = epc; + WorkstateNotextBox.Text = no; + } + + private void saveButton_Click(object sender, EventArgs e) + { + if (!int.TryParse(WorkstateNotextBox.Text,out int result)) + { + MessageBox.Show("工作状态编号必须是整数"); + return; + } + Zx_rfid_setting zx_Rfid_Setting = zx_rfid_settingService.GetRfidInfoById(_id); + zx_Rfid_Setting.RfidIp = RfidIptextBox.Text; + zx_Rfid_Setting.RfidEpc = RfidEpctextBox.Text; + zx_Rfid_Setting.WorkstateNo = result; + zx_rfid_settingService.UpdateRfidInfo(zx_Rfid_Setting); + MessageBox.Show("修改成功"); + } + } +} diff --git a/HighWayIot.Winform/UserControlPages/ParamConfigPages/UpdateRfidWindow.resx b/HighWayIot.Winform/UserControlPages/ParamConfigPages/UpdateRfidWindow.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/HighWayIot.Winform/UserControlPages/ParamConfigPages/UpdateRfidWindow.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/HighWayIot.Winform/UserControlPages/TestPage.cs b/HighWayIot.Winform/UserControlPages/TestPage.cs index f5012c6..3b1cd8d 100644 --- a/HighWayIot.Winform/UserControlPages/TestPage.cs +++ b/HighWayIot.Winform/UserControlPages/TestPage.cs @@ -7,7 +7,7 @@ using System.Collections.Generic; using System.Linq; using System.Net; using System.Windows.Forms; -using TouchSocket.Core; + using static System.Windows.Forms.VisualStyles.VisualStyleElement;