public OperateResult AddTable(Table table, TableColumn[] columns) { // try // { int tableID = 0; base.ExecuteReader( new SqlQuery(base.OptimizeSql(DbSql.Table_GetTableIDByName), new object[,]{ {"@name",table.Name} }), rd => { if (rd.Read()) { tableID = rd.GetInt32(0); } } ); if (tableID != 0) { return OperateResult.Exists; } int rowcount = base.ExecuteNonQuery( new SqlQuery(base.OptimizeSql(DbSql.Table_Add), new object[,]{ {"@name",table.Name}, {"@note", table.Note}, {"@apiserver", table.ApiServer}, {"@issystem", table.IsSystem}, {"@available", table.Available} }) ); //添加表单成功 if (rowcount == 1) { base.ExecuteReader( new SqlQuery(base.OptimizeSql(DbSql.Table_GetTableIDByName), new object[,]{ {"@name",table.Name} }), rd => { if (rd.Read()) { tableID = rd.GetInt32(0); } } ); //添加列 if (columns != null) { foreach (TableColumn col in columns) { base.ExecuteNonQuery( new SqlQuery(base.OptimizeSql(DbSql.Table_CreateColumn), new object[,]{ {"@tableid", tableID}, {"@name", col.Name}, {"@note", col.Note}, {"@validformat", col.ValidFormat}, {"@orderindex", col.OrderIndex} }) ); } } return OperateResult.Success; } else { return OperateResult.Fail; } //} // catch(Exception ex) // { // return OperateResult.Except; //} }
public OperateResult UpdateTable(Table table, TableColumn[] columns) { return dal.UpdateTable(table, columns); }
public OperateResult UpdateTable(Table table, TableColumn[] columns) { int tableID = 0; base.ExecuteReader( new SqlQuery(base.OptimizeSql(DbSql.Table_GetTableIDByName), new object[,]{ {"@name", table.Name} }), rd => { if (rd.Read()) { tableID = rd.GetInt32(0); } } ); if (tableID != 0 && tableID != table.Id) { return OperateResult.Exists; } int rowcount = base.ExecuteNonQuery( new SqlQuery(base.OptimizeSql(DbSql.Table_Update), new object[,]{ {"@name", table.Name}, {"@note", table.Note}, {"@apiserver", table.ApiServer}, {"@issystem", table.IsSystem}, {"@available", table.Available}, {"@tableid", table.Id} }) ); return rowcount == 1 ? OperateResult.Success : OperateResult.Fail; }
public OperateResult AddTable(Table table, TableColumn[] columns) { return dal.AddTable(table, columns); }