• 分类管理代码


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head id="Head1" runat="server">
    <title>分类管理</title>
    <link href="../images/style/style.css"  type="text/css" rel="stylesheet">
    <script type="text/javascript" charset="gb2312" src="../images/js/common.js"></script>
    <script  type="text/javascript" charset="GB2312" src="/Office/style/1/js/Ajax.js"></script>
    <script type="text/javascript">
    function openWindow(url,width,height)
    {
    window.open(url,"_blank","height="+height+",width="+width+",top="+((screen.availHeight-height)/2)+",left="+((screen.availWidth-width)/2)+",toolbar=no,menubar=yes,scrollbars=yes, resizable=yes,location=no, status=no");
    }
    </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <table bgcolor="#c4d8ed" border="0" cellpadding="0" cellspacing="0" width="100%">
                <tbody>
                    <tr>
                        <td>
                        </td>
                        <td>
                            <table align="center" border="1" cellpadding="4" cellspacing="1" class="toptable grid fixed">
                                <tbody>
                                    <tr>
                                        <td class="category" style="height: 17px; 190px;">
                                        </td>
                                        <td align="center" class="category" style="height: 17px">
                                            分类名:<asp:TextBox ID="TbKeyword" runat="server"></asp:TextBox>
                                            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                                            <asp:Button ID="BtSearch" runat="server" OnClick="BtSearch_Click" Text="搜索" />
                                            &nbsp;&nbsp;
                                            <input id="BtAdd" type="button" value="添加一级分类" onclick="openWindow('TypeEdit.aspx?parentid=0&depth=0&action=add',800,300)"/></td>
                                    </tr>
                                </tbody>
                            </table>
                          
                            <table align="center" border="1" cellpadding="4" cellspacing="1" class="toptable grid fixed"
                                style="color: #0000ff">
                                <tbody>
                                    <tr>
                                        <td align="center" colspan="6" style="height: 144px">
                                            <asp:GridView ID="gvList" runat="server" AutoGenerateColumns="False"                 BorderColor="#337FB2" BorderWidth="2px" CellPadding="4" Font-Size="Small" ForeColor="#333333"                                  Height="32%" OnRowDataBound="gvList_RowDataBound" Width="100%">
                                                <FooterStyle BackColor="#A6A1E0" Font-Bold="True" ForeColor="White" />
                                                <Columns>
                                                    <asp:BoundField HeaderText="选择">
                                                        <ItemStyle Width="5%" />
                                                    </asp:BoundField>
                                                    <asp:BoundField DataField="Column_ID" HeaderText="编号">
                                                        <ItemStyle Width="10%" />
                                                    </asp:BoundField>
                                                    <asp:BoundField DataField="Column_Name" HeaderText="分类名称" />
                                                    <asp:BoundField DataField="Column_Order" HeaderText="顺序编号">
                                                        <ItemStyle Width="15%" />
                                                    </asp:BoundField>
                                                    <asp:BoundField HeaderText="子类数目" DataField="childsnNum" />
                                                    <asp:BoundField HeaderText="上移" />
                                                    <asp:BoundField HeaderText="下移" />
                                                    <asp:BoundField HeaderText="操作" />
                                                    <asp:BoundField HeaderText="查看子类" />
                                                </Columns>
                                                <RowStyle BackColor="White" Font-Bold="True" Font-Size="Small" ForeColor="#003399"
                                                    HorizontalAlign="Center" />
                                                <EditRowStyle BackColor="#999999" />
                                                <SelectedRowStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
                                                <PagerStyle BackColor="#337FB2" ForeColor="White" HorizontalAlign="Center" VerticalAlign="Middle" />
                                                <HeaderStyle BackColor="#337FB2" Font-Size="12px" ForeColor="White" HorizontalAlign="Center"
                                                    VerticalAlign="Middle" />
                                                <AlternatingRowStyle BackColor="#E8F4FF" Font-Bold="True" Font-Size="Small" HorizontalAlign="Center" />
                                            </asp:GridView>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td align="center" style="height: 29px">
                                            <input id="checkallpri" class="nogrid" name="checkallpri" onclick="checkAll('action','checkallpri')"
                                                style="border-right: medium none; border-top: medium none; border-left: medium none;
                                                border-bottom: medium none" type="checkbox" /></td>
                                        <td colspan="5" style="height: 29px">
                                            &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<asp:Button ID="BtVerfly" runat="server" OnClick="BtVerfly_Click"
                                                Text="审核" />
                                            &nbsp; &nbsp;
                                            <asp:Button ID="BtDel" runat="server" OnClick="BtDel_Click" Text="删除" />
                                            &nbsp;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<input id="Button1" type="button" value="返回" onclick="history.go(-2)"/><span class="t2"></span></td>
                                    </tr>
                                    <tr>
                                        <td colspan="6">
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="6">
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                          
                        </td>
                        <td>
                        </td>
                    </tr>
                </tbody>
            </table>
        <br />  <br />
        </div>
        </form>
    </body>
    </html>

    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.Data.SqlClient;

    namespace domain.UI.images.News
    {
        public partial class TypeList : domain.BLL.AdminPage
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                if (!Page.IsPostBack)
                {
                    AjaxFunction();
                    //Power(this.U_Account, this.MIDS[Convert.ToInt32(domain.BLL.ModelList.系统设置)]);
                    BindSortList();
                    if (this.GetRequest("columnid").Length > 0 && this.GetRequest("mark").Length < 1)
                    {
                        Move(Convert.ToInt32(this.GetRequest("direction")), this.GetRequest("columnid"), this.GetRequest("columnorder"));
                    }
                    ViewState["depth"] = this.GetRequest("depth").Length < 1 ? ("0") : (this.GetRequest("depth"));

                }
            }
            public override domain.BLL.RightClass Power(string U_Account, string M_ID)
            {
                domain.BLL.RightClass rc = base.Power(U_Account, M_ID);
                this.BtDel.Visible = rc.right_Delete;
                this.BtVerfly.Visible = rc.right_Verify;

                return rc;

            }
            public void AjaxFunction()
            {
                string IsAjax = GetRequest("IsAjax");
                if (IsAjax.Length > 0)
                {
                    string temp = "";
                    string State = GetRequest("State").ToLower();
                    State = State == "true" || State.Length < 1 ? ("0") : ("1");
                    string Gid = GetRequest("Gid");
                    string sql = "update newssort set bs_showindex=@bs_showindex where Column_ID=@Column_ID";
                    if (this.Db.GetState(sql, new SqlParameter[] { new SqlParameter("@bs_showindex", State), new SqlParameter("@Column_ID", Gid) }))
                    {
                        temp = "1";
                    }
                    else
                    {
                        temp = "0";
                    }
                    Response.Clear();
                    Response.Write(temp);
                    Response.End();
                }
            }
            /// <summary>
            /// 移动操作
            /// </summary>
            /// <param name="direction"></param>
            /// <param name="columnid"></param>
            public void Move(int direction, string columnid, string columnorder)
            {

                string sql = "";
                string message = "";
                switch (direction)
                {
                    case -1:
                        sql = string.Format("select top 2 Column_Name,Column_ID,Column_Order,(select count(*) from newssort a where a.parent_id=t.column_id) childsnNum from newssort t where Parent_ID='{0}'  and Column_Order<={1} order by Column_Order desc", columnid, columnorder);
                        message = "已经是该栏目的顶分类不能移动";
                        break;
                    case 1:
                        sql = string.Format("select top 2 Column_Name,Column_ID,Column_Order,(select count(*) from newssort a where a.parent_id=t.column_id) childsnNum from newssort t where Parent_ID='{0}'  and Column_Order>={1} order by Column_Order asc", columnid, columnorder);
                        message = "已经是该栏目的底分类不能移动";
                        break;
                    default:

                        break;

                }
                DataTable dt = this.Db.GetTable(sql);
                if (dt != null)
                {
                    if (dt.Rows.Count < 2)
                    {
                        this.ShowMessage(message, "history.go(-1)");
                    }
                    else
                    {

                        string selfid = Convert.ToString(dt.Rows[0]["Column_ID"] ?? "");
                        string selforder = Convert.ToString(dt.Rows[0]["Column_Order"] ?? "");
                        string otherid = Convert.ToString(dt.Rows[1]["Column_ID"] ?? "");
                        string otherorder = Convert.ToString(dt.Rows[1]["Column_Order"] ?? "");
                        ArrayList al = new ArrayList();
                        al.Add(string.Format("update [newssort] set [Column_Order]={0} where Column_ID='{1}'", otherorder, selfid));
                        al.Add(string.Format("update [newssort] set [Column_Order]={0} where Column_ID='{1}'", selforder, otherid));
                        if (this.Db.GetTranState(al))
                        {

                            Response.Redirect(Request.UrlReferrer.ToString().Length < 1 ? (Request.Url.ToString().IndexOf("?") >= 0 ? (Request.Url.ToString().IndexOf("mark=") >= 0 ? (System.Text.RegularExpressions.Regex.Replace(Request.Url.ToString(), "mark=[^&]*", "mark=0")) : (Request.Url.ToString() + "&mark=0")) : (Request.Url.ToString() + "?mark=0")) : (Request.UrlReferrer.ToString().IndexOf("?") >= 0 ? (Request.UrlReferrer.ToString().IndexOf("mark=") >= 0 ? (System.Text.RegularExpressions.Regex.Replace(Request.UrlReferrer.ToString(), "mark=[^&]*", "mark=0")) : (Request.UrlReferrer.ToString() + "&mark=0")) : (Request.UrlReferrer.ToString() + "?mark=0")));

                        }
                        else
                        {
                            this.ShowError("网络连接错误请联系系统管理员!!");
                        }

                    }
                }


            }
            /// <summary>
            /// /分类绑定
            /// </summary>
            public void BindSortList()
            {
                string parent_id = this.GetRequest("parentid");
                parent_id = parent_id.Length < 1 ? ("0") : (parent_id);
                string keys = Convert.ToString(ViewState["keys"]);
                string sql = string.Format("select Column_Name,Column_ID,Column_Order,Column_depth,parent_id,(select count(*) from newssort a where a.parent_id=t.column_id) childsnNum,bs_showindex from newssort t where Parent_ID='{0}'{1} order by Column_Order", parent_id, keys);
                this.gvList.DataSource = this.Db.GetTable(sql);
                this.gvList.DataBind();
            }
            /// <summary>
            /// 递归生成列表
            /// </summary>
            /// <param name="parentid"></param>
            public void BindSort(string parentid, string parentname)
            {
                DataTable dt = this.Db.GetTable(string.Format("select Column_Name,Column_ID from [newssort] where Parent_ID='{0}'", parentid));
                if (dt != null)
                {

                }
                else
                {

                }
            }

            protected void BtSearch_Click(object sender, EventArgs e)
            {
                string keys = this.TbKeyword.Text.Trim();
                keys = keys.Length < 1 ? ("") : (" and Column_name like '%" + keys + "%'");
                ViewState["keys"] = keys;
                this.BindSortList();
            }

            protected void BtVerfly_Click(object sender, EventArgs e)
            {

            }

            protected void BtDel_Click(object sender, EventArgs e)
            {
                //删除没有子类的栏目
                ArrayList al = this.GetSqls("delete from newssort  where Column_id='{0}' and not exists(select * from newssort where parent_id='{0}')");
                if (this.Db.GetTranState(al))
                {
                    this.ShowMessage("删除成功!!", "document.location=document.location.href");
                }
                else
                {
                    this.ShowError("没有要删除的数据或数据不存在!!请联系系统管理员!!");
                }


            }

            protected void gvList_RowDataBound(object sender, GridViewRowEventArgs e)
            {
                if (e.Row.RowIndex != -1)
                {
                    DataRowView drv = e.Row.DataItem as DataRowView;
                    string column_id = Convert.ToString(drv["Column_ID"] ?? "");
                    string parent_id = Convert.ToString(drv["parent_id"] ?? "");
                    string column_order = Convert.ToString(drv["Column_Order"] ?? "");
                    string column_depth = Convert.ToString(drv["Column_depth"] ?? "");
                    string State = Convert.ToString(drv["bs_showindex"] ?? "").ToLower();
                    e.Row.Cells[0].Text = string.Format(this.CheckBoxString, column_id);
                    e.Row.Cells[5].Text = string.Format("<a href='" + Request.Path.ToString() + "?direction={0}&columnid={1}&columnorder={2}'>上移</a>", "-1", parent_id, column_order);
                    e.Row.Cells[6].Text = string.Format("<a href='" + Request.Path.ToString() + "?direction={0}&columnid={1}&columnorder={2}'>下移</a>", "1", parent_id, column_order);
                    // e.Row.Cells[7].Text = string.Format("<a href='EditSort.aspx?parentid={0}&depth={1}&action=add' target='_blank'>添加子类</a>&nbsp;<a href='EditSort.aspx?id={0}&action=update' target='_blank'>编辑该类</a>", Convert.ToString(drv["Column_ID"] ?? ""), column_depth);
                    e.Row.Cells[7].Text = string.Format("<a href='#' onclick=\"openWindow('TypeEdit.aspx?parentid={0}&depth={1}&action=add',800,300);return false;\">添加子类</a>&nbsp;<a href='#'  onclick=\"openWindow('EditSort.aspx?id={0}&action=upd',800,300);return false;\">编辑该类</a>", Convert.ToString(drv["Column_ID"] ?? ""), column_depth);
                    e.Row.Cells[8].Text = string.Format("<a href='"+Request.Path.ToString()+"?parentid={0}&depth={1}'>查看子类</a>&nbsp;{2}", Convert.ToString(drv["Column_ID"] ?? ""), column_depth, column_depth == "2" ? ("<a href='#' target='_blank' onclick='if(confirm(\"确认要操作么??\")){new Ajax().getData(document.location.href,\"IsAjax=true&Gid=" + column_id + "&State=" + State + "\",function(obj){if(obj.responseText==\"1\"){alert(\"操作成功!!\");document.location=document.location.href;}else{alert(\"网络链接异常!!请稍候重试!!\")}})}return false;'>" + (State == "true" ? ("取消推荐") : ("<font color='red'>推荐</font>")) + "</a>") : (""));
                }

            }
        }
    }

  • 相关阅读:
    Log4net简介
    LOG4NET用法
    RabbitMQ 使用参考
    消息队列 RabbitMQ 入门介绍
    RabbitMQ三种Exchange模式(fanout,direct,topic)的性能比较
    RabbitMQ学习之:(十二)在Node.js环境下使用RabbitMQ
    RabbitMQ学习之:(十一)AMQP.0-10规范,中文翻译1,2,3章 (转载)
    谷歌如何测试软件 —— 第三部分
    【转】在淘宝一年测试工作的感悟
    青春年少,风华正茂
  • 原文地址:https://www.cnblogs.com/bestsaler/p/1835622.html
Copyright © 2020-2023  润新知