Example #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(ROYcms.Sys.Model.ROYcms_Form model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into " + PubConstant.date_prefix + "Form(");
            strSql.Append("title,zhaiyao,classname,ClassKind_id,Class_id,SetFrom,Path,Contents,Time,GUID)");
            strSql.Append(" values (");
            strSql.Append("@title,@zhaiyao,@classname,@ClassKind_id,@Class_id,@SetFrom,@Path,@Contents,@Time,@GUID)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@title",        SqlDbType.NVarChar,  100),
                new SqlParameter("@zhaiyao",      SqlDbType.NVarChar,  200),
                new SqlParameter("@classname",    SqlDbType.Int,         4),
                new SqlParameter("@ClassKind_id", SqlDbType.Int,         4),
                new SqlParameter("@Class_id",     SqlDbType.Int,         4),
                new SqlParameter("@SetFrom",      SqlDbType.NVarChar,  200),
                new SqlParameter("@Path",         SqlDbType.NVarChar,  100),
                new SqlParameter("@Contents",     SqlDbType.Text),
                new SqlParameter("@Time",         SqlDbType.DateTime),
                new SqlParameter("@GUID",         SqlDbType.NVarChar, 100)
            };
            parameters[0].Value = model.title;
            parameters[1].Value = model.zhaiyao;
            parameters[2].Value = model.classname;
            parameters[3].Value = model.ClassKind_id;
            parameters[4].Value = model.Class_id;
            parameters[5].Value = model.SetFrom;
            parameters[6].Value = model.Path;
            parameters[7].Value = model.Contents;
            parameters[8].Value = model.Time;
            parameters[9].Value = model.GUID;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
Example #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ROYcms.Sys.Model.ROYcms_Form GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,title,zhaiyao,classname,ClassKind_id,Class_id,SetFrom,Path,Contents,Time,GUID from " + PubConstant.date_prefix + "Form ");
            strSql.Append(" where id=@id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            ROYcms.Sys.Model.ROYcms_Form model = new ROYcms.Sys.Model.ROYcms_Form();
            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.title   = ds.Tables[0].Rows[0]["title"].ToString();
                model.zhaiyao = ds.Tables[0].Rows[0]["zhaiyao"].ToString();
                if (ds.Tables[0].Rows[0]["classname"].ToString() != "")
                {
                    model.classname = int.Parse(ds.Tables[0].Rows[0]["classname"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ClassKind_id"].ToString() != "")
                {
                    model.ClassKind_id = int.Parse(ds.Tables[0].Rows[0]["ClassKind_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Class_id"].ToString() != "")
                {
                    model.Class_id = int.Parse(ds.Tables[0].Rows[0]["Class_id"].ToString());
                }
                model.SetFrom  = ds.Tables[0].Rows[0]["SetFrom"].ToString();
                model.Path     = ds.Tables[0].Rows[0]["Path"].ToString();
                model.Contents = ds.Tables[0].Rows[0]["Contents"].ToString();
                if (ds.Tables[0].Rows[0]["Time"].ToString() != "")
                {
                    model.Time = DateTime.Parse(ds.Tables[0].Rows[0]["Time"].ToString());
                }
                model.GUID = ds.Tables[0].Rows[0]["GUID"].ToString();
                return(model);
            }
            else
            {
                return(null);
            }
        }
Example #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(ROYcms.Sys.Model.ROYcms_Form model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update " + PubConstant.date_prefix + "Form set ");
            strSql.Append("title=@title,");
            strSql.Append("zhaiyao=@zhaiyao,");
            strSql.Append("classname=@classname,");
            strSql.Append("ClassKind_id=@ClassKind_id,");
            strSql.Append("Class_id=@Class_id,");
            strSql.Append("SetFrom=@SetFrom,");
            strSql.Append("Path=@Path,");
            strSql.Append("Contents=@Contents,");
            strSql.Append("Time=@Time,");
            strSql.Append("GUID=@GUID");
            strSql.Append(" where id=@id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id",           SqlDbType.Int,         4),
                new SqlParameter("@title",        SqlDbType.NVarChar,  100),
                new SqlParameter("@zhaiyao",      SqlDbType.NVarChar,  200),
                new SqlParameter("@classname",    SqlDbType.Int,         4),
                new SqlParameter("@ClassKind_id", SqlDbType.Int,         4),
                new SqlParameter("@Class_id",     SqlDbType.Int,         4),
                new SqlParameter("@SetFrom",      SqlDbType.NVarChar,  200),
                new SqlParameter("@Path",         SqlDbType.NVarChar,  100),
                new SqlParameter("@Contents",     SqlDbType.Text),
                new SqlParameter("@Time",         SqlDbType.DateTime),
                new SqlParameter("@GUID",         SqlDbType.NVarChar, 100)
            };
            parameters[0].Value  = model.id;
            parameters[1].Value  = model.title;
            parameters[2].Value  = model.zhaiyao;
            parameters[3].Value  = model.classname;
            parameters[4].Value  = model.ClassKind_id;
            parameters[5].Value  = model.Class_id;
            parameters[6].Value  = model.SetFrom;
            parameters[7].Value  = model.Path;
            parameters[8].Value  = model.Contents;
            parameters[9].Value  = model.Time;
            parameters[10].Value = model.GUID;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }