public ArticleTag GetArticleTagByArticleTagID(int articleTagID)
        {
            ArticleTag tag = new ArticleTag();

            string commText = "SELECT * FROM ArticleTag where ArticleTagID="+articleTagID ;
            using (SqlConnection conn = new SqlConnection(DataHelper2.SqlConnectionString))
            {
                {
                    using (SqlCommand comm = new SqlCommand())
                    {
                        comm.Connection = conn;
                        comm.CommandText = commText;
                        conn.Open();

                        using (SqlDataReader reader = comm.ExecuteReader())
                        {
                            if (reader.Read())
                            {

                                tag.TagID = int.Parse(reader["TagID"].ToString());
                                tag.TagName = reader["TagName"].ToString();
                                tag.ArticleIDs = reader["ArticleIDs"].ToString();

                            }
                        }
                    }
                }
            }
            return tag;
        }
        public List<ArticleTag> GetArticleTags(int count)
        {
            List<ArticleTag> list = new List<ArticleTag>();
            string commText = string.Empty;
            switch (count)
            {
                case 0:
                    commText = "SELECT articletagID,ArticleTagName, ArticleIDs FROM ArticleTag order by articletagID desc";
                    break;
                default:
                    commText = "select top " + count.ToString() + " * ArticleTag order by articletagID   desc";
                    break;
            }

            using (SqlConnection conn = new SqlConnection(DataHelper2.SqlConnectionString))
            {
                {
                    using (SqlCommand comm = new SqlCommand())
                    {
                        comm.Connection = conn;
                        comm.CommandText = commText;
                        conn.Open();

                        using (SqlDataReader reader = comm.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                ArticleTag tag = new ArticleTag();

                                tag.TagID = int.Parse(reader["ArticletagID"].ToString());
                                tag.TagName = reader["ArticleTagName"].ToString();
                                tag.ArticleIDs  = reader["ArticleIDs"].ToString();

                                list.Add(tag);
                            }
                        }
                    }
                }
            }
            return list;
        }
        public bool ArticleTagCreateDeleteUpdate(ArticleTag articleTag, UserAction ua)
        {
            bool result = false;
            string commandText = string.Empty;
            switch (ua)
            {
                case UserAction.Create:
                    commandText = "INSERT INTO ArticleTag  (ArticleTagID, ArticleTagName, ArticleIDs) VALUES ("+articleTag.TagID +", '"+articleTag.TagName +"', '"+articleTag.ArticleIDs +"')";
                    break;
                case UserAction.Delete:
                    commandText = "DELETE FROM ArticleTag WHERE (ArticleTagID = "+articleTag.TagID +")";
                    break;
                case UserAction.Update:
                    commandText = "UPDATE ArticleTag SET ArticleTagName ='"+articleTag.TagName +"', ArticleIDs ='"+articleTag.ArticleIDs +"' WHERE (ArticleTagID = "+articleTag.TagID +")";
                    break;
            }
            using (SqlConnection conn = new SqlConnection(DataHelper2.SqlConnectionString))
            {
                using (SqlCommand comm = new SqlCommand())
                {
                    comm.CommandText = commandText;
                    comm.Connection = conn;
                    conn.Open();
                    try
                    {
                        comm.ExecuteNonQuery();
                        result = true;
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.Message);
                    }

                }
            }

            return result;
        }