using System; using System.Collections.Generic; using System.Linq; using System.Data; using System.Data.SqlClient; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using BLL; namespace FineUIPro.Web.common.SysManage { public partial class UpdatePassword : PageBase { protected void Page_Load(object sender, EventArgs e) { // 表头过滤 FilterDataRowItem = FilterDataRowItemImplement; if (!IsPostBack) { ddlPageSize.SelectedValue = Grid1.PageSize.ToString(); // 绑定表格 BindGrid(); } } /// /// 绑定数据 /// private void BindGrid() { string strSql = "SELECT UserId,Account,UserCode,UserName,IsPost,RoleName,UnitName " + @"FROM View_Common_UserList"; string strWhere = " where Account = @Account"; if (this.CurrUser.Account != BLL.Const.Gly) { strSql += strWhere; } SqlParameter[] parameter = new SqlParameter[] { new SqlParameter("@Account",this.CurrUser.Account), }; DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter); // 2.获取当前分页数据 //var table = this.GetPagedDataTable(Grid1, tb1); Grid1.RecordCount = tb.Rows.Count; tb = GetFilteredTable(Grid1.FilteredData, tb); var table = this.GetPagedDataTable(Grid1, tb); Grid1.DataSource = table; Grid1.DataBind(); } #region 过滤表头 /// /// 过滤表头 /// /// /// protected void Grid1_FilterChange(object sender, EventArgs e) { BindGrid(); } /// /// 根据表头信息过滤列表数据 /// /// /// /// /// /// private bool FilterDataRowItemImplement(object sourceObj, string fillteredOperator, object fillteredObj, string column) { bool valid = false; if (column == "UserName") { string sourceValue = sourceObj.ToString(); string fillteredValue = fillteredObj.ToString(); if (fillteredOperator == "equal" && sourceValue == fillteredValue) { valid = true; } else if (fillteredOperator == "contain" && sourceValue.Contains(fillteredValue)) { valid = true; } } if (column == "UnitName") { string sourceValue = sourceObj.ToString(); string fillteredValue = fillteredObj.ToString(); if (fillteredOperator == "equal" && sourceValue == fillteredValue) { valid = true; } else if (fillteredOperator == "contain" && sourceValue.Contains(fillteredValue)) { valid = true; } } if (column == "IsPost") { string sourceValue = sourceObj.ToString(); string fillteredValue = fillteredObj.ToString(); if (fillteredOperator == "equal" && sourceValue == fillteredValue) { valid = true; } } return valid; } #endregion #region 分页 /// /// 分页 /// /// /// protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e) { Grid1.PageIndex = e.NewPageIndex; BindGrid(); } /// /// 分页显示条数下拉框 /// /// /// protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e) { Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue); BindGrid(); } #endregion /// /// 排序 /// /// /// protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e) { Grid1.SortDirection = e.SortDirection; Grid1.SortField = e.SortField; BindGrid(); } /// /// 关闭窗口 /// /// /// protected void Window1_Close(object sender, EventArgs e) { BindGrid(); } #region 重置密码 /// /// 批量删除数据 /// /// /// protected void btnRefresh_Click(object sender, EventArgs e) { if (Grid1.SelectedRowIndexArray.Length > 0) { foreach (int rowIndex in Grid1.SelectedRowIndexArray) { string rowID = Grid1.DataKeys[rowIndex][0].ToString(); var user = BLL.Sys_UserService.GetUsersByUserId(rowID); if (user != null) { string password = BLL.Sys_UserService.GetEncryptionPassword(user.UnitId, user.Phone); if (user.UserId == BLL.Const.GlyId) { password = Sys_UserService.EncryptionPassword(BLL.Const.glyPassWord); } BLL.Sys_UserService.UpdatePassword(rowID, password); } } BindGrid(); BLL.Sys_LogService.AddLog(BLL.Const.System_1, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "重置密码"); ShowNotify("密码已重置为初始密码!"); } else { ShowNotify("请至少选中一行!"); } } #endregion /// /// 编辑 /// /// /// protected void btnEdit_Click(object sender, EventArgs e) { if (Grid1.SelectedRowIndexArray.Length == 0) { Alert.ShowInParent("请至少选择一条记录!"); return; } string Id = Grid1.SelectedRowID; PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("UpdatePasswordEdit.aspx?userId={0}", Id, "编辑 - "))); } /// /// Grid行双击事件 /// /// /// protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e) { btnEdit_Click(null, null); } } }