yangw
nodyang@aliyun.com 1 month ago
parent 4b9e751d03
commit 183b162c7a

@ -1,15 +1,14 @@
using System; using Chloe;
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 DB.Dto; using DB.Dto;
using DB.Entity; using DB.Entity;
using NewLife.Web;
using System;
using System.Collections.Generic;
using System.Linq;
using Tool; using Tool;
namespace DB.Service namespace DB.Service
@ -31,6 +30,39 @@ namespace DB.Service
} }
} }
public UserInfo Query(long id)
{
using (var dbContext = DbFactory.GetContext)
{
var queryByKey = dbContext.QueryByKey<UserInfo>(id);
return queryByKey;
}
}
public void Update(UserInfo useInfo)
{
using (var dbContext = DbFactory.GetContext)
{
dbContext.Update(useInfo);
}
}
public void UpdateDel(IReadOnlyCollection<long> lsLongs)
{
using (var dbContext = DbFactory.GetContext)
{
foreach (var lsLong in lsLongs)
{
dbContext.Update<UserInfo>(a => a.ID == lsLong, a => new UserInfo()
{
IsDelete = 1
});
}
}
}
public PagedList<UserDto> GetPagedList(int pageIndex, int pageSize, string key) public PagedList<UserDto> 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<UserInfo>().
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<string> GetAllName() public List<string> GetAllName()
{ {

@ -29,14 +29,14 @@
private void InitializeComponent() private void InitializeComponent()
{ {
this.panel1 = new System.Windows.Forms.Panel(); 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.label1 = new System.Windows.Forms.Label();
this.comboPwd = new HZH_Controls.Controls.TextBoxEx();
this.comboUser = new System.Windows.Forms.ComboBox(); this.comboUser = new System.Windows.Forms.ComboBox();
this.label2 = new System.Windows.Forms.Label(); 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.panel1.SuspendLayout();
this.panel2.SuspendLayout(); this.panel2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
@ -47,44 +47,79 @@
this.panel1.Controls.Add(this.panel2); this.panel1.Controls.Add(this.panel2);
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel1.Location = new System.Drawing.Point(0, 0); 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.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(585, 285); this.panel1.Size = new System.Drawing.Size(878, 428);
this.panel1.TabIndex = 0; 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 // label1
// //
this.label1.AutoSize = true; this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); 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.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.TabIndex = 0;
this.label1.Text = "登录用户:"; 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 // comboPwd
// //
this.comboPwd.DecLength = 2; this.comboPwd.DecLength = 2;
this.comboPwd.InputType = HZH_Controls.TextInputType.NotControl; 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[] { this.comboPwd.MaxValue = new decimal(new int[] {
20, 20,
0, 0,
@ -103,61 +138,38 @@
this.comboPwd.PromptFont = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); this.comboPwd.PromptFont = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
this.comboPwd.PromptText = ""; this.comboPwd.PromptText = "";
this.comboPwd.RegexPattern = ""; 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.TabIndex = 3;
this.comboPwd.KeyDown += new System.Windows.Forms.KeyEventHandler(this.comboPwd_KeyDown);
// //
// button1 // comboUser
//
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
// //
this.panel2.BackColor = System.Drawing.Color.White; this.comboUser.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.panel2.Controls.Add(this.pictureBox1); this.comboUser.FormattingEnabled = true;
this.panel2.Controls.Add(this.button2); this.comboUser.Location = new System.Drawing.Point(614, 99);
this.panel2.Controls.Add(this.button1); this.comboUser.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.panel2.Controls.Add(this.label1); this.comboUser.Name = "comboUser";
this.panel2.Controls.Add(this.comboPwd); this.comboUser.Size = new System.Drawing.Size(206, 32);
this.panel2.Controls.Add(this.comboUser); this.comboUser.TabIndex = 1;
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;
// //
// pictureBox1 // label2
// //
this.pictureBox1.Image = global::RfidWeb.Properties.Resources.; this.label2.AutoSize = true;
this.pictureBox1.Location = new System.Drawing.Point(27, 26); this.label2.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.pictureBox1.Name = "pictureBox1"; this.label2.Location = new System.Drawing.Point(486, 189);
this.pictureBox1.Size = new System.Drawing.Size(269, 233); this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; this.label2.Name = "label2";
this.pictureBox1.TabIndex = 6; this.label2.Size = new System.Drawing.Size(118, 24);
this.pictureBox1.TabStop = false; this.label2.TabIndex = 2;
this.label2.Text = "登录密码:";
// //
// FormLogin // 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.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.Controls.Add(this.panel1);
this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.Name = "FormLogin"; this.Name = "FormLogin";
this.Text = "登录窗口"; this.Text = "登录窗口";
this.panel1.ResumeLayout(false); this.panel1.ResumeLayout(false);

@ -4,6 +4,7 @@ using System.ComponentModel;
using System.Data; using System.Data;
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;
using System.Security.Cryptography;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
@ -30,6 +31,10 @@ namespace RfidWeb
comboUser.SelectedIndex = 0; comboUser.SelectedIndex = 0;
} }
comboPwd.Text = "123456";
comboPwd.Focus();
} }
private void button2_Click(object sender, EventArgs e) private void button2_Click(object sender, EventArgs e)
@ -48,7 +53,7 @@ namespace RfidWeb
return; return;
} }
pwd = pwd.MD5().ToUpper(); pwd = Aes.Create().Encrypt(pwd.GetBytes(), "nodyang".GetBytes()).ToBase64();
var one= userService.GetOne(userName, pwd); var one= userService.GetOne(userName, pwd);
if (one == null) if (one == null)
{ {
@ -62,6 +67,21 @@ namespace RfidWeb
this.Close(); 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)
{
} }
} }
} }

