/// <summary> /// 自定义模型数据添加或编辑一条数据 /// </summary> /// <param name="Id"></param> /// <param name="Class"></param> /// <param name="r"></param> /// <returns></returns> public int AdminCustom(int Id, int Class, int r) { int PER = 0; string TableName = CustomBLL.GetTableName(Class); if (TableName != null) { CustomModel = CustomBLL.SetVal(this, Id, Class); CustomModel.TableName = TableName; if (CustomBLL.Exists(Id, TableName)) //判断自定义模型内是否存在该记录 存在则编辑 不存在则删除 { if (r == 0) //添加 { PER = CustomBLL.Add(CustomModel); } else //编辑 { PER = CustomBLL.Update(CustomModel); } } else { PER = CustomBLL.Add(CustomModel); } } else { PER = 1; } return(PER); }
/// <summary> /// /// </summary> /// <param name="models"></param> /// <returns></returns> public int CreateTable(ROYcms.Sys.Model.ROYcms_Custom models) { //判断数据库表是否存在语句 select * from master.dbo.sysdatabases where name='表名' string CreateTableSql = "create table " + models.TableName + " (" + models.Tablelist + ");"; return(DbHelperSQL.ExecuteSql(CreateTableSql)); }
/// <summary> /// 加载... /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { Model = BLL.SetVal(this, 0, 0); Response.ContentType = "text/plain"; Model.TableName = "ROYcms_Model_news0001"; Response.Write(BLL.Update(Model)); // }
/// <summary> /// 更新一条数据 /// </summary> /// <param name="models"></param> /// <returns></returns> public int Update(ROYcms.Sys.Model.ROYcms_Custom models) { string UpdateSql = "update " + models.TableName + " set " + models.UpdateList + " where Id =" + models.newid; return(DbHelperSQL.ExecuteSql(UpdateSql)); }
/// <summary> /// 插入一条数据根据表单结构 /// </summary> /// <param name="models"></param> /// <returns></returns> public int Add(ROYcms.Sys.Model.ROYcms_Custom models) { string InsertSql = "insert into " + models.TableName + " (" + models.Tlist + ") values (" + models.InsertList + ")"; return(DbHelperSQL.ExecuteSql(InsertSql)); }