Beispiel #1
0
        /// <summary>
        /// 列表事件
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
        protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            String ID                 = ((CheckBox)e.Item.FindControl("ID")).Text;
            Int32  GroupID            = Convert.ToInt32(((HiddenField)e.Item.FindControl("Groupid")).Value);
            T_AccessControlEntity acl = Access.Find(a => { return(a.Node == GroupID); });

            if (ActionTypeHelper.IsDelete(acl.ActionType) || ActionTypeHelper.IsSetting(acl.ActionType))
            {
                switch (e.CommandName)
                {
                case "del":
                    DELContentImages(ID);
                    db.ExecuteCommand(String.Format("DELETE FROM [t_news] WHERE id in ({0})", ID));
                    break;

                case "focus":
                case "stick":
                case "status":
                    ExecuteObject obj = new ExecuteObject();
                    obj.cmdtype   = CmdType.UPDATE;
                    obj.tableName = "t_news";
                    obj.terms.Add("id", ID);
                    obj.cells.Add(e.CommandName, !Convert.ToBoolean(e.CommandArgument));
                    db.ExecuteCommand(obj);
                    break;
                }
                BindData();
            }
        }
 /// <summary>
 /// 新闻权限绑定
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void Repeater2_ItemDataBound(object sender, RepeaterItemEventArgs e)
 {
     if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
     {
         DataRowView           dv  = e.Item.DataItem as DataRowView;
         Int32                 id  = Convert.ToInt32(dv["id"]);
         T_AccessControlEntity acl = data.Find(a => { return(a.Node == id && a.TableName == "t_group"); });
         if (acl != null)
         {
             ((CheckBox)e.Item.FindControl("CheckBox1")).Checked = ActionTypeHelper.IsCreat(acl.ActionType);
             ((CheckBox)e.Item.FindControl("CheckBox2")).Checked = ActionTypeHelper.IsView(acl.ActionType);
             ((CheckBox)e.Item.FindControl("CheckBox3")).Checked = ActionTypeHelper.IsEdit(acl.ActionType);
             ((CheckBox)e.Item.FindControl("CheckBox4")).Checked = ActionTypeHelper.IsDelete(acl.ActionType);
             ((CheckBox)e.Item.FindControl("CheckBox5")).Checked = ActionTypeHelper.IsSetting(acl.ActionType);
         }
     }
 }
Beispiel #3
0
        /// <summary>
        /// 批量删除 批量启用
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            List <Int32> list = new List <Int32>()
            {
                0
            };
            Int32 arg = Convert.ToInt32(Request.Form["__EVENTARGUMENT"]);

            if (arg == 0 || arg == 1 || arg == -1)
            {
                foreach (RepeaterItem item in Repeater1.Items)
                {
                    CheckBox    chkbox  = item.FindControl("id") as CheckBox;
                    HiddenField groupid = item.FindControl("Groupid") as HiddenField;

                    if (chkbox.Checked)
                    {
                        T_AccessControlEntity acl = Access.Find(a => { return(a.Node == Convert.ToInt32(groupid.Value)); });
                        if (Admin.IsSuper || (ActionTypeHelper.IsSetting(acl.ActionType) || ActionTypeHelper.IsDelete(acl.ActionType)))
                        {
                            list.Add(Convert.ToInt32(chkbox.Text));
                        }
                    }
                }

                String id = String.Join(",", list.ToArray());
                switch (arg)
                {
                case 0:    //禁用
                    db.ExecuteCommand(String.Format("UPDATE [t_news] SET status = 0 WHERE id IN({0})", id));
                    break;

                case -1:    //删除
                    foreach (var _id in list)
                    {
                        DELContentImages(_id);
                    }
                    db.ExecuteCommand(String.Format("DELETE FROM [t_news] WHERE id in ({0})", id));
                    break;

                case 1:    //启用
                    db.ExecuteCommand(String.Format("UPDATE [t_news] SET status = 1 WHERE id IN({0})", id));
                    break;
                }

                BindData();
            }
        }
Beispiel #4
0
        /// <summary>
        /// 控件处理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                DataRowView dv      = e.Item.DataItem as DataRowView;
                Int32       ID      = Convert.ToInt32(dv["id"]);
                Int32       GroupID = Convert.ToInt32(dv["GroupID"]);

                CheckBox    chk    = e.Item.FindControl("id") as CheckBox;
                ImageButton del    = e.Item.FindControl("del") as ImageButton;
                ImageButton edit   = e.Item.FindControl("edit") as ImageButton;
                ImageButton status = e.Item.FindControl("status") as ImageButton;
                ImageButton focus  = e.Item.FindControl("focus") as ImageButton;
                ImageButton stick  = e.Item.FindControl("stick") as ImageButton;

                if (Convert.ToBoolean(dv["status"]))
                {
                    status.ImageUrl = "images/icos/checkbox_yes.png";
                }
                if (Convert.ToBoolean(dv["focus"]))
                {
                    focus.ImageUrl = "images/icos/checkbox_yes.png";
                }
                if (Convert.ToBoolean(dv["stick"]))
                {
                    stick.ImageUrl = "images/icos/checkbox_yes.png";
                }
                edit.OnClientClick = String.Format("javascript:location.href='News_Edit.aspx?id={0}';return false;", ID);
                del.OnClientClick  = String.Format("javascript:dialogConfirm({{el:this,text:'将删除 {0} 且无法恢复!确定要删除吗?'}});return false;", dv["title"]);

                if (!Admin.IsSuper)
                {
                    T_AccessControlEntity acl = Access.Find(a => { return(a.Node == GroupID); });
                    if (!ActionTypeHelper.IsEdit(acl.ActionType))
                    {
                        edit.Enabled  = false;
                        edit.ToolTip  = "无权限修改.";
                        edit.ImageUrl = "images/icos/write_disable.gif";
                    }

                    if (!ActionTypeHelper.IsDelete(acl.ActionType))
                    {
                        del.Enabled  = false;
                        del.ToolTip  = "无权限删除.";
                        del.ImageUrl = "images/icos/del_disabled.gif";
                    }
                    if (!ActionTypeHelper.IsSetting(acl.ActionType))
                    {
                        stick.Enabled = focus.Enabled = status.Enabled = false;
                        stick.ToolTip = focus.ToolTip = status.ToolTip = "无权限设置.";
                        if (Convert.ToBoolean(dv["status"]))
                        {
                            status.ImageUrl = "images/icos/checkbox_disabled.png";
                        }
                        if (Convert.ToBoolean(dv["focus"]))
                        {
                            focus.ImageUrl = "images/icos/checkbox_disabled.png";
                        }
                        if (Convert.ToBoolean(dv["stick"]))
                        {
                            stick.ImageUrl = "images/icos/checkbox_disabled.png";
                        }
                    }
                }
            }
        }