@ -272,11 +272,11 @@
// //
// pictureBox1 // 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.Location = new System.Drawing.Point(22, 14);
this.pictureBox1.Margin = new System.Windows.Forms.Padding(4); this.pictureBox1.Margin = new System.Windows.Forms.Padding(4);
this.pictureBox1.Name = "pictureBox1"; 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.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox1.TabIndex = 0; this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false; this.pictureBox1.TabStop = false;

@ -109,6 +109,7 @@
this.ucBtnUpdate.TabStop = false; this.ucBtnUpdate.TabStop = false;
this.ucBtnUpdate.TipsColor = System.Drawing.Color.FromArgb(((int)(((byte)(28)))), ((int)(((byte)(101)))), ((int)(((byte)(204))))); this.ucBtnUpdate.TipsColor = System.Drawing.Color.FromArgb(((int)(((byte)(28)))), ((int)(((byte)(101)))), ((int)(((byte)(204)))));
this.ucBtnUpdate.TipsText = ""; this.ucBtnUpdate.TipsText = "";
this.ucBtnUpdate.BtnClick += new System.EventHandler(this.ucBtnUpdate_BtnClick);
// //
// ucBtnAdd // ucBtnAdd
// //

@ -23,23 +23,27 @@ namespace RfidWeb.Frm
public FormAccount() public FormAccount()
{ {
InitializeComponent(); InitializeComponent();
Init();
OlduserDto= UserManager.GetUser();
OlduserDto= UserManager.GetUser();
Init();
} }
private void Init() private void Init()
{ {
List<DataGridViewColumnEntity> lstCulumns = new List<DataGridViewColumnEntity>(); List<DataGridViewColumnEntity> lstCulumns = new List<DataGridViewColumnEntity>
lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "Id", HeadText = "编号", Width = 100, WidthType = SizeType.Absolute }); {
lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "UserName", HeadText = "姓名", Width = 50, WidthType = SizeType.Percent }); new DataGridViewColumnEntity() { DataField = "Id", HeadText = "编号", Width = 100, WidthType = SizeType.Absolute },
lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "RoleName", HeadText = "权限名称", Width = 50, WidthType = SizeType.Percent }); 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.Columns = lstCulumns;
this.ucDataGridViewContent.IsShowCheckBox = true; this.ucDataGridViewContent.IsShowCheckBox = true;
ucPagerControl21.PageModel = PageModel.PageCount; ucPagerControl21.PageModel = PageModel.PageCount;
ucPagerControl21.PageIndex = 1; ucPagerControl21.PageIndex = 1;
ucPagerControl21.PageSize = 20; ucPagerControl21.PageSize = 20;
// ucPagerControl21_ShowSourceChanged(new object());
} }
@ -66,6 +70,9 @@ namespace RfidWeb.Frm
} }
var page = userService.GetPagedList(index, ucPagerControl21.PageSize, key,lsInts); var page = userService.GetPagedList(index, ucPagerControl21.PageSize, key,lsInts);
ucPagerControl21.PageCount = page.TotalPages; ucPagerControl21.PageCount = page.TotalPages;
this.ucDataGridViewContent.IsShowCheckBox = true;
// this.ucDataGridViewContent.DataSource = null;
this.ucDataGridViewContent.DataSource = page.Items; this.ucDataGridViewContent.DataSource = page.Items;
} }
@ -94,7 +101,58 @@ namespace RfidWeb.Frm
private void ucBtnDel_BtnClick(object sender, EventArgs e) private void ucBtnDel_BtnClick(object sender, EventArgs e)
{ {
var dataGridViewRows = ucDataGridViewContent.SelectRows; var dataGridViewRows = ucDataGridViewContent.SelectRows;
var dataSource = dataGridViewRows.First().DataSource as UserDto; if (dataGridViewRows.Count == 0)
{
FrmDialog.ShowDialog(this, "请勾选相关信息", "警告窗体");
return;
}
List<long> ls = new List<long>();
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());
} }
} }
} }

