376 lines
12 KiB
C#
376 lines
12 KiB
C#
using BLL;
|
||
using System;
|
||
using System.Configuration;
|
||
using System.Data;
|
||
using System.Linq;
|
||
|
||
namespace FineUIPro.Web.HSSE.Emergency
|
||
{
|
||
public partial class EmergencyProcess : 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 = Emergency_EmergencyProcessService.GetmodelByPojectIdandUnitId(this.CurrUser.LoginProjectId, trSafetyOrganization.SelectedNodeID);
|
||
if (model != null)
|
||
{
|
||
Emergency_EmergencyProcessService.DeleteEmergency_EmergencyProcessById(model.EmergencyProcessId);
|
||
}
|
||
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;
|
||
|
||
|
||
Emergency_EmergencyProcessService.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 = Emergency_EmergencyProcessService.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 = Emergency_EmergencyProcessService.GetmodelByPojectIdandUnitId(this.CurrUser.LoginProjectId, trSafetyOrganization.SelectedNodeID);
|
||
if (model==null)
|
||
{
|
||
Emergency_EmergencyProcessService.SavePic(this.CurrUser.LoginProjectId, trSafetyOrganization.SelectedNodeID,"");
|
||
model = Emergency_EmergencyProcessService.GetmodelByPojectIdandUnitId(this.CurrUser.LoginProjectId, trSafetyOrganization.SelectedNodeID);
|
||
}
|
||
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/EmergencyProcess&menuId={1}", model.EmergencyProcessId, BLL.Const.ProjectEmergencyProcessMenuId)));
|
||
|
||
}
|
||
}
|
||
//public partial class EmergencyProcess : PageBase
|
||
//{
|
||
// /// <summary>
|
||
// /// 项目id
|
||
// /// </summary>
|
||
// public string ProjectId
|
||
// {
|
||
// get
|
||
// {
|
||
// return (string)ViewState["ProjectId"];
|
||
// }
|
||
// set
|
||
// {
|
||
// ViewState["ProjectId"] = value;
|
||
// }
|
||
// }
|
||
|
||
// #region 加载
|
||
// /// <summary>
|
||
// /// 加载页面
|
||
// /// </summary>
|
||
// /// <param name="sender"></param>
|
||
// /// <param name="e"></param>
|
||
// protected void Page_Load(object sender, EventArgs e)
|
||
// {
|
||
// if (!IsPostBack)
|
||
// {
|
||
// ////权限按钮方法
|
||
// this.GetButtonPower();
|
||
// this.ProjectId = this.CurrUser.LoginProjectId;
|
||
// if (!string.IsNullOrEmpty(Request.Params["projectId"]) && Request.Params["projectId"] != this.ProjectId)
|
||
// {
|
||
// this.ProjectId = Request.Params["projectId"];
|
||
// }
|
||
// // 绑定表格
|
||
// this.BindGrid();
|
||
// }
|
||
// }
|
||
// #endregion
|
||
|
||
// #region GV绑定数据
|
||
// /// <summary>
|
||
// /// 绑定数据
|
||
// /// </summary>
|
||
// void BindGrid()
|
||
// {
|
||
// var getEmergencys = (from x in Funs.DB.Emergency_EmergencyProcess
|
||
// where x.ProjectId == this.ProjectId
|
||
// select x).ToList();
|
||
// if (getEmergencys.Count() == 0)
|
||
// {
|
||
// var getEEmergencyProcessItems = from x in Funs.DB.Emergency_EmergencyProcess
|
||
// where x.ProjectId == null
|
||
// select x;
|
||
// foreach (var item in getEEmergencyProcessItems)
|
||
// {
|
||
// Model.Emergency_EmergencyProcess newItem = new Model.Emergency_EmergencyProcess
|
||
// {
|
||
// EmergencyProcessId = SQLHelper.GetNewID(),
|
||
// ProjectId = this.ProjectId,
|
||
// ProcessSteps = item.ProcessSteps,
|
||
// ProcessName = item.ProcessName,
|
||
// StepOperator = item.StepOperator,
|
||
// Remark = item.Remark,
|
||
// };
|
||
// Funs.DB.Emergency_EmergencyProcess.InsertOnSubmit(newItem);
|
||
// Funs.DB.SubmitChanges();
|
||
|
||
// getEmergencys.Add(item);
|
||
// }
|
||
// }
|
||
|
||
// Grid1.RecordCount = getEmergencys.Count();
|
||
// DataTable tb = this.GetPagedDataTable(Grid1, getEmergencys);
|
||
// Grid1.DataSource = tb;
|
||
// Grid1.DataBind();
|
||
// }
|
||
// #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>
|
||
// void EditData()
|
||
// {
|
||
// if (Grid1.SelectedRowIndexArray.Length == 0)
|
||
// {
|
||
// Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
||
// return;
|
||
// }
|
||
// PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("EmergencyProcessEdit.aspx?EmergencyProcessId={0}", Grid1.SelectedRowID, "详细 - ")));
|
||
// }
|
||
// #endregion
|
||
|
||
// #region 获取按钮权限
|
||
// /// <summary>
|
||
// /// 获取按钮权限
|
||
// /// </summary>
|
||
// /// <param name="button"></param>
|
||
// /// <returns></returns>
|
||
// void GetButtonPower()
|
||
// {
|
||
// if (Request.Params["value"] == "0")
|
||
// {
|
||
// return;
|
||
// }
|
||
// var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.ProjectEmergencyProcessMenuId);
|
||
// if (buttonList.Count() > 0)
|
||
// {
|
||
// if (buttonList.Contains(BLL.Const.BtnModify))
|
||
// {
|
||
// this.btnMenuEdit.Hidden = false;
|
||
// }
|
||
// }
|
||
// }
|
||
// #endregion
|
||
//}
|
||
} |