public List<PageLink> PageLink_GetByLevel(string Level, int LevelLength)
 {
     List<Data.PageLink> list = new List<Data.PageLink>();
     using (SqlCommand dbCmd = new SqlCommand("sp_PageLink_GetByLevel", GetConnection()))
     {
         Data.PageLink obj = new Data.PageLink();
         dbCmd.CommandType = CommandType.StoredProcedure;
         dbCmd.Parameters.Add(new SqlParameter("@Level", Level));
         dbCmd.Parameters.Add(new SqlParameter("@LevelLength", LevelLength));
         SqlDataReader dr = dbCmd.ExecuteReader();
         if (dr.HasRows)
         {
             while (dr.Read())
             {
                 list.Add(obj.PageLinkIDataReader(dr));
             }
             dr.Close();
             //conn.Close();
         }
         else
         {
             dr.Close();
         }
     }
     return list;
 }
 public List<PageLink> PageLink_GetByAll()
 {
     List<Data.PageLink> list = new List<Data.PageLink>();
     using (SqlCommand dbCmd = new SqlCommand("sp_PageLink_GetByAll", GetConnection()))
     {
         Data.PageLink obj = new Data.PageLink();
         dbCmd.CommandType = CommandType.StoredProcedure;
         SqlDataReader dr = dbCmd.ExecuteReader();
         if (dr.HasRows)
         {
             while (dr.Read())
             {
                 list.Add(obj.PageLinkIDataReader(dr));
             }
             dr.Close();
             //conn.Close();
         }
         else
         {
             dr.Close();
         }
     }
     return list;
 }
 protected void Update_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         string Link = "";
         string Id = txtId.Value;
         Data.PageLink obj = new Data.PageLink();
         obj.Id = Id;
         obj.Name = txtName.Text;
         obj.Tag = Common.StringClass.NameToTag(txtName.Text);
         obj.Content = fckContent.Value;
         obj.Detail = fckDetail.Value;
         obj.Level = Level + "00000";
         obj.Title = txtTitle.Text;
         obj.Description = txtDescription.Text;
         obj.Keyword = txtKeyword.Text;
         obj.Type = ddlType.SelectedValue;
         obj.Link = txtLink.Text;
         obj.Target = ddlTarget.SelectedValue;
         obj.Position = ddlPosition.SelectedValue;
         obj.Ord = txtOrd.Text != "" ? txtOrd.Text : "1";
         obj.Index = chkIndex.Checked ? "1" : "0";
         obj.Active = chkActive.Checked ? "1" : "0";
         if (Insert == true)
         {
             PageLinkService.PageLink_Insert(obj);
             Id = sql.MaxId("PageLink", "Id");
         }
         else
         {
             PageLinkService.PageLink_Update(obj);
         }
         if (ddlType.SelectedValue == "2")
         {
            List< Data.PageLink> lstPageLink = PageLinkService.PageLink_GetById(Id);
             if( lstPageLink !=null && lstPageLink.Count>0)
             {
                 Link = "/page/" + Id + "/" + lstPageLink[0].Tag + ".html";
                 sql.ExecuteNonQuery("Update PageLink set Link='" + Link + "'  Where Id='" + Id + "'");
             }
         }
         BindGrid();
         pnView.Visible = true;
         pnUpdate.Visible = false;
         Level = "";
         Insert = false;
     }
 }
        public PageLink PageLinkIDataReader(IDataReader dr)
        {
            Data.PageLink obj = new Data.PageLink();
			obj.Id = (dr["Id"] is DBNull) ? string.Empty : dr["Id"].ToString();
 public List<PageLink> PageLink_Paging(string CurentPage, string PageSize)
 {
     List<Data.PageLink> list = new List<Data.PageLink>();
     using (SqlCommand dbCmd = new SqlCommand("sp_PageLink_Paging", GetConnection()))
     {
         Data.PageLink obj = new Data.PageLink();
         dbCmd.CommandType = CommandType.StoredProcedure;
         dbCmd.Parameters.Add(new SqlParameter("@CurentPage", CurentPage));
         dbCmd.Parameters.Add(new SqlParameter("@PageSize", PageSize));
         SqlDataReader dr = dbCmd.ExecuteReader();
         if (dr.HasRows)
         {
             while (dr.Read())
             {
                 list.Add(obj.PageLinkIDataReader(dr));
             }
             dr.Close();
             //conn.Close();
         }
         else
         {
             dr.Close();
         }
     }
     return list;
 }
 public List<PageLink> PageLink_GetByTop(string Top, string Where, string Order)
 {
     List<Data.PageLink> list = new List<Data.PageLink>();
     using (SqlCommand dbCmd = new SqlCommand("sp_PageLink_GetByTop", GetConnection()))
     {
         Data.PageLink obj = new Data.PageLink();
         dbCmd.CommandType = CommandType.StoredProcedure;
         dbCmd.Parameters.Add(new SqlParameter("@Top", Top));
         dbCmd.Parameters.Add(new SqlParameter("@Where", Where));
         dbCmd.Parameters.Add(new SqlParameter("@Order", Order));
         SqlDataReader dr = dbCmd.ExecuteReader();
         if (dr.HasRows)
         {
             while (dr.Read())
             {
                 list.Add(obj.PageLinkIDataReader(dr));
             }
             dr.Close();
             //conn.Close();
         }
         else
         {
             dr.Close();
         }
     }
     return list;
 }