Пример #1
0
    protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        PageBll      pageBll    = new PageBll();
        PagesEnitity pageEntity = new PagesEnitity();
        Label        label      = (Label)this.GridView1.Rows[e.RowIndex].FindControl("lbID");
        TextBox      textBox    = (TextBox)this.GridView1.Rows[e.RowIndex].FindControl("txtName1");
        TextBox      textBox2   = (TextBox)this.GridView1.Rows[e.RowIndex].FindControl("txtUrl");
        TextBox      textBox3   = (TextBox)this.GridView1.Rows[e.RowIndex].FindControl("txtSort");

        if (label != null && textBox != null && textBox2 != null && textBox3 != null)
        {
            pageEntity.PageName = textBox.Text;
            pageEntity.PageSort = int.Parse(textBox3.Text);
            pageEntity.PageURL  = textBox2.Text;
            pageEntity.Id       = int.Parse(label.Text);
            if (pageBll.Update(pageEntity))
            {
                this.Page.ClientScript.RegisterStartupScript(base.GetType(), "msg", "alert('更新成功');", true);
            }
            else
            {
                this.Page.ClientScript.RegisterStartupScript(base.GetType(), "msg", "alert('更新失败');", true);
            }
        }
        this.GridView1.EditIndex = -1;
        this.bind();
    }
Пример #2
0
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        PageBll      pageBll    = new PageBll();
        PagesEnitity pageEntity = new PagesEnitity();
        Label        label      = (Label)this.GridView1.Rows[e.RowIndex].Cells[1].FindControl("lbID");

        if (label != null)
        {
            pageEntity.Id = int.Parse(label.Text);
            int childCount = pageBll.GetChildCount(pageEntity);
            if (childCount > 0)
            {
                this.Page.ClientScript.RegisterStartupScript(base.GetType(), "msg", "alert('有子项不允许删除!');", true);
            }
            else
            {
                if (pageBll.Delete(pageEntity))
                {
                    this.Page.ClientScript.RegisterStartupScript(base.GetType(), "msg", "alert('删除成功');", true);
                }
                else
                {
                    this.Page.ClientScript.RegisterStartupScript(base.GetType(), "msg", "alert('删除失败');", true);
                }
            }
            this.bind();
        }
    }
Пример #3
0
 protected void ImagesButton1_Click(object sender, EventArgs e)
 {
     if (this.Session["ManageLand"].ToString() == this.txtCode.Text)
     {
         PageBll      pageBll    = new PageBll();
         PagesEnitity pageEntity = new PagesEnitity();
         new DataBase();
         int    num      = 0;
         int    pID      = 0;
         string pageName = base.Server.HtmlEncode(this.txtName.Text);
         string pageUrl  = base.Server.HtmlEncode(this.txtDes.Text);
         if (base.Request.QueryString["id"] != null)
         {
             num           = int.Parse(base.Request.QueryString["id"].ToString());
             pageEntity.Id = num;
             DataTable byID = pageBll.GetByID(pageEntity);
             if (byID != null && byID.Rows.Count == 1)
             {
                 pID = int.Parse(byID.Rows[0]["PageSort"].ToString());
             }
         }
         pageEntity.ParentID = num;
         pageEntity.PageSort = pageBll.GetMaxSort(pageEntity);
         pageEntity.PID      = pID;
         pageEntity.PageName = pageName;
         pageEntity.PageURL  = pageUrl;
         pageBll.Add(pageEntity);
         this.txtDes.Text  = "";
         this.txtName.Text = "";
         this.bind();
         return;
     }
     this.Page.ClientScript.RegisterStartupScript(base.GetType(), "alert", "<script>alert('验证码错误')</script>");
 }
Пример #4
0
    private void bind()
    {
        PageBll      pageBll    = new PageBll();
        PagesEnitity pageEntity = new PagesEnitity();

        pageEntity.ParentID       = 0;
        this.GridView1.DataSource = pageBll.GetByParent(pageEntity);
        this.GridView1.DataBind();
    }
Пример #5
0
        public DataTable GetByUrl(PagesEnitity en)
        {
            DataBase db     = new DataBase();
            string   comstr = "select p.pageDes    from pages p  where p.PageUrl=@PageUrl";

            SqlParameter[] param = new SqlParameter[]
            {
                new SqlParameter("@PageUrl", SqlDbType.VarChar, 200)
            };
            param[0].Value = en.PageURL;
            return(db.GetDataTable(comstr, param));
        }
Пример #6
0
        public bool Delete(PagesEnitity en)
        {
            DataBase db     = new DataBase();
            string   comstr = "delete Pages where id=@ID";

            SqlParameter[] param = new SqlParameter[]
            {
                new SqlParameter("@ID", SqlDbType.Int, 4)
            };
            param[0].Value = en.Id;
            return(db.ExecuteSql(comstr, param) > 0);
        }
