int main() { MYSQL conn; MYSQL_RES *res_ptr; MYSQL_ROW sql_row; mysql_init(&conn); if(mysql_real_connect(&conn, "localhost", "jow", "ishu0302", "CDmanagement", 0, NULL, 0)) { show_menu("Oops", char **menu); char ch; ch = getchar(); while (ch != 'q') { switch(ch) { case 'a': add_cd(conn); break; case 'f': find_cd_by_title(conn); break; case 'c': count_cds(conn); break; default: printf("Select error, se;ect again\n"); break; } ch = getchar(); show_menu("Ops", char **menu); } }
void AddCdDialog::okClicked() { char artist[200]; char title[200]; char catalogue[200]; int cd_id = 0; strcpy(artist, artist_entry->text()); strcpy(title, title_entry->text()); strcpy(catalogue, catalogue_entry->text()); add_cd(artist, title, catalogue, &cd_id); }
int main() { struct current_cd_st cd; struct cd_search_st cd_res; struct current_tracks_st ct; int cd_id; int res, i; /* The first thing your app must always do is initialize a database connection, providing a valid user name and password */ database_start("root", "weiyi"); /* Then you test adding a CD: */ res = add_cd("Bu Yi", "He Bu Wan De Jiu", "201407301321", &cd_id); printf("Result of adding a cd was %d, cd_id is %d\n", res, cd_id); memset(&ct, 0, sizeof(ct)); ct.cd_id = cd_id; strcpy(ct.track[0], "San Feng"); strcpy(ct.track[1], "Yang Rou Mian"); strcpy(ct.track[2], "Na Me Jiu"); add_tracks(&ct); /* Now search for the CD and retrieve information from the first CD found */ res = find_cds("Jiu", &cd_res); printf("Found %d cds, first has ID %d\n", res, cd_res.cd_id[0]); res = get_cd(cd_res.cd_id[0], &cd); printf("get_cd returned %d\n", res); memset(&ct, 0, sizeof(ct)); res = get_cd_tracks(cd_res.cd_id[0], &ct); printf("get_cd_tracks returned %d\n", res); printf("Title: %s\n", cd.title); i = 0; while (i < res) { printf("\ttrack %d is %s\n", i, ct.track[i]); i++; } /* Finally, delete the CD */ res = delete_cd(cd_res.cd_id[0]); printf("delete_cd returned %d\n", res); /* Then disconnect and exit */ database_end(); return EXIT_SUCCESS; }
int main(void) { struct current_cd_st cd; struct cd_search_st cd_res; struct current_tracks_st ct; int cd_id; int res, i; database_start(NULL, NULL); res = add_cd("Mahler", "Symphony No 1", "4596102", &cd_id); printf("Result of adding a cd was %d, cd_id is %d\n", res, cd_id); memset(&ct, 0, sizeof(ct)); ct.cd_id = cd_id; strcpy(ct.track[0], "Langsam Schleppend"); strcpy(ct.track[1], "Kraftig bewegt"); strcpy(ct.track[2], "Feirelich und gemessen"); strcpy(ct.track[3], "Sturmish bewegt"); add_tracks(&ct); res = find_cds("Symphony", &cd_res); printf("Found %d cds, first has ID %d\n", res, cd_res.cd_id[0]); res = get_cd(cd_res.cd_id[0], &cd); printf("get_cd returned %d\n", res); memset(&ct, 0, sizeof(ct)); res = get_cd_tracks(cd_res.cd_id[0], &ct); printf("get_cd tracks returned %d\n", res); printf("Title: %s\n", cd.title); i = 0; while(i < res) { printf("\t tracks %d is %s\n", i, ct.track[i]); i++; } res = delete_cd(cd_res.cd_id[0]); printf("Delete_cd returned %d\n", res); database_end(); return EXIT_SUCCESS; }
void addDocument::on_buttonBox_accepted() { std::string title, autor, editor, resume, style, actor; int editorYear, pisteNumber; if(ui->le_title->text() == "") { QMessageBox::information(this, tr("Add cancel"), tr("You must write an title to addind a document !"), QMessageBox::Ok); } else { title = ui->le_title->text().toStdString(); autor = ui->le_autor->text().toStdString(); editor = ui->le_editor->text().toStdString(); resume = ui->le_resume->toPlainText().toStdString(); style = ui->le_style->text().toStdString(); actor = ui->le_actor->text().toStdString(); editorYear = ui->le_editorYear->text().toInt(); pisteNumber = ui->le_pisteNumber->text().toInt(); if(ui->cb_type->currentIndex() == 0) //add a book { Book* doc = new Book(title,autor,resume,editorYear, editor); add_book(doc); myLib->push_back(doc); QMessageBox::information(this, tr("Add"), tr("Your document is add !"), QMessageBox::Ok); } else if(ui->cb_type->currentIndex() == 1) //add a CD { CD* doc = new CD(title,autor,style,pisteNumber); add_cd(doc); myLib->push_back(doc); QMessageBox::information(this, tr("Add"), tr("Your document is add !"), QMessageBox::Ok); } else if(ui->cb_type->currentIndex() == 2)//add a Movie { Movie* doc = new Movie(title,autor,resume,style,autor); add_movie(doc); myLib->push_back(doc); QMessageBox::information(this, tr("Add"), tr("Your document is add !"), QMessageBox::Ok); } } }