protected void btnRelease_Click(object sender, EventArgs e) { if (!Save()) return; LAnnounceData model = new LAnnounceData(); LAnnounceBB announceBB = new LAnnounceBB(); try { if (this.IdValue != null && this.IdValue != 0) { model = announceBB.GetModel(this.IdValue); model.isIndexShow = true; model.updtEmpId = this.currentUser.empId; model.updtDt = DateTime.Now.ToString(); announceBB.ModifyRecord(model); } else { this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "alert('发布失败!');", true); } } catch (Exception ex) { this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true); return; } finally { announceBB.Dispose(); } Response.Redirect("LAnnounceList.aspx?itemNo=" + this.itemNo + "&pTypeNo=main", false); }
protected void btnRelease_Click(object sender, EventArgs e) { //获取选中的数据Id foreach (GridViewRow gvrow in this.grid.Rows) { CheckBox chkId = (CheckBox)gvrow.FindControl("chkId"); string id = ""; if (chkId.Checked == true) { id = chkId.ValidationGroup; LAnnounceBB announceBB = new LAnnounceBB(); try { LAnnounceData model = new LAnnounceData(); model = announceBB.GetModel(int.Parse(id)); if (model.isIndexShow) { this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"此通知已经发布!\");", true); } else { model.isIndexShow = true; announceBB.ModifyRecord(model); this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"发布成功!\");", true); } } finally { announceBB.Dispose(); } this.BindGrid(); return; } } this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"请选择一条记录!\");", true); return; }
protected bool Save() { if (!this.Validata()) return false; LAnnounceData model = new LAnnounceData(); LAnnounceBB announceBB = new LAnnounceBB(); try { if (this.State == "1") { this.SetModel(ref model); this.IdValue = announceBB.AddRecord(model); } else if (this.State == "2") { model = announceBB.GetModel(this.IdValue); this.SetModel(ref model); announceBB.ModifyRecord(model); } return true; } catch (Exception ex) { this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true); return false; } finally { announceBB.Dispose(); } }