Ejemplo n.º 1
0
        /// <summary>
        /// 根据条件语句取得第一个实体
        /// </summary>
        /// <param name="m_where">条件语句,不包含“where”</param>
        /// <returns></returns>
        public static MovieDramaUrl Find(string m_where)
        {
            IDbHelper     Sql = GetHelper();
            MovieDramaUrl M   = new MovieDramaUrl();
            DbDataReader  Rs  = Sql.ExecuteReader(CommandType.Text, "select [id],[MovieID],[MovieTitle],[MovieDramaID],[MovieDramaTitle],[Title],[UpdateTime],[Enable],[Url] from [MovieDramaUrl] where " + m_where, true);

            if (!Rs.Read())
            {
                M.Id = long.MinValue;
            }
            else
            {
                M.Id              = Rs["id"].ToInt64();
                M.MovieID         = Rs["MovieID"].ToInt32();
                M.MovieTitle      = Rs["MovieTitle"].ToString();
                M.MovieDramaID    = Rs["MovieDramaID"].ToInt64();
                M.MovieDramaTitle = Rs["MovieDramaTitle"].ToString();
                M.Title           = Rs["Title"].ToString();
                M.UpdateTime      = Rs["UpdateTime"].ToDateTime();
                M.Enable          = Rs["Enable"].ToBoolean();
                M.Url             = Rs["Url"].ToString();
            }
            Rs.Close();
            Rs = null;
            return(M);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 将修改过的实体修改到数据库
        /// </summary>
        /// <param name="M">赋值后的实体</param>
        /// <returns></returns>
        public static int Update(MovieDramaUrl M)
        {
            IDbHelper     Sql = GetHelper();
            StringBuilder sb  = new StringBuilder();

            sb.Append("update [MovieDramaUrl] set ");

            sb.Append("[MovieID]=" + M.MovieID.ToS());
            sb.Append(",");
            sb.Append("[MovieTitle]=N'" + M.MovieTitle + "'");
            sb.Append(",");
            sb.Append("[MovieDramaID]=" + M.MovieDramaID.ToS());
            sb.Append(",");
            sb.Append("[MovieDramaTitle]=N'" + M.MovieDramaTitle + "'");
            sb.Append(",");
            sb.Append("[Title]=N'" + M.Title + "'");
            sb.Append(",");
            sb.Append("[UpdateTime]=N'" + M.UpdateTime + "'");
            sb.Append(",");
            sb.Append("[Enable]=" + M.Enable.ToS());
            sb.Append(",");
            sb.Append("[Url]=N'" + M.Url + "'");

            sb.Append(" where Id='" + M.Id + "'");
            sb.Append("");

            if (DataBase.CmsDbType == DataBase.DbType.SqlServer)
            {
                sb.Append(";select @@ROWCOUNT");
            }
            if (DataBase.CmsDbType == DataBase.DbType.SQLite)
            {
                sb.Append(";select 0");
            }
            if (DataBase.CmsDbType == DataBase.DbType.MySql)
            {
                sb.Append(";SELECT ROW_COUNT()");
            }
            if (DataBase.CmsDbType == DataBase.DbType.Access)
            {
                sb.Append(";select 0");
            }
            if (DataBase.CmsDbType == DataBase.DbType.Oracle)
            {
                sb.Append(";select SQL%ROWCOUNT");
            }


            return(Sql.ExecuteScalar(CommandType.Text, sb.ToString()).ToInt32());
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 将数据插入表
        /// </summary>
        /// <param name="M">赋值后的实体</param>
        /// <returns></returns>
        public static void Insert(MovieDramaUrl M)
        {
            IDbHelper     Sql = GetHelper();
            StringBuilder sb  = new StringBuilder();

            sb.Append("insert into [MovieDramaUrl]([id],[MovieID],[MovieTitle],[MovieDramaID],[MovieDramaTitle],[Title],[UpdateTime],[Enable],[Url]) values(");
            sb.Append(M.MovieID.ToS());
            sb.Append(",");
            sb.Append("N'" + M.MovieTitle + "'");
            sb.Append(",");
            sb.Append(M.MovieDramaID.ToS());
            sb.Append(",");
            sb.Append("N'" + M.MovieDramaTitle + "'");
            sb.Append(",");
            sb.Append("N'" + M.Title + "'");
            sb.Append(",");
            sb.Append("N'" + M.UpdateTime + "'");
            sb.Append(",");
            sb.Append(M.Enable.ToS());
            sb.Append(",");
            sb.Append("N'" + M.Url + "'");
            sb.Append(")");

            if (DataBase.CmsDbType == DataBase.DbType.SqlServer)
            {
                sb.Append(";select @@Identity");
            }
            if (DataBase.CmsDbType == DataBase.DbType.SQLite)
            {
                sb.Append(";select last_insert_rowid()");
            }
            if (DataBase.CmsDbType == DataBase.DbType.MySql)
            {
                sb.Append(";select LAST_INSERT_ID()");
            }
            if (DataBase.CmsDbType == DataBase.DbType.Access)
            {
                sb.Append(";select max(id) from MovieDramaUrl");
            }
            if (DataBase.CmsDbType == DataBase.DbType.Oracle)
            {
                sb.Append(";select LAST_INSERT_ID()");
            }


            M.Id = Sql.ExecuteScalar(CommandType.Text, sb.ToString()).ToInt32();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// DataTable转换为list
        /// </summary>
        /// <param name="dt"></param>
        /// <returns></returns>
        protected static List <MovieDramaUrl> DataTableToList(DataTable dt)
        {
            List <MovieDramaUrl> Ms = new List <MovieDramaUrl>();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                MovieDramaUrl M = new MovieDramaUrl();
                M.Id              = dt.Rows[i]["id"].ToInt64();
                M.MovieID         = dt.Rows[i]["MovieID"].ToInt32();
                M.MovieTitle      = dt.Rows[i]["MovieTitle"].ToString();
                M.MovieDramaID    = dt.Rows[i]["MovieDramaID"].ToInt64();
                M.MovieDramaTitle = dt.Rows[i]["MovieDramaTitle"].ToString();
                M.Title           = dt.Rows[i]["Title"].ToString();
                M.UpdateTime      = dt.Rows[i]["UpdateTime"].ToDateTime();
                M.Enable          = dt.Rows[i]["Enable"].ToBoolean();
                M.Url             = dt.Rows[i]["Url"].ToString();

                Ms.Add(M);
            }
            return(Ms);
        }
Ejemplo n.º 5
0
 public void AddToMovieDramaUrl(MovieDramaUrl movieDramaUrl)
 {
     base.AddObject("MovieDramaUrl", movieDramaUrl);
 }
Ejemplo n.º 6
0
 public static MovieDramaUrl CreateMovieDramaUrl(long id)
 {
     MovieDramaUrl movieDramaUrl = new MovieDramaUrl();
     movieDramaUrl.id = id;
     return movieDramaUrl;
 }