326 lines
12 KiB
C#
326 lines
12 KiB
C#
using BLL;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using AspNet = System.Web.UI.WebControls;
|
|
|
|
namespace FineUIPro.Web.HSSE.Check
|
|
{
|
|
public partial class ProjectLeaderCheck : PageBase
|
|
{
|
|
#region 定义项
|
|
/// <summary>
|
|
/// 主键
|
|
/// </summary>
|
|
public string ProjectId
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["ProjectId"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["ProjectId"] = value;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 加载
|
|
/// <summary>
|
|
/// 加载页面
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
this.ProjectId = this.CurrUser.LoginProjectId;
|
|
if (!string.IsNullOrEmpty(Request.Params["projectId"]) && Request.Params["projectId"] != this.CurrUser.LoginProjectId)
|
|
{
|
|
this.ProjectId = Request.Params["projectId"];
|
|
}
|
|
|
|
////权限按钮方法
|
|
this.GetButtonPower();
|
|
this.btnNew.OnClientClick = Window1.GetShowReference("ProjectLeaderCheckEdit.aspx") + "return false;";
|
|
Funs.DropDownPageSize(this.ddlPageSize);
|
|
// 绑定表格
|
|
this.BindGrid();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 绑定数据
|
|
/// </summary>
|
|
private void BindGrid()
|
|
{
|
|
var getData = Check_ProjectLeaderCheckService.getListData(this.ProjectId, this.txtStartTime.Text, this.txtEndTime.Text, Grid1);
|
|
Grid1.RecordCount = Check_ProjectLeaderCheckService.count;
|
|
Grid1.DataSource = getData;
|
|
Grid1.DataBind();
|
|
}
|
|
|
|
#region 分页 排序
|
|
/// <summary>
|
|
/// 改变索引事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 分页下拉选择事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
this.Grid1.PageSize = Convert.ToInt32(this.ddlPageSize.SelectedValue);
|
|
BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 排序
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e)
|
|
{
|
|
this.BindGrid();
|
|
}
|
|
#endregion
|
|
#endregion
|
|
|
|
#region 查询
|
|
/// <summary>
|
|
/// 查询
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void TextBox_TextChanged(object sender, EventArgs e)
|
|
{
|
|
this.BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region 编辑
|
|
/// <summary>
|
|
/// 双击事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
|
|
{
|
|
this.EditData();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 右键编辑事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnMenuEdit_Click(object sender, EventArgs e)
|
|
{
|
|
this.EditData();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 编辑数据方法
|
|
/// </summary>
|
|
private void EditData()
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
string id = Grid1.SelectedRowID;
|
|
var meeting = BLL.Check_ProjectLeaderCheckService.GetProjectLeaderCheckById(id);
|
|
if (meeting != null)
|
|
{
|
|
if (this.btnMenuEdit.Hidden) ////双击事件 编辑权限有:编辑页面,无:查看页面 或者状态是完成时查看页面
|
|
{
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ProjectLeaderCheckView.aspx?ProjectLeaderCheckId={0}", id, "查看 - ")));
|
|
}
|
|
else
|
|
{
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ProjectLeaderCheckEdit.aspx?ProjectLeaderCheckId={0}", id, "编辑 - ")));
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 删除
|
|
/// <summary>
|
|
/// 右键删除事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnMenuDelete_Click(object sender, EventArgs e)
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length > 0)
|
|
{
|
|
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
|
|
{
|
|
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
|
|
var newCheckTwolevel = BLL.Check_ProjectLeaderCheckService.GetProjectLeaderCheckById(rowID);
|
|
if (newCheckTwolevel != null)
|
|
{
|
|
BLL.LogService.AddSys_Log(this.CurrUser, newCheckTwolevel.CheckCode, newCheckTwolevel.ProjectLeaderCheckId, BLL.Const.ProjectLeaderCheckMenuId, BLL.Const.BtnDelete);
|
|
BLL.Check_ProjectLeaderCheckService.DeleteProjectLeaderCheckById(rowID);
|
|
|
|
}
|
|
}
|
|
Project_HSSEData_HSSEService.StatisticalData(this.CurrUser.LoginProjectId, Project_HSSEData_HSSEService.HSSEDateType.SupervisionAndInspection);
|
|
this.BindGrid();
|
|
ShowNotify("删除数据成功!", MessageBoxIcon.Success);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 获取按钮权限
|
|
/// <summary>
|
|
/// 获取按钮权限
|
|
/// </summary>
|
|
/// <param name="button"></param>
|
|
/// <returns></returns>
|
|
private void GetButtonPower()
|
|
{
|
|
if (Request.Params["value"] == "0")
|
|
{
|
|
return;
|
|
}
|
|
var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.ProjectLeaderCheckMenuId);
|
|
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
|
|
|
|
#region 导出按钮
|
|
/// 导出按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
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, Encoding.UTF8) + ".xls");
|
|
Response.ContentType = "application/excel";
|
|
Response.ContentEncoding = Encoding.UTF8;
|
|
this.Grid1.PageSize = this.Grid1.RecordCount;
|
|
this.BindGrid();
|
|
Response.Write(GetGridHtml(Grid1));
|
|
Response.End();
|
|
}
|
|
#endregion
|
|
|
|
|
|
/// <summary>
|
|
/// 导出方法
|
|
/// </summary>
|
|
/// <param name="grid"></param>
|
|
/// <returns></returns>
|
|
private string GetGridHtml(Grid grid)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.Append("<meta http-equiv=\"content-type\" content=\"application/excel; charset=UTF-8\"/>");
|
|
sb.Append("<table cellspacing=\"0\" rules=\"all\" border=\"1\" style=\"border-collapse:collapse;\">");
|
|
sb.Append("<tr>");
|
|
foreach (GridColumn column in grid.Columns)
|
|
{
|
|
sb.AppendFormat("<td>{0}</td>", column.HeaderText);
|
|
}
|
|
sb.Append("</tr>");
|
|
foreach (GridRow row in grid.Rows)
|
|
{
|
|
string ID = row.DataKeys[0].ToString();
|
|
string imageUrl = AttachFileService.getFileUrl(ID);
|
|
sb.Append("<tr style='height: 60; '> ");
|
|
foreach (GridColumn column in grid.Columns)
|
|
{
|
|
string html = row.Values[column.ColumnIndex].ToString();
|
|
if (column.ColumnID == "tfNumber" && (row.FindControl("lblNumber") as AspNet.Label) != null)
|
|
{
|
|
html = (row.FindControl("lblNumber") as AspNet.Label).Text;
|
|
}
|
|
if (column.ColumnID == "tfUnitName" && (row.FindControl("lbUnitName") as AspNet.Label) != null)
|
|
{
|
|
html = (row.FindControl("lbUnitName") as AspNet.Label).Text;
|
|
}
|
|
if (column.ColumnID == "tfName" && (row.FindControl("lbName") as AspNet.Label) != null)
|
|
{
|
|
html = (row.FindControl("lbName") as AspNet.Label).Text;
|
|
}
|
|
if (column.ColumnID == "tfImageUrl" && !string.IsNullOrEmpty(imageUrl))
|
|
{
|
|
List<string> list = Funs.GetStrListByStr(imageUrl, ',');
|
|
if (list.Count == 1)
|
|
{
|
|
html = "<img width='60' height='60' src='" + (BLL.Funs.SGGLUrl + imageUrl).Replace('\\', '/') + "'></img>";
|
|
}
|
|
else
|
|
{
|
|
foreach (var item in list)
|
|
{
|
|
html += "<img width='60' height='60' src='" + (BLL.Funs.SGGLUrl + item).Replace('\\', '/') + "'></img>";
|
|
}
|
|
}
|
|
}
|
|
|
|
sb.AppendFormat("<td>{0}</td>", html);
|
|
}
|
|
sb.Append("</tr>");
|
|
}
|
|
sb.Append("</table>");
|
|
|
|
return sb.ToString();
|
|
}
|
|
|
|
protected void btnView_Click(object sender, EventArgs e)
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ProjectLeaderCheckView.aspx?ProjectLeaderCheckId={0}", Grid1.SelectedRowID, "查看 - ")));
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取整改前图片(放于Img中)
|
|
/// </summary>
|
|
/// <param name="registrationId"></param>
|
|
/// <returns></returns>
|
|
protected string ConvertImageUrlByImage(object CheckTwolevelId)
|
|
{
|
|
string url = string.Empty;
|
|
if (CheckTwolevelId != null)
|
|
{
|
|
var getdata = AttachFileService.getFileUrl(CheckTwolevelId.ToString());
|
|
if (!string.IsNullOrEmpty(getdata))
|
|
{
|
|
url = BLL.UploadAttachmentService.ShowImage("../../", getdata);
|
|
}
|
|
}
|
|
return url;
|
|
}
|
|
}
|
|
} |