Пример #7
0
        public bool Update_Des(PagesEnitity en)
        {
            DataBase db = new DataBase();

            SqlParameter[] param = new SqlParameter[2];
            param[0]       = new SqlParameter("@PageDes", SqlDbType.VarChar, 200);
            param[0].Value = en.PageDes;
            param[0]       = new SqlParameter("@ID", SqlDbType.Int, 4);
            param[0].Value = en.Id;
            string comstr = "update Pages set PageDes=@PageDes where id=@ID";

            return(db.ExecuteSql(comstr, param) > 0);
        }
Пример #8
0
        public bool Update_Sort(PagesEnitity en)
        {
            DataBase db = new DataBase();

            SqlParameter[] param = new SqlParameter[2];
            param[0]       = new SqlParameter("@PageSort", SqlDbType.Int, 4);
            param[0].Value = en.PageSort;
            param[1]       = new SqlParameter("@ID", SqlDbType.Int, 4);
            param[1].Value = en.Id;
            string comstr = "Update Pages set PageSort=@PageSort where id=@ID  ";

            comstr += "update pages set pid=@pageSort where parentid=@ID  ";
            return(db.ExecuteSql(comstr, param) > 0);
        }
Пример #9
0
    private void bind()
    {
        int parentID = 0;

        if (base.Request.QueryString["id"] != null)
        {
            parentID = int.Parse(base.Request.QueryString["id"].ToString());
            this.GridView1.Columns[2].Visible = false;
            this.GridView1.Columns[3].Visible = true;
        }
        PageBll      pageBll    = new PageBll();
        PagesEnitity pageEntity = new PagesEnitity();

        pageEntity.ParentID       = parentID;
        this.GridView1.DataSource = pageBll.GetByParent(pageEntity);
        this.GridView1.DataBind();
    }
Пример #10
0
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            PageBll      pageBll      = new PageBll();
            PagesEnitity pageEntity   = new PagesEnitity();
            CheckBoxList checkBoxList = (CheckBoxList)e.Row.FindControl("ckChild");
            CheckBox     checkBox     = (CheckBox)e.Row.FindControl("ckParent");
            LinkButton   linkButton   = (LinkButton)e.Row.FindControl("lkPages");

            if (checkBoxList != null && linkButton != null && checkBox != null)
            {
                int parentID = int.Parse(linkButton.CommandArgument.ToString());
                pageEntity.ParentID         = parentID;
                checkBoxList.DataSource     = pageBll.GetByParent(pageEntity);
                checkBoxList.DataTextField  = "pagename";
                checkBoxList.DataValueField = "ID";
                checkBoxList.DataBind();
                ManagerPagePowerBll managerPagePowerBll = new ManagerPagePowerBll();
                DataTable           allByManager        = managerPagePowerBll.GetAllByManager(new ManagerPagePowerEnitity {
                    ManagerID = this.GetManagerID()
                });
                if (allByManager != null)
                {
                    for (int i = 0; i < allByManager.Rows.Count; i++)
                    {
                        if (allByManager.Rows[i]["ID"].ToString() == parentID.ToString())
                        {
                            checkBox.Checked = true;
                        }
                        for (int j = 0; j < checkBoxList.Items.Count; j++)
                        {
                            if (allByManager.Rows[i]["ID"].ToString() == checkBoxList.Items[j].Value.ToString())
                            {
                                checkBoxList.Enabled           = true;
                                checkBoxList.Items[j].Selected = true;
                            }
                        }
                    }
                }
            }
        }
    }
Пример #11
0
        public int GetChildCount(PagesEnitity en)
        {
            DataBase db     = new DataBase();
            string   comstr = "select count(*) from pages where parentid=@ID";

            SqlParameter[] param = new SqlParameter[] {
                new SqlParameter("@ID", SqlDbType.Int, 4)
            };
            param[0].Value = en.Id;
            string str = db.ExecuteValue(comstr, param);
            int    result;

            if (str.Length > 0)
            {
                result = int.Parse(str);
            }
            else
            {
                result = 0;
            }
            return(result);
        }
Пример #12
0
 public DataTable GetByParent(PagesEnitity en)
 {
     return(this.dal.GetByParent(en));
 }
Пример #13
0
 public DataTable GetByID(PagesEnitity en)
 {
     return(this.dal.GetByID(en));
 }
Пример #14
0
 public int GetMaxSort(PagesEnitity en)
 {
     return(this.dal.GetMaxSort(en));
 }
Пример #15
0
 public bool Add(PagesEnitity en)
 {
     return(this.dal.Add(en));
 }
Пример #16
0
 public int GetChildCount(PagesEnitity en)
 {
     return(this.dal.GetChildCount(en));
 }
Пример #17
0
 public bool Delete(PagesEnitity en)
 {
     return(this.dal.Delete(en));
 }
Пример #18
0
 public bool Update_Des(PagesEnitity en)
 {
     return(this.dal.Update_Des(en));
 }