Exemplo n.º 1
0
        /// <summary>
        ///Add
        /// </summary>
        public int Add(PopularSport model)
        {
            string sql = "insert into PopularSport (CategoryId,Name,Remark,Client,AddDate,ImgPath1,ImgPath2,ImgPath3) values (@CategoryId,@Name,@Remark,@Client,@AddDate,@ImgPath1,@ImgPath2,@ImgPath3);select @IDENTITYVal = @@IDENTITY;";
            List <SqlParameter> sqlParams = new List <SqlParameter>();

            sqlParams.Add(new SqlParameter()
            {
                ParameterName = "@IDENTITYVal", SqlDbType = SqlDbType.Int
            });
            sqlParams.Add(new SqlParameter()
            {
                ParameterName = "@CategoryId", SqlDbType = SqlDbType.Int, Value = model.CategoryId
            });
            sqlParams.Add(new SqlParameter()
            {
                ParameterName = "@Name", SqlDbType = SqlDbType.NVarChar, Value = model.Name
            });
            sqlParams.Add(new SqlParameter()
            {
                ParameterName = "@Remark", SqlDbType = SqlDbType.NVarChar, Value = model.Remark
            });
            sqlParams.Add(new SqlParameter()
            {
                ParameterName = "@Client", SqlDbType = SqlDbType.NVarChar, Value = model.Client
            });
            sqlParams.Add(new SqlParameter()
            {
                ParameterName = "@AddDate", SqlDbType = SqlDbType.DateTime, Value = model.AddDate
            });
            sqlParams.Add(new SqlParameter()
            {
                ParameterName = "@ImgPath1", SqlDbType = SqlDbType.NVarChar, Value = model.ImgPath1
            });
            sqlParams.Add(new SqlParameter()
            {
                ParameterName = "@ImgPath2", SqlDbType = SqlDbType.NVarChar, Value = model.ImgPath2
            });
            sqlParams.Add(new SqlParameter()
            {
                ParameterName = "@ImgPath3", SqlDbType = SqlDbType.NVarChar, Value = model.ImgPath3
            });
            sqlParams[0].Direction = ParameterDirection.Output;
            int result    = SqlHelper.ExecuteNonQuery(ConfigurationManager.ConnectionStrings["SqlConnection"].ToString(), CommandType.Text, sql, sqlParams.ToArray());
            int identityV = Convert.ToInt32(sqlParams[0].Value);

            return(identityV);
        }
Exemplo n.º 2
0
        /// <summary>
        ///更新
        /// </summary>
        public bool Update(PopularSport model)
        {
            string sql = "update PopularSport set CategoryId=@CategoryId,Name=@Name,Remark=@Remark,Client=@Client,AddDate=@AddDate,ImgPath1=@ImgPath1,ImgPath2=@ImgPath2,ImgPath3=@ImgPath3 where Id=@Id";
            List <SqlParameter> sqlParams = new List <SqlParameter>();

            sqlParams.Add(new SqlParameter()
            {
                ParameterName = "@Id", SqlDbType = SqlDbType.Int, Value = model.Id
            });
            sqlParams.Add(new SqlParameter()
            {
                ParameterName = "@CategoryId", SqlDbType = SqlDbType.Int, Value = model.CategoryId
            });
            sqlParams.Add(new SqlParameter()
            {
                ParameterName = "@Name", SqlDbType = SqlDbType.NVarChar, Value = model.Name
            });
            sqlParams.Add(new SqlParameter()
            {
                ParameterName = "@Remark", SqlDbType = SqlDbType.NVarChar, Value = model.Remark
            });
            sqlParams.Add(new SqlParameter()
            {
                ParameterName = "@Client", SqlDbType = SqlDbType.NVarChar, Value = model.Client
            });
            sqlParams.Add(new SqlParameter()
            {
                ParameterName = "@AddDate", SqlDbType = SqlDbType.DateTime, Value = model.AddDate
            });
            sqlParams.Add(new SqlParameter()
            {
                ParameterName = "@ImgPath1", SqlDbType = SqlDbType.NVarChar, Value = model.ImgPath1
            });
            sqlParams.Add(new SqlParameter()
            {
                ParameterName = "@ImgPath2", SqlDbType = SqlDbType.NVarChar, Value = model.ImgPath2
            });
            sqlParams.Add(new SqlParameter()
            {
                ParameterName = "@ImgPath3", SqlDbType = SqlDbType.NVarChar, Value = model.ImgPath3
            });
            int result = SqlHelper.ExecuteNonQuery(ConfigurationManager.ConnectionStrings["SqlConnection"].ToString(), CommandType.Text, sql, sqlParams.ToArray());

            return(result > 0);
        }
Exemplo n.º 3
0
 /// <summary>
 ///更新
 /// </summary>
 public bool Update(PopularSport model)
 {
     return(dal.Update(model));
 }
Exemplo n.º 4
0
 /// <summary>
 ///Add
 /// </summary>
 public int Add(PopularSport model)
 {
     return(dal.Add(model));
 }