/// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(ROYcms.Sys.Model.ROYcms_AdminUrlMap model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update ROYcms_AdminUrlMap set ");
            strSql.Append("Name=@Name,");
            strSql.Append("Path=@Path,");
            strSql.Append("Description=@Description,");
            strSql.Append("TIME=@TIME");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Name",        SqlDbType.VarChar,   100),
                new SqlParameter("@Path",        SqlDbType.VarChar,   200),
                new SqlParameter("@Description", SqlDbType.VarChar,   500),
                new SqlParameter("@TIME",        SqlDbType.DateTime),
                new SqlParameter("@Id",          SqlDbType.Int, 4)
            };
            parameters[0].Value = model.Name;
            parameters[1].Value = model.Path;
            parameters[2].Value = model.Description;
            parameters[3].Value = model.TIME;
            parameters[4].Value = model.Id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(ROYcms.Sys.Model.ROYcms_AdminUrlMap model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into ROYcms_AdminUrlMap(");
            strSql.Append("Name,Path,Description,TIME)");
            strSql.Append(" values (");
            strSql.Append("@Name,@Path,@Description,@TIME)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Name",        SqlDbType.VarChar, 100),
                new SqlParameter("@Path",        SqlDbType.VarChar, 200),
                new SqlParameter("@Description", SqlDbType.VarChar, 500),
                new SqlParameter("@TIME",        SqlDbType.DateTime)
            };
            parameters[0].Value = model.Name;
            parameters[1].Value = model.Path;
            parameters[2].Value = model.Description;
            parameters[3].Value = model.TIME;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Example #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            int Id = ROYcms.Common.Request.GetQueryInt("Id");

            if (Id > 0)
            {
                Model = BLL.GetModel(Id);
            }
        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ROYcms.Sys.Model.ROYcms_AdminUrlMap GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Id,Name,Path,Description,TIME from ROYcms_AdminUrlMap ");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id", SqlDbType.Int, 4)
            };
            parameters[0].Value = Id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["Id"] != null && ds.Tables[0].Rows[0]["Id"].ToString() != "")
                {
                    model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Name"] != null && ds.Tables[0].Rows[0]["Name"].ToString() != "")
                {
                    model.Name = ds.Tables[0].Rows[0]["Name"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Path"] != null && ds.Tables[0].Rows[0]["Path"].ToString() != "")
                {
                    model.Path = ds.Tables[0].Rows[0]["Path"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Description"] != null && ds.Tables[0].Rows[0]["Description"].ToString() != "")
                {
                    model.Description = ds.Tables[0].Rows[0]["Description"].ToString();
                }
                if (ds.Tables[0].Rows[0]["TIME"] != null && ds.Tables[0].Rows[0]["TIME"].ToString() != "")
                {
                    model.TIME = DateTime.Parse(ds.Tables[0].Rows[0]["TIME"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }