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

            strSql.Append("insert into " + PubConstant.date_prefix + "template(");
            strSql.Append("z_id,name,tag,htmlcontent,htmltimes,class_name,y");
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append("" + model.z_id + ",");
            strSql.Append("'" + model.name + "',");
            strSql.Append("'" + model.tag + "',");
            strSql.Append("'" + model.htmlcontent + "',");
            strSql.Append("'" + model.htmltimes + "',");
            strSql.Append("'" + model.class_name + "',");
            strSql.Append("" + model.y + "");
            strSql.Append(")");
            strSql.Append(";select @@IDENTITY");
            object obj = ROYcms.DB.DbHelpers.GetSingle(strSql.ToString());

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemple #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void ImageButton1_Click(object sender, System.Web.UI.ImageClickEventArgs e)
 {
     //更新数据
     ROYcms.Sys.Model.ROYcms_template Model_update = new ROYcms.Sys.Model.ROYcms_template();
     if (Request["id"] != null)
     {
         Model_update.bh          = Convert.ToInt32(Request["id"] == null ? "0" : Request["id"]);
         Model_update.name        = TextBox_title.Text;
         Model_update.tag         = TextBox_miaoshu.Text;
         Model_update.htmlcontent = TextBox_HTML.Text;
         Model_update.class_name  = Request["type"];
         Model_update.htmltimes   = DateTime.Now;
         Model_update.y           = 0;
         BLL.Update(Model_update);
     }
     //更新模板文件
     try
     {
         string path = Server.MapPath("~/" + ROYcms.Config.ROYcmsConfig.GetCmsConfigValue("templet_root") + "/" + Session["template_z_path"].ToString() + "/" + Request["type"] + Request["id"] + ".html");
         if (!Directory.Exists(Server.MapPath("~/" + ROYcms.Config.ROYcmsConfig.GetCmsConfigValue("templet_root") + "/" + Session["template_z_path"].ToString() + "/")))
         {
             Directory.CreateDirectory(Server.MapPath("~/" + ROYcms.Config.ROYcmsConfig.GetCmsConfigValue("templet_root") + "/" + Session["template_z_path"].ToString() + "/"));
         }
         SystemCms.CreateFile(path, TextBox_HTML.Text, ROYcms.Config.ROYcmsConfig.GetCmsConfigValue("templet_language"));
         ROYcms.Common.SystemCms.RemoveAllCache();//清除全局缓存
     }
     catch { Response.Redirect("/administrator/Message.aspx?message=更新模板出错了!&z=no"); }
     Response.Redirect("/administrator/Message.aspx?message=更新模板成功!&z=yes");
 }
Exemple #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         ROYcms.Sys.Model.ROYcms_template Model = new ROYcms.Sys.Model.ROYcms_template();
         if (Request["id"] != null)
         {
             Model = BLL.GetModel(Convert.ToInt32(Request["id"] == null ? "0" : Request["id"]));
             TextBox_title.Text   = Model.name;
             TextBox_miaoshu.Text = Model.tag;
         }
         else
         {
             TextBox_title.Visible    = false;
             TextBox_miaoshu.Visible  = false;
             Label1.Visible           = false;
             Label2.Visible           = false;
             Label_title.Text         = "默认模板编辑";
             Label_title_content.Text = "模板名 - " + Request["type"];
         }
         try
         {
             TextBox_HTML.Text = SystemCms.Read_File(Server.MapPath(ROYcms.Config.ROYcmsConfig.GetCmsConfigValue("templet_root") + Session["template_z_path"].ToString() + Request["type"] + Request["id"] + ".html"), ROYcms.Config.ROYcmsConfig.GetCmsConfigValue("templet_language"));
         }
         catch
         {
             TextBox_HTML.Text = Model.htmlcontent;
         }
     }
 }
Exemple #4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(ROYcms.Sys.Model.ROYcms_template model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update " + PubConstant.date_prefix + "template set ");
            strSql.Append("z_id=" + model.z_id + ",");
            strSql.Append("name='" + model.name + "',");
            strSql.Append("tag='" + model.tag + "',");
            strSql.Append("htmlcontent='" + model.htmlcontent + "',");
            strSql.Append("htmltimes='" + model.htmltimes + "',");
            strSql.Append("class_name='" + model.class_name + "',");
            strSql.Append("y=" + model.y + "");
            strSql.Append(" where bh=" + model.bh + " ");
            ROYcms.DB.DbHelpers.NonQuery(strSql.ToString());
        }
Exemple #5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ROYcms.Sys.Model.ROYcms_template GetModel(int bh)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1  ");
            strSql.Append(" bh,z_id,name,tag,htmlcontent,htmltimes,class_name,y ");
            strSql.Append(" from " + PubConstant.date_prefix + "template ");
            strSql.Append(" where bh=" + bh + " and  y = '0'");
            ROYcms.Sys.Model.ROYcms_template model = new ROYcms.Sys.Model.ROYcms_template();
            DataSet ds = DbHelperSQL.Query(strSql.ToString());

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["bh"].ToString() != "")
                {
                    model.bh = int.Parse(ds.Tables[0].Rows[0]["bh"].ToString());
                }
                if (ds.Tables[0].Rows[0]["z_id"].ToString() != "")
                {
                    model.z_id = int.Parse(ds.Tables[0].Rows[0]["z_id"].ToString());
                }
                model.name        = ds.Tables[0].Rows[0]["name"].ToString();
                model.tag         = ds.Tables[0].Rows[0]["tag"].ToString();
                model.htmlcontent = ds.Tables[0].Rows[0]["htmlcontent"].ToString();
                if (ds.Tables[0].Rows[0]["htmltimes"].ToString() != "")
                {
                    model.htmltimes = DateTime.Parse(ds.Tables[0].Rows[0]["htmltimes"].ToString());
                }
                model.class_name = ds.Tables[0].Rows[0]["class_name"].ToString();
                if (ds.Tables[0].Rows[0]["y"].ToString() != "")
                {
                    model.y = int.Parse(ds.Tables[0].Rows[0]["y"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }