Пример #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(BookShop.Model.VidoFile model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update VidoFile set ");
            strSql.Append("Title=@Title,");
            strSql.Append("FivPath=@FivPath,");
            strSql.Append("Status=@Status,");
            strSql.Append("FileExt=@FileExt");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Title",   SqlDbType.NVarChar,  50),
                new SqlParameter("@FivPath", SqlDbType.NVarChar, 255),
                new SqlParameter("@Status",  SqlDbType.NVarChar,  50),
                new SqlParameter("@FileExt", SqlDbType.NVarChar,  50),
                new SqlParameter("@Id",      SqlDbType.Int, 4)
            };
            parameters[0].Value = model.Title;
            parameters[1].Value = model.FivPath;
            parameters[2].Value = model.Status;
            parameters[3].Value = model.FileExt;
            parameters[4].Value = model.Id;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(BookShop.Model.VidoFile model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into VidoFile(");
            strSql.Append("Title,FivPath,Status,FileExt)");
            strSql.Append(" values (");
            strSql.Append("@Title,@FivPath,@Status,@FileExt)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Title",   SqlDbType.NVarChar,  50),
                new SqlParameter("@FivPath", SqlDbType.NVarChar, 255),
                new SqlParameter("@Status",  SqlDbType.NVarChar,  50),
                new SqlParameter("@FileExt", SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = model.Title;
            parameters[1].Value = model.FivPath;
            parameters[2].Value = model.Status;
            parameters[3].Value = model.FileExt;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Пример #3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public BookShop.Model.VidoFile DataRowToModel(DataRow row)
 {
     BookShop.Model.VidoFile model = new BookShop.Model.VidoFile();
     if (row != null)
     {
         if (row["Id"] != null && row["Id"].ToString() != "")
         {
             model.Id = int.Parse(row["Id"].ToString());
         }
         if (row["Title"] != null)
         {
             model.Title = row["Title"].ToString();
         }
         if (row["FivPath"] != null)
         {
             model.FivPath = row["FivPath"].ToString();
         }
         if (row["Status"] != null)
         {
             model.Status = row["Status"].ToString();
         }
         if (row["FileExt"] != null)
         {
             model.FileExt = row["FileExt"].ToString();
         }
     }
     return(model);
 }
Пример #4
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public BookShop.Model.VidoFile DataRowToModel(DataRow row)
 {
     BookShop.Model.VidoFile model=new BookShop.Model.VidoFile();
     if (row != null)
     {
         if(row["Id"]!=null && row["Id"].ToString()!="")
         {
             model.Id=int.Parse(row["Id"].ToString());
         }
         if(row["Title"]!=null)
         {
             model.Title=row["Title"].ToString();
         }
         if(row["FivPath"]!=null)
         {
             model.FivPath=row["FivPath"].ToString();
         }
         if(row["Status"]!=null)
         {
             model.Status=row["Status"].ToString();
         }
         if(row["FileExt"]!=null)
         {
             model.FileExt=row["FileExt"].ToString();
         }
     }
     return model;
 }
Пример #5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public BookShop.Model.VidoFile GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Id,Title,FivPath,Status,FileExt from VidoFile ");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id", SqlDbType.Int, 4)
            };
            parameters[0].Value = Id;

            BookShop.Model.VidoFile model = new BookShop.Model.VidoFile();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Пример #6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public BookShop.Model.VidoFile GetModel(int Id)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 Id,Title,FivPath,Status,FileExt from VidoFile ");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters = {
                    new SqlParameter("@Id", SqlDbType.Int,4)
            };
            parameters[0].Value = Id;

            BookShop.Model.VidoFile model=new BookShop.Model.VidoFile();
            DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
            if(ds.Tables[0].Rows.Count>0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }