WinUser.xaml.cs
3.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
using HHECS.Model;
using HHECS.View.Win;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Media;
namespace HHECS.View.UserOperation
{
/// <summary>
/// User.xaml 的交互逻辑
/// </summary>
public partial class WinUser : MyWindow
{
public WinUser()
{
InitializeComponent();
AppSession.CheckPermission(AppSession.MenuOperations, SPBtns.Children);
}
private void BtnQuery_Click(object sender, RoutedEventArgs e)
{
Update();
}
private void Update()
{
string sql = "where 1=1 ";
if (!String.IsNullOrWhiteSpace(TxtUserCode.Text))
{
sql += $" and userCode like '{TxtUserCode.Text}%'";
}
if (!String.IsNullOrWhiteSpace(TxtUserName.Text))
{
sql += $" and userName like '{TxtUserName.Text}%'";
}
BllResult<List<User>> result = AppSession.Bll.GetUserByCondition(sql);
if (result.Success)
{
DatagridMain.ItemsSource = result.Data;
}
else
{
MessageBox.Show($"查询失败:{result.Msg}");
}
}
private void BtnNew_Click(object sender, RoutedEventArgs e)
{
WinUserAddOrEdit user = new WinUserAddOrEdit(null);
user.ShowDialog();
}
private void BtnEdit_Click(object sender, RoutedEventArgs e)
{
if (DatagridMain.SelectedItem == null)
{
MessageBox.Show("请先选中一条数据");
}
else
{
User user = (User)DatagridMain.SelectedItem;
WinUserAddOrEdit userAddOrEdit = new WinUserAddOrEdit(user.Id);
userAddOrEdit.ShowDialog();
}
}
private void BtnDisable_Click(object sender, RoutedEventArgs e)
{
if (DatagridMain.SelectedItems.Count == 0)
{
MessageBox.Show("请先选中数据");
}
else
{
var temp = new List<User>();
foreach (var item in DatagridMain.SelectedItems)
{
temp.Add((User)item);
}
BllResult result = AppSession.Bll.SetUserDisable(temp.Select(t => t.Id).ToList(),1);
if (result.Success)
{
MessageBox.Show("禁用成功");
}
else
{
MessageBox.Show("禁用失败");
}
}
Update();
}
private void BtnEnable_Click(object sender, RoutedEventArgs e)
{
if (DatagridMain.SelectedItems.Count == 0)
{
MessageBox.Show("请先选中数据");
}
else
{
var temp = new List<User>();
foreach (var item in DatagridMain.SelectedItems)
{
temp.Add((User)item);
}
BllResult result = AppSession.Bll.SetUserDisable(temp.Select(t => t.Id).ToList(),0);
if (result.Success)
{
MessageBox.Show("启用成功");
}
else
{
MessageBox.Show("启用失败");
}
}
Update();
}
}
}