/// <summary> /// 添加管理规定 /// </summary> /// <param name="manageRule"></param> public static void AddManageRule(Model.ActionPlan_ManagerRule manageRule) { Model.SUBHSSEDB db = Funs.DB; Model.ActionPlan_ManagerRule newManageRule = new Model.ActionPlan_ManagerRule { ManagerRuleId = manageRule.ManagerRuleId, ManageRuleCode = manageRule.ManageRuleCode, OldManageRuleId = manageRule.OldManageRuleId, ProjectId = manageRule.ProjectId, ManageRuleName = manageRule.ManageRuleName, ManageRuleTypeId = manageRule.ManageRuleTypeId, VersionNo = manageRule.VersionNo, AttachUrl = manageRule.AttachUrl, Remark = manageRule.Remark, CompileMan = manageRule.CompileMan, CompileDate = manageRule.CompileDate, Flag = manageRule.Flag, State = manageRule.State, SeeFile = manageRule.SeeFile }; db.ActionPlan_ManagerRule.InsertOnSubmit(newManageRule); db.SubmitChanges(); ////增加一条编码记录 BLL.CodeRecordsService.InsertCodeRecordsByMenuIdProjectIdUnitId(BLL.Const.ActionPlan_ManagerRuleMenuId, manageRule.ProjectId, null, manageRule.ManagerRuleId, manageRule.CompileDate); }
/// <summary> /// 根据主键删除管理规定 /// </summary> /// <param name="manageRuleId"></param> public static void DeleteManageRuleById(string managerRuleId) { Model.SUBHSSEDB db = Funs.DB; Model.ActionPlan_ManagerRule manageRule = db.ActionPlan_ManagerRule.FirstOrDefault(e => e.ManagerRuleId == managerRuleId); if (manageRule != null) { if (!string.IsNullOrEmpty(manageRule.AttachUrl)) { BLL.UploadFileService.DeleteFile(Funs.RootPath, manageRule.AttachUrl); } ///删除编码表记录 BLL.CodeRecordsService.DeleteCodeRecordsByDataId(managerRuleId); ////删除附件表 // BLL.CommonService.DeleteAttachFileById(manageRule.ManagerRuleId); ///删除工程师日志收集记录 var flowOperate = from x in db.Sys_FlowOperate where x.DataId == manageRule.ManagerRuleId select x; if (flowOperate.Count() > 0) { foreach (var item in flowOperate) { BLL.HSSELogService.CollectHSSELog(manageRule.ProjectId, item.OperaterId, item.OperaterTime, "31", "项目现场HSE教育管理规定", Const.BtnDelete, 1); } ////删除审核流程表 BLL.CommonService.DeleteFlowOperateByID(manageRule.ManagerRuleId); } db.ActionPlan_ManagerRule.DeleteOnSubmit(manageRule); db.SubmitChanges(); } }
/// <summary> /// 发布 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnMenuIssuance_Click(object sender, EventArgs e) { string strShowNotify = string.Empty; if (Grid1.SelectedRowIndexArray.Length > 0) { foreach (int rowIndex in Grid1.SelectedRowIndexArray) { string managerRuleId = Grid1.DataKeys[rowIndex][0].ToString(); Model.ActionPlan_ManagerRule managerRule = BLL.ActionPlan_ManagerRuleService.GetManagerRuleById(managerRuleId); if (managerRule != null) { if (managerRule.State == BLL.Const.State_2) { List <Model.ActionPlan_ManagerRule> issuanceManagerRules = BLL.ActionPlan_ManagerRuleService.GetIsIssueManagerRulesByName(managerRule.ManageRuleName); if (issuanceManagerRules.Count == 0) //无对应版本的管理规定 { managerRule.VersionNo = "V1.0"; managerRule.IsIssue = true; managerRule.IssueDate = DateTime.Now; BLL.ActionPlan_ManagerRuleService.UpdateManageRule(managerRule); } else //存在对应版本的管理规定 { string maxVersionNo = issuanceManagerRules[issuanceManagerRules.Count - 1].VersionNo; managerRule.VersionNo = "V" + (Convert.ToInt32(maxVersionNo.Substring(1, maxVersionNo.LastIndexOf(".") - 1)) + 1) + ".0"; managerRule.IsIssue = true; managerRule.IssueDate = DateTime.Now; BLL.ActionPlan_ManagerRuleService.UpdateManageRule(managerRule); } } else { strShowNotify += "管理规定:" + managerRule.ManageRuleName + ";"; } } } } this.BindGrid(); if (!string.IsNullOrEmpty(strShowNotify)) { Alert.ShowInTop(strShowNotify + "尚未审批完成,无法发布!", MessageBoxIcon.Warning); } else { ShowNotify("发布成功!", MessageBoxIcon.Success); } }
/// <summary> /// 修改管理规定 /// </summary> /// <param name="manageRule"></param> public static void UpdateManageRule(Model.ActionPlan_ManagerRule manageRule) { Model.SUBHSSEDB db = Funs.DB; Model.ActionPlan_ManagerRule newManageRule = db.ActionPlan_ManagerRule.FirstOrDefault(e => e.ManagerRuleId == manageRule.ManagerRuleId); if (newManageRule != null) { newManageRule.ManageRuleName = manageRule.ManageRuleName; newManageRule.ManageRuleTypeId = manageRule.ManageRuleTypeId; newManageRule.VersionNo = manageRule.VersionNo; newManageRule.AttachUrl = manageRule.AttachUrl; newManageRule.Remark = manageRule.Remark; newManageRule.CompileMan = manageRule.CompileMan; newManageRule.CompileDate = manageRule.CompileDate; newManageRule.IsIssue = manageRule.IsIssue; newManageRule.IssueDate = manageRule.IssueDate; newManageRule.Flag = manageRule.Flag; newManageRule.State = manageRule.State; newManageRule.SeeFile = manageRule.SeeFile; db.SubmitChanges(); } }
/// <summary> /// 保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { if (ItemSelectedList.Count() > 0) { foreach (var item in ItemSelectedList) { Model.Law_ManageRule rule = BLL.ManageRuleService.GetManageRuleById(item); if (rule != null) { string newKeyID = SQLHelper.GetNewID(typeof(Model.ActionPlan_ManagerRule)); Model.ActionPlan_ManagerRule newManagerRule = new Model.ActionPlan_ManagerRule { ManagerRuleId = newKeyID, OldManageRuleId = rule.ManageRuleId, ProjectId = this.CurrUser.LoginProjectId, ManageRuleName = rule.ManageRuleName, ManageRuleTypeId = rule.ManageRuleTypeId, CompileDate = DateTime.Now, Remark = rule.Remark, CompileMan = this.CurrUser.UserId, IsIssue = false, Flag = true, State = BLL.Const.State_0, AttachUrl = rule.AttachUrl, SeeFile = rule.SeeFile }; BLL.ActionPlan_ManagerRuleService.AddManageRule(newManagerRule); ////保存流程审核数据 this.ctlAuditFlow.btnSaveData(this.CurrUser.LoginProjectId, BLL.Const.ActionPlan_ManagerRuleMenuId, newManagerRule.ManagerRuleId, true, newManagerRule.ManageRuleName, "../ActionPlan/ManagerRuleView.aspx?ManagerRuleId={0}"); Model.SUBHSSEDB db = Funs.DB; Model.AttachFile attachFile = db.AttachFile.FirstOrDefault(x => x.ToKeyId == item); if (attachFile != null) { Model.AttachFile newAttachFile = new Model.AttachFile { AttachFileId = SQLHelper.GetNewID(typeof(Model.AttachFile)), ToKeyId = newKeyID }; string[] urls = attachFile.AttachUrl.Split(','); foreach (string url in urls) { string urlStr = BLL.Funs.RootPath + url; if (File.Exists(urlStr)) { string newUrl = urlStr.Replace("ManageRule", "ActionPlanManagerRule"); if (!Directory.Exists(newUrl.Substring(0, newUrl.LastIndexOf("\\")))) { Directory.CreateDirectory(newUrl.Substring(0, newUrl.LastIndexOf("\\"))); } if (!File.Exists(newUrl)) { File.Copy(urlStr, newUrl); } } } newAttachFile.AttachSource = attachFile.AttachSource.Replace("ManageRule", "ActionPlanManagerRule"); newAttachFile.AttachUrl = attachFile.AttachUrl.Replace("ManageRule", "ActionPlanManagerRule"); newAttachFile.MenuId = BLL.Const.ActionPlan_ManagerRuleMenuId; db.AttachFile.InsertOnSubmit(newAttachFile); db.SubmitChanges(); } } } PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } else { Alert.ShowInParent("请至少选择一条记录!"); return; } }