//add void Add_Scientist::on_add_clicked() { bool valid = true; string tmpname = ui->FirstName->text().toStdString(); string tmpmid = ui->MidName->text().toStdString(); string tmplast = ui->LastName->text().toStdString(); string tmpgender = ui->Gender->text().toStdString(); QString tmpyearborn = ui->YearBorn->text(); QString tmpyeardied = ui->Yeardied->text(); Refresh(); //Error checking if(!help.CheckValidtyOfString(tmpname)) { valid = false; ui->first_label->setText("<font color='red'>First Name*</font>"); } if(!help.CheckValidtyOfString(tmplast)) { valid = false; ui->last_lable->setText("<font color='red'>Last Name*</font>"); } if((!help.CheckValidtyOfString(tmpmid)) && (!tmpmid.empty())) { valid = false; ui->middle_label->setText("<font color='red'>Middle Name</font>"); } if(!(tmpyearborn.toInt()) || (tmpyearborn.toInt() > help.CurrentYear()) || (tmpyearborn.toInt() < 0)) { valid = false; ui->born_lable->setText("<font color='red'>Year Born*</font>"); } if((tmpyearborn.toInt() > tmpyeardied.toInt()) && !tmpyeardied.isEmpty()) { valid = false; ui->dead_lable->setText("<font color='red'>Year Died</font>"); } help.Tolower(tmpgender); if(!((tmpgender == "male") || (tmpgender == "female"))) { valid = false; ui->gender_lable->setText("<font color='red'>Gender*</font>"); } if(valid == true) { ComputerScientist cstemp; cstemp.setFirst(tmpname); cstemp.setMid(tmpmid); cstemp.setLast(tmplast); cstemp.setgender(tmpgender); cstemp.setbday(tmpyearborn.toInt()); cstemp.setdday(tmpyeardied.toInt()); d.AddComputerScientist(cstemp); this->done(1); } }
void SQLQueryData::FillcsVector(QSqlQuery& query, vector<ComputerScientist> &temp) { //Loop through and fill vector with ComputerScientists. while(query.next()) { ComputerScientist tmp; tmp.setID(query.value("id").toInt()); tmp.setFirst(query.value("first_name").toString().toStdString()); tmp.setMid((query.value("middle_name").toString().toStdString())); tmp.setLast(query.value("last_name").toString().toStdString()); tmp.setgender((query.value("gender").toString().toStdString())); tmp.setbday((query.value("birth_year").toInt())); tmp.setdday((query.value("death_year").toInt())); temp.push_back(tmp); } temp.shrink_to_fit(); }