コード例 #1
0
 protected void btnaddTax_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrWhiteSpace(Request.QueryString["taxId"]))
     {
         Taxonomy_M tax = new Taxonomy_M();
         tax.TaxonomyId   = Convert.ToInt32(Request.QueryString["taxId"]);
         tax.TaxonomyName = txtTaxName.Text;
         tax.Taxonomydesc = txtTaxDesc.Text;
         if (Taxonomy_B.updateTax(tax))
         {
             ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('修改成功');location.href='AdminTax.aspx';</script>");
         }
         else
         {
             ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('修改失败');</script>");
         }
     }
     else
     {
         Taxonomy_M tax = new Taxonomy_M();
         tax.TaxonomyName = txtTaxName.Text;
         tax.Taxonomydesc = txtTaxDesc.Text;
         if (Taxonomy_B.addTax(tax))
         {
             ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('添加成功');</script>");
             txtTaxName.Text = "";
             txtTaxDesc.Text = "";
         }
         else
         {
             ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('添加失败');</script>");
         }
     }
 }
コード例 #2
0
        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="pageSize">每页数据行数</param>
        /// <param name="pageIndex">页码</param>
        /// <returns>返回集合</returns>
        public static List <Taxonomy_M> TaxListPager(string pageSize, string pageIndex)
        {
            List <Taxonomy_M> list = new List <Taxonomy_M>();
            string            sql  = string.Format("select top ({0}) *from Taxonomy where TaxonomyId not in(select top (({1}-1)*{0}) TaxonomyId from Taxonomy order by TaxonomyId) order by TaxonomyId", pageSize, pageIndex);
            SqlDataReader     dr   = SQLDBHelper.ExecuteReader(sql);

            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    Taxonomy_M tax = new Taxonomy_M();
                    if (dr["TaxonomyId"] != DBNull.Value)
                    {
                        tax.TaxonomyId = Convert.ToInt32(dr["TaxonomyId"]);
                    }
                    if (dr["TaxonomyName"] != DBNull.Value)
                    {
                        tax.TaxonomyName = dr["TaxonomyName"].ToString();
                    }
                    if (dr["Taxonomydesc"] != DBNull.Value)
                    {
                        tax.Taxonomydesc = dr["Taxonomydesc"].ToString();
                    }
                    list.Add(tax);
                }
            }
            dr.Close();
            return(list);
        }
コード例 #3
0
        /// <summary>
        /// 查询所有类型
        /// </summary>
        /// <returns>返回集合</returns>
        public static List <Taxonomy_M> TaxList()
        {
            List <Taxonomy_M> list = new List <Taxonomy_M>();
            string            sql  = "select * from Taxonomy";
            SqlDataReader     dr   = SQLDBHelper.ExecuteReader(sql);

            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    Taxonomy_M tax = new Taxonomy_M();
                    if (dr["TaxonomyId"] != DBNull.Value)
                    {
                        tax.TaxonomyId = Convert.ToInt32(dr["TaxonomyId"]);
                    }
                    if (dr["TaxonomyName"] != DBNull.Value)
                    {
                        tax.TaxonomyName = dr["TaxonomyName"].ToString();
                    }
                    if (dr["Taxonomydesc"] != DBNull.Value)
                    {
                        tax.Taxonomydesc = dr["Taxonomydesc"].ToString();
                    }
                    list.Add(tax);
                }
            }
            dr.Close();
            return(list);
        }
コード例 #4
0
ファイル: TaxPost.aspx.cs プロジェクト: WANGLANGWUXING/BLOG
        protected void rptPostList_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            HiddenField categoryID   = e.Item.FindControl("CategoryID") as HiddenField;
            LinkButton  CategoryName = e.Item.FindControl("CategoryName") as LinkButton;

            if (!string.IsNullOrWhiteSpace(categoryID.Value))
            {
                Taxonomy_M tax = Taxonomy_B.getTaxonomyByID(categoryID.Value);
                CategoryName.Text = tax.TaxonomyName;
            }
        }
コード例 #5
0
ファイル: TaxPost.aspx.cs プロジェクト: WANGLANGWUXING/BLOG
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!string.IsNullOrWhiteSpace(Request.QueryString["TaxID"]))
     {
         string     TaxID = Request.QueryString["TaxID"];
         Taxonomy_M tax   = Taxonomy_B.getTaxonomyByID(TaxID);
         txtTax.Text            = tax.TaxonomyName;
         rptPostList.DataSource = Posts_B.PostListByTaxID(TaxID);
         rptPostList.DataBind();
     }
 }
コード例 #6
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (!string.IsNullOrWhiteSpace(Request.QueryString["taxId"]))
         {
             Taxonomy_M tax = Taxonomy_B.getTaxonomyByID(Request.QueryString["taxId"]);
             txtTaxName.Text = tax.TaxonomyName;
             txtTaxDesc.Text = tax.Taxonomydesc;
             btnaddTax.Text  = "编辑分类";
         }
     }
 }
