Beispiel #1
0
 public OperateResult UpdateTable(Table table, TableColumn[] columns)
 {
     return dal.UpdateTable(table, columns);
 }
Beispiel #2
0
        public OperateResult AddTable(Table table, TableColumn[] columns)
        {
            // try
            // {

            int tableID = 0;

            base.ExecuteReader(
                 new SqlQuery(base.OptimizeSQL(SP.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(SP.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(SP.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(SP.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;
            //}
        }
Beispiel #3
0
 public OperateResult AddTable(Table table, TableColumn[] columns)
 {
     return dal.AddTable(table, columns);
 }
Beispiel #4
0
        public OperateResult UpdateTable(Table table, TableColumn[] columns)
        {
            int tableID = 0;
            base.ExecuteReader(
                     new SqlQuery(base.OptimizeSQL(SP.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(SP.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;
        }