/// <summary> /// 修改处罚通知单 /// </summary> /// <param name="punishNotice"></param> public static void UpdatePunishNotice(Model.Check_PunishNotice punishNotice) { Model.SUBHSSEDB db = Funs.DB; Model.Check_PunishNotice newPunishNotice = db.Check_PunishNotice.FirstOrDefault(e => e.PunishNoticeId == punishNotice.PunishNoticeId); if (newPunishNotice != null) { //newPunishNotice.ProjectId = punishNotice.ProjectId; //newPunishNotice.PunishNoticeCode = punishNotice.PunishNoticeCode; newPunishNotice.UnitId = punishNotice.UnitId; newPunishNotice.PunishNoticeDate = punishNotice.PunishNoticeDate; newPunishNotice.BasicItem = punishNotice.BasicItem; newPunishNotice.PunishMoney = punishNotice.PunishMoney; newPunishNotice.FileContents = punishNotice.FileContents; newPunishNotice.AttachUrl = punishNotice.AttachUrl; newPunishNotice.CompileMan = punishNotice.CompileMan; newPunishNotice.CompileDate = punishNotice.CompileDate; newPunishNotice.States = punishNotice.States; newPunishNotice.PunishStates = punishNotice.PunishStates; newPunishNotice.SignMan = punishNotice.SignMan; newPunishNotice.ApproveMan = punishNotice.ApproveMan; newPunishNotice.ContractNum = punishNotice.ContractNum; newPunishNotice.IncentiveReason = punishNotice.IncentiveReason; newPunishNotice.Currency = punishNotice.Currency; newPunishNotice.PunishName = punishNotice.PunishName; db.SubmitChanges(); } }
/// <summary> /// 添加处罚通知单 /// </summary> /// <param name="punishNotice"></param> public static void AddPunishNotice(Model.Check_PunishNotice punishNotice) { Model.SUBHSSEDB db = Funs.DB; Model.Check_PunishNotice newPunishNotice = new Model.Check_PunishNotice { PunishNoticeId = punishNotice.PunishNoticeId, ProjectId = punishNotice.ProjectId, PunishNoticeCode = punishNotice.PunishNoticeCode, UnitId = punishNotice.UnitId, PunishNoticeDate = punishNotice.PunishNoticeDate, BasicItem = punishNotice.BasicItem, PunishMoney = punishNotice.PunishMoney, FileContents = punishNotice.FileContents, AttachUrl = punishNotice.AttachUrl, CompileMan = punishNotice.CompileMan, CompileDate = punishNotice.CompileDate, States = punishNotice.States, PunishStates = punishNotice.PunishStates, SignMan = punishNotice.SignMan, ApproveMan = punishNotice.ApproveMan, ContractNum = punishNotice.ContractNum, IncentiveReason = punishNotice.IncentiveReason, Currency = punishNotice.Currency, PunishName = punishNotice.PunishName, }; db.Check_PunishNotice.InsertOnSubmit(newPunishNotice); db.SubmitChanges(); CodeRecordsService.InsertCodeRecordsByMenuIdProjectIdUnitId(Const.ProjectPunishNoticeMenuId, punishNotice.ProjectId, null, punishNotice.PunishNoticeId, punishNotice.CompileDate); }
/// <summary> /// 加载页面 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.btnClose.OnClientClick = ActiveWindow.GetHideReference(); this.PunishNoticeId = Request.Params["PunishNoticeId"]; this.txtCurrency.Text = "人民币"; if (!string.IsNullOrEmpty(this.PunishNoticeId)) { Model.Check_PunishNotice punishNotice = BLL.PunishNoticeService.GetPunishNoticeById(this.PunishNoticeId); if (punishNotice != null) { this.txtPunishNoticeCode.Text = CodeRecordsService.ReturnCodeByDataId(this.PunishNoticeId); if (punishNotice.PunishNoticeDate != null) { this.txtPunishNoticeDate.Text = string.Format("{0:yyyy-MM-dd}", punishNotice.PunishNoticeDate); } if (!string.IsNullOrEmpty(punishNotice.UnitId)) { var unit = BLL.UnitService.GetUnitByUnitId(punishNotice.UnitId); if (unit != null) { this.txtUnitName.Text = unit.UnitName; } } Model.Sys_User user1 = BLL.UserService.GetUserByUserId(punishNotice.SignMan); if (user1 != null) { this.txtSignMan.Text = user1.UserName; } Model.Sys_User user2 = BLL.UserService.GetUserByUserId(punishNotice.ApproveMan); if (user2 != null) { this.txtApproveMan.Text = user2.UserName; } this.txtContractNum.Text = punishNotice.ContractNum; this.txtIncentiveReason.Text = punishNotice.IncentiveReason; this.txtBasicItem.Text = punishNotice.BasicItem; if (punishNotice.PunishMoney != null) { this.txtPunishMoney.Text = Convert.ToString(punishNotice.PunishMoney); this.txtBig.Text = Funs.NumericCapitalization(Funs.GetNewDecimalOrZero(txtPunishMoney.Text));//转换大写 } this.AttchUrl = punishNotice.AttachUrl; //this.divFile.InnerHtml = BLL.UploadAttachmentService.ShowAttachment("../", this.AttchUrl); this.txtFileContents.Text = HttpUtility.HtmlDecode(punishNotice.FileContents); if (!string.IsNullOrEmpty(punishNotice.Currency)) { this.txtCurrency.Text = punishNotice.Currency; } this.txtPunishName.Text = punishNotice.PunishName; } } ///初始化审核菜单 this.ctlAuditFlow.MenuId = BLL.Const.ProjectPunishNoticeMenuId; this.ctlAuditFlow.DataId = this.PunishNoticeId; } }
/// <summary> /// 根据主键删除处罚通知单 /// </summary> /// <param name="punishNoticeId"></param> public static void DeletePunishNoticeById(string punishNoticeId) { Model.SUBHSSEDB db = Funs.DB; Model.Check_PunishNotice punishNotice = db.Check_PunishNotice.FirstOrDefault(e => e.PunishNoticeId == punishNoticeId); if (punishNotice != null) { CodeRecordsService.DeleteCodeRecordsByDataId(punishNoticeId); UploadFileService.DeleteFile(Funs.RootPath, punishNotice.AttachUrl); ///删除工程师日志收集记录 var flowOperate = from x in db.Sys_FlowOperate where x.DataId == punishNotice.PunishNoticeId select x; if (flowOperate.Count() > 0) { foreach (var item in flowOperate) { BLL.HSSELogService.CollectHSSELog(punishNotice.ProjectId, item.OperaterId, item.OperaterTime, "211", "处罚通知单", Const.BtnDelete, 1); } ////删除流程表 BLL.CommonService.DeleteFlowOperateByID(punishNotice.PunishNoticeId); } db.Check_PunishNotice.DeleteOnSubmit(punishNotice); db.SubmitChanges(); } }
/// <summary> /// 保存Check_PunishNotice /// </summary> /// <param name="newItem">处罚通知单</param> /// <returns></returns> public static void SavePunishNotice(Model.PunishNoticeItem newItem) { using (Model.SUBHSSEDB db = new Model.SUBHSSEDB(Funs.ConnString)) { Model.Check_PunishNotice newPunishNotice = new Model.Check_PunishNotice { PunishNoticeId = newItem.PunishNoticeId, PunishNoticeCode = newItem.PunishNoticeCode, ProjectId = newItem.ProjectId, PunishNoticeDate = Funs.GetNewDateTime(newItem.PunishNoticeDate), UnitId = newItem.UnitId, ContractNum = newItem.ContractNum, IncentiveReason = newItem.IncentiveReason, BasicItem = newItem.BasicItem, PunishMoney = newItem.PunishMoney, Currency = newItem.Currency, FileContents = System.Web.HttpUtility.HtmlEncode(newItem.FileContents), States = Const.State_0, PunishStates = newItem.PunishStates, }; if (!string.IsNullOrEmpty(newItem.CompileManId)) { newPunishNotice.CompileMan = newItem.CompileManId; } if (newPunishNotice.PunishStates == Const.State_1) { newPunishNotice.SignMan = newItem.SignManId; } var getUpdate = db.Check_PunishNotice.FirstOrDefault(x => x.PunishNoticeId == newItem.PunishNoticeId); if (getUpdate == null) { newPunishNotice.CompileDate = DateTime.Now; newPunishNotice.PunishNoticeId = SQLHelper.GetNewID(); newPunishNotice.PunishNoticeCode = CodeRecordsService.ReturnCodeByMenuIdProjectId(Const.ProjectPunishNoticeMenuId, newPunishNotice.ProjectId, newPunishNotice.UnitId); db.Check_PunishNotice.InsertOnSubmit(newPunishNotice); db.SubmitChanges(); CodeRecordsService.InsertCodeRecordsByMenuIdProjectIdUnitId(Const.ProjectPunishNoticeMenuId, newPunishNotice.ProjectId, newPunishNotice.UnitId, newPunishNotice.PunishNoticeId, newPunishNotice.CompileDate); //// 回写巡检记录表 if (!string.IsNullOrEmpty(newItem.HazardRegisterId)) { List <string> listIds = Funs.GetStrListByStr(newItem.HazardRegisterId, ','); foreach (var item in listIds) { var getHazardRegister = db.HSSE_Hazard_HazardRegister.FirstOrDefault(x => x.HazardRegisterId == item); if (getHazardRegister != null) { getHazardRegister.States = "3"; getHazardRegister.HandleIdea += "已下发处罚通知单:" + newPunishNotice.PunishNoticeCode; getHazardRegister.ResultId = newPunishNotice.PunishNoticeId; getHazardRegister.ResultType = "2"; db.SubmitChanges(); } } } //// 回写专项检查明细表 if (!string.IsNullOrEmpty(newItem.CheckSpecialDetailId)) { List <string> listIds = Funs.GetStrListByStr(newItem.CheckSpecialDetailId, ','); foreach (var item in listIds) { var getCheckSpecialDetail = db.Check_CheckSpecialDetail.FirstOrDefault(x => x.CheckSpecialDetailId == item); if (getCheckSpecialDetail != null) { getCheckSpecialDetail.DataType = "2"; getCheckSpecialDetail.DataId = newPunishNotice.PunishNoticeId; db.SubmitChanges(); } } } } else { newPunishNotice.PunishNoticeId = getUpdate.PunishNoticeId; getUpdate.PunishStates = newItem.PunishStates; if (newPunishNotice.PunishStates == "0" || newPunishNotice.PunishStates == "1") ////编制人 修改或提交 { getUpdate.PunishNoticeDate = newPunishNotice.PunishNoticeDate; getUpdate.UnitId = newPunishNotice.UnitId; getUpdate.ContractNum = newPunishNotice.ContractNum; getUpdate.IncentiveReason = newPunishNotice.IncentiveReason; getUpdate.BasicItem = newPunishNotice.BasicItem; getUpdate.PunishMoney = newPunishNotice.PunishMoney; getUpdate.Currency = newPunishNotice.Currency; getUpdate.FileContents = newPunishNotice.FileContents; if (newPunishNotice.PunishStates == "1" && !string.IsNullOrEmpty(newItem.SignManId)) { getUpdate.SignMan = newItem.SignManId; } else { newPunishNotice.PunishStates = getUpdate.PunishStates = "0"; } db.SubmitChanges(); } else if (newPunishNotice.PunishStates == "2") ////【签发】总包安全经理 { /// 不同意 打回 同意抄送专业工程师、施工经理、相关施工分包单位并提交【批准】总包项目经理 if (newItem.IsAgree == false) { newPunishNotice.PunishStates = getUpdate.PunishStates = "0"; } else { if (!string.IsNullOrEmpty(newItem.ProfessionalEngineerId)) { getUpdate.ProfessionalEngineerId = newItem.ProfessionalEngineerId; } if (!string.IsNullOrEmpty(newItem.ConstructionManagerId)) { getUpdate.ConstructionManagerId = newItem.ConstructionManagerId; } if (!string.IsNullOrEmpty(newItem.UnitHeadManId)) { getUpdate.UnitHeadManId = newItem.UnitHeadManId; } if (!string.IsNullOrEmpty(newItem.ApproveManId)) { getUpdate.ApproveMan = newItem.ApproveManId; getUpdate.SignDate = DateTime.Now; } else { newPunishNotice.PunishStates = getUpdate.States = "1"; } } db.SubmitChanges(); } else if (newPunishNotice.PunishStates == "3") ////【批准】总包项目经理 { /// 不同意 打回 同意下发【回执】施工分包单位 if (newItem.IsAgree == false || string.IsNullOrEmpty(newItem.DutyPersonId)) { newPunishNotice.PunishStates = getUpdate.PunishStates = "1"; } else { getUpdate.DutyPersonId = newItem.DutyPersonId; getUpdate.ApproveDate = DateTime.Now; } db.SubmitChanges(); } else if (newPunishNotice.PunishStates == "4") ////【批准】总包项目经理 { /// 不同意 打回 同意下发【回执】施工分包单位 if (string.IsNullOrEmpty(newItem.ReceiptUrl)) { newPunishNotice.PunishStates = getUpdate.PunishStates = "3"; } else { getUpdate.DutyPersonDate = DateTime.Now; getUpdate.States = Const.State_2; } db.SubmitChanges(); } } if (newItem.PunishStates == Const.State_0 || newItem.PunishStates == Const.State_1) { //// 通知单附件 APIUpLoadFileService.SaveAttachUrl(Const.ProjectPunishNoticeStatisticsMenuId, newPunishNotice.PunishNoticeId, newItem.PunishUrl, "0"); } if (newItem.PunishStates == Const.State_4) { //// 回执单附件 APIUpLoadFileService.SaveAttachUrl(Const.ProjectPunishNoticeMenuId, newPunishNotice.PunishNoticeId, newItem.ReceiptUrl, "0"); } if (getUpdate != null && getUpdate.States == Const.State_2) { CommonService.btnSaveData(newPunishNotice.ProjectId, Const.ProjectPunishNoticeMenuId, newPunishNotice.PunishNoticeId, newPunishNotice.CompileMan, true, newPunishNotice.PunishNoticeCode, "../Check/PunishNoticeView.aspx?PunishNoticeId={0}"); var getcheck = from x in db.Check_CheckSpecialDetail where x.DataId == getUpdate.PunishNoticeId select x; if (getcheck.Count() > 0) { foreach (var item in getcheck) { item.CompleteStatus = true; item.CompletedDate = DateTime.Now; db.SubmitChanges(); } } } } }
///// <summary> ///// 附件 ///// </summary> //private string AttchUrl //{ // get // { // return (string)ViewState["AttchUrl"]; // } // set // { // ViewState["AttchUrl"] = value; // } //} #endregion #region 加载 /// <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; this.btnClose.OnClientClick = ActiveWindow.GetHideReference(); this.InitDropDownList(); this.PunishNoticeId = Request.Params["PunishNoticeId"]; this.txtCurrency.Text = "人民币"; if (!string.IsNullOrEmpty(this.PunishNoticeId)) { Model.Check_PunishNotice punishNotice = BLL.PunishNoticeService.GetPunishNoticeById(this.PunishNoticeId); if (punishNotice != null) { this.ProjectId = punishNotice.ProjectId; if (this.ProjectId != this.CurrUser.LoginProjectId) { this.InitDropDownList(); } this.txtPunishNoticeCode.Text = CodeRecordsService.ReturnCodeByDataId(this.PunishNoticeId); this.txtPunishNoticeDate.Text = string.Format("{0:yyyy-MM-dd}", punishNotice.PunishNoticeDate); if (!string.IsNullOrEmpty(punishNotice.UnitId)) { this.drpUnitId.SelectedValue = punishNotice.UnitId; } this.txtIncentiveReason.Text = punishNotice.IncentiveReason; this.txtBasicItem.Text = punishNotice.BasicItem; if (punishNotice.PunishMoney.HasValue) { this.txtPunishMoney.Text = Convert.ToString(punishNotice.PunishMoney); this.txtBig.Text = Funs.NumericCapitalization(Funs.GetNewDecimalOrZero(txtPunishMoney.Text)); } //this.AttchUrl = punishNotice.AttachUrl; //this.divFile.InnerHtml = BLL.UploadAttachmentService.ShowAttachment("../", this.AttchUrl); this.txtFileContents.Text = HttpUtility.HtmlDecode(punishNotice.FileContents); if (!string.IsNullOrEmpty(punishNotice.SignMan)) { this.drpSignMan.SelectedValue = punishNotice.SignMan; } if (!string.IsNullOrEmpty(punishNotice.ApproveMan)) { this.drpApproveMan.SelectedValue = punishNotice.ApproveMan; } this.txtContractNum.Text = punishNotice.ContractNum; if (!string.IsNullOrEmpty(punishNotice.Currency)) { this.txtCurrency.Text = punishNotice.Currency; } this.drpPunishName.SelectedValue = punishNotice.PunishName; } } else { this.drpSignMan.SelectedValue = this.CurrUser.UserId; this.txtPunishNoticeDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now); var codeTemplateRule = BLL.ProjectData_CodeTemplateRuleService.GetProjectData_CodeTemplateRuleByMenuIdProjectId(BLL.Const.ProjectPunishNoticeMenuId, this.ProjectId); if (codeTemplateRule != null) { this.txtFileContents.Text = HttpUtility.HtmlDecode(codeTemplateRule.Template); } ////自动生成编码 this.txtPunishNoticeCode.Text = BLL.CodeRecordsService.ReturnCodeByMenuIdProjectId(BLL.Const.ProjectPunishNoticeMenuId, this.ProjectId, this.CurrUser.UnitId); } ///初始化审核菜单 this.ctlAuditFlow.MenuId = BLL.Const.ProjectPunishNoticeMenuId; this.ctlAuditFlow.DataId = this.PunishNoticeId; this.ctlAuditFlow.ProjectId = this.ProjectId; this.ctlAuditFlow.UnitId = this.CurrUser.UnitId; } }
/// <summary> /// 保存数据 /// </summary> /// <param name="type"></param> private void SaveData(string type) { if (string.IsNullOrEmpty(this.drpUnitId.SelectedValue)) { Alert.ShowInTop("请选择受罚单位", MessageBoxIcon.Warning); return; } Model.Check_PunishNotice punishNotice = new Model.Check_PunishNotice { ProjectId = this.ProjectId, PunishNoticeCode = this.txtPunishNoticeCode.Text.Trim() }; if (!string.IsNullOrEmpty(this.drpUnitId.SelectedValue)) { punishNotice.UnitId = this.drpUnitId.SelectedValue; } punishNotice.PunishName = this.drpPunishName.SelectedValue; punishNotice.PunishNoticeDate = Funs.GetNewDateTime(this.txtPunishNoticeDate.Text.Trim()); punishNotice.IncentiveReason = this.txtIncentiveReason.Text.Trim(); punishNotice.BasicItem = this.txtBasicItem.Text.Trim(); punishNotice.PunishMoney = Funs.GetNewDecimalOrZero(this.txtPunishMoney.Text.Trim()); punishNotice.FileContents = HttpUtility.HtmlEncode(this.txtFileContents.Text); //punishNotice.AttachUrl = this.AttchUrl; punishNotice.CompileMan = this.CurrUser.UserId; punishNotice.CompileDate = DateTime.Now; punishNotice.States = Const.State_0; if (this.drpSignMan.SelectedValue != BLL.Const._Null) { punishNotice.SignMan = this.drpSignMan.SelectedValue; } if (this.drpApproveMan.SelectedValue != BLL.Const._Null) { punishNotice.ApproveMan = this.drpApproveMan.SelectedValue; } punishNotice.ContractNum = this.txtContractNum.Text.Trim(); punishNotice.Currency = this.txtCurrency.Text.Trim(); if (type == BLL.Const.BtnSubmit) { punishNotice.States = this.ctlAuditFlow.NextStep; } punishNotice.PunishStates = punishNotice.States; if (punishNotice.States == Const.State_2) { punishNotice.PunishStates = Const.State_4; } if (!string.IsNullOrEmpty(this.PunishNoticeId)) { punishNotice.PunishNoticeId = this.PunishNoticeId; BLL.PunishNoticeService.UpdatePunishNotice(punishNotice); BLL.LogService.AddSys_Log(this.CurrUser, punishNotice.PunishNoticeCode, punishNotice.PunishNoticeId, BLL.Const.ProjectPunishNoticeMenuId, BLL.Const.BtnModify); } else { this.PunishNoticeId = SQLHelper.GetNewID(typeof(Model.Check_PunishNotice)); punishNotice.PunishNoticeId = this.PunishNoticeId; BLL.PunishNoticeService.AddPunishNotice(punishNotice); BLL.LogService.AddSys_Log(this.CurrUser, punishNotice.PunishNoticeCode, punishNotice.PunishNoticeId, BLL.Const.ProjectPunishNoticeMenuId, BLL.Const.BtnAdd); } ////保存流程审核数据 this.ctlAuditFlow.btnSaveData(this.ProjectId, BLL.Const.ProjectPunishNoticeMenuId, this.PunishNoticeId, (type == BLL.Const.BtnSubmit ? true : false), punishNotice.PunishNoticeCode, "../Check/PunishNoticeView.aspx?PunishNoticeId={0}"); }