コード例 #7
0
        /// <summary>
        /// 增
        /// </summary>
        /// <param name="tax"></param>
        /// <returns></returns>
        public static bool addTax(Taxonomy_M tax)
        {
            SqlParameter paramTaxName = new SqlParameter();

            paramTaxName.ParameterName = "@TaxonomyName";
            paramTaxName.DbType        = DbType.String;
            paramTaxName.Value         = tax.TaxonomyName;
            SqlParameter paramTaxdesc = new SqlParameter();

            paramTaxdesc.ParameterName = "@Taxonomydesc";
            paramTaxdesc.DbType        = DbType.String;
            paramTaxdesc.Value         = tax.Taxonomydesc;
            return(SQLDBHelper.ExecuteNonQuery("proc_Insert_Tax", paramTaxName, paramTaxdesc));
        }
コード例 #8
0
ファイル: AdminPost.aspx.cs プロジェクト: WANGLANGWUXING/BLOG
        protected void postList_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            HiddenField cateID   = e.Item.FindControl("cateID") as HiddenField;
            Label       cateName = e.Item.FindControl("cateName") as Label;

            if (!string.IsNullOrWhiteSpace(cateID.Value))
            {
                Taxonomy_M cate = Taxonomy_B.getTaxonomyByID(cateID.Value);
                cateName.Text = cate.TaxonomyName;
            }
            HiddenField postID       = e.Item.FindControl("postID") as HiddenField;
            Label       commentCount = e.Item.FindControl("commentCount") as Label;

            if (!string.IsNullOrWhiteSpace(postID.Value))
            {
                int count = Comments_B.commentCountByPostID(postID.Value);
                commentCount.Text = count.ToString() + "条评论";
            }
        }
コード例 #9
0
        /// <summary>
        /// 改
        /// </summary>
        /// <param name="tax"></param>
        /// <returns></returns>
        public static bool updateTax(Taxonomy_M tax)
        {
            SqlParameter paramTaxName = new SqlParameter();

            paramTaxName.ParameterName = "@TaxonomyName";
            paramTaxName.DbType        = DbType.String;
            paramTaxName.Value         = tax.TaxonomyName;
            SqlParameter paramTaxdesc = new SqlParameter();

            paramTaxdesc.ParameterName = "@Taxonomydesc";
            paramTaxdesc.DbType        = DbType.String;
            paramTaxdesc.Value         = tax.Taxonomydesc;
            SqlParameter paramTaxId = new SqlParameter();

            paramTaxId.ParameterName = "@TaxonomyId";
            paramTaxId.DbType        = DbType.String;
            paramTaxId.Value         = tax.TaxonomyId;
            return(SQLDBHelper.ExecuteNonQuery("proc_Update_Tax", paramTaxName, paramTaxdesc, paramTaxId));
        }
コード例 #10
0
        /// <summary>
        /// 根据类型ID获取类型
        /// </summary>
        /// <param name="id">类型id</param>
        /// <returns>返回类型对象</returns>
        public static Taxonomy_M getTaxonomyByID(string id)
        {
            Taxonomy_M    tax = new Taxonomy_M();
            string        sql = "select * from Taxonomy where TaxonomyId=" + id;
            SqlDataReader dr  = SQLDBHelper.ExecuteReader(sql);

            if (dr.HasRows)
            {
                dr.Read();
                if (dr["TaxonomyId"] != DBNull.Value)
                {
                    tax.TaxonomyId = Convert.ToInt32(dr["TaxonomyId"]);
                }
                if (dr["TaxonomyName"] != DBNull.Value)
                {
                    tax.TaxonomyName = dr["TaxonomyName"].ToString();
                }
                if (dr["Taxonomydesc"] != DBNull.Value)
                {
                    tax.Taxonomydesc = dr["Taxonomydesc"].ToString();
                }
            }
            return(tax);
        }
コード例 #11
0
ファイル: Taxonomy_B.cs プロジェクト: WANGLANGWUXING/BLOG
 /// <summary>
 /// 改
 /// </summary>
 /// <param name="tax"></param>
 /// <returns></returns>
 public static bool updateTax(Taxonomy_M tax)
 {
     return(Taxonomy_D.updateTax(tax));
 }
コード例 #12
0
ファイル: Taxonomy_B.cs プロジェクト: WANGLANGWUXING/BLOG
 /// <summary>
 /// 增
 /// </summary>
 /// <param name="tax"></param>
 /// <returns></returns>
 public static bool addTax(Taxonomy_M tax)
 {
     return(Taxonomy_D.addTax(tax));
 }