/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { Repeater_admin.DataSource = Index.Bll.GetAllList(); Repeater_admin.DataBind(); if (Request["id"] != null) { Model = BLL.GetModel(Convert.ToInt32(Request["id"])); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { if (Request["id"] != null) { Model = ___ROYcms_Objet_bll.GetModel(Convert.ToInt32(Request["id"])); } //else { Model.Title = "11111111"; } }
/// <summary> /// 得到一个对象实体 /// </summary> public ROYcms.Sys.Model.ROYcms_Objet GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 * from " + PubConstant.date_prefix + "Objet "); strSql.Append(" where id=@id "); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; ROYcms.Sys.Model.ROYcms_Objet model = new ROYcms.Sys.Model.ROYcms_Objet(); 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(); if (ds.Tables[0].Rows[0]["ClassKind"].ToString() != "") { model.ClassKind = Convert.ToInt32(ds.Tables[0].Rows[0]["ClassKind"].ToString()); } model.zhaiyao = ds.Tables[0].Rows[0]["zhaiyao"].ToString(); model.logo = ds.Tables[0].Rows[0]["logo"].ToString(); model.AppendixConfig = ds.Tables[0].Rows[0]["AppendixConfig"].ToString(); model.AppendixPath = ds.Tables[0].Rows[0]["AppendixPath"].ToString(); if (ds.Tables[0].Rows[0]["Visible"].ToString() != "") { model.Visible = int.Parse(ds.Tables[0].Rows[0]["Visible"].ToString()); } model.Role = ds.Tables[0].Rows[0]["Role"].ToString(); if (ds.Tables[0].Rows[0]["Time"].ToString() != "") { model.Time = DateTime.Parse(ds.Tables[0].Rows[0]["Time"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(ROYcms.Sys.Model.ROYcms_Objet model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into " + PubConstant.date_prefix + "Objet("); strSql.Append("Title,ClassKind,zhaiyao,logo,AppendixConfig,AppendixPath,Visible,Role,Time)"); strSql.Append(" values ("); strSql.Append("@Title,@ClassKind,@zhaiyao,@logo,@AppendixConfig,@AppendixPath,@Visible,@Role,@Time)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@Title", SqlDbType.VarChar, 50), new SqlParameter("@ClassKind", SqlDbType.Int, 4), new SqlParameter("@zhaiyao", SqlDbType.VarChar, 50), new SqlParameter("@logo", SqlDbType.VarChar, 50), new SqlParameter("@AppendixConfig", SqlDbType.VarChar, 50), new SqlParameter("@AppendixPath", SqlDbType.VarChar, 50), new SqlParameter("@Visible", SqlDbType.Int, 4), new SqlParameter("@Role", SqlDbType.VarChar, 50), new SqlParameter("@Time", SqlDbType.DateTime) }; parameters[0].Value = model.Title; parameters[1].Value = model.ClassKind; parameters[2].Value = model.zhaiyao; parameters[3].Value = model.logo; parameters[4].Value = model.AppendixConfig; parameters[5].Value = model.AppendixPath; parameters[6].Value = model.Visible; parameters[7].Value = model.Role; parameters[8].Value = model.Time; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(1); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 更新一条数据 /// </summary> public void Update(ROYcms.Sys.Model.ROYcms_Objet model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update " + PubConstant.date_prefix + "Objet set "); strSql.Append("Title=@Title,"); strSql.Append("ClassKind=@ClassKind,"); strSql.Append("zhaiyao=@zhaiyao,"); strSql.Append("logo=@logo,"); strSql.Append("AppendixConfig=@AppendixConfig,"); strSql.Append("AppendixPath=@AppendixPath,"); strSql.Append("Visible=@Visible,"); strSql.Append("Role=@Role,"); strSql.Append("Time=@Time"); strSql.Append(" where id=@id "); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4), new SqlParameter("@Title", SqlDbType.VarChar, 50), new SqlParameter("@ClassKind", SqlDbType.Int, 4), new SqlParameter("@zhaiyao", SqlDbType.VarChar, 50), new SqlParameter("@logo", SqlDbType.VarChar, 50), new SqlParameter("@AppendixConfig", SqlDbType.VarChar, 50), new SqlParameter("@AppendixPath", SqlDbType.VarChar, 50), new SqlParameter("@Visible", SqlDbType.Int, 4), new SqlParameter("@Role", SqlDbType.VarChar, 50), new SqlParameter("@Time", SqlDbType.DateTime) }; parameters[0].Value = model.id; parameters[1].Value = model.Title; parameters[2].Value = model.ClassKind; parameters[3].Value = model.zhaiyao; parameters[4].Value = model.logo; parameters[5].Value = model.AppendixConfig; parameters[6].Value = model.AppendixPath; parameters[7].Value = model.Visible; parameters[8].Value = model.Role; parameters[9].Value = model.Time; DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); }