using System;
using System.Collections.Generic;
using System.Text;
using Fm.DataAccess;
using System.Data;
using System.Data.Common;
using System.Collections;

namespace Fm.Bussiness
{
    public class sys_art_content
    {
        //构造函数
        public sys_art_content()
        { }
        /// <summary>
        /// 文档基本属性数据添加
        /// </summary>
        /// <param name="title">标题</param>
        /// <param name="cl_id">所属栏目</param>
        /// <param name="zt_id">所属专题</param>
        /// <param name="so_id">来源</param>
        /// <param name="au_id">作者</param>
        /// <param name="u_id">发布者</param>
        /// <param name="content">内容</param>
        /// <param name="img">缩略图</param>
        /// <returns></returns>
        public bool art_content_add(string title,int cl_id,int so_id,int au_id,int u_id,string content,string img)
        {
            string sqlstr = "insert into Fm_Art values('" + title + "'," + cl_id + "," + so_id + "," + au_id + "," + u_id + ",'" + content + "','" + DateTime.Now.ToString() + "',0,'" + img + "')";
            DbCommand db=DataAccess.DataAccess.db.GetSqlStringCommand(sqlstr);
            return DataAccess.DataAccess.GetData.Query<DbCommand>(db);
        }
        /// <summary>
        /// 文档扩展属性数据添加
        /// </summary>
        /// <param name="art_hand">是否为头条</param>
        /// <param name="art_map">是否为图文</param>
        /// <param name="art_flash">是否为幻灯</param>
        /// <param name="art_commend">是否推荐</param>
        /// <param name="art_top">是否置顶</param>
        /// <param name="art_color">标题颜色</param>
        /// <param name="art_keyword">关键字</param>
        /// <param name="art_intro">文档描述</param>
        /// <param name="art_id">文档ID</param>
        /// <returns></returns>
        public bool art_content_kadd(int art_hand,int art_map,int art_flash,int art_commend,int art_top,string art_color,string art_keyword,string art_intro,int art_id)
        {
            string sqlstr = "insert into Fm_artk values("+art_hand+","+art_map+","+art_flash+","+art_commend+","+art_top+",'"+art_color+"','"+art_keyword+"','"+art_intro+"',"+art_id+")";
            DbCommand db = DataAccess.DataAccess.db.GetSqlStringCommand(sqlstr);
            return DataAccess.DataAccess.GetData.Query<DbCommand>(db);
        }
        /// <summary>
        /// 文档几本属性的数据修改
        /// </summary>
        /// <param name="art_id">文档ID</param>
        /// <param name="title">标题</param>
        /// <param name="cl_id">所属栏目ID</param>
        /// <param name="zt_id">专题ID</param>
        /// <param name="so_id">来源ID</param>
        /// <param name="au_id">作者ID</param>
        /// <param name="u_id">发布者ID</param>
        /// <param name="content">内容</param>
        /// <param name="img">缩略图地址</param>
        /// <returns></returns>
        public bool art_content_update(int art_id,string title, int cl_id, int so_id, int au_id,  string content, string img)
        {
            string sqlstr = "update Fm_Art set art_title='"+title+"',cl_id="+cl_id+",so_id="+so_id+",au_id="+au_id+",art_content='"+content+"',art_img='"+img+"' where art_id="+art_id+"";
            DbCommand db = DataAccess.DataAccess.db.GetSqlStringCommand(sqlstr);
            return DataAccess.DataAccess.GetData.Query<DbCommand>(db);
        }
        /// <summary>
        /// 文档扩展属性数据修改
        /// </summary>
        /// <param name="art_hand">头条</param>
        /// <param name="art_map">图文</param>
        /// <param name="art_flash">幻灯</param>
        /// <param name="art_commend">推荐</param>
        /// <param name="art_top">置顶</param>
        /// <param name="art_color">标题颜色</param>
        /// <param name="art_keyword">关键字</param>
        /// <param name="art_intro">描述</param>
        /// <param name="art_id">文档ID</param>
        /// <returns></returns>
        public bool art_content_kupdate(int art_hand, int art_map, int art_flash, int art_commend, int art_top, string art_color, string art_keyword, string art_intro, int art_id)
        {
            string sqlstr = "update Fm_artk set art_hand="+art_hand+",art_map="+art_map+",art_flash="+art_flash+",art_commend="+art_commend+",art_top="+art_top+",art_color='"+art_color+"',art_keyword='"+art_keyword+"',art_intro='"+art_intro+"' where art_id="+art_id+"";
            DbCommand db = DataAccess.DataAccess.db.GetSqlStringCommand(sqlstr);
            return DataAccess.DataAccess.GetData.Query<DbCommand>(db);
        }
        /// <summary>
        /// 文档删除操作
        /// </summary>
        /// <param name="art_id">文档ID</param>
        /// <returns></returns>
        public bool art_content_del(int art_id)
        {
            DbCommand db=DataAccess.DataAccess.db.GetSqlStringCommand("delete from Fm_Art where art_id="+art_id+"");
            if (DataAccess.DataAccess.GetData.Query<DbCommand>(db))
            {
                DbCommand db1 = DataAccess.DataAccess.db.GetSqlStringCommand("delete from Fm_artk where art_id=" + art_id + "");
                return DataAccess.DataAccess.GetData.Query<DbCommand>(db1);
            }
            else
            {
                return false;
            }
        }
    }
}
