void studentinfo::on_pushButton_2_clicked() { CancelBookingStatus(); displaysBookingStatus(); display_main(); }
void studentinfo::on_pushButton_booking_clicked() { QString temp; qry=new QSqlQuery(mydb); qry->prepare("select PersonBook from DataInfo"); qry->exec(); if(qry->next()) { if(qry->value(0).toString()==Username){ QMessageBox::warning(this,tr("Attention"),tr("You have already book for an apointment,if you want to change the sechedule,you need to cancel it first!")); }else{ updateLoginInfo(); display_main(); } } }
studentinfo::studentinfo(QString Name,QWidget *parent) : QDialog(parent), ui(new Ui::studentinfo) { ui->setupUi(this); Username=Name; if(!connOpen()) ui->label_stu_status->setText("Failed to open the database!"); else ui->label_stu_status->setText("Connected....."); // show the name of student ui->label_name->setText(Name); // display the status of booking displaysBookingStatus(); // display the date that is available for book display_main(); }
int main (int argc, char ** argv) { g_type_init (); return display_main (argv, argc); }
int main(int argc, char **argv) { options_t options = { 0, }; char *validity_str = NULL; libabac_init(); subjects = xmalloc(sizeof(subject_t) * 2); subjects_size = 2; roles = xmalloc(sizeof(char *) * 2); roles_size = 2; struct option getopts[] = { { "help", 0, &options.help, 1 }, { "generate", 0, &options.mode, MODE_GENERATE }, { "verify", 0, &options.mode, MODE_VERIFY }, { "keyid", 0, &options.mode, MODE_KEYID }, { "attribute", 0, &options.mode, MODE_ATTRIBUTE }, { "roles", 0, &options.mode, MODE_ROLES }, { "version", 0, &options.mode, MODE_VERSION }, { "display", 0, &options.mode, MODE_DISPLAY }, { "cert", 1, 0, OPT_CERT }, // generate options { "cn", 1, 0, OPT_CN }, { "validity", 1, 0, OPT_VALIDITY }, // attribute options { "issuer", 1, 0, OPT_ISSUER }, { "key", 1, 0, OPT_KEY }, { "role", 1, 0, OPT_ROLE }, { "subject-cert", 1, 0, OPT_SUBJECT_CERT }, { "subject-id", 1, 0, OPT_SUBJECT_ID }, { "subject-role", 1, 0, OPT_SUBJECT_ROLE }, { "out", 1, 0, OPT_OUT }, // attribute_rule option { "attrrule", 1, 0, OPT_ATTRRULE }, // verify option { "attrcert", 1, 0, OPT_ATTRCERT }, // display options { "show", 1, 0, OPT_SHOW }, { NULL }, }; for ( ; ; ) { int c = getopt_long(argc, argv, "", getopts, NULL); if (c < 0) break; switch (c) { // set the option from the value in the getopts struct case 0: continue; case OPT_CERT: options.cert = xstrdup(optarg); break; // generate options case OPT_CN: options.cn = xstrdup(optarg); break; case OPT_VALIDITY: // also an attribute option validity_str = xstrdup(optarg); break; // attribute options case OPT_ISSUER: options.issuer = xstrdup(optarg); break; case OPT_KEY: // also an generate option options.key = xstrdup(optarg); break; case OPT_ROLE: options.role = xstrdup(optarg); break; case OPT_SUBJECT_CERT: subject(xstrdup(optarg), 1); break; case OPT_SUBJECT_ID: subject(xstrdup(optarg), 0); break; case OPT_SUBJECT_ROLE: role(xstrdup(optarg)); break; case OPT_OUT: options.out = xstrdup(optarg); break; // attribute rule options case OPT_ATTRRULE: options.attrrule = xstrdup(optarg); break; // verify options case OPT_ATTRCERT: options.attrcert = xstrdup(optarg); break; // display options case OPT_SHOW: options.show = xstrdup(optarg); break; case '?': break; default: printf("wat\n"); return 45; } } if (options.help || optind < argc) { if (optind > 0 && optind < argc) printf("I don't understand %s\n", argv[optind]); usage(&options); } // parse the validity if (validity_str != NULL) { char suffix = 'd'; // default suffix is days int multiplier; int len = strlen(validity_str); assert(len > 0); // get the suffix char if it's alphabetical if (isalpha(validity_str[len - 1])) { suffix = validity_str[len - 1]; // truncate validity_str[len - 1] = '\0'; --len; // make sure it's not only a suffix if (len == 0) { printf("Invalid validity\n"); usage(&options); } } // convert the suffix to a multiplier switch(suffix) { case 's': multiplier = 1; break; case 'm': multiplier = 60; break; case 'h': multiplier = 3600; break; case 'd': multiplier = 86400; break; case 'y': multiplier = 31536000; break; default: printf("Invalid suffix, must be s m h d y\n"); usage(&options); } // ascii to int char *end; options.validity = strtol(validity_str, &end, 10); if (errno != 0 || end - validity_str < len) { printf("Invalid validity\n"); usage(&options); } if (options.validity <= 0) { printf("Invalid validity: must be > 0\n"); usage(&options); } // multiply! options.validity *= multiplier; free(validity_str); } if (options.mode == MODE_ATTRIBUTE && options.attrrule == NULL) { int i; // have to do error checking on subjects here if ( (num_subjects == 0) || (num_subjects != num_roles && num_subjects != 1 && num_roles != 0) ) { printf( "You have %d subject%s and %d role%s, which is invalid\n", num_subjects, num_subjects == 1 ? "" : "s", num_roles, num_roles == 1 ? "" : "s" ); usage(&options); } for (i = 0; i < num_roles; ++i) subjects[i].role = roles[i]; free(roles); options.subjects = subjects; options.num_subjects = num_subjects; } // launch the sub command switch (options.mode) { case MODE_GENERATE: if (options.validity == 0) options.validity = 1080 * 86400; generate_main(&options); break; case MODE_KEYID: keyid_main(&options); break; case MODE_ATTRIBUTE: if (options.validity == 0) options.validity = 365 * 86400; if(options.attrrule) attribute_rule_main(&options); else attribute_main(&options); break; case MODE_ROLES: roles_main(&options); break; case MODE_VERIFY: verify_main(&options); break; case MODE_DISPLAY: display_main(&options); break; case MODE_VERSION: printf("ABAC/creddy " ABAC_VERSION "\n"); break; default: usage(&options); } return 0; }