예제 #1
0
        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;
            //}
        }
예제 #2
0
 public OperateResult UpdateTable(Table table, TableColumn[] columns)
 {
     return dal.UpdateTable(table, columns);
 }
예제 #3
0
        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;
        }
예제 #4
0
 public OperateResult AddTable(Table table, TableColumn[] columns)
 {
     return dal.AddTable(table, columns);
 }