protected void bt_add_Click(object sender, EventArgs e) { string type = tb_type.Text.Trim(); string msgContent = tb_msg.Text.Trim(); if (string.IsNullOrEmpty(type) == false && string.IsNullOrEmpty(msgContent) == false) { MsgContents msg = new MsgContents(); msg.PageType = type; msg.TypeTitle = ""; msg.MsgContent = msgContent; if (rbt_warn.Checked == true) { msg.msgUse = 0; } else { msg.msgUse = 1; } if (MsgContentsBLL.addMsg(msg) == true) { //成功 loadList(); //Response.Write("<script language='javascript'>alert('请正确填写时分秒');</script>"); } } else { //信息没有填写完整 Response.Write("<script language='javascript'>alert('请填写类型或短信内容!');</script>"); } }
protected void gv_msg_RowDeleting(object sender, GridViewDeleteEventArgs e) { string id = gv_msg.Rows[e.RowIndex].Cells[1].Text; MsgContentsBLL.deleteMsg(id); loadList(); }
void loadList() { DataTable tab = MsgContentsBLL.getMsgByPageType(); if (tab != null && tab.Rows.Count > 0) { gv_msg.DataSource = tab.DefaultView; gv_msg.DataBind(); } }
protected void gv_msg_RowUpdating(object sender, GridViewUpdateEventArgs e) { string id = ((TextBox)(gv_msg.Rows[e.RowIndex].Cells[1].Controls[0])).Text.ToString().Trim(); string type = ((TextBox)(gv_msg.Rows[e.RowIndex].Cells[2].Controls[0])).Text.ToString().Trim(); string msg = ((TextBox)(gv_msg.Rows[e.RowIndex].Cells[3].Controls[0])).Text.ToString().Trim(); int ret = 0; if (rbt_warn.Checked == true) { ret = 1; } MsgContentsBLL.updateMsg(id, type, msg, ret); gv_msg.EditIndex = -1; loadList(); }
string getTempMsg(HttpContext context) { int ret = Convert.ToInt16(context.Request.Form["type"]); DataTable dt = MsgContentsBLL.getMsgByPageType(ret); ArrayList list = new ArrayList(); if (dt != null && dt.Rows.Count > 0) { string json_obj = "{'msg':["; for (int i = 0; i < dt.Rows.Count; i++) { string type = Convert.ToString(dt.Rows[i]["page_type"]); if (string.IsNullOrEmpty(type) == true) { return("{'ret':'1'}"); } ; if (list.Count <= 0) { list.Add(type); } else { if (list.IndexOf(type) < 0) { list.Add(type); } } json_obj += "{"; json_obj += @"'pageType':'" + Convert.ToString(dt.Rows[i]["page_type"]) + "',"; json_obj += @"'typeTitle':'" + Convert.ToString(dt.Rows[i]["type_title"]) + "',"; json_obj += @"'msgContent':'" + Convert.ToString(dt.Rows[i]["msg_content"]) + "'"; json_obj += "}"; if (i != dt.Rows.Count - 1) { json_obj += ","; } } json_obj += "],'ret':'0',typelist:'" + listToString(list) + "'}"; return(json_obj); } return(""); }