/// <summary> /// 得到一个对象实体 /// </summary> public ROYcms.Sys.Model.ROYcms_TemplateGroup GetModel(int bh) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 "); strSql.Append(" bh,z_name,z_path,z_url,z_content,z_time "); strSql.Append(" from " + PubConstant.date_prefix + "TemplateGroup "); strSql.Append(" where bh=" + bh + " "); ROYcms.Sys.Model.ROYcms_TemplateGroup model = new ROYcms.Sys.Model.ROYcms_TemplateGroup(); DataSet ds = ROYcms.DB.DbHelpers.GetDataSet(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()); } model.z_name = ds.Tables[0].Rows[0]["z_name"].ToString(); model.z_path = ds.Tables[0].Rows[0]["z_path"].ToString(); model.z_url = ds.Tables[0].Rows[0]["z_url"].ToString(); model.z_content = ds.Tables[0].Rows[0]["z_content"].ToString(); if (ds.Tables[0].Rows[0]["z_time"].ToString() != "") { model.z_time = DateTime.Parse(ds.Tables[0].Rows[0]["z_time"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(ROYcms.Sys.Model.ROYcms_TemplateGroup model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into " + PubConstant.date_prefix + "TemplateGroup("); strSql.Append("z_name,z_path,z_url,z_content,z_time"); strSql.Append(")"); strSql.Append(" values ("); strSql.Append("'" + model.z_name + "',"); strSql.Append("'" + model.z_path + "',"); strSql.Append("'" + model.z_url + "',"); strSql.Append("'" + model.z_content + "',"); strSql.Append("'" + model.z_time + "'"); strSql.Append(")"); strSql.Append(";select @@IDENTITY"); object obj = ROYcms.DB.DbHelpers.GetSingle(strSql.ToString()); if (obj == null) { return(1); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { LIST_bind(); ButEdit.Visible = false; if (Request["t"] == "del") { //删除模板文件夹 ROYcms.Sys.Model.ROYcms_TemplateGroup _model = bll.GetModel(Convert.ToInt32(Request["bh"])); Directory.Delete(Server.MapPath("~/" + ROYcms.Config.ROYcmsConfig.GetCmsConfigValue("templet_root") + "/" + _model.z_path + "/"), true); del(Convert.ToInt32(Request["bh"])); } if (Request["t"] == "edit") { btnAdd.Visible = false; ButEdit.Visible = true; ShowInfo(Convert.ToInt32(Request["bh"])); } if (Request["t"] == "show") { btnAdd.Visible = false; ButEdit.Visible = false; btnCancel.Visible = false; ShowInfo(Convert.ToInt32(Request["bh"])); this.txtz_name.ReadOnly = true; this.txtz_path.ReadOnly = true; this.txtz_url.ReadOnly = true; this.txtz_content.ReadOnly = true; } } }
/// <summary> /// /// </summary> /// <param name="bh"></param> private void ShowInfo(int bh) { ROYcms.Sys.Model.ROYcms_TemplateGroup model = bll.GetModel(bh); this.txtz_name.Text = model.z_name; this.txtz_path.Text = model.z_path; this.txtz_url.Text = model.z_url; this.txtz_content.Text = model.z_content; }
/// <summary> /// 更新一条数据 /// </summary> public void Update(ROYcms.Sys.Model.ROYcms_TemplateGroup model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update " + PubConstant.date_prefix + "TemplateGroup set "); strSql.Append("z_name='" + model.z_name + "',"); strSql.Append("z_path='" + model.z_path + "',"); strSql.Append("z_url='" + model.z_url + "',"); strSql.Append("z_content='" + model.z_content + "',"); strSql.Append("z_time='" + model.z_time + "'"); strSql.Append(" where bh=" + model.bh + " "); ROYcms.DB.DbHelpers.NonQuery(strSql.ToString()); }
/// <summary> /// /// </summary> void ADD() { /******************************增加窗体代码********************************/ string strErr = ""; if (this.txtz_name.Text == "") { strErr += "模板方案组名称不能为空!\\n"; } if (this.txtz_path.Text == "") { strErr += "模板文件夹不能为空!\\n"; } if (this.txtz_url.Text == "") { strErr += "模板绑定地址不能为空!\\n"; } if (this.txtz_content.Text == "") { strErr += "模板组方案描述不能为空!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } string z_name = this.txtz_name.Text; string z_path = this.txtz_path.Text; string z_url = this.txtz_url.Text; string z_content = this.txtz_content.Text; DateTime z_time = DateTime.Now; ROYcms.Sys.Model.ROYcms_TemplateGroup model = new ROYcms.Sys.Model.ROYcms_TemplateGroup(); model.z_name = z_name; model.z_path = z_path; model.z_url = z_url; model.z_content = z_content; model.z_time = z_time; bll.Add(model); ROYcms.Sys.Model.ROYcms_TemplateGroup _model = bll.GetModel(Convert.ToInt32(Request["bh"])); if (!Directory.Exists(Server.MapPath("~/" + ROYcms.Config.ROYcmsConfig.GetCmsConfigValue("templet_root") + "/" + z_path + "/"))) { Directory.CreateDirectory(Server.MapPath("~/" + ROYcms.Config.ROYcmsConfig.GetCmsConfigValue("templet_root") + "/" + z_path + "/")); } }
/// <summary> /// /// </summary> void UPDATE() { /*修改代码-提交更新 */ string strErr = ""; if (this.txtz_name.Text == "") { strErr += "模板方案组名称不能为空!\\n"; } if (this.txtz_path.Text == "") { strErr += "模板文件夹不能为空!\\n"; } if (this.txtz_url.Text == "") { strErr += "模板绑定地址不能为空!\\n"; } if (this.txtz_content.Text == "") { strErr += "模板组方案描述不能为空!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } string z_name = this.txtz_name.Text; string z_path = this.txtz_path.Text; string z_url = this.txtz_url.Text; string z_content = this.txtz_content.Text; DateTime z_time = DateTime.Now; ROYcms.Sys.Model.ROYcms_TemplateGroup model = new ROYcms.Sys.Model.ROYcms_TemplateGroup(); model.bh = Convert.ToInt32(Request["bh"]); model.z_name = z_name; model.z_path = z_path; model.z_url = z_url; model.z_content = z_content; model.z_time = z_time; bll.Update(model); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void template_f_SelectedIndexChanged(object sender, EventArgs e) { if (template_f.SelectedValue != "") { ROYcms.Sys.Model.ROYcms_TemplateGroup model = _bll.GetModel(Convert.ToInt32(template_f.SelectedValue)); Session["template_z_id"] = model.bh; Session["template_z_name"] = model.z_name; Session["template_z_path"] = model.z_path; Session["template_z_url"] = model.z_url; } else { Session["template_z_id"] = "0"; Session["template_z_name"] = "默认方案"; Session["template_z_path"] = "default"; Session["template_z_url"] = "~/"; } listBing(); }
/// <summary> /// 更新一条数据 /// </summary> public void Update(ROYcms.Sys.Model.ROYcms_TemplateGroup model) { dal.Update(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(ROYcms.Sys.Model.ROYcms_TemplateGroup model) { return(dal.Add(model)); }