Esempio n. 1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["user"] == null)
     {
         Response.Redirect("index.aspx");
     }
     else
     {
         u = (Users)Session["user"];
     }
     if (!IsPostBack)
     {
         ddlLanMu.DataSource     = Lanmu.getLanMuList();
         ddlLanMu.DataTextField  = "lanMuName";
         ddlLanMu.DataValueField = "lanMuId";
         ddlLanMu.DataBind();
         if (Request.QueryString["id"] != null)
         {
             string id = Request.QueryString["id"].ToString();
             News   n  = News.getNewsById(id);
             txtTitle.Text  = n.title;
             content1.Value = n.contents;
             foreach (ListItem x in ddlLanMu.Items)
             {
                 if (x.Value == n.lanMuId.ToString())
                 {
                     x.Selected = true;
                 }
             }
         }
     }
 }
    protected void submitUser_Click(object sender, EventArgs e)
    {
        Lanmu l = new Lanmu();

        l.lanMuName = addLanMuName.Text;
        if (Lanmu.addLanMu(l) == true)
        {
            Response.Write("<script>alert('添加成功!')</script>");
        }
        else
        {
            Response.Write("<script>alert('添加失败!')</script>");
        }
    }
    protected void submitEditLanMu_Click(object sender, EventArgs e)
    {
        Lanmu l = new Lanmu();

        l.lanMuName = editLanMu.Text;
        l.lanMuId   = Convert.ToInt32(Request.QueryString["id"].ToString());
        if (Lanmu.editLanMu(l) == true)
        {
            Response.Write("<script>alert('修改成功!')</script>");
        }
        else
        {
            Response.Write("<script>alert('修改失败!')</script>");
        }
    }
    protected void delLanMu_Click(object sender, EventArgs e)
    {
        LinkButton  btn = (LinkButton)sender;
        GridViewRow gvr = (GridViewRow)btn.NamingContainer;
        string      id  = gvr.Cells[0].Text;

        if (Lanmu.delLanMu(id) == true && (Convert.ToInt32(id) != 1))
        {
            Response.Write("<script>alert('删除成功!')</script>");
            showLanMuList();
        }
        else
        {
            Response.Write("<script>alert('删除失败!')</script>");
        }
    }
 public void showLanMuList()
 {
     gvLanMu.DataSource = Lanmu.getLanMuList();
     gvLanMu.DataBind();
 }
Esempio n. 6
0
    public static bool editLanMu(Lanmu l)
    {
        string sqlString = "update t_lanMu set lanMuName='" + l.lanMuName + "'  where lanMuId=" + l.lanMuId;

        return(sqlhelper.excuteBool(sqlString));
    }
Esempio n. 7
0
    public static bool addLanMu(Lanmu l)
    {
        string sqlString = "insert into t_lanMu (lanMuName) values('" + l.lanMuName + "')";

        return(sqlhelper.excuteBool(sqlString));
    }