using BLL; using System; using System.Collections.Generic; using System.Configuration; using System.Linq; namespace FineUIPro.Web.SYHSE { public partial class Data_HiddenDangers : PageBase { /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Funs.DropDownPageSize(this.ddlPageSize); if (this.CurrUser.UserId == BLL.Const.hfnbdId) { this.btnMenuDelete.Hidden = false; } // 绑定表格 this.BindGrid(); } } #region 绑定数据 /// /// 绑定数据 /// private void BindGrid() { var getData = SYHSEData_HiddenDangersService.getListData(this.CurrUser.LoginProjectId,drpType.SelectedValue, this.txtStartTime.Text.Trim(), this.txtEndTime.Text.Trim(), Grid1); Grid1.RecordCount = SYHSEData_HiddenDangersService.count; Grid1.DataSource = getData; Grid1.DataBind(); } #endregion #region 查询 /// /// 查询 /// /// /// protected void btSearch_Click(object sender, EventArgs e) { this.BindGrid(); } #endregion protected void btAdd_Click(object sender, EventArgs e) { if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.SYHSE_HiddenDangersMenuId, Const.BtnAdd)) { PageContext.RegisterStartupScript(WindowAdd.GetShowReference(String.Format("Data_HiddenDangersEdit.aspx?Id={0}", string.Empty, "新增 - "))); } else { ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); } } protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e) { if (Grid1.SelectedRowIndexArray.Length == 0) { Alert.ShowInTop("请至少选择一条记录", MessageBoxIcon.Warning); return; } PageContext.RegisterStartupScript(WindowAdd.GetShowReference(String.Format("Data_HiddenDangersEdit.aspx?Id={0}", Grid1.SelectedRowID, "编辑 - "))); } #region 删除数据 /// /// 右键删除事件 /// /// /// protected void btnMenuDelete_Click(object sender, EventArgs e) { this.DeleteData(); } public string ConvertMan(Object userId) { if (userId != null) { Model.Sys_User user = Funs.DB.Sys_User.FirstOrDefault(e => e.UserId == userId.ToString()); if (user != null) { return user.UserName; } else { return userId.ToString(); } } else { return ""; } } /// /// 删除方法 /// private void DeleteData() { if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.SYHSE_HiddenDangersMenuId, Const.BtnDelete)) { if (Grid1.SelectedRowIDArray.Length > 0) { foreach (var item in Grid1.SelectedRowIDArray) { SYHSEData_HiddenDangersService.DeleteProjectById(item); } BindGrid(); ShowNotify("删除数据成功!", MessageBoxIcon.Success); } } else { ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); } } #endregion #region 分页 /// /// 分页 /// /// /// protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e) { BindGrid(); } protected void WindowAdd_Close(object sender, WindowCloseEventArgs e) { this.BindGrid(); } /// /// 分页显示条数下拉框 /// /// /// protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e) { Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue); BindGrid(); } protected string ConvertImageUrlByImage(object registrationId) { string url = string.Empty; if (registrationId != null) { IList sourlist = AttachFileService.GetBeforeFileList(registrationId.ToString(), BLL.Const.SYHSE_HiddenDangersMenuId); if (sourlist != null && sourlist.Count > 0) { string AttachUrl = ""; foreach (var item in sourlist) { if (!string.IsNullOrEmpty(item.AttachUrl) && item.AttachUrl.ToLower().EndsWith(".jpg") || item.AttachUrl.ToLower().EndsWith(".jpeg") || item.AttachUrl.ToLower().EndsWith(".png")) AttachUrl += item.AttachUrl.TrimEnd(',') + ","; } url = BLL.UploadAttachmentService.ShowImage(ConfigurationManager.AppSettings["CEMS_IMG_URL"], AttachUrl.TrimEnd(',')); } } return url; } protected string ConvertImgUrlByImage(object registrationId) { string url = string.Empty; if (registrationId != null) { IList sourlist = AttachFileService.Getfilelist(registrationId.ToString() + "1", BLL.Const.SYHSE_HiddenDangersMenuId); if (sourlist != null && sourlist.Count > 0) { string AttachUrl = ""; foreach (var item in sourlist) { if (!string.IsNullOrEmpty(item.AttachUrl) && item.AttachUrl.ToLower().EndsWith(".jpg") || item.AttachUrl.ToLower().EndsWith(".jpeg") || item.AttachUrl.ToLower().EndsWith(".png")) AttachUrl += item.AttachUrl.TrimEnd(',') + ","; } url = BLL.UploadAttachmentService.ShowImage(ConfigurationManager.AppSettings["CEMS_IMG_URL"], AttachUrl.TrimEnd(',')); } } return url; } /// /// 排序 /// /// /// protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e) { BindGrid(); } #endregion protected void drpUnit_SelectedIndexChanged(object sender, EventArgs e) { BindGrid(); } protected void Window1_Close(object sender, WindowCloseEventArgs e) { this.BindGrid(); } protected void btnImport_Click(object sender, EventArgs e) { if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.HJGL_WeldReportMenuId, BLL.Const.BtnSave)) { PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("Data_HiddenDangersIn.aspx", "导入 - "))); } else { ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); } } } }