/* SHUTDOWN -- Call this to exit gracefully from the whole cl; never return. * Write out any remaining PF_UPDATE'd pfiles by restoring topd to just above * first task unless we are in batch mode, then just flush io and die.. * So that the restor will include the cl's pfile and any other pfiles that * might have been cached or assigned into, we force its topd to be * below its pfile head. See the "pfp < topdp" loop in restor(). * Don't bother with restor'ing if BATCH since we don't want to write out * anything then anyway. */ static void shutdown (void) { float cpu, clk; pr_dumpcache (0, YES); /* flush process cache */ clgflush(); /* flush graphics output */ if (firstask->t_flags & T_BATCH) { iofinish (currentask); if (notify()) { cpu = (float)c_cputime(cpustart) / 1000.; clk = (float)c_clktime(clkstart); fprintf (stderr, "\n[%d] done %.1f %.0m %d%%\n", bkgno, cpu, clk/60., (int)((clk > 0 ? cpu / clk : 0.) * 100.)); } } else { firstask->t_topd = dereference (firstask->t_ltp) + LTASKSIZ; restor (firstask); } yy_startblock (LOG); /* flush and close log */ close_logfile (logfile()); clexit(); }
/* ONEOF -- "on eof" (not "one of"): * The current task has issued eof, either directly or via the "bye" command. * Flush out all pending io, copy working pfile back to original if have one, * pop a state back to the previous state and restore its environment. * Avoid calling effecmode() if called from a builtin task since builtins * do not have the "mode" parameter. * * If currentask is the first cl or we are batch, then we are truely done. * Return true to the caller (EXECUTE), causing a return to the main. */ void oneof (void) { register struct pfile *pfp; register struct package *pkp; static int nerrs = 0; int flags; if (cldebug) eprintf ("received `%s' from `%s'\n", yeof ? "eof" : "bye", currentask == firstask ? "root" : currentask->t_ltp->lt_lname); if (!(firstask->t_flags & T_BATCH)) if (currentask == firstask && !gologout && !loggingout && isatty (fileno (stdin)) && nerrs++ < 8) cl_error (E_UERR, "use `logout' to log out of the CL"); flags = currentask->t_flags; if (!(flags & (T_BUILTIN|T_CL|T_SCRIPT|T_BATCH))) fflush (currentask->t_out); iofinish (currentask); /* Copy back the main pfile and any pset-param files. If the task * which has terminated is a package script task, fix up the pfile * pointer in the package descriptor to point to the updated pset. */ if (currentask->t_ltp->lt_flags & LT_PFILE) { pfcopyback (pfp = currentask->t_pfp); if (currentask->t_ltp->lt_flags & LT_DEFPCK) if ((pkp = pacfind(currentask->t_ltp->lt_lname))) if (pkp->pk_pfp == pfp) pkp->pk_pfp = pfp->pf_oldpfp; for (pfp = pfp->pf_npset; pfp != NULL; pfp = pfp->pf_npset) pfcopyback (pfp); } if (currentask == firstask) alldone = 1; else { currentask = poptask(); if (currentask->t_flags & T_BATCH) alldone = 1; } restor (currentask); /* restore environment */ }
void PayBack::on_pushButton_clicked() { if(ui->lineEdit->text().isEmpty()) { QMessageBox::warning(this,"Error","You must complete all fields"); return ; } if(ui->lineEdit->text().toFloat() > loan) { QMessageBox::warning(this,"Error","You cannot pay more than you owe"); return ; } QString historyCommand; QString accountCommand; historyCommand += "insert into records values ("+ key + QString(",0,0,0,") + ui->lineEdit->text() + QString(",\'") + ui->dateEdit->text() + QString("\'") + QString(");"); accountCommand += "update accounts set loan=loan-" + ui->lineEdit->text() + QString(" where id=") + key; QSqlQuery query1(historyCommand); if(query1.lastError().isValid()) { QMessageBox::warning(this,"PayBack recording Error",query1.lastError().text()); return ; } QSqlQuery query2(accountCommand); if(query2.lastError().isValid()) { QMessageBox::warning(this,"Account update Error",query2.lastError().text()); return ; } if(ui->lineEdit->text().toFloat() == loan) { QSqlQuery query("update accounts set date_due=NULL where id=" + key); while(query.lastError().isValid()) { QMessageBox::warning(this,"sql Error",query.lastError().text()); return ; } QSqlQuery query1("updaet surtee set surtee1=NULL, surtee2=NULL, surtee3=NULL where id=" + key); if(query.lastError().isValid()) { QMessageBox::warning(this,"Update surtee error",query.lastError().text()); return ; } QSqlQuery restor("delete from surtee where id=" + key); if(restor.lastError().isValid()) { QMessageBox::warning(this,"restor surtee error",restor.lastError().text()); return ; } } QMessageBox::information(this,"Success","Operation Successful"); close(); }