Пример #1
0
/* Creates and sends message.*/
void twitClient::createAndSendMessage(char command[],const std::string& other)
{
    char* msg = new char[PACKAGE_SIZE];
    resetMessage(msg);
    fillMessage(msg,command,other);
    sendMessage(msg);
    delete[] (msg);
}
Пример #2
0
void loop() {
  if (lastbytein != 0xFF && dataIO == DOUT) {
    counter = 0;
    noInterrupts();
    Serial.println(lastbytein, HEX);
    delay(1);
    switch(messageStep) { // Starts at -1
      case S_INIT:
      case S_COMMAND_ECHO:
        send(lastbytein);
        if (messageStep == S_COMMAND_ECHO) {
          executeCommand(lastbytein);
        }
        messageStep++;
        break;
      case S_RESP_LEN:
        send(messageToSend[0]);
        messageIndex = 1;
        messageStep++;
        break;
      case S_BYTE_SEND:
        if (lastbyteout != ~lastbytein) {
          resetMessage();
          break;
        }
        send(messageToSend[messageIndex]);
        if (messageIndex == messageToSend[0]) { // Checks if at last bite, and resets
          resetMessage();
          messageStep = S_COMMAND_ECHO;
          break;
        }
        messageIndex++;
        messageStep++;
        break;
    }
    interrupts();
  }
}
Пример #3
0
void RF_reciever::resetAll()
{
	//reset the messages
	RF_reciever::bitNumber=0;
	resetMessage();

	//empty the queues
	while(!queueTime.isEmpty())
	{
		queueTime.dequeue();
	}

	while(!queuePinState.isEmpty())
	{
		queuePinState.dequeue();
	}

}
Пример #4
0
void printInvoicesByShipvia::sPrint()
{
  if ( (_metrics->value("InvcNumberGeneration") == "O") ||
       (_metrics->value("InvcNumberGeneration") == "M") )
  {
    q.prepare( "UPDATE orderseq "
               "SET orderseq_number=:invoicenumber "
               "WHERE (orderseq_name='InvcNumber');" );
    q.bindValue(":invoicenumber", _firstInvoiceNum->text().toInt());
    q.exec();
    if (q.lastError().type() != QSqlError::None)
    {
      systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
      return;
    }
  }

  XSqlQuery invoices;
  invoices.prepare( "SELECT invchead_id, invchead_invcnumber, findCustomerForm(invchead_cust_id, 'I') AS reportname "
                    "FROM invchead "
                    "WHERE ( (NOT invchead_printed)"
                    " AND (NOT invchead_posted)"
                    " AND (invchead_shipvia=:shipvia) ) "
                    "ORDER BY invchead_ordernumber" );
  invoices.bindValue(":shipvia", _shipvia->currentText());
  invoices.exec();
  if (invoices.first())
  {
    XSqlQuery local;
    QPrinter  printer(QPrinter::HighResolution);
    bool      setupPrinter = TRUE;
    bool userCanceled = false;
    if (orReport::beginMultiPrint(&printer, userCanceled) == false)
    {
      if(!userCanceled)
        systemError(this, tr("Could not initialize printing system for multiple reports."));
      return;
    }

    do
    {
      int invoiceNumber = invoices.value("invchead_invcnumber").toInt();
      if (invoiceNumber == 0)
      {
        local.prepare("SELECT fetchInvcNumber() AS invoicenumber;");
        local.exec();
        if (local.first())
        {
          invoiceNumber = local.value("invoicenumber").toInt();
          local.prepare( "UPDATE invchead "
                         "SET invchead_invcnumber=:invoicenumber "
                         "WHERE (invchead_id=:invchead_id);" );
          local.bindValue(":invoicenumber", invoiceNumber);
          local.bindValue(":invchead_id", invoices.value("invchead_id").toInt());
          local.exec();
        }
	// not else because local is re-prepared inside the block
	if (local.lastError().type() != QSqlError::None)
	{
	  systemError(this, local.lastError().databaseText(), __FILE__, __LINE__);
	  return;
	}
      }

      XSqlQuery xrate;
      xrate.prepare("SELECT curr_rate "
		   "FROM curr_rate, invchead "
		   "WHERE ((curr_id=invchead_curr_id)"
		   "  AND  (invchead_id=:invchead_id)"
		   "  AND  (invchead_invcdate BETWEEN curr_effective AND curr_expires));");
      // if SUM becomes dependent on curr_id then move XRATE before it in the loop

      XSqlQuery sum;
      sum.prepare("SELECT COALESCE(SUM(round((invcitem_billed * invcitem_qty_invuomratio) *"
                  "                 (invcitem_price / "
                  "                  CASE WHEN (item_id IS NULL) THEN 1"
                  "                       ELSE invcitem_price_invuomratio"
                  "                  END), 2)),0) + "
                  "       invchead_freight + invchead_tax + "
                  "       invchead_misc_amount AS subtotal "
                  "  FROM invchead LEFT OUTER JOIN"
                  "       invcitem ON (invcitem_invchead_id=invchead_id) LEFT OUTER JOIN"
                  "       item ON (invcitem_item_id=item_id) "
                  " WHERE(invchead_id=:invchead_id) "
                  " GROUP BY invchead_freight, invchead_tax, invchead_misc_amount;");
      message( tr("Printing Invoice #%1...")
               .arg(invoiceNumber) );

      for (int i = 0; i < _invoiceWatermarks->topLevelItemCount(); i++ )
      {
	QTreeWidgetItem *cursor = _invoiceWatermarks->topLevelItem(i);
        ParameterList params;
        params.append("invchead_id", invoices.value("invchead_id").toInt());
        params.append("showcosts", ((cursor->text(2) == tr("Yes")) ? "TRUE" : "FALSE"));
        params.append("watermark", cursor->text(1));

        orReport report(invoices.value("reportname").toString(), params);

        message( tr("Printing Invoice #%1...")
                 .arg(invoiceNumber) );

        if (!report.isValid())
        {
          QMessageBox::critical( this, tr("Cannot Find Invoice Form"),
                                 tr( "The Invoice Form '%1' cannot be found for Invoice #%2.\n"
                                     "This Invoice cannot be printed until a Customer Form Assignment is updated to remove any\n"
                                     "references to this Invoice Form or this Invoice Form is created." )
                                 .arg(invoices.value("reportname").toString())
                                 .arg(invoiceNumber) );

          resetMessage();
        }
        else
        {
          if (report.print(&printer, setupPrinter))
            setupPrinter = FALSE;
          else
          {
            systemError( this, tr("A Printing Error occurred at printInvoices::%1.")
                               .arg(__LINE__) );
	    orReport::endMultiPrint(&printer);
            return;
          }

          if (_post->isChecked())
          {
	    int invcheadId = invoices.value("invchead_id").toInt();
	    sum.bindValue(":invchead_id", invcheadId);
	    if (sum.exec() && sum.first() && sum.value("subtotal").toDouble() == 0)
	    {
	      if (QMessageBox::question(this, tr("Invoice Has Value 0"),
					tr("Invoice #%1 has a total value of 0.\n"
					   "Would you like to post it anyway?")
					  .arg(invoiceNumber),
					QMessageBox::Yes,
					QMessageBox::No | QMessageBox::Default)
		    == QMessageBox::No)
		continue;
	    }
	    else if (sum.lastError().type() != QSqlError::NoError)
	    {
	      systemError(this, sum.lastError().databaseText(), __FILE__, __LINE__);
	      continue;
	    }
	    else if (sum.value("subtotal").toDouble() != 0)
	    {
	      xrate.bindValue(":invchead_id", invcheadId);
	      xrate.exec();
	      if (xrate.lastError().type() != QSqlError::NoError)
	      {
		 systemError(this, tr("System Error posting Invoice #%1\n%2")
				     .arg(invoiceNumber)
				     .arg(xrate.lastError().databaseText()),
			     __FILE__, __LINE__);
		 continue;
	      }
	      else if (!xrate.first() || xrate.value("curr_rate").isNull())
	      {
		 systemError(this, tr("Could not post Invoice #%1 because of a missing exchange rate.")
				     .arg(invoiceNumber));
		 continue;
	      }
	    }

            message( tr("Posting Invoice #%1...")
                     .arg(invoiceNumber) );

            local.prepare("SELECT postInvoice(:invchead_id) AS result;");
            local.bindValue(":invchead_id", invcheadId);
            local.exec();
	    if (local.lastError().type() != QSqlError::None)
	    {
	      systemError(this, local.lastError().databaseText(), __FILE__, __LINE__);
	    }
          }
        }
      }
      if (_metrics->boolean("EnableBatchManager"))
      {  
        // TODO: Check for EDI and handle submission to Batch here
        XSqlQuery query;
        query.prepare("SELECT CASE WHEN (COALESCE(shipto_ediprofile_id, -2) = -2)"
                "              THEN COALESCE(cust_ediprofile_id,-1)"
                "            ELSE COALESCE(shipto_ediprofile_id,-2)"
                "       END AS result,"
                "       COALESCE(cust_emaildelivery, false) AS custom"
                "  FROM cust, invchead"
                "       LEFT OUTER JOIN shipto"
                "         ON (invchead_shipto_id=shipto_id)"
                "  WHERE ((invchead_cust_id=cust_id)"
                "    AND  (invchead_id=:invchead_id)); ");
        query.bindValue(":invchead_id", invoices.value("invchead_id").toInt());
        query.exec();
        if(query.first())
        {
          if(query.value("result").toInt() == -1)
          {
            if(query.value("custom").toBool())
            {
              ParameterList params;
              params.append("invchead_id", invoices.value("invchead_id").toInt());

              deliverInvoice newdlg(this, "", TRUE);
              newdlg.set(params);
              newdlg.exec();
            }
          }
          else
          {
            ParameterList params;
            params.append("action_name", "TransmitInvoice");
            params.append("invchead_id", invoices.value("invchead_id").toInt());

            submitAction newdlg(this, "", TRUE);
            newdlg.set(params);
            newdlg.exec();
          }
        }
        else if (query.lastError().type() != QSqlError::None)
        {
	      systemError(this, query.lastError().databaseText(), __FILE__, __LINE__);
	      return;
        }
      }
    }
    while (invoices.next());
    orReport::endMultiPrint(&printer);

    resetMessage();

    if (!_post->isChecked())
    {
      if ( QMessageBox::information( this, tr("Mark Invoices as Printed?"),
                                     tr("Did all of the Invoices print correctly?"),
                                     tr("&Yes"), tr("&No"), QString::null, 0, 1) == 0)
      {
        q.prepare( "UPDATE invchead "
                   "   SET invchead_printed=TRUE "
                   " WHERE ( (NOT invchead_printed)"
                   "   AND   (invchead_shipvia=:shipvia) ); ");
        q.bindValue(":shipvia", _shipvia->currentText());
        q.exec();
	if (q.lastError().type() != QSqlError::None)
	{
	  systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
	  return;
	}

        omfgThis->sInvoicesUpdated(-1, TRUE);
      }
    }
  }
  else if (invoices.lastError().type() != QSqlError::None)
  {
    systemError(this, invoices.lastError().databaseText(), __FILE__, __LINE__);
    return;
  }
  else
    QMessageBox::information( this, tr("No Invoices to Print"),
                              tr("There aren't any Invoices to print for the selected Ship Via.") );

  accept();
}
Пример #5
0
void printInvoicesByShipvia::sPrint()
{
  XSqlQuery invoices;
  invoices.prepare( "SELECT * FROM ("
                    "  SELECT invchead_id, invchead_invcnumber, invchead_ordernumber, "
                    "    findCustomerForm(invchead_cust_id, 'I') AS reportname "
                    "  FROM invchead "
                    "  WHERE ( (NOT invchead_printed)"
                    "  AND   (NOT invchead_posted)"
                    "  AND   (invchead_shipvia=:shipvia)) ) AS data "
                    "WHERE   (checkInvoiceSitePrivs(invchead_id)) "
                    "ORDER BY invchead_ordernumber;" );

  invoices.bindValue(":shipvia", _shipvia->currentText());
  invoices.exec();
  if (invoices.first())
  {
    XSqlQuery local;
    QPrinter  printer(QPrinter::HighResolution);
    bool      setupPrinter = TRUE;
    bool userCanceled = false;
    if (orReport::beginMultiPrint(&printer, userCanceled) == false)
    {
      if(!userCanceled)
        systemError(this, tr("Could not initialize printing system for multiple reports."));
      return;
    }

    do
    {
      int invoiceNumber = invoices.value("invchead_invcnumber").toInt();
      if (invoiceNumber == 0)
      {
        local.prepare("SELECT fetchInvcNumber() AS invoicenumber;");
        local.exec();
        if (local.first())
        {
          invoiceNumber = local.value("invoicenumber").toInt();
          local.prepare( "UPDATE invchead "
                         "SET invchead_invcnumber=text(:invoicenumber) "
                         "WHERE (invchead_id=:invchead_id);" );
          local.bindValue(":invoicenumber", invoiceNumber);
          local.bindValue(":invchead_id", invoices.value("invchead_id").toInt());
          local.exec();
        }
	// not else because local is re-prepared inside the block
	if (local.lastError().type() != QSqlError::NoError)
	{
	  systemError(this, local.lastError().databaseText(), __FILE__, __LINE__);
	  return;
	}
      }

      XSqlQuery xrate;
      xrate.prepare("SELECT curr_rate "
		   "FROM curr_rate, invchead "
		   "WHERE ((curr_id=invchead_curr_id)"
		   "  AND  (invchead_id=:invchead_id)"
		   "  AND  (invchead_invcdate BETWEEN curr_effective AND curr_expires));");
      // if SUM becomes dependent on curr_id then move XRATE before it in the loop

      XSqlQuery sum;
      sum.prepare("SELECT invoiceTotal(:invchead_id) AS subtotal;");
      message( tr("Printing Invoice #%1...")
               .arg(invoiceNumber) );

      for (int i = 0; i < _invoiceWatermarks->topLevelItemCount(); i++ )
      {
	QTreeWidgetItem *cursor = _invoiceWatermarks->topLevelItem(i);
        ParameterList params;
        params.append("invchead_id", invoices.value("invchead_id").toInt());
        params.append("showcosts", ((cursor->text(2) == tr("Yes")) ? "TRUE" : "FALSE"));
        params.append("watermark", cursor->text(1));

        orReport report(invoices.value("reportname").toString(), params);

        message( tr("Printing Invoice #%1...")
                 .arg(invoiceNumber) );

        if (!report.isValid())
        {
          QMessageBox::critical( this, tr("Cannot Find Invoice Form"),
                                 tr( "The Invoice Form '%1' cannot be found for Invoice #%2.\n"
                                     "This Invoice cannot be printed until a Customer Form Assignment is updated to remove any\n"
                                     "references to this Invoice Form or this Invoice Form is created." )
                                 .arg(invoices.value("reportname").toString())
                                 .arg(invoiceNumber) );

          resetMessage();
        }
        else
        {
          if (report.print(&printer, setupPrinter))
            setupPrinter = FALSE;
          else
          {
            systemError( this, tr("A Printing Error occurred at printInvoices::%1.")
                               .arg(__LINE__) );
	    orReport::endMultiPrint(&printer);
            return;
          }

          if (_post->isChecked())
          {
	    int invcheadId = invoices.value("invchead_id").toInt();
	    sum.bindValue(":invchead_id", invcheadId);
	    if (sum.exec() && sum.first() && sum.value("subtotal").toDouble() == 0)
	    {
	      if (QMessageBox::question(this, tr("Invoice Has Value 0"),
					tr("Invoice #%1 has a total value of 0.\n"
					   "Would you like to post it anyway?")
					  .arg(invoiceNumber),
					QMessageBox::Yes,
					QMessageBox::No | QMessageBox::Default)
		    == QMessageBox::No)
		continue;
	    }
	    else if (sum.lastError().type() != QSqlError::NoError)
	    {
	      systemError(this, sum.lastError().databaseText(), __FILE__, __LINE__);
	      continue;
	    }
	    else if (sum.value("subtotal").toDouble() != 0)
	    {
	      xrate.bindValue(":invchead_id", invcheadId);
	      xrate.exec();
	      if (xrate.lastError().type() != QSqlError::NoError)
	      {
		 systemError(this, tr("System Error posting Invoice #%1\n%2")
				     .arg(invoiceNumber)
				     .arg(xrate.lastError().databaseText()),
			     __FILE__, __LINE__);
		 continue;
	      }
	      else if (!xrate.first() || xrate.value("curr_rate").isNull())
	      {
		 systemError(this, tr("Could not post Invoice #%1 because of a missing exchange rate.")
				     .arg(invoiceNumber));
		 continue;
	      }
	    }

            message( tr("Posting Invoice #%1...")
                     .arg(invoiceNumber) );

            local.prepare("SELECT postInvoice(:invchead_id) AS result;");
            local.bindValue(":invchead_id", invcheadId);
            local.exec();
	    if (local.lastError().type() != QSqlError::NoError)
	    {
	      systemError(this, local.lastError().databaseText(), __FILE__, __LINE__);
	    }
          }
        }
      }

      emit finishedPrinting(invoices.value("invchead_id").toInt());
    }
    while (invoices.next());
    orReport::endMultiPrint(&printer);

    resetMessage();

    if (!_post->isChecked())
    {
      if ( QMessageBox::information( this, tr("Mark Invoices as Printed?"),
                                     tr("Did all of the Invoices print correctly?"),
                                     tr("&Yes"), tr("&No"), QString::null, 0, 1) == 0)
      {
        q.prepare( "UPDATE invchead "
                   "   SET invchead_printed=TRUE "
                   " WHERE ( (NOT invchead_printed)"
                   "   AND   (invchead_shipvia=:shipvia) ); ");
        q.bindValue(":shipvia", _shipvia->currentText());
        q.exec();
	if (q.lastError().type() != QSqlError::NoError)
	{
	  systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
	  return;
	}

        omfgThis->sInvoicesUpdated(-1, TRUE);
      }
    }
  }
  else if (invoices.lastError().type() != QSqlError::NoError)
  {
    systemError(this, invoices.lastError().databaseText(), __FILE__, __LINE__);
    return;
  }
  else
    QMessageBox::information( this, tr("No Invoices to Print"),
                              tr("There aren't any Invoices to print for the selected Ship Via.") );

  accept();
}
Пример #6
0
//parses the queue of bits and translates them into messages
//returns "true" if a valid message was found
bool RF_reciever::convertBitToMessage(byte currentBit)
{
	//increment noise counter (used by heartbeat function)
	noiseCount++;

			if(currentBit==LONG_GAP)
			{
				debugPrint(F("\nGap"));
				resetMessage();
				return false;
			}
			else
			{
				debugPrint(String(currentBit));
			}


			//process 'ones', 'zeros' should have been done by resetMessage() function
		if(currentBit==ONE_BIT) // so process it but only if bit==1
		{
			if(bitNumber<=3) //preamble
			{
				bitSet(preamble,3-bitNumber);
			}
			else if(bitNumber>3 and bitNumber<=11) //ID
			{
				//check preamble
				if(bitNumber==4 and preamble!=5)
				{
					debugPrint(F("\nBadPre")); //bad preamble so exit
					resetMessage();
					return false;
				}

				bitSet(id,11-bitNumber); //set ID
			}
			else if(bitNumber==12) //battery
			{
				batteryOK=true;
			}
			else if(bitNumber==13) //manual transmit
			{
				ManualTransmit=true;
			}
			else if(bitNumber>13 and bitNumber<=15) //channel
			{
				bitSet(channel,15-bitNumber);
			}
			else if(bitNumber==16) //negative temperature flag
			{
				negativeTemperature=true;
			}
			else if(bitNumber>16 and bitNumber<=27) //temperature10 number
			{
				bitSet(temperature10,27-bitNumber);
			}
			else if(bitNumber>27 and bitNumber<=35) //relative humidity number
			{
				bitSet(relativeHumidity,35-bitNumber);
			}
		}

		if(bitNumber<35)
		{
			RF_reciever::bitNumber++;
		}
		else
		{
			//end of message so timestamp and validate

			timeMicros=micros(); //approximate time of this message
			RF_reciever::bitNumber=0;

			debugPrint(F("\nNew Message!\n"));


			if(validateMessage())
			{
				//have a new valid message!
				return true;

			}
			else
			{
				//message was invalid, clear message and begin again
				resetMessage();
				return false;
			}

		}

	return false; //no complete and valid message yet

}
Пример #7
0
void postCashReceipts::sPost()
{
  int journalNumber;

  q.exec("SELECT fetchJournalNumber('C/R') AS journalnumber;");
  if (q.first())
    journalNumber = q.value("journalnumber").toInt();
  else
  {
    systemError(this, tr("A System Error occurred at %1::%2.")
                      .arg(__FILE__)
                      .arg(__LINE__) );
    return;
  }

  q.exec( "SELECT cashrcpt_id, cust_number "
          "FROM cashrcpt, cust "
          "WHERE (cashrcpt_cust_id=cust_id);" );
  if (q.first())
  {
    int counter = 0;

    XSqlQuery post;
    post.prepare("SELECT postCashReceipt(:cashrcpt_id, :journalNumber) AS result;");
    
    do
    {
      message( tr("Posting Cash Receipt #%1...")
               .arg(q.value("cust_number").toString()) );

      post.bindValue(":cashrcpt_id", q.value("cashrcpt_id"));
      post.bindValue(":journalNumber", journalNumber);
      post.exec();
      if (post.first())
      {
        switch (post.value("result").toInt())
        {
          case -1:
            QMessageBox::critical( this, tr("Cannot Post Cash Receipt"),
                                   tr( "The selected Cash Receipt cannot be posted as the amount distributed is greater than\n"
                                       "the amount received. You must correct this before you may post this Cash Receipt." ) );
            break;

          case -5:
            QMessageBox::critical( this, tr("Cannot Post Cash Receipt"),
                                   tr( "A Cash Receipt for Customer #%1 cannot be posted as the A/R Account cannot be determined.\n"
                                       "You must make a A/R Account Assignment for the Customer Type to which this Customer\n"
                                       "is assigned for you may post this Cash Receipt." )
                                   .arg(q.value("cust_number").toString())  );
            break;

          case -6:
            QMessageBox::critical( this, tr("Cannot Post Cash Receipt"),
                                   tr( "A Cash Receipt for Customer #%1 cannot be posted as the Bank Account cannot be determined.\n"
                                       "You must make a Bank Account Assignment for this Cash Receipt before you may post it." )
                                   .arg(q.value("cust_number").toString())  );
            break;

          case -7:
            QMessageBox::critical( this, tr("Cannot Post Cash Receipt"),
                                   tr( "A Cash Receipt for Customer #%1 cannot be posted due to an unknown error.\n"
                                       "Contact you Systems Administrator." )
                                   .arg(q.value("cust_number").toString())  );

          default:
            counter++;
        }
      }
      else
      {
        systemError( this, tr("While posting the cash receipt for Customer %1:"
			      "\n\n%2")
                           .arg(q.value("cust_number").toString())
                           .arg(post.lastError().databaseText()),
		     __FILE__, __LINE__ );
        break;
      }
    }
    while (q.next());

    resetMessage();

    if ( (counter) && (_printJournal->isChecked()) )
    {
      ParameterList params;
      params.append("journalNumber", journalNumber);
     
      orReport report("CashReceiptsJournal", params);
      if (report.isValid())
        report.print();
      else
        report.reportError(this);
    }

    omfgThis->sCashReceiptsUpdated(-1, true);

    accept();
  }
  else
  {
    QMessageBox::information( this, tr("No Unposted Cash Receipts"),
                              tr("There are no unposted Cash Receipts to post.") );
  }
}
Пример #8
0
/*The main loop - receives messages from the server or input the user. */
void twitClient::sendReceive()
{
    fd_set readfds,master;
    int bytesReceive,retVal = SUCCESS_EXIT, maxfd = (_socketfd > STDIN)?_socketfd:STDIN;
    char buf[PACKAGE_SIZE];
    std::vector<std::string> clientsNames;
    FD_ZERO(&readfds);
    FD_ZERO(&master);
    FD_SET(_socketfd,&master);
    FD_SET(STDIN,&master);

    if (_send == SUCCESS) // sending BEGIN successfully.
    {
		while(true)
		{
			readfds = master;
			select(maxfd + 1, &readfds,NULL, NULL, NULL);
			for (int i = 0; (i <= maxfd) && (_finish == false); i++)
			{
				if (FD_ISSET(i, &readfds))
				{
					if (i == _socketfd)
					{
						resetMessage(buf);
						bytesReceive = recv(i, buf, sizeof(buf), 0);
						if (bytesReceive <= 0)
						{
							if (bytesReceive == 0)
							{
								std::cout << SERVER_CRASHED << std::endl;
							}
							if (bytesReceive < 0)
							{
								std::cout << RECEIVE_ERROR << std::endl;
								retVal = FAILURE_EXIT;
							}
							_finish = true;
							close(i);
							FD_CLR(i,&master);
						}
						else if ((retVal = receiveFromServer(buf,clientsNames)) != NOT_EXIT)
						{
							_finish = true;
							close(i);
							FD_CLR(i,&master);
						}
					}
					else if (i == STDIN)
					{
						if ((getCommands() == true) || (_send == FAILURE))
						{
							_finish = true;
							close(_socketfd);
							FD_CLR(i,&master);
						}
					}
				}
			}

			if (_finish == true)
			{
				break;
			}
		}
    }
    if (retVal == FAILURE_EXIT)
    {
    	exit(FAILURE_EXIT);
    }
    if (_send == FAILURE)
    {
        exit(FAILURE_EXIT);
    }
}
Пример #9
0
void postCashReceipts::sPost()
{
  XSqlQuery postPost;
  int journalNumber;

  postPost.exec("SELECT fetchJournalNumber('C/R') AS journalnumber;");
  if (postPost.first())
    journalNumber = postPost.value("journalnumber").toInt();
  else
  {
    systemError(this, tr("A System Error occurred at %1::%2.")
                      .arg(__FILE__)
                      .arg(__LINE__) );
    return;
  }

  postPost.exec( "SELECT cashrcpt_id, cust_number "
          "FROM cashrcpt, custinfo "
          "WHERE ( (NOT cashrcpt_posted)"
          "  AND   (NOT cashrcpt_void)"
          "  AND   (cashrcpt_cust_id=cust_id) );" );
  if (postPost.first())
  {
    int counter = 0;

    XSqlQuery post;
    post.prepare("SELECT postCashReceipt(:cashrcpt_id, :journalNumber) AS result;");

    do
    {
      message( tr("Posting Cash Receipt #%1...")
               .arg(postPost.value("cust_number").toString()) );

      post.bindValue(":cashrcpt_id", postPost.value("cashrcpt_id"));
      post.bindValue(":journalNumber", journalNumber);
      post.exec();
      if (post.first())
      {
        switch (post.value("result").toInt())
        {
          case -1:
            QMessageBox::critical( this, tr("Cannot Post Cash Receipt"),
                                   tr( "The selected Cash Receipt cannot be posted as the amount distributed is greater than\n"
                                       "the amount received. You must correct this before you may post this Cash Receipt." ) );
            break;

          case -5:
            QMessageBox::critical( this, tr("Cannot Post Cash Receipt"),
                                   tr( "A Cash Receipt for Customer #%1 cannot be posted as the A/R Account cannot be determined.\n"
                                       "You must make a A/R Account Assignment for the Customer Type to which this Customer\n"
                                       "is assigned for you may post this Cash Receipt." )
                                   .arg(postPost.value("cust_number").toString())  );
            break;

          case -6:
            QMessageBox::critical( this, tr("Cannot Post Cash Receipt"),
                                   tr( "A Cash Receipt for Customer #%1 cannot be posted as the Bank Account cannot be determined.\n"
                                       "You must make a Bank Account Assignment for this Cash Receipt before you may post it." )
                                   .arg(postPost.value("cust_number").toString())  );
            break;

          case -7:
            QMessageBox::critical( this, tr("Cannot Post Cash Receipt"),
                                   tr( "A Cash Receipt for Customer #%1 cannot be posted due to an unknown error.\n"
                                       "Contact you Systems Administrator." )
                                   .arg(postPost.value("cust_number").toString())  );

          default:
            counter++;
        }
      }
      else if (ErrorReporter::error(QtCriticalMsg, this, tr("Error Posting"),
                                    post, __FILE__, __LINE__))
      {
        break;
      }
    }
    while (postPost.next());

    resetMessage();

    if ( (counter) && (_printJournal->isChecked()) )
    {
      ParameterList params;
      params.append("source", "A/R");
      params.append("sourceLit", tr("A/R"));
      params.append("startJrnlnum", journalNumber);
      params.append("endJrnlnum", journalNumber);

      if (_metrics->boolean("UseJournals"))
      {
        params.append("title",tr("Journal Series"));
        params.append("table", "sltrans");
      }
      else
      {
        params.append("title",tr("General Ledger Series"));
        params.append("gltrans", true);
        params.append("table", "gltrans");
      }

      orReport report("GLSeries", params);
      if (report.isValid())
        report.print();
      else
        report.reportError(this);
    }

    omfgThis->sCashReceiptsUpdated(-1, true);

    accept();
  }
  else
  {
    QMessageBox::information( this, tr("No Unposted Cash Receipts"),
                              tr("There are no unposted Cash Receipts to post.") );
  }
}
Пример #10
0
void LabelVersion::mousePressEvent( QMouseEvent * event) { resetMessage();}