You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
CaiQie/RfidWeb/Frm/FormAccount.cs

148 lines
4.0 KiB
C#

1 month ago
using HZH_Controls.Controls;
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.Web;
using System.Windows.Forms;
using DB.Dto;
using DB.Service;
1 month ago
using HZH_Controls.Forms;
1 month ago
namespace RfidWeb.Frm
{
public partial class FormAccount : UserControl
{
private UserService userService = new UserService();
1 month ago
private UserDto OlduserDto;
1 month ago
public FormAccount()
{
InitializeComponent();
1 month ago
1 month ago
OlduserDto= UserManager.GetUser();
1 month ago
Init();
1 month ago
}
private void Init()
{
1 week ago
this.dataGridView1.AutoGenerateColumns = false;
1 month ago
ucPagerControl21.PageModel = PageModel.PageCount;
ucPagerControl21.PageIndex = 1;
ucPagerControl21.PageSize = 20;
1 month ago
1 month ago
1 month ago
}
private void ucPagerControl21_ShowSourceChanged(object currentSource)
{
string key = this.textBoxSel.Text.Trim();
var index = ucPagerControl21.PageIndex;
List<int> lsInts = new List<int>();
1 month ago
if (OlduserDto != null)
1 month ago
{
1 month ago
switch (OlduserDto.RoleLevel)
1 month ago
{
1 month ago
case 1:
lsInts.AddRange(new[] { 1, 2, 3 });
break;
case 2:
lsInts.AddRange(new[] { 2, 3 });
break;
case 3:
lsInts.Add(3);
break;
1 month ago
}
}
var page = userService.GetPagedList(index, ucPagerControl21.PageSize, key,lsInts);
ucPagerControl21.PageCount = page.TotalPages;
1 week ago
this.dataGridView1.DataSource = page.Items;
1 month ago
}
private void ucBtnSelect_BtnClick(object sender, EventArgs e)
{
1 month ago
Replace();
1 month ago
}
1 month ago
private void ucBtnAdd_BtnClick(object sender, EventArgs e)
{
var user = UserManager.GetUser();
if (user != null)
{
FormRegister formRegis = new FormRegister(user);
formRegis.StartPosition = FormStartPosition.CenterScreen; // 设置窗口显示在屏幕中央
formRegis.ShowDialog();
}
else
{
FormLogin fromLogin=new FormLogin();
fromLogin.ShowDialog();
}
}
private void ucBtnDel_BtnClick(object sender, EventArgs e)
{
1 week ago
var dataGridViewRows = this.dataGridView1.SelectedRows;
1 month ago
if (dataGridViewRows.Count == 0)
{
FrmDialog.ShowDialog(this, "请勾选相关信息", "警告窗体");
return;
}
List<long> ls = new List<long>();
1 week ago
foreach (DataGridViewRow dataGridViewRow in dataGridViewRows)
1 month ago
{
1 week ago
var obj = dataGridViewRow.DataBoundItem as UserDto;
ls.Add(obj.Id);
1 month ago
}
if (ls.Any())
{
userService.UpdateDel(ls);
1 month ago
Replace();
1 month ago
}
1 week ago
1 month ago
}
private void ucBtnUpdate_BtnClick(object sender, EventArgs e)
{
1 week ago
var dataGridViewRows = this.dataGridView1.SelectedRows;
if (dataGridViewRows.Count != 1)
1 month ago
{
FrmDialog.ShowDialog(this, "只能修改一条", "警告窗体");
return;
}
1 week ago
var dto = dataGridViewRows[0].DataBoundItem as UserDto;
FormRegister formRegis = new FormRegister(dto.Id, OlduserDto);
formRegis.StartPosition = FormStartPosition.CenterScreen; // 设置窗口显示在屏幕中央
formRegis.ShowDialog();
1 month ago
1 week ago
Replace();
1 month ago
}
1 month ago
1 month ago
private void Replace()
{
ucPagerControl21.PageIndex = 1;
1 month ago
ucPagerControl21_ShowSourceChanged(new object());
1 month ago
}
1 month ago
}
}