SGGL_SHJ/SGGL/FineUIPro.Web/HSSE/SecuritySystem/SafetyOrganization.aspx.cs

250 lines
8.4 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using BLL;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web.UI.WebControls;
namespace FineUIPro.Web.HSSE.SecuritySystem
{
public partial class SafetyOrganization : PageBase
{
#region
/// <summary>
/// 主键
/// </summary>
public string ProjectId
{
get
{
return (string)ViewState["ProjectId"];
}
set
{
ViewState["ProjectId"] = value;
}
}
#endregion
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Funs.DropDownPageSize(this.ddlPageSize);
this.ProjectId = this.CurrUser.LoginProjectId;
if (!string.IsNullOrEmpty(Request.Params["projectId"]) && Request.Params["projectId"] != this.CurrUser.LoginProjectId)
{
this.ProjectId = Request.Params["projectId"];
}
this.InitTreeMenu();
}
}
#region
/// <summary>
/// 加载树
/// </summary>
private void InitTreeMenu()
{
this.trSafetyOrganization.Nodes.Clear();
TreeNode rootNode = new TreeNode
{
Text = "安全组织机构",
NodeID = "0",
Expanded = true
};
this.trSafetyOrganization.Nodes.Add(rootNode);
BoundTree(rootNode.Nodes);
}
/// <summary>
/// 加载树
/// </summary>
/// <param name="nodes"></param>
/// <param name="menuId"></param>
private void BoundTree(TreeNodeCollection nodes)
{
var unitLists = BLL.ProjectUnitService.GetProjectUnitListByProjectId(this.ProjectId);
if (unitLists.Count() > 0)
{
if (BLL.ProjectUnitService.GetProjectUnitTypeByProjectIdUnitId(this.ProjectId, this.CurrUser.UnitId))
{
unitLists = unitLists.Where(x => x.UnitId == this.CurrUser.UnitId).ToList();
}
TreeNode tn = null;
foreach (var dr in unitLists)
{
tn = new TreeNode();
var unitName = BLL.UnitService.GetUnitNameByUnitId(dr.UnitId);
if (unitName != null)
{
tn.Text = unitName;
}
tn.NodeID = dr.UnitId;
tn.EnableClickEvent = true;
var gunitType = BLL.ConstValue.GetConstByConstValueAndGroupId(dr.UnitType, BLL.ConstValue.Group_ProjectUnitType);
if (gunitType != null)
{
tn.ToolTip = gunitType.ConstText + "" + unitName;
}
//tn.ToolTip = "编号:" + dr.SafetyOrganizationCode + "<br/>机构名称:" + dr.SafetyOrganizationName + "<br/>职责:" + dr.Duties + "<br/>组成文件:" + dr.BundleFile + "<br/>机构人员:" + dr.AgencyPersonnel;
nodes.Add(tn);
}
}
}
#endregion
#region Grid
/// <summary>
/// 绑定Grid
/// </summary>
private void BindGrid()
{
string unitIdSelect = string.Empty;
if (this.trSafetyOrganization.SelectedNode != null)
{
unitIdSelect = this.trSafetyOrganization.SelectedNode.NodeID;
}
string strSql = @"SELECT p.SitePersonId,p.PersonId,p.CardNo,p.PersonName,p.ProjectId,p.UnitId
,w.WorkPostName,w.WorkPostCode,ps.Telephone,w.Remark
FROM SitePerson_Person AS P
LEFT JOIN Person_Persons AS ps ON P.PersonId =ps.PersonId
LEFT JOIN Base_WorkPost AS W ON P.WorkPostId =W.WorkPostId
WHERE w.PostType='1' AND p.ProjectId= '" + this.ProjectId + "' AND p.UnitId='" + unitIdSelect + "'";
List<SqlParameter> listStr = new List<SqlParameter>();
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
Grid1.RecordCount = tb.Rows.Count;
var table = this.GetPagedDataTable(Grid1, tb);
Grid1.DataSource = table;
Grid1.DataBind();
}
#endregion
#region GV
/// <summary>
/// Grid1排序
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_Sort(object sender, GridSortEventArgs e)
{
BindGrid();
}
/// <summary>
/// 分页下拉选择事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
{
Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
BindGrid();
}
/// <summary>
/// 页码变化事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
{
BindGrid();
}
#endregion
#region GV
/// <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 btnEditItem_Click(object sender, EventArgs 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;
}
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("SafetyOrganizationEdit.aspx?SitePersonId={0}", Grid1.SelectedRowID, "编辑 - ")));
}
#endregion
/// <summary>
/// 关闭窗口
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Window2_Close(object sender, WindowCloseEventArgs e)
{
BindGrid();
}
/// <summary>
/// Tree点击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void trSafetyOrganization_NodeCommand(object sender, TreeCommandEventArgs e)
{
BindGrid();
}
#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, System.Text.Encoding.UTF8) + ".xls");
Response.ContentType = "application/excel";
Response.ContentEncoding = System.Text.Encoding.UTF8;
this.Grid1.PageSize = this.Grid1.RecordCount;
this.BindGrid();
Response.Write(GetGridTableHtml(Grid1));
Response.End();
}
#endregion
}
}