Exemple #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Maticsoft.Model.CMS_Css model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into CMS_Css(");
            strSql.Append("FileName,Describe,Body,IsDefault)");
            strSql.Append(" values (");
            strSql.Append("@FileName,@Describe,@Body,@IsDefault)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@FileName",  SqlDbType.Char,  50),
                new SqlParameter("@Describe",  SqlDbType.Char, 100),
                new SqlParameter("@Body",      SqlDbType.Char,  50),
                new SqlParameter("@IsDefault", SqlDbType.Bit, 1)
            };
            parameters[0].Value = model.FileName;
            parameters[1].Value = model.Describe;
            parameters[2].Value = model.Body;
            parameters[3].Value = model.IsDefault;

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

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

            strSql.Append("update CMS_Css set ");
            strSql.Append("FileName=@FileName,");
            strSql.Append("Describe=@Describe,");
            strSql.Append("Body=@Body,");
            strSql.Append("IsDefault=@IsDefault");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@FileName",  SqlDbType.Char,  50),
                new SqlParameter("@Describe",  SqlDbType.Char, 100),
                new SqlParameter("@Body",      SqlDbType.Char,  50),
                new SqlParameter("@IsDefault", SqlDbType.Bit,    1),
                new SqlParameter("@Id",        SqlDbType.Int, 4)
            };
            parameters[0].Value = model.FileName;
            parameters[1].Value = model.Describe;
            parameters[2].Value = model.Body;
            parameters[3].Value = model.IsDefault;
            parameters[4].Value = model.Id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.CMS_Css GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Id,FileName,Describe,Body,IsDefault from CMS_Css ");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id", SqlDbType.Int, 4)
            };
            parameters[0].Value = Id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["Id"].ToString() != "")
                {
                    model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
                }
                model.FileName = ds.Tables[0].Rows[0]["FileName"].ToString();
                model.Describe = ds.Tables[0].Rows[0]["Describe"].ToString();
                model.Body     = ds.Tables[0].Rows[0]["Body"].ToString();
                if (ds.Tables[0].Rows[0]["IsDefault"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["IsDefault"].ToString() == "1") || (ds.Tables[0].Rows[0]["IsDefault"].ToString().ToLower() == "true"))
                    {
                        model.IsDefault = true;
                    }
                    else
                    {
                        model.IsDefault = false;
                    }
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }