diff --git a/DB/Service/UserService.cs b/DB/Service/UserService.cs index f4956f1..0b0fa6c 100644 --- a/DB/Service/UserService.cs +++ b/DB/Service/UserService.cs @@ -1,15 +1,14 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Web.Security; -using System.Windows.Forms.VisualStyles; -using Chloe; +using Chloe; using DB.Dto; using DB.Entity; +using NewLife.Web; + +using System; +using System.Collections.Generic; +using System.Linq; + using Tool; namespace DB.Service @@ -31,6 +30,39 @@ namespace DB.Service } } + public UserInfo Query(long id) + { + using (var dbContext = DbFactory.GetContext) + { + var queryByKey = dbContext.QueryByKey(id); + return queryByKey; + } + } + + public void Update(UserInfo useInfo) + { + using (var dbContext = DbFactory.GetContext) + { + dbContext.Update(useInfo); + } + } + + + public void UpdateDel(IReadOnlyCollection lsLongs) + { + using (var dbContext = DbFactory.GetContext) + { + foreach (var lsLong in lsLongs) + { + dbContext.Update(a => a.ID == lsLong, a => new UserInfo() + { + IsDelete = 1 + }); + } + } + } + + public PagedList GetPagedList(int pageIndex, int pageSize, string key) { @@ -160,6 +192,35 @@ namespace DB.Service } + public UserDto GetOne(string name,long id) + { + using (var dbContext = DbFactory.GetContext) + { + var userInfo = dbContext.Query(). + Where(x => x.UserName == name) + .WhereIf(id>0,x=>x.ID!=id) + .FirstOrDefault(); + if (userInfo != null) + { + var first = roleService.GetList().First(x => x.ID == userInfo.RoleId); + UserDto user = new UserDto + { + Id = userInfo.ID, + UserName = userInfo.UserName, + RoleId = first.ID, + RoleName = first.RoleName, + RoleLevel = first.RoleLevel + }; + return user; + } + + } + + return null; + } + + + public List GetAllName() { diff --git a/RfidWeb/FormLogin.Designer.cs b/RfidWeb/FormLogin.Designer.cs index 1f6292b..891c521 100644 --- a/RfidWeb/FormLogin.Designer.cs +++ b/RfidWeb/FormLogin.Designer.cs @@ -29,14 +29,14 @@ private void InitializeComponent() { this.panel1 = new System.Windows.Forms.Panel(); + this.panel2 = new System.Windows.Forms.Panel(); + this.pictureBox1 = new System.Windows.Forms.PictureBox(); + this.button2 = new System.Windows.Forms.Button(); + this.button1 = new System.Windows.Forms.Button(); this.label1 = new System.Windows.Forms.Label(); + this.comboPwd = new HZH_Controls.Controls.TextBoxEx(); this.comboUser = new System.Windows.Forms.ComboBox(); this.label2 = new System.Windows.Forms.Label(); - this.comboPwd = new HZH_Controls.Controls.TextBoxEx(); - this.button1 = new System.Windows.Forms.Button(); - this.button2 = new System.Windows.Forms.Button(); - this.panel2 = new System.Windows.Forms.Panel(); - this.pictureBox1 = new System.Windows.Forms.PictureBox(); this.panel1.SuspendLayout(); this.panel2.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); @@ -47,44 +47,79 @@ this.panel1.Controls.Add(this.panel2); this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; this.panel1.Location = new System.Drawing.Point(0, 0); + this.panel1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(585, 285); + this.panel1.Size = new System.Drawing.Size(878, 428); this.panel1.TabIndex = 0; // + // panel2 + // + this.panel2.BackColor = System.Drawing.Color.White; + this.panel2.Controls.Add(this.pictureBox1); + this.panel2.Controls.Add(this.button2); + this.panel2.Controls.Add(this.button1); + this.panel2.Controls.Add(this.label1); + this.panel2.Controls.Add(this.comboPwd); + this.panel2.Controls.Add(this.comboUser); + this.panel2.Controls.Add(this.label2); + this.panel2.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel2.Location = new System.Drawing.Point(0, 0); + this.panel2.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.panel2.Name = "panel2"; + this.panel2.Size = new System.Drawing.Size(878, 428); + this.panel2.TabIndex = 2; + this.panel2.Paint += new System.Windows.Forms.PaintEventHandler(this.panel2_Paint); + // + // pictureBox1 + // + this.pictureBox1.Image = global::RfidWeb.Properties.Resources.海威图标在上; + this.pictureBox1.Location = new System.Drawing.Point(40, 39); + this.pictureBox1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.pictureBox1.Name = "pictureBox1"; + this.pictureBox1.Size = new System.Drawing.Size(404, 350); + this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; + this.pictureBox1.TabIndex = 6; + this.pictureBox1.TabStop = false; + // + // button2 + // + this.button2.Location = new System.Drawing.Point(688, 274); + this.button2.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(134, 66); + this.button2.TabIndex = 5; + this.button2.Text = "取消"; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.button2_Click); + // + // button1 + // + this.button1.Location = new System.Drawing.Point(501, 274); + this.button1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(136, 66); + this.button1.TabIndex = 4; + this.button1.Text = "登录"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // // label1 // 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(324, 69); + this.label1.Location = new System.Drawing.Point(486, 104); + this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(79, 16); + this.label1.Size = new System.Drawing.Size(118, 24); this.label1.TabIndex = 0; this.label1.Text = "登录用户:"; // - // comboUser - // - this.comboUser.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.comboUser.FormattingEnabled = true; - this.comboUser.Location = new System.Drawing.Point(409, 66); - this.comboUser.Name = "comboUser"; - this.comboUser.Size = new System.Drawing.Size(139, 24); - this.comboUser.TabIndex = 1; - // - // label2 - // - 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(324, 126); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(79, 16); - this.label2.TabIndex = 2; - this.label2.Text = "登录密码:"; - // // comboPwd // this.comboPwd.DecLength = 2; this.comboPwd.InputType = HZH_Controls.TextInputType.NotControl; - this.comboPwd.Location = new System.Drawing.Point(409, 126); + this.comboPwd.Location = new System.Drawing.Point(614, 189); + this.comboPwd.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.comboPwd.MaxValue = new decimal(new int[] { 20, 0, @@ -103,61 +138,38 @@ this.comboPwd.PromptFont = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); this.comboPwd.PromptText = ""; this.comboPwd.RegexPattern = ""; - this.comboPwd.Size = new System.Drawing.Size(139, 21); + this.comboPwd.Size = new System.Drawing.Size(206, 28); this.comboPwd.TabIndex = 3; + this.comboPwd.KeyDown += new System.Windows.Forms.KeyEventHandler(this.comboPwd_KeyDown); // - // button1 - // - this.button1.Location = new System.Drawing.Point(334, 183); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(91, 44); - this.button1.TabIndex = 4; - this.button1.Text = "登录"; - this.button1.UseVisualStyleBackColor = true; - this.button1.Click += new System.EventHandler(this.button1_Click); - // - // button2 - // - this.button2.Location = new System.Drawing.Point(459, 183); - this.button2.Name = "button2"; - this.button2.Size = new System.Drawing.Size(89, 44); - this.button2.TabIndex = 5; - this.button2.Text = "取消"; - this.button2.UseVisualStyleBackColor = true; - this.button2.Click += new System.EventHandler(this.button2_Click); - // - // panel2 + // comboUser // - this.panel2.BackColor = System.Drawing.Color.White; - this.panel2.Controls.Add(this.pictureBox1); - this.panel2.Controls.Add(this.button2); - this.panel2.Controls.Add(this.button1); - this.panel2.Controls.Add(this.label1); - this.panel2.Controls.Add(this.comboPwd); - this.panel2.Controls.Add(this.comboUser); - this.panel2.Controls.Add(this.label2); - this.panel2.Dock = System.Windows.Forms.DockStyle.Fill; - this.panel2.Location = new System.Drawing.Point(0, 0); - this.panel2.Name = "panel2"; - this.panel2.Size = new System.Drawing.Size(585, 285); - this.panel2.TabIndex = 2; + this.comboUser.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.comboUser.FormattingEnabled = true; + this.comboUser.Location = new System.Drawing.Point(614, 99); + this.comboUser.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.comboUser.Name = "comboUser"; + this.comboUser.Size = new System.Drawing.Size(206, 32); + this.comboUser.TabIndex = 1; // - // pictureBox1 + // label2 // - this.pictureBox1.Image = global::RfidWeb.Properties.Resources.海威图标在上; - this.pictureBox1.Location = new System.Drawing.Point(27, 26); - this.pictureBox1.Name = "pictureBox1"; - this.pictureBox1.Size = new System.Drawing.Size(269, 233); - this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; - this.pictureBox1.TabIndex = 6; - this.pictureBox1.TabStop = false; + 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(486, 189); + this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(118, 24); + this.label2.TabIndex = 2; + this.label2.Text = "登录密码:"; // // FormLogin // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(585, 285); + this.ClientSize = new System.Drawing.Size(878, 428); this.Controls.Add(this.panel1); + this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.Name = "FormLogin"; this.Text = "登录窗口"; this.panel1.ResumeLayout(false); diff --git a/RfidWeb/FormLogin.cs b/RfidWeb/FormLogin.cs index cf8759b..a61fcc4 100644 --- a/RfidWeb/FormLogin.cs +++ b/RfidWeb/FormLogin.cs @@ -4,6 +4,7 @@ using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; +using System.Security.Cryptography; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; @@ -29,7 +30,11 @@ namespace RfidWeb { comboUser.SelectedIndex = 0; } - + + comboPwd.Text = "123456"; + comboPwd.Focus(); + + } private void button2_Click(object sender, EventArgs e) @@ -48,7 +53,7 @@ namespace RfidWeb return; } - pwd = pwd.MD5().ToUpper(); + pwd = Aes.Create().Encrypt(pwd.GetBytes(), "nodyang".GetBytes()).ToBase64(); var one= userService.GetOne(userName, pwd); if (one == null) { @@ -62,6 +67,21 @@ namespace RfidWeb this.Close(); + } + + private void comboPwd_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) + { + if (e.KeyCode == Keys.Enter) + { + button1.PerformClick(); // 触发按钮点击事件 + e.Handled = true; // 阻止默认的按键处理 + e.SuppressKeyPress = true; // 防止"叮"声 + } + } + + private void panel2_Paint(object sender, PaintEventArgs e) + { + } } } diff --git a/RfidWeb/FormMain.Designer.cs b/RfidWeb/FormMain.Designer.cs index b79be49..4fd6ea6 100644 --- a/RfidWeb/FormMain.Designer.cs +++ b/RfidWeb/FormMain.Designer.cs @@ -272,11 +272,11 @@ // // pictureBox1 // - this.pictureBox1.Image = global::RfidWeb.Properties.Resources.海威物联; + this.pictureBox1.Image = global::RfidWeb.Properties.Resources.log; this.pictureBox1.Location = new System.Drawing.Point(22, 14); this.pictureBox1.Margin = new System.Windows.Forms.Padding(4); this.pictureBox1.Name = "pictureBox1"; - this.pictureBox1.Size = new System.Drawing.Size(324, 40); + this.pictureBox1.Size = new System.Drawing.Size(340, 40); this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; this.pictureBox1.TabIndex = 0; this.pictureBox1.TabStop = false; diff --git a/RfidWeb/Frm/FormAccount.Designer.cs b/RfidWeb/Frm/FormAccount.Designer.cs index a0305b1..210355e 100644 --- a/RfidWeb/Frm/FormAccount.Designer.cs +++ b/RfidWeb/Frm/FormAccount.Designer.cs @@ -109,6 +109,7 @@ this.ucBtnUpdate.TabStop = false; this.ucBtnUpdate.TipsColor = System.Drawing.Color.FromArgb(((int)(((byte)(28)))), ((int)(((byte)(101)))), ((int)(((byte)(204))))); this.ucBtnUpdate.TipsText = ""; + this.ucBtnUpdate.BtnClick += new System.EventHandler(this.ucBtnUpdate_BtnClick); // // ucBtnAdd // diff --git a/RfidWeb/Frm/FormAccount.cs b/RfidWeb/Frm/FormAccount.cs index 49ce42e..833c2e1 100644 --- a/RfidWeb/Frm/FormAccount.cs +++ b/RfidWeb/Frm/FormAccount.cs @@ -23,24 +23,28 @@ namespace RfidWeb.Frm public FormAccount() { InitializeComponent(); - Init(); + OlduserDto= UserManager.GetUser(); - + Init(); } private void Init() { - List lstCulumns = new List(); - lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "Id", HeadText = "编号", Width = 100, WidthType = SizeType.Absolute }); - lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "UserName", HeadText = "姓名", Width = 50, WidthType = SizeType.Percent }); - lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "RoleName", HeadText = "权限名称", Width = 50, WidthType = SizeType.Percent }); + List lstCulumns = new List + { + new DataGridViewColumnEntity() { DataField = "Id", HeadText = "编号", Width = 100, WidthType = SizeType.Absolute }, + new DataGridViewColumnEntity() { DataField = "UserName", HeadText = "姓名", Width = 50, WidthType = SizeType.Percent }, + new DataGridViewColumnEntity() { DataField = "RoleName", HeadText = "权限名称", Width = 50, WidthType = SizeType.Percent } + }; this.ucDataGridViewContent.Columns = lstCulumns; this.ucDataGridViewContent.IsShowCheckBox = true; ucPagerControl21.PageModel = PageModel.PageCount; ucPagerControl21.PageIndex = 1; ucPagerControl21.PageSize = 20; - + // ucPagerControl21_ShowSourceChanged(new object()); + + } private void ucPagerControl21_ShowSourceChanged(object currentSource) @@ -66,6 +70,9 @@ namespace RfidWeb.Frm } var page = userService.GetPagedList(index, ucPagerControl21.PageSize, key,lsInts); ucPagerControl21.PageCount = page.TotalPages; + + this.ucDataGridViewContent.IsShowCheckBox = true; + // this.ucDataGridViewContent.DataSource = null; this.ucDataGridViewContent.DataSource = page.Items; } @@ -94,7 +101,58 @@ namespace RfidWeb.Frm private void ucBtnDel_BtnClick(object sender, EventArgs e) { var dataGridViewRows = ucDataGridViewContent.SelectRows; - var dataSource = dataGridViewRows.First().DataSource as UserDto; + if (dataGridViewRows.Count == 0) + { + FrmDialog.ShowDialog(this, "请勾选相关信息", "警告窗体"); + return; + } + + List ls = new List(); + foreach (var dr in dataGridViewRows) + { + var dto = dr.DataSource as UserDto; + if (dto != null) + { + ls.Add(dto.Id); + } + } + + if (ls.Any()) + { + userService.UpdateDel(ls); + + ucPagerControl21.PageIndex = 1; + + this.ucDataGridViewContent.IsShowCheckBox = false; + ucPagerControl21_ShowSourceChanged(new object()); + + } + + + } + + + + private void ucBtnUpdate_BtnClick(object sender, EventArgs e) + { + + var dataGridViewRows = ucDataGridViewContent.SelectRows; + if (dataGridViewRows.Count!=1) + { + FrmDialog.ShowDialog(this, "只能修改一条", "警告窗体"); + return; + } + + + var dto = dataGridViewRows.First().DataSource as UserDto; + FormRegister formRegis = new FormRegister(dto.Id, OlduserDto); + formRegis.StartPosition = FormStartPosition.CenterScreen; // 设置窗口显示在屏幕中央 + formRegis.ShowDialog(); + + ucPagerControl21.PageIndex = 1; + this.ucDataGridViewContent.IsShowCheckBox = false; + ucPagerControl21_ShowSourceChanged(new object()); + } } } diff --git a/RfidWeb/Frm/FormRegister.Designer.cs b/RfidWeb/Frm/FormRegister.Designer.cs index cd475d7..f49995b 100644 --- a/RfidWeb/Frm/FormRegister.Designer.cs +++ b/RfidWeb/Frm/FormRegister.Designer.cs @@ -33,6 +33,7 @@ this.btnCancel = new HZH_Controls.Controls.UCBtnExt(); this.btnOK = new HZH_Controls.Controls.UCBtnExt(); this.panel1 = new System.Windows.Forms.Panel(); + 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(); @@ -40,7 +41,6 @@ this.ucCombox1 = new HZH_Controls.Controls.UCCombox(); this.ucTextBoxPwd = new HZH_Controls.Controls.UCTextBoxEx(); this.ucTextBoxUser = new HZH_Controls.Controls.UCTextBoxEx(); - this.label5 = new System.Windows.Forms.Label(); this.tableLayoutPanel1.SuspendLayout(); this.panel1.SuspendLayout(); this.SuspendLayout(); @@ -145,6 +145,16 @@ this.panel1.Size = new System.Drawing.Size(835, 398); this.panel1.TabIndex = 8; // + // label5 + // + this.label5.AutoSize = true; + this.label5.Font = new System.Drawing.Font("微软雅黑", 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label5.Location = new System.Drawing.Point(199, 218); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(99, 41); + this.label5.TabIndex = 12; + this.label5.Text = "级 别:"; + // // label4 // this.label4.AutoSize = true; @@ -200,7 +210,7 @@ this.ucCombox1.IsShowRect = true; this.ucCombox1.ItemHeight = 35; this.ucCombox1.ItemWidth = 70; - this.ucCombox1.Location = new System.Drawing.Point(352, 218); + this.ucCombox1.Location = new System.Drawing.Point(352, 220); this.ucCombox1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.ucCombox1.Name = "ucCombox1"; this.ucCombox1.Padding = new System.Windows.Forms.Padding(2); @@ -304,16 +314,6 @@ this.ucTextBoxUser.TabIndex = 5; this.ucTextBoxUser.TextAlign = System.Windows.Forms.HorizontalAlignment.Left; // - // label5 - // - this.label5.AutoSize = true; - this.label5.Font = new System.Drawing.Font("微软雅黑", 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.label5.Location = new System.Drawing.Point(199, 218); - this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(99, 41); - this.label5.TabIndex = 12; - this.label5.Text = "级 别:"; - // // FormRegister // this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F); diff --git a/RfidWeb/Frm/FormRegister.cs b/RfidWeb/Frm/FormRegister.cs index ed08b60..bc15fd8 100644 --- a/RfidWeb/Frm/FormRegister.cs +++ b/RfidWeb/Frm/FormRegister.cs @@ -4,6 +4,7 @@ using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; +using System.Security.Cryptography; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; @@ -11,39 +12,66 @@ using DB.Dto; using DB.Entity; using DB.Service; using NewLife; +using NewLife.Data; + using Tool; namespace RfidWeb.Frm { public partial class FormRegister : Form { + private readonly string Kes = "nodyang"; private RoleService roleService = new RoleService(); private UserService userService = new UserService(); - + private long id = 0; private UserDto OlduserDto; public FormRegister() { InitializeComponent(); + + + label3.Text = ""; label4.Text = ""; - var list = roleService.GetList(); - List> key = new List>(); - foreach (var role in list) - { - key.Add(new KeyValuePair(role.ID.ToString(), role.RoleName)); - } - - ucCombox1.Source = key; + FillCbo(); ucCombox1.SelectedIndex = 0; } + public void FillCbo() + { + var list = roleService.GetList(); + List> key = new List>(); + foreach (var role in list) + { + key.Add(new KeyValuePair(role.ID.ToString(), role.RoleName)); + } + + ucCombox1.Source = key; + } + public FormRegister(UserDto userDto):this() { this.OlduserDto = userDto; } + public FormRegister(long id,UserDto userDto) + { + InitializeComponent(); + this.OlduserDto = userDto; + this.id = id; + var info = userService.Query(id); + this.ucTextBoxUser.InputText = info.UserName; + this.ucTextBoxPwd.InputText = Aes.Create().Decrypt(info.Pwd.ToBase64(), Kes.GetBytes()).ToStr(); + + label3.Text = ""; + label4.Text = ""; + + FillCbo(); + ucCombox1.SelectedValue =info.RoleId.ToString(); + } + private void btnCancel_BtnClick(object sender, EventArgs e) { this.Close(); @@ -69,26 +97,43 @@ namespace RfidWeb.Frm } - var userDto = userService.GetOne(user); + var userDto = userService.GetOne(user,id); if (userDto != null) { this.label3.Text = "已经存在"; return; } + + if (id == 0) + { + UserInfo userInfo = new UserInfo + { + ID = SnowflakeFactory.NewId, + UserName = user, + Pwd = Aes.Create().Encrypt(pwd.GetBytes(), Kes.GetBytes()).ToBase64(), + RoleId = roleId, + CreateUserId = OlduserDto.Id.ToString(), + CreateUserName = OlduserDto.UserName, + CreateDate = DateTime.Now, - UserInfo userInfo = new UserInfo(); - userInfo.ID = SnowflakeFactory.NewId; - userInfo.UserName=user; - userInfo.Pwd = pwd.MD5().ToUpper(); - userInfo.RoleId=roleId; - userInfo.CreateUserId = OlduserDto.Id.ToString(); - userInfo.CreateUserName = OlduserDto.UserName; - userInfo.CreateDate=DateTime.Now; - - userInfo.LastModifyUserId = OlduserDto.Id.ToString(); - userInfo.LastModifyUserName = OlduserDto.UserName; - userInfo.LastModifyDate = DateTime.Now; - userService.Add(userInfo); + LastModifyUserId = OlduserDto.Id.ToString(), + LastModifyUserName = OlduserDto.UserName, + LastModifyDate = DateTime.Now + }; + userService.Add(userInfo); + } + else + { + var info = userService.Query(id); + info.UserName = user; + info.Pwd = Aes.Create().Encrypt(pwd.GetBytes(), Kes.GetBytes()).ToBase64(); + info.RoleId=roleId; + info.LastModifyUserId = OlduserDto.Id.ToString(); + info.LastModifyUserName = OlduserDto.UserName; + info.LastModifyDate = DateTime.Now; + userService.Update(info); + } + this.Close(); } } } diff --git a/RfidWeb/Frm/UserMain.Designer.cs b/RfidWeb/Frm/UserMain.Designer.cs index a7f3371..6122939 100644 --- a/RfidWeb/Frm/UserMain.Designer.cs +++ b/RfidWeb/Frm/UserMain.Designer.cs @@ -544,7 +544,7 @@ // this.label13.AutoSize = true; this.label13.Font = new System.Drawing.Font("宋体", 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.label13.Location = new System.Drawing.Point(149, 11); + this.label13.Location = new System.Drawing.Point(127, 6); this.label13.Name = "label13"; this.label13.Size = new System.Drawing.Size(143, 33); this.label13.TabIndex = 1; @@ -631,11 +631,12 @@ // this.label18.AutoSize = true; this.label18.Font = new System.Drawing.Font("宋体", 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.label18.Location = new System.Drawing.Point(167, 11); + this.label18.Location = new System.Drawing.Point(156, 5); this.label18.Name = "label18"; this.label18.Size = new System.Drawing.Size(143, 33); this.label18.TabIndex = 4; this.label18.Text = "层切工位"; + this.label18.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // pictureBox3 // diff --git a/RfidWeb/Properties/Resources.Designer.cs b/RfidWeb/Properties/Resources.Designer.cs index 18cc66a..8672480 100644 --- a/RfidWeb/Properties/Resources.Designer.cs +++ b/RfidWeb/Properties/Resources.Designer.cs @@ -110,6 +110,16 @@ namespace RfidWeb.Properties { } } + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap log { + get { + object obj = ResourceManager.GetObject("log", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// 查找 System.Drawing.Bitmap 类型的本地化资源。 /// diff --git a/RfidWeb/Properties/Resources.resx b/RfidWeb/Properties/Resources.resx index 2f93d12..208452f 100644 --- a/RfidWeb/Properties/Resources.resx +++ b/RfidWeb/Properties/Resources.resx @@ -118,9 +118,15 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + ..\Resources\海威图标在上.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\海威物联.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\btn_sel1.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\右箭头.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -130,6 +136,10 @@ ..\Resources\mesnac1.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\照明开.png;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + 照明开 + ..\Resources\frmBei.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -139,13 +149,6 @@ ..\Resources\左箭头.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\btn_sel1.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\照明开.png;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - 照明开 - ..\Resources\消音开.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -158,7 +161,7 @@ ..\Resources\照明关.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\海威图标在上.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\log.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a \ No newline at end of file diff --git a/RfidWeb/Resources/log.png b/RfidWeb/Resources/log.png new file mode 100644 index 0000000..49e0878 Binary files /dev/null and b/RfidWeb/Resources/log.png differ diff --git a/RfidWeb/RfidWeb.csproj b/RfidWeb/RfidWeb.csproj index 4f8420f..fdd43dd 100644 --- a/RfidWeb/RfidWeb.csproj +++ b/RfidWeb/RfidWeb.csproj @@ -242,6 +242,7 @@ +