using BLL; using System; using System.Linq; namespace FineUIPro.Web.ZHGL.Person { public partial class ProjectPerson : PageBase { #region 项目主键 /// /// 项目主键 /// public string ProjectId { get { return (string)ViewState["ProjectId"]; } set { ViewState["ProjectId"] = value; } } #endregion /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Funs.DropDownPageSize(this.ddlPageSize); WorkPostService.InitWorkPostDropDownList(this.drpWorkPost, false); Funs.FineUIPleaseSelect(drpWorkPost, "按岗位查询"); this.ProjectId = this.CurrUser.LoginProjectId; if (!string.IsNullOrEmpty(Request.Params["projectId"]) && Request.Params["projectId"] != this.CurrUser.LoginProjectId) { this.ProjectId = Request.Params["projectId"]; } this.ucTree.UnitId = this.CurrUser.UnitId; this.ucTree.ProjectId = this.ProjectId; if (this.CurrUser != null && this.CurrUser.PageSize.HasValue) { Grid1.PageSize = this.CurrUser.PageSize.Value; } this.ddlPageSize.SelectedValue = Grid1.PageSize.ToString(); // 绑定表格 this.BindGrid(); if (!string.IsNullOrEmpty(this.CurrUser.LoginProjectId) && CommonService.GetThisUnitId() != Const.CncecFccId) { this.panelLeftRegion.Hidden = true; // this.Grid1.Columns[0].Hidden = true; ////权限按钮方法 this.GetButtonPower(); } //Funs.DropDownPageSize(this.ddlPageSize); //ProjectService.InitProjectDropDownList(this.drpProject, false); //Funs.FineUIPleaseSelect(drpProject, "按项目查询"); //Funs.FineUIPleaseSelect(drpUnit, "按单位查询"); //WorkPostService.InitWorkPostDropDownList(this.drpWorkPost, false); //Funs.FineUIPleaseSelect(drpWorkPost, "按岗位查询"); //if (!string.IsNullOrEmpty(this.CurrUser.LoginProjectId)) //{ // this.drpProject.SelectedValue = this.CurrUser.LoginProjectId; // this.drpProject.Readonly = true; // if (this.CurrUser.UnitId != CommonService.GetThisUnitId() && !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(); } } protected void changeTree(object sender, EventArgs e) { this.ProjectId = this.ucTree.ProjectId; this.BindGrid(); if (CommonService.GetThisUnitId() == Const.CncecFccId) { this.GetButtonPower(); } if (!string.IsNullOrEmpty(this.ucTree.ProjectId)) { btnImport.Hidden = true; } else { btnImport.Hidden = false; } } #region 获取按钮权限 /// /// 获取按钮权限 /// /// /// private void GetButtonPower() { if (Request.Params["value"] == "0") { return; } //if (string.IsNullOrEmpty(this.CurrUser.LoginProjectId) && !string.IsNullOrEmpty(this.ProjectId)) //{ // this.btnNew.Hidden = true; // this.btnMenuDelete.Hidden = true; // return; //} //var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.ProjectThemeActivitiesMenuId); //if (buttonList.Count() > 0) //{ // if (buttonList.Contains(BLL.Const.BtnAdd)) // { // this.btnNew.Hidden = false; // } // if (buttonList.Contains(BLL.Const.BtnModify)) // { // this.btnMenuEdit.Hidden = false; // } // if (buttonList.Contains(BLL.Const.BtnDelete)) // { // this.btnMenuDelete.Hidden = false; // } //} } #endregion /// /// 绑定数据 /// private void BindGrid() { var getData = PersonService.getListData(this.ProjectId, this.ucTree.UnitId, this.drpWorkPost.SelectedValue, this.txtPersonName.Text.Trim(), this.txtIdCard.Text.Trim(), this.rbIsPostStates.SelectedValue, Grid1); Grid1.RecordCount = PersonService.count; Grid1.DataSource = getData; Grid1.DataBind(); } #region 查询 /// /// 查询 /// /// /// protected void btSearch_Click(object sender, EventArgs e) { this.BindGrid(); } #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) { if (Grid1.SelectedRowIndexArray.Length == 0) { Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning); return; } var PersonId = Grid1.SelectedRowID; PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("../../HSSE/SitePerson/PersonListEdit.aspx?PersonId={0}&CompanyEdit=CompanyEdit", PersonId, "编辑 - "))); //string id = this.tvProjectAndUnit.SelectedNodeID; //string[] str = id.Split('|'); //if (str.Count() > 1) //{ // string unitId = id.Split('|')[0]; // //string projectId = id.Split('|')[1]; // PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("PersonListEdit.aspx?PersonId={0}&&ProjectId={1}&&UnitId={2}", PersonId, projectId, unitId, "编辑 - "))); //} } /// /// 编辑数据方法 /// 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 btnSee_Click(object sender, EventArgs e) { if (Grid1.SelectedRowIndexArray.Length == 0) { Alert.ShowInParent("请选择一条记录!", MessageBoxIcon.Warning); return; } SeePersonInfo(Grid1.SelectedRowID); } /// /// /// /// private void SeePersonInfo(string PersonId) { //string sitepersonId = Funs.GetStrListByStr(Grid1.SelectedRowID, '#')[0]; PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("../../HSSE/SitePerson/PersonListEdit.aspx?PersonId={0}&Company=Company", PersonId, "查看 - "))); } #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(); } #region 导入 /// /// 导入按钮 /// /// /// protected void btnImport_Click(object sender, EventArgs e) { PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("../../HSSE/SitePerson/PersonIn.aspx?UnitId={0}", this.ucTree.UnitId, "导入 - "))); } /// /// 关闭导入弹出窗口 /// /// /// protected void Window2_Close(object sender, WindowCloseEventArgs e) { BindGrid(); } #endregion #region 删除 /// /// 右键删除事件 /// /// /// protected void btnMenuDelete_Click(object sender, EventArgs e) { this.DeleteData(); } /// /// 删除方法 /// private void DeleteData() { if (Grid1.SelectedRowIndexArray.Length > 0) { bool isShow = false; if (Grid1.SelectedRowIndexArray.Length == 1) { isShow = true; } int i = 0; foreach (int rowIndex in Grid1.SelectedRowIndexArray) { string rowID = Grid1.DataKeys[rowIndex][0].ToString(); if (this.judgementDelete(rowID, isShow)) { i++; var getV = BLL.PersonService.GetPersonById(rowID); if (getV != null) { BLL.LogService.AddSys_Log(this.CurrUser, getV.PersonName, getV.PersonId, BLL.Const.PersonListMenuId, BLL.Const.BtnDelete); BLL.PersonService.DeletePerson(rowID); } } } //Project_HSSEData_HSSEService.StatisticalData(this.CurrUser.LoginProjectId, Project_HSSEData_HSSEService.HSSEDateType.ProjectInformation); //Project_HSSEData_HSSEService.StatisticalData(this.CurrUser.LoginProjectId, Project_HSSEData_HSSEService.HSSEDateType.OfSafetySupervisors); //Project_CQMSDataService.StatisticalData(this.CurrUser.LoginProjectId, Project_CQMSDataService.CQMSDateType.ManagerData); BindGrid(); if (i > 0) { ShowNotify("删除数据成功!(表格数据已重新绑定)", MessageBoxIcon.Success); } } } /// /// 判断是否可删除 /// /// /// /// private bool judgementDelete(string rowID, bool isShow) { string content = string.Empty; //var q = from x in Funs.DB.QualityAudit_PersonQuality where x.PersonId == rowID select x; //if (q.Count() > 0) //{ // content += "人员资质中已存在该人员,无法删除!"; //} if (string.IsNullOrEmpty(content)) { return true; } else { if (isShow) { Alert.ShowInTop(content); } return false; } } #endregion } }