2024-05-08 10:02:08 +08:00
|
|
|
|
namespace FineUIPro.Web.common.SysManage
|
|
|
|
|
{
|
|
|
|
|
using System;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Data.SqlClient;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Web.UI;
|
|
|
|
|
using BLL;
|
|
|
|
|
|
|
|
|
|
public partial class UserList : PageBase
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 加载页面
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!IsPostBack)
|
|
|
|
|
{
|
|
|
|
|
BLL.Base_UnitService.InitUnitDropDownList(drpUnit, true, null,Resources.Lan.PleaseSelect);
|
|
|
|
|
|
|
|
|
|
ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
|
|
|
|
|
if (CurrUser.Account == Const.Gly)
|
|
|
|
|
{
|
|
|
|
|
btnMenuUnLock.Hidden = false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
btnMenuUnLock.Hidden = true;
|
|
|
|
|
}
|
|
|
|
|
// 绑定表格
|
|
|
|
|
BindGrid();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 绑定数据/查询
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 绑定数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void BindGrid()
|
|
|
|
|
{
|
|
|
|
|
string strSql = @"SELECT Users.UserId,Users.Account, Users.UserCode, Users.UserName,
|
|
|
|
|
Users.IsPost, Users.Email,Users.RoleIds as RoleName,Unit.UnitName,
|
|
|
|
|
Unit.UnitCode, Users.Phone
|
|
|
|
|
FROM dbo.Sys_User AS Users
|
|
|
|
|
LEFT JOIN dbo.Base_Unit AS Unit ON Users.UnitId =Unit.UnitId
|
|
|
|
|
where Users.UserId !=@Gly ";
|
|
|
|
|
|
|
|
|
|
List<SqlParameter> parms = new List<SqlParameter>();
|
|
|
|
|
parms.Add(new SqlParameter("@Gly", Const.GlyId));
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(this.txtUserName.Text))
|
|
|
|
|
{
|
|
|
|
|
strSql += " and Users.UserName LIKE @UserName";
|
|
|
|
|
parms.Add(new SqlParameter("@UserName", "%" + this.txtUserName.Text.Trim() + "%"));
|
|
|
|
|
}
|
|
|
|
|
if (this.drpUnit.SelectedValue != Const._Null)
|
|
|
|
|
{
|
|
|
|
|
strSql += " and Users.UnitId = @UnitId";
|
|
|
|
|
parms.Add(new SqlParameter("@UnitId", this.drpUnit.SelectedValue));
|
|
|
|
|
}
|
|
|
|
|
SqlParameter[] parameter = parms.ToArray();
|
|
|
|
|
DataTable dt = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|
|
|
|
|
|
|
|
|
// 2.获取当前分页数据
|
|
|
|
|
Grid1.RecordCount = dt.Rows.Count;
|
|
|
|
|
var table = this.GetPagedDataTable(Grid1, dt);
|
|
|
|
|
Grid1.DataSource = table;
|
|
|
|
|
Grid1.DataBind();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 查询
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
protected void btnQuery_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.BindGrid();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 增加按钮事件
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 增加按钮事件
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
protected void btnNew_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (GetButtonPower(BLL.Const.BtnAdd))
|
|
|
|
|
{
|
|
|
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("UserListEdit.aspx", "新增 - ")));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 编辑/查看/删除数据
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 编辑
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void EditData()
|
|
|
|
|
{
|
|
|
|
|
if (GetButtonPower(BLL.Const.BtnModify))
|
|
|
|
|
{
|
|
|
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
|
|
|
{
|
|
|
|
|
Alert.ShowInParent("请至少选择一条记录!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
string Id = Grid1.SelectedRowID;
|
|
|
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("UserListEdit.aspx?userId={0}", Id, "编辑 - ")));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ShowNotify("您没有这个权限,请与管理员联系!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Grid行双击事件
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
EditData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 右键编辑事件
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
protected void btnMenuEdit_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.EditData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 解锁
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
protected void btnMenuUnLock_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2024-05-10 09:49:58 +08:00
|
|
|
|
if (this.CurrUser.Account == Const.Gly)
|
2024-05-08 10:02:08 +08:00
|
|
|
|
{
|
2024-05-10 09:49:58 +08:00
|
|
|
|
if (!string.IsNullOrEmpty(Grid1.SelectedRowID))
|
|
|
|
|
{
|
|
|
|
|
string userId = Grid1.SelectedRowID;
|
|
|
|
|
Sys_UserService.UpdateErrorNum(userId, 0);
|
|
|
|
|
Sys_UserService.UpdateLockTime(userId, null);
|
|
|
|
|
ShowNotify("该用户解锁成功!", MessageBoxIcon.Success);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ShowNotify("请选择要解锁的用户!");
|
|
|
|
|
}
|
2024-05-08 10:02:08 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2024-05-10 09:49:58 +08:00
|
|
|
|
ShowNotify("您没有这个权限,请与管理员联系!");
|
2024-05-08 10:02:08 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void btnMenuView_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("UserView.aspx?userId={0}", Grid1.SelectedRowID, "查看 - ")));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 批量删除数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
protected void btnMenuDelete_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (GetButtonPower(BLL.Const.BtnDelete))
|
|
|
|
|
{
|
|
|
|
|
if (Grid1.SelectedRowIndexArray.Length > 0)
|
|
|
|
|
{
|
|
|
|
|
string strShowNotify = string.Empty;
|
|
|
|
|
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
|
|
|
|
|
{
|
|
|
|
|
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
|
|
|
|
|
var user = BLL.Sys_UserService.GetUsersByUserId(rowID);
|
|
|
|
|
string content = judgementDelete(rowID);
|
|
|
|
|
if (user != null)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(content))
|
|
|
|
|
{
|
|
|
|
|
BLL.Sys_UserService.DeleteUser(rowID);
|
|
|
|
|
BLL.Sys_LogService.AddLog(Const.System_1, this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.UserMenuId, Const.BtnDelete, rowID);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strShowNotify += Resources.Lan.UserName + ":" + user.UserName + content;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BindGrid();
|
|
|
|
|
if (!string.IsNullOrEmpty(strShowNotify))
|
|
|
|
|
{
|
|
|
|
|
Alert.ShowInTop(strShowNotify, MessageBoxIcon.Warning);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ShowNotify(Resources.Lan.DeletedSuccessfully, MessageBoxIcon.Success);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Alert.ShowInTop(Resources.Lan.NoPrivilegePrompt, MessageBoxIcon.Warning);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 分页/排序
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 分页
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Grid1.PageIndex = e.NewPageIndex;
|
|
|
|
|
BindGrid();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 分页显示条数下拉框
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
|
|
|
|
|
BindGrid();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 排序
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Grid1.SortDirection = e.SortDirection;
|
|
|
|
|
Grid1.SortField = e.SortField;
|
|
|
|
|
BindGrid();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 关闭窗口
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 关闭窗口
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
protected void Window1_Close(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
BindGrid();
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 获取按钮权限
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取按钮权限
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="button"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
private bool GetButtonPower(string button)
|
|
|
|
|
{
|
|
|
|
|
return BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.UserMenuId, button);
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 格式化字符串
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 转换热处理类型
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="pt"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
protected string ConvertRoleName(object roleIds)
|
|
|
|
|
{
|
|
|
|
|
string roleNames = string.Empty;
|
|
|
|
|
if (roleIds != null)
|
|
|
|
|
{
|
|
|
|
|
string[] roles = roleIds.ToString().Split('|');
|
|
|
|
|
foreach (string r in roles)
|
|
|
|
|
{
|
|
|
|
|
var q = BLL.Sys_RoleService.GetRole(r);
|
|
|
|
|
if (q != null)
|
|
|
|
|
{
|
|
|
|
|
roleNames = roleNames + q.RoleName + ",";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (roleNames.Length > 0)
|
|
|
|
|
{
|
|
|
|
|
roleNames = roleNames.Substring(0, roleNames.Length - 1);
|
|
|
|
|
}
|
|
|
|
|
return roleNames;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 判断是否可删除
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 判断是否可以删除
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
private string judgementDelete(string userId)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
string content = string.Empty;
|
|
|
|
|
if (Funs.DB.Project_User.FirstOrDefault(x => x.UserId== userId) != null)
|
|
|
|
|
{
|
|
|
|
|
content = "该用户已在【项目用户】中使用,不能删除!";
|
|
|
|
|
}
|
|
|
|
|
return content;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|