Exemplo n.º 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.AlbumTypes model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into AlbumTypes(");
            strSql.Append("AlbumTypeName,AddUser,AddTime)");
            strSql.Append(" values (");
            strSql.Append("@AlbumTypeName,@AddUser,@AddTime)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@AlbumTypeName", SqlDbType.NVarChar, 50),
                new SqlParameter("@AddUser",       SqlDbType.NVarChar, 50),
                new SqlParameter("@AddTime",       SqlDbType.DateTime)
            };
            parameters[0].Value = model.AlbumTypeName;
            parameters[1].Value = model.AddUser;
            parameters[2].Value = model.AddTime;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.AlbumTypes model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update AlbumTypes set ");
            strSql.Append("AlbumTypeName=@AlbumTypeName,");
            strSql.Append("AddUser=@AddUser,");
            strSql.Append("AddTime=@AddTime");
            strSql.Append(" where AlbumTypeId=@AlbumTypeId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@AlbumTypeName", SqlDbType.NVarChar,  50),
                new SqlParameter("@AddUser",       SqlDbType.NVarChar,  50),
                new SqlParameter("@AddTime",       SqlDbType.DateTime),
                new SqlParameter("@AlbumTypeId",   SqlDbType.Int, 4)
            };
            parameters[0].Value = model.AlbumTypeName;
            parameters[1].Value = model.AddUser;
            parameters[2].Value = model.AddTime;
            parameters[3].Value = model.AlbumTypeId;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int AddAlbumType(Model.AlbumTypes model)
        {
            SqlParameter[] parameters =
            {
                new SqlParameter("@AlbumTypeName", SqlDbType.NVarChar, 50),
                new SqlParameter("@AddUser",       SqlDbType.NVarChar, 50),
                new SqlParameter("@AddTime",       SqlDbType.DateTime)
            };
            parameters[0].Value = model.AlbumTypeName;
            parameters[1].Value = model.AddUser;
            parameters[2].Value = model.AddTime;
            int result = 0;

            return(DbHelperSQL.RunProcedure("AddAlbumType", parameters, out result));
        }
Exemplo n.º 4
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Model.AlbumTypes DataRowToModel(DataRow row)
 {
     Model.AlbumTypes model = new Model.AlbumTypes();
     if (row != null)
     {
         if (row["AlbumTypeId"] != null && row["AlbumTypeId"].ToString() != "")
         {
             model.AlbumTypeId = int.Parse(row["AlbumTypeId"].ToString());
         }
         if (row["AlbumTypeName"] != null)
         {
             model.AlbumTypeName = row["AlbumTypeName"].ToString();
         }
         if (row["AddUser"] != null)
         {
             model.AddUser = row["AddUser"].ToString();
         }
         if (row["AddTime"] != null && row["AddTime"].ToString() != "")
         {
             model.AddTime = DateTime.Parse(row["AddTime"].ToString());
         }
     }
     return(model);
 }
Exemplo n.º 5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.AlbumTypes GetModel(int AlbumTypeId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 AlbumTypeId,AlbumTypeName,AddUser,AddTime from AlbumTypes ");
            strSql.Append(" where AlbumTypeId=@AlbumTypeId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@AlbumTypeId", SqlDbType.Int, 4)
            };
            parameters[0].Value = AlbumTypeId;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Model.AlbumTypes model)
 {
     return(dal.Update(model));
 }
Exemplo n.º 7
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int AddAlbumType(Model.AlbumTypes model)
 {
     return(dal.AddAlbumType(model));
 }