Ejemplo n.º 1
0
        public List <article_categoryInfo> GetList(int Top, string strWhere, string filedOrder)
        {
            List <article_categoryInfo> list = new List <article_categoryInfo>();

            try
            {
                StringBuilder strSql = new StringBuilder();
                strSql.Append("select ");
                if (Top > 0)
                {
                    strSql.Append(" top " + Top.ToString());
                }
                strSql.Append(" * ");
                strSql.Append(" FROM article_category ");
                if (strWhere.Trim() != "")
                {
                    strSql.Append(" where " + strWhere);
                }
                if (filedOrder.Trim() != "")
                {
                    strSql.Append(" order by " + filedOrder);
                }
                using (SqlDataReader dr = SqlDbHelper.ExecuteReader(Config.SqlConnection, strSql.ToString(), CommandType.Text))
                {
                    while (dr.Read())
                    {
                        article_categoryInfo info = GetInfoByDr(dr);
                        list.Add(info);
                    }
                }
                return(list);
            }
            catch { }
            return(null);
        }
Ejemplo n.º 2
0
        public article_categoryInfo GetModel(int id)
        {
            try
            {
                StringBuilder strSql = new StringBuilder();
                strSql.Append("select * ");
                strSql.Append("  from article_category ");
                strSql.Append(" where id=@id");
                SqlParameter[] parameters =
                {
                    new SqlParameter("@id", SqlDbType.Int, 4)
                };
                parameters[0].Value = id;

                article_categoryInfo info = new article_categoryInfo();
                using (SqlDataReader dr = SqlDbHelper.ExecuteReader(Config.SqlConnection, strSql.ToString(), CommandType.Text, parameters))
                {
                    if (dr.Read())
                    {
                        info = GetInfoByDr(dr);
                    }
                }
                return(info);
            }
            catch { }
            return(null);
        }
Ejemplo n.º 3
0
        public int Update(article_categoryInfo model, ref string resultMsg)
        {
            try
            {
                StringBuilder strSql = new StringBuilder();
                strSql.Append("update article_category set ");

                strSql.Append(" img = @img , ");
                strSql.Append(" content = @content , ");
                strSql.Append(" seo_title = @seo_title , ");
                strSql.Append(" seo_keywords = @seo_keywords , ");
                strSql.Append(" seo_description = @seo_description , ");
                strSql.Append(" channel_id = @channel_id , ");
                strSql.Append(" title = @title , ");
                strSql.Append(" call_index = @call_index , ");
                strSql.Append(" parentid = @parentid , ");
                strSql.Append(" orderby = @orderby , ");
                strSql.Append(" link_url = @link_url,  ");
                strSql.Append(" companyid = @companyid  ");
                strSql.Append(" where id=@id ");

                SqlParameter[] parameters =
                {
                    new SqlParameter("@id",              SqlDbType.Int,        4),
                    new SqlParameter("@img",             SqlDbType.NVarChar, 255),
                    new SqlParameter("@content",         SqlDbType.Text),
                    new SqlParameter("@seo_title",       SqlDbType.NVarChar, 255),
                    new SqlParameter("@seo_keywords",    SqlDbType.NVarChar, 255),
                    new SqlParameter("@seo_description", SqlDbType.NVarChar, 255),
                    new SqlParameter("@channel_id",      SqlDbType.Int,        4),
                    new SqlParameter("@title",           SqlDbType.NVarChar, 100),
                    new SqlParameter("@call_index",      SqlDbType.NVarChar,  50),
                    new SqlParameter("@parentid",        SqlDbType.Int,        4),
                    new SqlParameter("@orderby",         SqlDbType.Int,        4),
                    new SqlParameter("@link_url",        SqlDbType.NVarChar, 255),
                    new SqlParameter("@companyid",       SqlDbType.Int,        4),
                };

                parameters[0].Value  = model.id;
                parameters[1].Value  = model.img;
                parameters[2].Value  = model.content;
                parameters[3].Value  = model.seo_title;
                parameters[4].Value  = model.seo_keywords;
                parameters[5].Value  = model.seo_description;
                parameters[6].Value  = model.channel_id;
                parameters[7].Value  = model.title;
                parameters[8].Value  = model.call_index;
                parameters[9].Value  = model.parentid;
                parameters[10].Value = model.orderby;
                parameters[11].Value = model.link_url;
                parameters[12].Value = model.companyid;
                int rows = SqlDbHelper.ExecuteNonQuery(Config.SqlConnection, strSql.ToString(), CommandType.Text, parameters);

                return(rows);
            }
            catch (Exception exc)
            { resultMsg = exc.Message; }
            return(0);
        }
Ejemplo n.º 4
0
        public int Add(article_categoryInfo model, ref string resultMsg)
        {
            try
            {
                StringBuilder strSql = new StringBuilder();
                strSql.Append("insert into article_category(");
                strSql.Append("img,content,seo_title,seo_keywords,seo_description,channel_id,title,call_index,parentid,orderby,link_url,companyid");
                strSql.Append(") values (");
                strSql.Append("@img,@content,@seo_title,@seo_keywords,@seo_description,@channel_id,@title,@call_index,@parentid,@orderby,@link_url,@companyid");
                strSql.Append(") ");
                strSql.Append(";select @@IDENTITY");
                SqlParameter[] parameters =
                {
                    new SqlParameter("@img",             SqlDbType.NVarChar, 255),
                    new SqlParameter("@content",         SqlDbType.Text),
                    new SqlParameter("@seo_title",       SqlDbType.NVarChar, 255),
                    new SqlParameter("@seo_keywords",    SqlDbType.NVarChar, 255),
                    new SqlParameter("@seo_description", SqlDbType.NVarChar, 255),
                    new SqlParameter("@channel_id",      SqlDbType.Int,        4),
                    new SqlParameter("@title",           SqlDbType.NVarChar, 100),
                    new SqlParameter("@call_index",      SqlDbType.NVarChar,  50),
                    new SqlParameter("@parentid",        SqlDbType.Int,        4),
                    new SqlParameter("@orderby",         SqlDbType.Int,        4),
                    new SqlParameter("@link_url",        SqlDbType.NVarChar, 255),
                    new SqlParameter("@companyid",       SqlDbType.Int,        4),
                };

                parameters[0].Value  = model.img;
                parameters[1].Value  = model.content;
                parameters[2].Value  = model.seo_title;
                parameters[3].Value  = model.seo_keywords;
                parameters[4].Value  = model.seo_description;
                parameters[5].Value  = model.channel_id;
                parameters[6].Value  = model.title;
                parameters[7].Value  = model.call_index;
                parameters[8].Value  = model.parentid;
                parameters[9].Value  = model.orderby;
                parameters[10].Value = model.link_url;
                parameters[11].Value = model.companyid;
                object obj = SqlDbHelper.ExecuteScalar(Config.SqlConnection, strSql.ToString(), CommandType.Text, parameters);
                if (obj == null)
                {
                    return(0);
                }
                else
                {
                    return(Convert.ToInt32(obj));
                }
            }
            catch (Exception exc)
            { resultMsg = exc.Message; }
            return(0);
        }
Ejemplo n.º 5
0
        private void bind()
        {
            ddlarticle_categorybind();
            if (id > 0)
            {
                hfid.Value = id.ToString();
                article_categoryInfo info = BLL.article_categoryBLL.GetModel(id);
                txbtitle.Text   = info.title;
                txborderby.Text = info.orderby.ToString();

                try { ddlarticle_category.SelectedValue = info.parentid.ToString(); }
                catch { }
            }
            else
            {
                txborderby.Text = "99";
            }
        }
