Example #1
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;
 }
Example #2
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;
 }
        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>");

                }
            }
        }
Example #4
0
 /// <summary>
 /// 改
 /// </summary>
 /// <param name="tax"></param>
 /// <returns></returns>
 public static bool updateTax(Taxonomy_M tax)
 {
     return Taxonomy_D.updateTax(tax);
 }
Example #5
0
 /// <summary>
 /// 增
 /// </summary>
 /// <param name="tax"></param>
 /// <returns></returns>
 public static bool addTax(Taxonomy_M tax)
 {
     return Taxonomy_D.addTax(tax);
 }
Example #6
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;
 }
Example #7
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);
 }
Example #8
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);

        }