namespace FineUIPro.Web.HJGL.WeldingManage { using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.IO; using BLL; public partial class ProcedureImageList : PageBase { #region 加载页面 /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ddlPageSize.SelectedValue = Grid1.PageSize.ToString(); // 绑定表格 BindGrid(); } else if (GetRequestEventArgument() == "reloadGrid") { BindGrid(); } } #endregion #region 绑定数据 /// /// 绑定数据 /// private void BindGrid() { string strSql = @"SELECT Image.ImageId,Image.ImageContent,Image.AttachUrl,Image.WME_ID,Image.Thickness,Image.JOTY_ID,Image.JST_ID" + @" ,WeldMethod.WME_Name,JointType.JOTY_Name,SlopeType.JST_Name " + @" FROM HJGL_PW_ProcedureImageManage AS Image " + @" LEFT JOIN HJGL_BS_WeldMethod AS WeldMethod ON Image.WME_ID=WeldMethod.WME_ID" + @" LEFT JOIN HJGL_BS_JointType AS JointType ON Image.JOTY_ID=JointType.JOTY_ID" + @" LEFT JOIN HJGL_BS_SlopeType AS SlopeType ON Image.JST_ID=SlopeType.JST_ID WHERE 1=1 "; List listStr = new List(); if (!string.IsNullOrEmpty(this.txtImageContent.Text.Trim())) { strSql += " AND Welder.ImageContent LIKE @ImageContent"; listStr.Add(new SqlParameter("@ImageContent", "%" + this.txtImageContent.Text.Trim() + "%")); } SqlParameter[] parameter = listStr.ToArray(); 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(); for (int i = 0; i < Grid1.Rows.Count; i++) { System.Web.UI.WebControls.LinkButton lbtnUrl = ((System.Web.UI.WebControls.LinkButton)(this.Grid1.Rows[i].FindControl("lbtnUrl"))); string url = lbtnUrl.CommandArgument.ToString(); if (!string.IsNullOrEmpty(url)) { url = url.Replace('\\', '/'); lbtnUrl.Text = BLL.UploadAttachmentService.ShowAttachment("../../", url); } } } #endregion #region 双击事件 /// /// Grid行双击事件 /// /// /// protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e) { if (Grid1.SelectedRowIndexArray.Length == 0) { Alert.ShowInTop("请选择一条记录!", MessageBoxIcon.Warning); return; } if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_ProcedureImageListMenuId, Const.BtnAdd)) { PageContext.RegisterStartupScript(WindowEdit.GetShowReference(String.Format("ProcedureImageEdit.aspx?ImageId={0}", Grid1.SelectedRowID, "维护 - "))); } else { ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); } } #endregion #region 工艺评定图片 /// /// 增加工艺评定图片 /// /// /// protected void btnNew_Click(object sender, EventArgs e) { if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_ProcedureImageListMenuId, Const.BtnAdd)) { PageContext.RegisterStartupScript(WindowEdit.GetShowReference(String.Format("ProcedureImageEdit.aspx?ImageId={0}", String.Empty, "新增 - "))); } else { ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); } } /// /// 工艺评定图片编辑 /// /// /// protected void btnMenuEdit_Click(object sender, EventArgs e) { if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.HJGL_ProcedureImageListMenuId, BLL.Const.BtnModify)) { if (Grid1.SelectedRowIndexArray.Length == 0) { Alert.ShowInTop("请选择一条记录!", MessageBoxIcon.Warning); return; } PageContext.RegisterStartupScript(WindowEdit.GetShowReference(String.Format("ProcedureImageEdit.aspx?ImageId={0}", Grid1.SelectedRowID, "维护 - "))); } else { ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); } } /// /// 删除按钮 /// /// /// protected void btnMenuDelete_Click(object sender, EventArgs e) { if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_ProcedureImageListMenuId, Const.BtnDelete)) { if (Grid1.SelectedRowIndexArray.Length == 0) { Alert.ShowInTop("请选择一条记录!", MessageBoxIcon.Warning); return; } bool isShow = true; if (Grid1.SelectedRowIndexArray.Length > 1) { isShow = false; } foreach (int rowIndex in Grid1.SelectedRowIndexArray) { string rowID = Grid1.DataKeys[rowIndex][0].ToString(); if (judgementDelete(rowID, isShow)) { Model.HJGL_PW_ProcedureImageManage procedureImage = BLL.HJGL_ProcedureImageService.GetImageById(rowID); string rootPath = Server.MapPath("~/"); string urlFullPath = rootPath + procedureImage.AttachUrl; if (File.Exists(urlFullPath)) { File.Delete(urlFullPath); } BLL.HJGL_ProcedureImageService.DeleteProcedureImage(rowID); BLL.Sys_LogService.AddLog(Const.System_3, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "删除工艺评定图片信息"); } } Alert.ShowInTop("删除成功!", MessageBoxIcon.Success); this.BindGrid(); } else { ShowNotify("您没有这个权限,请与管理员联系!",MessageBoxIcon.Warning); } } #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(); } /// /// 排序 /// /// /// protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e) { Grid1.SortDirection = e.SortDirection; Grid1.SortField = e.SortField; BindGrid(); } #endregion #region 查询 /// /// 查询 /// /// /// protected void TextBox_TextChanged(object sender, EventArgs e) { this.BindGrid(); } #endregion #region 判断是否可删除 /// /// 判断是否可以删除 /// /// private bool judgementDelete(string id, bool isShow) { string content = string.Empty; //if (BLL.HJGL_PW_JointInfoService.GetJointInfoByCellWelder(id) > 0) //{ // content = "焊口中已使用了该人员,不能删除!"; //} if (string.IsNullOrEmpty(content)) { return true; } else { if (isShow) { Alert.ShowInTop(content, MessageBoxIcon.Error); } return false; } } #endregion } }