using BLL; using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Text; namespace FineUIPro.Web.HJGL.PersonManage { public partial class NDTPersonRegister : PageBase { /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Funs.DropDownPageSize(this.ddlPageSize); // 绑定表格 this.BindGrid(); } } #region 绑定数据 /// /// 绑定数据 /// private void BindGrid() { string strSql = @"SELECT welder.WED_ID, welder.WED_Code, welder.WED_Name, welder.WorkCode, welder.EquipmentID, welder.QueClass, welder.WLimitDate, welder.ProjectId, welder.WederType " + @" FROM View_PersonManageList AS welder" + @" WHERE welder.WederType ='2' AND welder.ProjectId=@projectId"; List listStr = new List(); listStr.Add(new SqlParameter("@projectId",this.CurrUser.LoginProjectId)); SqlParameter[] parameter = listStr.ToArray(); DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter); Grid1.RecordCount = tb.Rows.Count; //tb = GetFilteredTable(Grid1.FilteredData, tb); var table = this.GetPagedDataTable(Grid1, tb); Grid1.DataSource = table; Grid1.DataBind(); } /// /// 改变索引事件 /// /// /// 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(); } /// /// 关闭弹出窗口 /// /// /// protected void Window1_Close(object sender, EventArgs e) { BindGrid(); } #endregion #region 增加按钮事件 /// /// 增加按钮事件 /// /// /// protected void btnNew_Click(object sender, EventArgs e) { if (GetButtonPower(Const.BtnAdd)) { PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("NDTPersonRegisterEdit.aspx", "新增 - "))); } else { Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); return; } } #endregion #region 编辑 /// /// 双击事件 /// /// /// protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e) { this.EditData(); } /// /// 右键编辑事件 /// /// /// protected void btnMenuEdit_Click(object sender, EventArgs e) { this.EditData(); } /// /// 编辑数据方法 /// private void EditData() { if (GetButtonPower(Const.BtnModify)) { if (Grid1.SelectedRowIndexArray.Length == 0) { Alert.ShowInTop("请至少选择一条记录", MessageBoxIcon.Warning); return; } PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("NDTPersonRegisterEdit.aspx?welderId={0}", Grid1.SelectedRowID, "编辑 - "))); } else { Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); return; } } #endregion #region 删除 /// /// 右键删除事件 /// /// /// protected void btnMenuDelete_Click(object sender, EventArgs e) { if (GetButtonPower(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 welder = BLL.WelderService.GetWelderById(rowID); if (welder != null) { string cont = judgementDelete(rowID); if (string.IsNullOrEmpty(cont)) { BLL.WelderScoreService.DeleteWelderScoreBywed_id(rowID); BLL.WeldMethodItemService.DeleteWeldMethodItem(rowID); BLL.WelderItemService.DeleteItemByWenId(rowID); BLL.PersonManageService.DeleteBSWelder(rowID); } else { strShowNotify += "无损检测人员登记" + ":" + welder.WED_Name + cont; } } } BindGrid(); if (!string.IsNullOrEmpty(strShowNotify)) { Alert.ShowInTop(strShowNotify, MessageBoxIcon.Warning); } else { ShowNotify("删除成功!", MessageBoxIcon.Success); } } } else { Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); return; } } #region 判断是否可删除 /// /// 判断是否可以删除 /// /// private string judgementDelete(string id) { string content = string.Empty; //if (Funs.DB.Pipeline_WeldJoint.FirstOrDefault(x => x.PipeAssembly1Id == id) != null) //{ // content += "已在【焊口信息】中使用,不能删除!"; //} return content; } #endregion #endregion #region 获取按钮权限 /// /// 获取按钮权限 /// /// /// private bool GetButtonPower(string button) { return BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.HJGL_NDTPersonRegisterMenuId, button); } #endregion protected void Grid1_RowCommand(object sender, GridCommandEventArgs e) { object[] keys = Grid1.DataKeys[e.RowIndex]; string fileId = string.Empty; if (keys == null) { return; } else { fileId = keys[0].ToString(); } if (e.CommandName == "attchUrl") { PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type={0}&toKeyId={1}&path=FileUpload/Solution&menuId={2}", -1, fileId, Const.NDTPersonRegisterMenuId))); } } #region 导出按钮 /// 导出按钮 /// /// /// protected void btnOut_Click(object sender, EventArgs e) { Response.ClearContent(); string filename = Funs.GetNewFileName(); Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("无损检测人员登记表" + filename, System.Text.Encoding.UTF8) + ".xls"); Response.ContentType = "application/excel"; Response.ContentEncoding = Encoding.UTF8; this.Grid1.PageSize = this.Grid1.RecordCount; this.BindGrid(); Response.Write(GetGridTableHtml(Grid1)); Response.End(); } #endregion } }