Ejemplo n.º 6
0
        private article_categoryInfo GetInfoByDr(SqlDataReader dr)
        {
            article_categoryInfo info = new article_categoryInfo();

            info.id              = int.Parse(dr["id"] != DBNull.Value ? dr["id"].ToString() : "0");
            info.img             = dr["img"] != DBNull.Value ? dr["img"].ToString() : "";
            info.content         = dr["content"] != DBNull.Value ? dr["content"].ToString() : "";
            info.seo_title       = dr["seo_title"] != DBNull.Value ? dr["seo_title"].ToString() : "";
            info.seo_keywords    = dr["seo_keywords"] != DBNull.Value ? dr["seo_keywords"].ToString() : "";
            info.seo_description = dr["seo_description"] != DBNull.Value ? dr["seo_description"].ToString() : "";
            info.channel_id      = int.Parse(dr["channel_id"] != DBNull.Value ? dr["channel_id"].ToString() : "0");
            info.title           = dr["title"] != DBNull.Value ? dr["title"].ToString() : "";
            info.call_index      = dr["call_index"] != DBNull.Value ? dr["call_index"].ToString() : "";
            info.parentid        = int.Parse(dr["parentid"] != DBNull.Value ? dr["parentid"].ToString() : "");
            info.orderby         = int.Parse(dr["orderby"] != DBNull.Value ? dr["orderby"].ToString() : "0");
            info.link_url        = dr["link_url"] != DBNull.Value ? dr["link_url"].ToString() : "";
            info.companyid       = int.Parse(dr["companyid"] != DBNull.Value ? dr["companyid"].ToString() : "0");
            return(info);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 树结构
        /// </summary>
        /// <param name="dtNodeSets">菜单记录数据所在的表</param>
        /// <param name="strParentColumn">表中用于标记父记录的字段</param>
        /// <param name="strRootValue">第一层记录的父记录值(通常设计为0或者-1或者Null)用来表示没有父记录</param>
        /// <param name="strIndexColumn">索引字段,也就是放在DropDownList的Value里面的字段</param>
        /// <param name="strTextColumn">显示文本字段,也就是放在DropDownList的Text里面的字段</param>
        /// <param name="i">用来控制缩入量的值,请输入-1</param>
        public ArrayList MakeTreeList(DataTable dtNodeSets, string strParentColumn, string strRootValue, string strIndexColumn, string strTextColumn, int i)
        {
            //每向下一层,多一个缩入单位
            i++;

            DataView dvNodeSets = new DataView(dtNodeSets);

            dvNodeSets.RowFilter = strParentColumn + "=" + strRootValue;

            string strPading = ""; //缩入字符



            //通过i来控制缩入字符的长度,我这里设定的是一个全角的空格
            for (int j = 0; j < i; j++)
            {
                strPading += "  ";//如果要增加缩入的长度,改成两个全角的空格就可以了
            }
            foreach (DataRowView drv in dvNodeSets)
            {
                article_categoryInfo info = new article_categoryInfo();
                string title = drv[strTextColumn] != DBNull.Value ? drv[strTextColumn].ToString() : "";
                if (i > 0)
                {
                    title = strPading + "&nbsp;&nbsp;├&nbsp;&nbsp;&nbsp;" + (drv[strTextColumn] != DBNull.Value ? drv[strTextColumn].ToString() : "");
                }
                info.id          = drv["id"] != DBNull.Value ? Convert.ToInt32(drv["id"]) : 0;
                info.orderby     = drv["orderby"] != DBNull.Value ? Convert.ToInt32(drv["orderby"]) : 0;
                info.title       = title;
                info.parentid    = drv["parentid"] != DBNull.Value ? Convert.ToInt32(drv["parentid"]) : 0;
                info.companyname = drv["companyname"] != DBNull.Value ? drv["companyname"].ToString() : "";
                list.Add(info);
                MakeTreeList(dtNodeSets, strParentColumn, drv[strIndexColumn].ToString(), strIndexColumn, strTextColumn, i);
            }


            //递归结束,要回到上一层,所以缩入量减少一个单位
            i--;
            return(list);
        }
Ejemplo n.º 8
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public static int Update(article_categoryInfo model, ref string resultMsg)
 {
     return(dal.Update(model, ref resultMsg));
 }
Ejemplo n.º 9
0
 public static int Add(article_categoryInfo info, ref string resultMsg)
 {
     return(dal.Add(info, ref resultMsg));
 }