@ -33,6 +33,7 @@
this.btnCancel = new HZH_Controls.Controls.UCBtnExt(); this.btnCancel = new HZH_Controls.Controls.UCBtnExt();
this.btnOK = new HZH_Controls.Controls.UCBtnExt(); this.btnOK = new HZH_Controls.Controls.UCBtnExt();
this.panel1 = new System.Windows.Forms.Panel(); this.panel1 = new System.Windows.Forms.Panel();
this.label5 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label(); this.label4 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label();
@ -40,7 +41,6 @@
this.ucCombox1 = new HZH_Controls.Controls.UCCombox(); this.ucCombox1 = new HZH_Controls.Controls.UCCombox();
this.ucTextBoxPwd = new HZH_Controls.Controls.UCTextBoxEx(); this.ucTextBoxPwd = new HZH_Controls.Controls.UCTextBoxEx();
this.ucTextBoxUser = new HZH_Controls.Controls.UCTextBoxEx(); this.ucTextBoxUser = new HZH_Controls.Controls.UCTextBoxEx();
this.label5 = new System.Windows.Forms.Label();
this.tableLayoutPanel1.SuspendLayout(); this.tableLayoutPanel1.SuspendLayout();
this.panel1.SuspendLayout(); this.panel1.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
@ -145,6 +145,16 @@
this.panel1.Size = new System.Drawing.Size(835, 398); this.panel1.Size = new System.Drawing.Size(835, 398);
this.panel1.TabIndex = 8; 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 // label4
// //
this.label4.AutoSize = true; this.label4.AutoSize = true;
@ -200,7 +210,7 @@
this.ucCombox1.IsShowRect = true; this.ucCombox1.IsShowRect = true;
this.ucCombox1.ItemHeight = 35; this.ucCombox1.ItemHeight = 35;
this.ucCombox1.ItemWidth = 70; 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.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.ucCombox1.Name = "ucCombox1"; this.ucCombox1.Name = "ucCombox1";
this.ucCombox1.Padding = new System.Windows.Forms.Padding(2); this.ucCombox1.Padding = new System.Windows.Forms.Padding(2);
@ -304,16 +314,6 @@
this.ucTextBoxUser.TabIndex = 5; this.ucTextBoxUser.TabIndex = 5;
this.ucTextBoxUser.TextAlign = System.Windows.Forms.HorizontalAlignment.Left; 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 // FormRegister
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F); this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F);

