<!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; width: 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="添加一級(jí)分類" 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="編號(hào)">
                                                              <ItemStyle Width="10%" />
                                                          </asp:BoundField>
                                                          <asp:BoundField DataField="Column_Name" HeaderText="分類名稱" />
                                                          <asp:BoundField DataField="Column_Order" HeaderText="順序編號(hào)">
                                                              <ItemStyle Width="15%" />
                                                          </asp:BoundField>
                                                          <asp:BoundField HeaderText="子類數(shù)目" 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.系統(tǒng)設(shè)置)]);
                          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>
                  /// 移動(dòng)操作
                  /// </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 = "已經(jīng)是該欄目的頂分類不能移動(dòng)";
                              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 = "已經(jīng)是該欄目的底分類不能移動(dòng)";
                              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("網(wǎng)絡(luò)連接錯(cuò)誤請(qǐng)聯(lián)系系統(tǒng)管理員!!");
                              }

                          }
                      }


                  }
                  /// <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("沒有要?jiǎng)h除的數(shù)據(jù)或數(shù)據(jù)不存在!!請(qǐng)聯(lián)系系統(tǒng)管理員!!");
                      }


                  }

                  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(\"確認(rèn)要操作么??\")){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(\"網(wǎng)絡(luò)鏈接異常!!請(qǐng)稍候重試!!\")}})}return false;'>" + (State == "true" ? ("取消推薦") : ("<font color='red'>推薦</font>")) + "</a>") : (""));
                      }

           

                  }
              }
          }

          posted on 2009-06-03 15:10 sanmao 閱讀(171) 評(píng)論(0)  編輯  收藏

          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           

          常用鏈接

          留言簿(5)

          隨筆分類

          隨筆檔案

          搜索

          •  

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          主站蜘蛛池模板: 三台县| 建德市| 集贤县| 洪湖市| 石棉县| 宁明县| 和平县| 开鲁县| 广饶县| 陈巴尔虎旗| 吉木乃县| 大竹县| 来安县| 新龙县| 黔南| 南丹县| 永平县| 江城| 民丰县| 和静县| 中阳县| 汾阳市| 麦盖提县| 永登县| 隆安县| 格尔木市| 朝阳市| 大厂| 乐山市| 清河县| 灌云县| 拜城县| 沂南县| 土默特左旗| 开阳县| 大化| 临澧县| 香港| 丹棱县| 泾川县| 渑池县|