Exemplo n.º 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(SeoWebSite.Model.ScheduleClass model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update ScheduleClass set ");
            strSql.Append("name=@name,");
            strSql.Append("data=@data");
            strSql.Append(" where id=@id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id",   SqlDbType.Int,       4),
                new SqlParameter("@name", SqlDbType.NVarChar, 50),
                new SqlParameter("@data", SqlDbType.NVarChar, 1000)
            };
            parameters[0].Value = model.id;
            parameters[1].Value = model.name;
            parameters[2].Value = model.data;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public SeoWebSite.Model.ScheduleClass GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,name,data from ScheduleClass ");
            strSql.Append(" where id=@id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            SeoWebSite.Model.ScheduleClass model = new SeoWebSite.Model.ScheduleClass();
            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.name = ds.Tables[0].Rows[0]["name"].ToString();
                model.data = ds.Tables[0].Rows[0]["data"].ToString();
                return(model);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(SeoWebSite.Model.ScheduleClass model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into ScheduleClass(");
            strSql.Append("id,name,data,cclassid)");
            strSql.Append(" values (");
            strSql.Append("@id,@name,@data,@cclassid)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id",       SqlDbType.Int,         4),
                new SqlParameter("@name",     SqlDbType.NVarChar,   50),
                new SqlParameter("@data",     SqlDbType.NVarChar, 1000),
                new SqlParameter("@cclassid", SqlDbType.Int, 4)
            };
            parameters[0].Value = model.id;
            parameters[1].Value = model.name;
            parameters[2].Value = model.data;
            parameters[3].Value = model.cclassid;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
Exemplo n.º 4
0
        /// <summary>
        /// �õ�һ������ʵ��
        /// </summary>
        public SeoWebSite.Model.ScheduleClass GetModel(int id)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 id,name,data from ScheduleClass ");
            strSql.Append(" where id=@id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int,4)};
            parameters[0].Value = id;

            SeoWebSite.Model.ScheduleClass model=new SeoWebSite.Model.ScheduleClass();
            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.name=ds.Tables[0].Rows[0]["name"].ToString();
                model.data=ds.Tables[0].Rows[0]["data"].ToString();
                return model;
            }
            else
            {
                return null;
            }
        }