using BLL; using System; using System.Linq; namespace FineUIPro.Web.Person { public partial class ProjectPerson : PageBase { /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Funs.DropDownPageSize(this.ddlPageSize); ////权限按钮方法 this.GetButtonPower(); this.btnNew.OnClientClick = Window1.GetShowReference("ProjectPersonEdit.aspx") + "return false;"; ProjectService.InitProjectShortNameDropDownList(this.drpProject, false); Funs.FineUIPleaseSelect(drpProject, "按项目查询"); Funs.FineUIPleaseSelect(drpUnit, "按单位查询"); WorkPostService.InitWorkPostDropDownList(this.drpWorkPost, false); Funs.FineUIPleaseSelect(drpWorkPost, "按岗位查询"); DropListService.InitConstDropDownList(this.drpPersonType, DropListService.Group_PersonType, false); Funs.FineUIPleaseSelect(drpPersonType, "按人员类型查询"); if (!string.IsNullOrEmpty(this.CurrUser.LoginProjectId)) { this.drpProject.SelectedValue = this.CurrUser.LoginProjectId; this.drpProject.Readonly = true; if (this.CurrUser.UnitId != Const.UnitId_SEDIN && !string.IsNullOrEmpty(this.CurrUser.UnitId)) { UnitService.InitUnitDropDownList(this.drpUnit, this.drpProject.SelectedValue, false); Funs.FineUIPleaseSelect(drpUnit, "按单位查询"); this.drpUnit.SelectedValue = this.CurrUser.UnitId; this.drpUnit.Readonly = true; } } // 绑定表格 this.BindGrid(); } else { string arg = GetRequestEventArgument(); // 此函数所在文件:PageBase.cs string[] args = arg.Split('$'); string rowID = Grid1.SelectedRowID; if (args.Length > 0 && !string.IsNullOrEmpty(rowID)) { var commandName = args[0]; string sitepersonId = Funs.GetStrListByStr(rowID, '#')[0]; string personId = Funs.GetStrListByStr(rowID, '#')[1]; if (commandName == "editit") { if (!this.btnMenuEdit.Hidden) { PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ProjectPersonEdit.aspx?SitePersonId={0}", sitepersonId, "编辑 - "))); } else { ShowNotify("您没有权限!", MessageBoxIcon.Warning); } } else if (commandName == "details") { PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ProjectPersonView.aspx?SitePersonId={0}", sitepersonId, "查看 - "))); } else if (commandName == "reset") { if (!this.btnMenuEdit.Hidden) { BLL.Person_PersonsService.UpdatePassword(personId, BLL.Const.Password); ShowNotify("密码已重置为原始密码!", MessageBoxIcon.Success); } else { ShowNotify("您没有权限!", MessageBoxIcon.Warning); } } else if (commandName == "salary") { PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ProjectPersonView.aspx?SitePersonId={0}", sitepersonId, "查看 - "))); } } } } /// /// 绑定数据 /// private void BindGrid() { var getData = SitePerson_PersonService.getListData(this.drpProject.SelectedValue, this.drpUnit.SelectedValue, this.drpWorkPost.SelectedValue, this.txtPersonName.Text.Trim(), this.txtIdCard.Text.Trim(), this.rbIsPostStates.SelectedValue, this.drpPersonType.SelectedValue, Grid1); Grid1.RecordCount = SitePerson_PersonService.count; Grid1.DataSource = getData; Grid1.DataBind(); } #region 查询 /// /// 查询 /// /// /// protected void btSearch_Click(object sender, EventArgs e) { this.BindGrid(); } #endregion #region 获取按钮权限 /// /// 获取按钮权限 /// /// /// private void GetButtonPower() { string menuId = BLL.Const.ProjectPersonMenuId; if (!string.IsNullOrEmpty(this.CurrUser.LoginProjectId)) { menuId = BLL.Const.Project_ProjectPersonMenuId; } var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.PersonId, menuId); if (buttonList.Count() > 0) { if (buttonList.Contains(BLL.Const.BtnAdd)) { this.btnNew.Hidden = false; this.btnImport.Hidden = false; } if (buttonList.Contains(BLL.Const.BtnModify)) { this.btnMenuEdit.Hidden = false; } if (buttonList.Contains(BLL.Const.BtnDelete)) { this.btnMenuDelete.Hidden = false; } } } #endregion #region 删除数据 /// /// 右键删除事件 /// /// /// protected void btnMenuDelete_Click(object sender, EventArgs e) { this.DeleteData(); } /// /// 删除方法 /// private void DeleteData() { if (Grid1.SelectedRowIndexArray.Length > 0) { string strShowNotify = SitePerson_PersonService.DeleteSitePersons(Grid1.SelectedRowIDArray, this.CurrUser); BindGrid(); if (!string.IsNullOrEmpty(strShowNotify)) { Alert.ShowInTop(strShowNotify, MessageBoxIcon.Warning); } else { ShowNotify("删除数据成功!", MessageBoxIcon.Success); } } } #endregion #region 分页 /// /// 分页 /// /// /// protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e) { BindGrid(); } /// /// 分页显示条数下拉框 /// /// /// protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e) { Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue); BindGrid(); } /// /// 排序 /// /// /// protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e) { BindGrid(); } #endregion #region Grid编辑事件 /// /// Grid行双击事件 /// /// /// protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e) { this.EditData(); } /// /// 右键编辑事件 /// /// /// protected void btnMenuEdit_Click(object sender, EventArgs e) { this.EditData(); } /// /// 编辑数据方法 /// private void EditData() { if (Grid1.SelectedRowIndexArray.Length == 0) { Alert.ShowInParent("请至少选择一条记录!", MessageBoxIcon.Warning); return; } if (this.btnMenuEdit.Hidden) { SeePersonInfo(Grid1.SelectedRowID); } else { string sitepersonId = Funs.GetStrListByStr(Grid1.SelectedRowID, '#')[0]; PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ProjectPersonEdit.aspx?SitePersonId={0}", sitepersonId, "编辑 - "))); } } #endregion #region 导入 /// /// 导入按钮 /// /// /// protected void btnImport_Click(object sender, EventArgs e) { PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("UserIn.aspx", "导入 - "))); } #endregion #region 查看人员详细信息 /// /// 查看人员详细信息 /// /// /// protected void btnSee_Click(object sender, EventArgs e) { if (Grid1.SelectedRowIndexArray.Length == 0) { Alert.ShowInParent("请选择一条记录!", MessageBoxIcon.Warning); return; } SeePersonInfo(Grid1.SelectedRowID); } /// /// /// /// private void SeePersonInfo(string projectPersonId) { string sitepersonId = Funs.GetStrListByStr(Grid1.SelectedRowID, '#')[0]; PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ProjectPersonView.aspx?SitePersonId={0}", sitepersonId, "查看 - "))); } #endregion /// /// /// /// /// protected void drpProject_SelectedIndexChanged(object sender, EventArgs e) { this.drpUnit.Items.Clear(); UnitService.InitUnitDropDownList(this.drpUnit, this.drpProject.SelectedValue, false); Funs.FineUIPleaseSelect(drpUnit, "按单位查询"); this.BindGrid(); } } }