fix some function in database class
and fix datagrid pagination