Fix SQLite request bugs and accomlish all the logic design in main window.