/// <summary> /// 页面保存 /// </summary> protected void PageSave(string doType) { #region 表单取值 Response.Clear(); string msg = ""; bool result = false; string title = Utils.GetFormValue(txtTitle.UniqueID); string id = Utils.GetFormValue(hidNotiecID.UniqueID); string content = Utils.GetFormValue(txtContent.UniqueID); string sectionhideid = Utils.GetFormValue(this.SelectSection1.SelectIDClient); string pointdept = Utils.GetFormValue("PointDept"); string innersection = "公司内部"; #endregion #region 表单验证 if (string.IsNullOrEmpty(title)) { msg += "-请输入公告标题!+<br/>"; } if (string.IsNullOrEmpty(content)) { msg += "-请输入公告内容!<br/>"; } if (!string.IsNullOrEmpty(pointdept) && string.IsNullOrEmpty(sectionhideid)) { msg += "-请选择指定部门!<br/>"; } if (!string.IsNullOrEmpty(msg)) { Response.Write(UtilsCommons.AjaxReturnJson(result ? "1" : "0", msg)); Response.End(); return; } #endregion #region 实体赋值 EyouSoft.BLL.GovStructure.BNotice NoticeBLL = new BNotice(); MGovNotice noticeModel = new MGovNotice(); //消息类型 0:公告 1:学习交流 noticeModel.NoticeType = "1"; //公司编号 noticeModel.CompanyId = this.SiteUserInfo.CompanyId; //公告标题 noticeModel.Title = title; noticeModel.NoticeId = id; //公告内容 noticeModel.Content = content; //是否提醒 noticeModel.IsRemind = false; //是否发送短信 //noticeModel.IsMsg = ismsg == "sendMsg"; noticeModel.IsMsg = false; //短信内容 //noticeModel.MsgContent = msgcontent; //浏览量 //noticeModel.Views = 0; //部门编号 noticeModel.DepartId = this.SiteUserInfo.DeptId; //操作人编号 noticeModel.OperatorId = this.SiteUserInfo.UserId; //操作时间 noticeModel.IssueTime = DateTime.Now; //操作人 noticeModel.Operator = this.SiteUserInfo.Name;// Username; //发布对象实体 noticeModel.MGovNoticeReceiverList = GetList(sectionhideid, pointdept, "", "", innersection); noticeModel.ComAttachList = NewGetAttach(); #endregion #region 提交回应 if (doType == "update") { //如果公告编号不为空则为修改 result = NoticeBLL.UpdateGovNotice(noticeModel); msg = result ? "修改成功!" : "修改失败!"; } else { //公告编号为空则新增 result = NoticeBLL.AddGovNotice(noticeModel); msg = result ? "添加成功!" : "添加失败!"; } Response.Write(UtilsCommons.AjaxReturnJson(result ? "1" : "0", msg)); Response.End(); #endregion }
/// <summary> /// 保存按钮点击事件执行方法 /// </summary> protected void PageSave() { //通知公告实体类 MGovNotice modelMGovNotice = new MGovNotice(); //通知公告业务 BNotice bllBNotice = new BNotice(); //操作类型(添加 修改) string doType = "Add"; //获取实体 if (!string.IsNullOrEmpty(HidNoticeID.Value)) { modelMGovNotice = bllBNotice.GetGovNoticeModel(HidNoticeID.Value); doType = "Update"; } #region 通知公告实体属性赋值 #region 通知公告实体显性属性 //标题 string title = Utils.GetFormValue(txtTitle.UniqueID); //内容 string content = Utils.GetFormValue(txtContent.UniqueID); //发布人 string addUser = Utils.GetFormValue(txtAddUser.UniqueID); //发布时间 string addDate = Utils.GetFormValue(txtAddDate.UniqueID); modelMGovNotice.Title = title; modelMGovNotice.Content = content; modelMGovNotice.Operator = addUser; modelMGovNotice.IssueTime = Utils.GetDateTime(addDate); //附件实体 modelMGovNotice.ComAttachList = null; #region 接收人员实体 MGovNoticeReceiver modelMGovNoticeReceiver = null; List <MGovNoticeReceiver> MGovNoticeReceiverlist = new List <MGovNoticeReceiver>(); #region 公司内部(选择所有部门) if (cbxAll.Checked) { modelMGovNoticeReceiver = new MGovNoticeReceiver(); modelMGovNoticeReceiver.ItemType = ItemType.公司内部; modelMGovNoticeReceiver.NoticeId = modelMGovNotice.NoticeId; MGovNoticeReceiverlist.Add(modelMGovNoticeReceiver); //释放实体资源 modelMGovNoticeReceiver = null; } #endregion #region 指定部门 if (cbxSelect.Checked) { //指定部门ids值 string selectDepartlist = Utils.GetFormValue("SectionHideID"); if (!string.IsNullOrEmpty(selectDepartlist)) { if (selectDepartlist.Contains(",")) { //循环指定部门存入数据库 foreach (string strid in selectDepartlist.Split(',')) { MGovNoticeReceiver modelselectReceiver = new MGovNoticeReceiver(); modelselectReceiver.ItemId = strid; modelselectReceiver.ItemType = ItemType.指定部门; modelselectReceiver.NoticeId = modelMGovNotice.NoticeId; MGovNoticeReceiverlist.Add(modelselectReceiver); //释放实体资源 modelselectReceiver = null; } } else { modelMGovNoticeReceiver.ItemId = selectDepartlist; modelMGovNoticeReceiver.ItemType = ItemType.指定部门; modelMGovNoticeReceiver.NoticeId = modelMGovNotice.NoticeId; MGovNoticeReceiverlist.Add(modelMGovNoticeReceiver); //释放实体资源 modelMGovNoticeReceiver = null; } } } #endregion #region 行社 if (cbxPeer.Checked) { modelMGovNoticeReceiver = new MGovNoticeReceiver(); modelMGovNoticeReceiver.ItemType = ItemType.行社; modelMGovNoticeReceiver.NoticeId = modelMGovNotice.NoticeId; MGovNoticeReceiverlist.Add(modelMGovNoticeReceiver); //释放实体资源 modelMGovNoticeReceiver = null; } #endregion #region 组团社 if (cbxGrounp.Checked) { modelMGovNoticeReceiver = new MGovNoticeReceiver(); modelMGovNoticeReceiver.ItemType = ItemType.组团社; modelMGovNoticeReceiver.NoticeId = modelMGovNotice.NoticeId; MGovNoticeReceiverlist.Add(modelMGovNoticeReceiver); //释放实体资源 modelMGovNoticeReceiver = null; } #endregion #endregion modelMGovNotice.MGovNoticeReceiverList = MGovNoticeReceiverlist; #endregion #region 通知公告实体隐形属性 //操作人id modelMGovNotice.OperatorId = SiteUserInfo.UserId; //短信内容 modelMGovNotice.MsgContent = ""; //是否提醒 modelMGovNotice.IsRemind = false; //是否发送短信 modelMGovNotice.IsMsg = false; //公司编号 modelMGovNotice.CompanyId = SiteUserInfo.CompanyId; #endregion #endregion bool result = false; //新增公告 if (doType == "Add") { modelMGovNotice.NoticeId = Guid.NewGuid().ToString(); result = bllBNotice.AddGovNotice(modelMGovNotice); if (result) { EyouSoft.Common.Function.MessageBox.ResponseScript(this, "alert('新增成功!');;window.location='NoticeList.aspx?sl=1';"); } else { EyouSoft.Common.Function.MessageBox.ResponseScript(this, "alert('新增失败!');;window.location='NoticeList.aspx?sl=1';"); } } else//修改公告 { result = bllBNotice.UpdateGovNotice(modelMGovNotice); if (result) { EyouSoft.Common.Function.MessageBox.ResponseScript(this, "alert('修改成功!');;window.location='NoticeList.aspx?sl=1';"); } else { EyouSoft.Common.Function.MessageBox.ResponseScript(this, "alert('修改失败!');;window.location='NoticeList.aspx?sl=1';"); } } }