@ -4,6 +4,7 @@ using System.ComponentModel;
using System.Data; using System.Data;
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;
using System.Security.Cryptography;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
@ -11,39 +12,66 @@ using DB.Dto;
using DB.Entity; using DB.Entity;
using DB.Service; using DB.Service;
using NewLife; using NewLife;
using NewLife.Data;
using Tool; using Tool;
namespace RfidWeb.Frm namespace RfidWeb.Frm
{ {
public partial class FormRegister : Form public partial class FormRegister : Form
{ {
private readonly string Kes = "nodyang";
private RoleService roleService = new RoleService(); private RoleService roleService = new RoleService();
private UserService userService = new UserService(); private UserService userService = new UserService();
private long id = 0;
private UserDto OlduserDto; private UserDto OlduserDto;
public FormRegister() public FormRegister()
{ {
InitializeComponent(); InitializeComponent();
label3.Text = ""; label3.Text = "";
label4.Text = ""; label4.Text = "";
var list = roleService.GetList(); FillCbo();
List<KeyValuePair<string, string>> key = new List<KeyValuePair<string, string>>();
foreach (var role in list)
{
key.Add(new KeyValuePair<string, string>(role.ID.ToString(), role.RoleName));
}
ucCombox1.Source = key;
ucCombox1.SelectedIndex = 0; ucCombox1.SelectedIndex = 0;
} }
public void FillCbo()
{
var list = roleService.GetList();
List<KeyValuePair<string, string>> key = new List<KeyValuePair<string, string>>();
foreach (var role in list)
{
key.Add(new KeyValuePair<string, string>(role.ID.ToString(), role.RoleName));
}
ucCombox1.Source = key;
}
public FormRegister(UserDto userDto):this() public FormRegister(UserDto userDto):this()
{ {
this.OlduserDto = userDto; 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) private void btnCancel_BtnClick(object sender, EventArgs e)
{ {
this.Close(); this.Close();
@ -69,26 +97,43 @@ namespace RfidWeb.Frm
} }
var userDto = userService.GetOne(user); var userDto = userService.GetOne(user,id);
if (userDto != null) if (userDto != null)
{ {
this.label3.Text = "已经存在"; this.label3.Text = "已经存在";
return; return;
} }
UserInfo userInfo = new UserInfo(); if (id == 0)
userInfo.ID = SnowflakeFactory.NewId; {
userInfo.UserName=user; UserInfo userInfo = new UserInfo
userInfo.Pwd = pwd.MD5().ToUpper(); {
userInfo.RoleId=roleId; ID = SnowflakeFactory.NewId,
userInfo.CreateUserId = OlduserDto.Id.ToString(); UserName = user,
userInfo.CreateUserName = OlduserDto.UserName; Pwd = Aes.Create().Encrypt(pwd.GetBytes(), Kes.GetBytes()).ToBase64(),
userInfo.CreateDate=DateTime.Now; RoleId = roleId,
CreateUserId = OlduserDto.Id.ToString(),
userInfo.LastModifyUserId = OlduserDto.Id.ToString(); CreateUserName = OlduserDto.UserName,
userInfo.LastModifyUserName = OlduserDto.UserName; CreateDate = DateTime.Now,
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();
} }
} }
} }

@ -544,7 +544,7 @@
// //
this.label13.AutoSize = true; this.label13.AutoSize = true;
this.label13.Font = new System.Drawing.Font("宋体", 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); 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.Name = "label13";
this.label13.Size = new System.Drawing.Size(143, 33); this.label13.Size = new System.Drawing.Size(143, 33);
this.label13.TabIndex = 1; this.label13.TabIndex = 1;
@ -631,11 +631,12 @@
// //
this.label18.AutoSize = true; this.label18.AutoSize = true;
this.label18.Font = new System.Drawing.Font("宋体", 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); 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.Name = "label18";
this.label18.Size = new System.Drawing.Size(143, 33); this.label18.Size = new System.Drawing.Size(143, 33);
this.label18.TabIndex = 4; this.label18.TabIndex = 4;
this.label18.Text = "层切工位"; this.label18.Text = "层切工位";
this.label18.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
// //
// pictureBox3 // pictureBox3
// //

@ -110,6 +110,16 @@ namespace RfidWeb.Properties {
} }
} }
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap log {
get {
object obj = ResourceManager.GetObject("log", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary> /// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。 /// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary> /// </summary>

@ -118,9 +118,15 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="海威图标在上" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\海威图标在上.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="海威物联" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="海威物联" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\海威物联.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> <value>..\Resources\海威物联.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>
<data name="btn_sel1" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\btn_sel1.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="右箭头" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="右箭头" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\右箭头.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> <value>..\Resources\右箭头.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>
@ -130,6 +136,10 @@
<data name="mesnac" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="mesnac" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\mesnac1.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> <value>..\Resources\mesnac1.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>
<data name="照明开" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\照明开.png;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<comment>照明开</comment>
</data>
<data name="frmBei" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="frmBei" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\frmBei.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> <value>..\Resources\frmBei.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>
@ -139,13 +149,6 @@
<data name="左箭头" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="左箭头" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\左箭头.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> <value>..\Resources\左箭头.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>
<data name="btn_sel1" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\btn_sel1.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="照明开" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\照明开.png;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<comment>照明开</comment>
</data>
<data name="消音开" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="消音开" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\消音开.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> <value>..\Resources\消音开.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>
@ -158,7 +161,7 @@
<data name="照明关" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="照明关" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\照明关.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> <value>..\Resources\照明关.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>
<data name="海威图标在上" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="log" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\海威图标在上.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> <value>..\Resources\log.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>
</root> </root>

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

@ -242,6 +242,7 @@
<Content Include="read.txt" /> <Content Include="read.txt" />
<None Include="Resources\海威物联.jpg" /> <None Include="Resources\海威物联.jpg" />
<None Include="Resources\海威图标在上.jpg" /> <None Include="Resources\海威图标在上.jpg" />
<None Include="Resources\log.png" />
<Content Include="Resources\照明开.png" /> <Content Include="Resources\照明开.png" />
<None Include="Resources\脱机.png" /> <None Include="Resources\脱机.png" />
</ItemGroup> </ItemGroup>

Loading…
Cancel
Save