xinjiang/SGGL/FineUIPro.Web/HSSE/Emergency/EmergencyTeamAndTrain.aspx.cs

239 lines
8.3 KiB
C#
Raw Normal View History

2024-11-19 09:45:27 +08:00
using BLL;
using System;
using System.Configuration;
using System.Data;
using System.Linq;
namespace FineUIPro.Web.HSSE.Emergency
{
public partial class EmergencyTeamAndTrain : 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)
{
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.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
/// <summary>
/// 获取按钮权限
/// </summary>
/// <param name="button"></param>
/// <returns></returns>
private void GetButtonPower()
{
var buttonList = BLL.CommonService.GetAllButtonList(this.ProjectId, this.CurrUser.UserId, BLL.Const.ProjectSafetyOrganizationMenuId);
if (buttonList.Count() > 0)
{
if (buttonList.Contains(BLL.Const.BtnAdd))
{
this.btnNewItem.Hidden = false;
}
if (buttonList.Contains(BLL.Const.BtnDelete))
{
this.btnDeleteItem.Hidden = false;
}
}
}
#endregion
/// <summary>
/// 删除
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnDelete_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(trSafetyOrganization.SelectedNodeID))
{
var model = EmergencyOrganizationService.GetmodelByPojectIdandUnitId(this.CurrUser.LoginProjectId, trSafetyOrganization.SelectedNodeID);
if (model != null)
{
EmergencyOrganizationService.DeleteEmergency_EmergencyOrganizationById(model.EmergencyOrganizationId);
}
this.imgPhoto.ImageUrl = null;
}
else
{
Alert.ShowInTop("请选择一个单位!", MessageBoxIcon.Warning);
}
}
protected void filePhoto_FileSelected(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(trSafetyOrganization.SelectedNodeID))
{
if (filePhoto.HasFile)
{
string rootUrl = ConfigurationManager.AppSettings["localRoot"];
if (string.IsNullOrEmpty(rootUrl))
{
rootUrl = Funs.RootPath;
}
string fileName = filePhoto.ShortFileName;
if (!ValidateFileType(fileName))
{
// 清空文件上传控件
filePhoto.Reset();
ShowNotify("无效的文件类型!");
return;
}
fileName = fileName.Replace(":", "_").Replace(" ", "_").Replace("\\", "_").Replace("/", "_");
fileName = DateTime.Now.Ticks.ToString() + "_" + fileName;
filePhoto.SaveAs(rootUrl + "/FileUpload/EmergencyProcess/" + fileName);
imgPhoto.ImageUrl = "~/FileUpload/EmergencyProcess/" + fileName;
EmergencyOrganizationService.SavePic(this.CurrUser.LoginProjectId, trSafetyOrganization.SelectedNodeID, "FileUpload/EmergencyProcess/" + fileName);
// 清空文件上传组件(上传后要记着清空,否则点击提交表单时会再次上传!!)
filePhoto.Reset();
}
}
else
{
Alert.ShowInTop("请选择一个单位!", MessageBoxIcon.Warning);
}
}
/// <summary>
/// Tree点击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void trSafetyOrganization_NodeCommand(object sender, TreeCommandEventArgs e)
{
if (!string.IsNullOrEmpty(trSafetyOrganization.SelectedNodeID))
{
var unit = EmergencyOrganizationService.GetmodelByPojectIdandUnitId(this.CurrUser.LoginProjectId, trSafetyOrganization.SelectedNodeID);
this.imgPhoto.ImageUrl = null;
if (unit != null)
{
this.imgPhoto.ImageUrl = "~/" + unit.FlowChartPic;
}
}
else
{
this.imgPhoto.ImageUrl = null;
}
}
protected void btnAttachUrl_Click(object sender, EventArgs e)
{
var model = EmergencyOrganizationService.GetmodelByPojectIdandUnitId(this.CurrUser.LoginProjectId, trSafetyOrganization.SelectedNodeID);
if (model == null)
{
EmergencyOrganizationService.SavePic(this.CurrUser.LoginProjectId, trSafetyOrganization.SelectedNodeID, "");
model = EmergencyOrganizationService.GetmodelByPojectIdandUnitId(this.CurrUser.LoginProjectId, trSafetyOrganization.SelectedNodeID);
}
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/EmergencyOrganization&menuId={1}", model.EmergencyOrganizationId, BLL.Const.ProjectEmergencyTeamAndTrainMenuId)));
}
}
}