/// <summary> /// 生成隐患整改单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnMenuRectify_Click(object sender, EventArgs e) { if (Grid1.SelectedRowIndexArray.Length == 0) { Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning); return; } string rectifyNoticeCode = string.Empty; string CheckSpecialId = Grid1.SelectedRowID.Split(',')[0]; var checkSpecial = Check_CheckSpecialService.GetCheckSpecialByCheckSpecialId(CheckSpecialId); if (checkSpecial.States == Const.State_2) { string CheckSpecialDetailId = Grid1.SelectedRowID.Split(',')[1]; Model.Check_CheckSpecialDetail detail = Check_CheckSpecialDetailService.GetCheckSpecialDetailByCheckSpecialDetailId(CheckSpecialDetailId); if (string.IsNullOrEmpty(detail.RectifyNoticeId)) { Model.Check_RectifyNotices rectifyNotice = new Model.Check_RectifyNotices { RectifyNoticesId = SQLHelper.GetNewID(typeof(Model.Check_RectifyNotice)), ProjectId = checkSpecial.ProjectId, UnitId = detail.UnitId, CheckedDate = checkSpecial.CheckTime, RectifyNoticesCode = BLL.CodeRecordsService.ReturnCodeByMenuIdProjectId(BLL.Const.ProjectRectifyNoticeMenuId, checkSpecial.ProjectId, detail.UnitId), WrongContent = "开展了专项检查,发现问题及隐患:" + detail.Unqualified + "\n" + detail.Suggestions, SignPerson = this.CurrUser.UserId, SignDate = DateTime.Now, States = Const.State_0, }; var workArea = Funs.DB.ProjectData_WorkArea.FirstOrDefault(x => x.ProjectId == checkSpecial.ProjectId && x.WorkAreaName == detail.WorkArea); if (workArea != null) { rectifyNotice.WorkAreaId = workArea.WorkAreaId; } RectifyNoticesService.AddRectifyNotices(rectifyNotice); rectifyNoticeCode = rectifyNotice.RectifyNoticesCode; detail.RectifyNoticeId = rectifyNotice.RectifyNoticesId; Check_CheckSpecialDetailService.UpdateCheckSpecialDetail(detail); } if (!string.IsNullOrEmpty(rectifyNoticeCode)) { Alert.ShowInTop("已生成隐患整改通知单:" + rectifyNoticeCode + "!", MessageBoxIcon.Success); } else { Alert.ShowInTop("隐患整改通知单已存在,请到对应模块进行处理!", MessageBoxIcon.Warning); } } else { Alert.ShowInTop("该记录尚未审批完成,无法进行操作!", MessageBoxIcon.Warning); return; } }
/// <summary> /// 保存数据 /// </summary> /// <param name="type"></param> private void SaveData(string type) { Model.Check_CheckSpecial checkSpecial = new Model.Check_CheckSpecial { CheckSpecialCode = this.txtCheckSpecialCode.Text.Trim(), ProjectId = this.ProjectId }; ///组成员 string partInPersonIds = string.Empty; string partInPersons = string.Empty; foreach (var item in this.drpPartInPersons.SelectedValueArray) { var user = BLL.UserService.GetUserByUserId(item); if (user != null) { partInPersonIds += user.UserId + ","; partInPersons += user.UserName + ","; } } if (!string.IsNullOrEmpty(partInPersonIds)) { checkSpecial.PartInPersonIds = partInPersonIds.Substring(0, partInPersonIds.LastIndexOf(",")); checkSpecial.PartInPersons = partInPersons.Substring(0, partInPersons.LastIndexOf(",")); } checkSpecial.PartInPersonNames = this.txtPartInPersonNames.Text.Trim(); checkSpecial.CheckTime = Funs.GetNewDateTime(this.txtCheckDate.Text.Trim()); ////单据状态 checkSpecial.States = Const.State_0; if (type == Const.BtnSubmit) { checkSpecial.States = Const.State_1; } if (!string.IsNullOrEmpty(this.drpSupCheckItemSet.SelectedValue) && this.drpSupCheckItemSet.SelectedValue != Const._Null) { checkSpecial.CheckItemSetId = this.drpSupCheckItemSet.SelectedValue; } if (!string.IsNullOrEmpty(this.CheckSpecialId)) { checkSpecial.CheckSpecialId = this.CheckSpecialId; Check_CheckSpecialService.UpdateCheckSpecial(checkSpecial); LogService.AddSys_Log(this.CurrUser, checkSpecial.CheckSpecialCode, checkSpecial.CheckSpecialId, BLL.Const.ProjectCheckSpecialMenuId, BLL.Const.BtnModify); Check_CheckSpecialDetailService.DeleteCheckSpecialDetails(this.CheckSpecialId); } else { checkSpecial.CheckSpecialId = SQLHelper.GetNewID(typeof(Model.Check_CheckSpecial)); this.CheckSpecialId = checkSpecial.CheckSpecialId; checkSpecial.CompileMan = this.CurrUser.UserId; Check_CheckSpecialService.AddCheckSpecial(checkSpecial); LogService.AddSys_Log(this.CurrUser, checkSpecial.CheckSpecialCode, checkSpecial.CheckSpecialId, BLL.Const.ProjectCheckSpecialMenuId, BLL.Const.BtnAdd); } this.SaveDetail(type, checkSpecial); }
/// <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.ProjectId = this.CurrUser.LoginProjectId; this.InitDropDownList(); this.CheckSpecialId = Request.Params["CheckSpecialId"]; var checkSpecial = Check_CheckSpecialService.GetCheckSpecialByCheckSpecialId(this.CheckSpecialId); if (checkSpecial != null) { this.ProjectId = checkSpecial.ProjectId; if (this.ProjectId != this.CurrUser.LoginProjectId) { this.InitDropDownList(); } this.txtCheckSpecialCode.Text = CodeRecordsService.ReturnCodeByDataId(this.CheckSpecialId); if (checkSpecial.CheckTime != null) { this.txtCheckDate.Text = string.Format("{0:yyyy-MM-dd}", checkSpecial.CheckTime); } this.txtPartInPersonNames.Text = checkSpecial.PartInPersonNames; if (!string.IsNullOrEmpty(checkSpecial.CheckItemSetId)) { this.drpSupCheckItemSet.SelectedValue = checkSpecial.CheckItemSetId; this.getCheckItemDrp(); } if (!string.IsNullOrEmpty(checkSpecial.PartInPersonIds)) { this.drpPartInPersons.SelectedValueArray = checkSpecial.PartInPersonIds.Split(','); } checkSpecialDetails = (from x in Funs.DB.View_CheckSpecialDetail where x.CheckSpecialId == this.CheckSpecialId orderby x.CheckItem select x).ToList(); if (checkSpecialDetails.Count() > 0) { this.drpSupCheckItemSet.Readonly = true; } } else { ////自动生成编码 this.txtCheckSpecialCode.Text = CodeRecordsService.ReturnCodeByMenuIdProjectId(BLL.Const.ProjectCheckSpecialMenuId, this.ProjectId, this.CurrUser.UnitId); this.txtCheckDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now); this.drpSupCheckItemSet.SelectedIndex = 0; this.drpSupCheckItemSet.SelectedIndex = 0; } // 删除选中单元格的客户端脚本 string deleteScript = GetDeleteScript(); // 新增数据初始值 JObject defaultObj = new JObject { { "WorkArea", "" }, { "UnitName", "" }, { "Unqualified", "" }, { "CheckContent", "" }, { "CompleteStatusName", "" }, { "HandleStepStr", "" }, { "HandleStep", "" }, { "UnitId", "" }, { "Delete", String.Format("<a href=\"javascript:;\" onclick=\"{0}\"><img src=\"{1}\"/></a>", deleteScript, IconHelper.GetResolvedIconUrl(Icon.Delete)) } }; // 在第一行新增一条数据 btnNew.OnClientClick = Grid1.GetAddNewRecordReference(defaultObj, false); // 删除选中行按钮 //btnDelete.OnClientClick = Grid1.GetNoSelectionAlertReference("请至少选择一项!") + deleteScript; Grid1.DataSource = checkSpecialDetails; Grid1.DataBind(); } }