using BLL; using System; using System.Configuration; using System.Data; using System.Linq; namespace FineUIPro.Web.HSSE.Emergency { public partial class EmergencyTeamAndTrain : PageBase { #region 定义项 /// /// 主键 /// public string ProjectId { get { return (string)ViewState["ProjectId"]; } set { ViewState["ProjectId"] = value; } } #endregion /// /// 加载页面 /// /// /// 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 加载树 /// /// 加载树 /// private void InitTreeMenu() { this.trSafetyOrganization.Nodes.Clear(); TreeNode rootNode = new TreeNode { Text = "安全组织机构", NodeID = "0", Expanded = true }; this.trSafetyOrganization.Nodes.Add(rootNode); BoundTree(rootNode.Nodes); } /// /// 加载树 /// /// /// 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 + ";
机构名称:" + dr.SafetyOrganizationName + ";
职责:" + dr.Duties + ";
组成文件:" + dr.BundleFile + ";
机构人员:" + dr.AgencyPersonnel; nodes.Add(tn); } } } #endregion #region 获取按钮权限 /// /// 获取按钮权限 /// /// /// 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 /// /// 删除 /// /// /// 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); } } /// /// Tree点击事件 /// /// /// 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))); } } }