AddBooksCatagory.aspx.cs
资源名称:SunShine.rar [点击查看]
上传用户:tjxpgg
上传日期:2017-05-14
资源大小:2244k
文件大小:2k
源码类别:
SilverLight
开发平台:
ASP/ASPX
- using System;
- using System.Data;
- using System.Configuration;
- using System.Collections;
- using System.Web;
- using System.Web.Security;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.WebControls.WebParts;
- using System.Web.UI.HtmlControls;
- using System.Xml;
- public partial class AddBooksCatagory : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- bind();
- }
- }
- public void bind()
- {
- this.GridView1.DataSource = DBHelp.Select("select * from Categories");
- this.GridView1.DataBind();
- }
- protected void Button1_Click(object sender, EventArgs e)
- {
- string name = this.TextBox1.Text.Trim();
- if (DBHelp.Update("insert into Categories values('" + name + "')"))
- {
- bind();
- }else
- {
- ClientScript.RegisterStartupScript(this.GetType(), "", "alert('添加失败╭∩╮(︶︿︶)╭∩╮')");
- }
- }
- private XmlDocument xmlTree = new XmlDocument();
- public void jiazaiXml()
- {
- DataTable dt= DBHelp.Select("select top 1 * from Categories asc");
- int id=Convert.ToInt32( dt.Rows[0][0]);
- xmlTree.Load(Server.MapPath("TreeView.xml"));
- XmlElement xe = xmlTree.CreateElement("siteMapNode");
- xe.SetAttribute("title", this.TextBox1.Text);
- xe.SetAttribute("url","BookList.aspx?id="+id.ToString());
- xe.SetAttribute("description", "");
- xmlTree.SelectSingleNode("siteMapNode").AppendChild(xe);
- xmlTree.Save(Server.MapPath("TreeView.xml"));
- }
- protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
- {
- string id = this.GridView1.Rows[e.RowIndex].Cells[0].Text;
- if (DBHelp.Update("delete from Categories where id=" + id + ""))
- {
- bind();
- }
- else
- {
- ClientScript.RegisterStartupScript(this.GetType(), "", "alert('删除失败')", true);
- }
- }
- }