示例#1
0
void EditContact::cancelData()
{
  done(-1);
}
示例#2
0
文件: error.c 项目: AhmadTux/freebsd
void
fatal(const char *msg)
{
    fprintf(stderr, "%s: f - %s\n", myname, msg);
    done(2);
}
示例#3
0
void itemPricingScheduleItem::sSave( bool pClose)
{
    if(_itemSelected->isChecked())
    {
        q.prepare( "SELECT ipsitem_id "
                   "  FROM ipsitem "
                   " WHERE((ipsitem_ipshead_id=:ipshead_id)"
                   "   AND (ipsitem_item_id=:item_id)"
                   "   AND (ipsitem_qty_uom_id=:uom_id)"
                   "   AND (ipsitem_qtybreak=:qtybreak)"
                   "   AND (ipsitem_id <> :ipsitem_id));" );
        q.bindValue(":ipshead_id", _ipsheadid);
        q.bindValue(":item_id", _item->id());
        q.bindValue(":qtybreak", _qtyBreak->toDouble());
        q.bindValue(":uom_id", _qtyUOM->id());
        q.bindValue(":ipsitem_id", _ipsitemid);
        q.exec();
        if (q.first())
        {
            QMessageBox::critical( this, tr("Cannot Create Pricing Schedule Item"),
                                   tr( "There is an existing Pricing Schedule Item for the selected Pricing Schedule, Item and Quantity Break defined.\n"
                                       "You may not create duplicate Pricing Schedule Items." ) );
            return;
        }
        else if (q.lastError().type() != QSqlError::NoError)
        {
            systemError(this, _rejectedMsg.arg(q.lastError().databaseText()),
                        __FILE__, __LINE__);
            done(-1);
        }
    }

    if (_mode == cNew)
    {
        if(_itemSelected->isChecked())
        {
            q.exec("SELECT NEXTVAL('ipsitem_ipsitem_id_seq') AS ipsitem_id;");
            if (q.first())
                _ipsitemid = q.value("ipsitem_id").toInt();
            //  ToDo

            q.prepare( "INSERT INTO ipsitem "
                       "( ipsitem_id, ipsitem_ipshead_id, ipsitem_item_id,"
                       "  ipsitem_qty_uom_id, ipsitem_qtybreak, "
                       "  ipsitem_price_uom_id, ipsitem_price, "
                       "  ipsitem_discntprcnt, ipsitem_fixedamtdiscount ) "
                       "VALUES "
                       "( :ipsitem_id, :ipshead_id, :ipsitem_item_id, "
                       "  :qty_uom_id, :ipsitem_qtybreak, "
                       "  :price_uom_id, :ipsitem_price, "
                       "  :ipsitem_discntprcnt, :ipsitem_fixedamtdiscount );" );
        }
        else if(_discountSelected->isChecked())
        {
            if(_dscbyItem->isChecked())
            {
                q.prepare( "SELECT * "
                           "FROM ipsitem JOIN ipshead ON (ipsitem_ipshead_id=ipshead_id) "
                           "WHERE ((ipshead_id = :ipshead_id)"
                           "   AND (ipsitem_item_id = :item_id)"
                           "   AND (ipsitem_qtybreak = :qtybreak));");

                q.bindValue(":ipshead_id", _ipsheadid);
                q.bindValue(":item_id", _dscitem->id());
                q.bindValue(":qtybreak", _qtyBreakCat->toDouble());
                q.exec();
                if (q.first())
                {
                    QMessageBox::critical( this, tr("Cannot Create Pricing Schedule Item"),
                                           tr( "There is an existing Pricing Schedule Item for the selected Pricing Schedule, Item and Quantity Break defined.\n"
                                               "You may not create duplicate Pricing Schedule Items." ) );
                    return;
                }
                else if (q.lastError().type() != QSqlError::NoError)
                {
                    systemError(this, _rejectedMsg.arg(q.lastError().databaseText()),
                                __FILE__, __LINE__);
                    done(-1);
                }
                q.exec("SELECT NEXTVAL ('ipsitem_ipsitem_id_seq') AS ipsitem_id;");
                if (q.first())
                    _ipsitemid = q.value("ipsitem_id").toInt();
                else if (q.lastError().type() != QSqlError::NoError)
                {
                    systemError(this, _rejectedMsg.arg(q.lastError().databaseText()),
                                __FILE__, __LINE__);
                    done(-1);
                }

                q.prepare("INSERT INTO ipsitem "
                          "( ipsitem_id, ipsitem_ipshead_id, "
                          "  ipsitem_item_id, ipsitem_qtybreak, "
                          "  ipsitem_price, ipsitem_qty_uom_id, "
                          "  ipsitem_price_uom_id, ipsitem_discntprcnt, "
                          "  ipsitem_fixedamtdiscount ) "
                          "VALUES "
                          "( :ipsitem_id, :ipshead_id, "
                          "  :ipsitem_item_id, :ipsitem_qtybreak, "
                          "  :ipsitem_price, :ipsitem_qty_uom_id, "
                          "  :ipsitem_price_uom_id, :ipsitem_discntprcnt, "
                          "  :ipsitem_fixedamtdiscount); ");

                XSqlQuery qry;
                qry.prepare("SELECT item_inv_uom_id, item_price_uom_id "
                            "FROM item "
                            "WHERE (item_id=:item_id);");
                qry.bindValue(":item_id", _dscitem->id());
                qry.exec();
                if (qry.first())
                {
                    q.bindValue(":ipsitem_qty_uom_id", qry.value("item_inv_uom_id"));
                    q.bindValue(":ipsitem_price_uom_id", qry.value("item_price_uom_id"));
                }
                else if (qry.lastError().type() != QSqlError::NoError)
                {
                    systemError(this, _rejectedMsg.arg(qry.lastError().databaseText()),
                                __FILE__, __LINE__);
                    done(-1);
                }
            }
            else if(_dscbyprodcat->isChecked())
            {
                q.prepare( "SELECT ipsprodcat_id "
                           "FROM ipsprodcat "
                           "WHERE ( (ipsprodcat_ipshead_id=:ipshead_id)"
                           " AND (ipsprodcat_prodcat_id=:prodcat_id)"
                           " AND (ipsprodcat_qtybreak=:qtybreak) );" );
                q.bindValue(":ipshead_id", _ipsheadid);
                q.bindValue(":prodcat_id", _prodcat->id());
                q.bindValue(":qtybreak", _qtyBreakCat->toDouble());
                q.exec();
                if (q.first())
                {
                    QMessageBox::critical( this, tr("Cannot Create Pricing Schedule Item"),
                                           tr( "There is an existing Pricing Schedule Item for the selected Pricing Schedule, Product Category and Quantity Break defined.\n"
                                               "You may not create duplicate Pricing Schedule Items." ) );
                    return;
                }
                else if (q.lastError().type() != QSqlError::NoError)
                {
                    systemError(this, _rejectedMsg.arg(q.lastError().databaseText()),
                                __FILE__, __LINE__);
                    done(-1);
                }

                q.exec("SELECT NEXTVAL('ipsprodcat_ipsprodcat_id_seq') AS ipsprodcat_id;");
                if (q.first())
                    _ipsprodcatid = q.value("ipsprodcat_id").toInt();
                else if (q.lastError().type() != QSqlError::NoError)
                {
                    systemError(this, _rejectedMsg.arg(q.lastError().databaseText()),
                                __FILE__, __LINE__);
                    done(-1);
                }
                //  ToDo

                q.prepare( "INSERT INTO ipsprodcat "
                           "( ipsprodcat_id, ipsprodcat_ipshead_id, ipsprodcat_prodcat_id, ipsprodcat_qtybreak,"
                           "  ipsprodcat_discntprcnt, ipsprodcat_fixedamtdiscount )"
                           "VALUES "
                           "( :ipsprodcat_id, :ipshead_id, :ipsprodcat_prodcat_id, :ipsprodcat_qtybreak,"
                           "  :ipsprodcat_discntprcnt, :ipsprodcat_fixedamtdiscount );" );
            }
        }
        else if(_freightSelected->isChecked())
        {
            q.prepare( "SELECT ipsfreight_id "
                       "FROM ipsfreight "
                       "WHERE ( (ipsfreight_ipshead_id=:ipshead_id)"
                       " AND (ipsfreight_warehous_id=:warehous_id)"
                       " AND (ipsfreight_shipzone_id=:shipzone_id)"
                       " AND (ipsfreight_freightclass_id=:freightclass_id)"
                       " AND (ipsfreight_shipvia=:shipvia)"
                       " AND (ipsfreight_qtybreak=:qtybreak) );" );
            q.bindValue(":ipshead_id", _ipsheadid);
            q.bindValue(":warehous_id", _siteFreight->id());
            q.bindValue(":shipzone_id", _zoneFreight->id());
            q.bindValue(":freightclass_id", _freightClass->id());
            q.bindValue(":shipvia", _shipViaFreight->currentText());
            q.bindValue(":qtybreak", _qtyBreakFreight->toDouble());
            q.exec();
            if (q.first())
            {
                QMessageBox::critical( this, tr("Cannot Create Pricing Schedule Item"),
                                       tr( "There is an existing Pricing Schedule Item for the selected Pricing Schedule, Freight Criteria and Quantity Break defined.\n"
                                           "You may not create duplicate Pricing Schedule Items." ) );
                return;
            }
            else if (q.lastError().type() != QSqlError::NoError)
            {
                systemError(this, _rejectedMsg.arg(q.lastError().databaseText()),
                            __FILE__, __LINE__);
                done(-1);
            }

            q.exec("SELECT NEXTVAL('ipsfreight_ipsfreight_id_seq') AS ipsfreight_id;");
            if (q.first())
                _ipsfreightid = q.value("ipsfreight_id").toInt();
            else if (q.lastError().type() != QSqlError::NoError)
            {
                systemError(this, _rejectedMsg.arg(q.lastError().databaseText()),
                            __FILE__, __LINE__);
                done(-1);
            }
            //  ToDo

            q.prepare( "INSERT INTO ipsfreight "
                       "( ipsfreight_id, ipsfreight_ipshead_id, ipsfreight_qtybreak, ipsfreight_price,"
                       "  ipsfreight_type, ipsfreight_warehous_id, ipsfreight_shipzone_id,"
                       "  ipsfreight_freightclass_id, ipsfreight_shipvia ) "
                       "VALUES "
                       "( :ipsfreight_id, :ipshead_id, :ipsfreight_qtybreak, :ipsfreight_price,"
                       "  :ipsfreight_type, :ipsfreight_warehous_id, :ipsfreight_shipzone_id,"
                       "  :ipsfreight_freightclass_id, :ipsfreight_shipvia ) " );
        }
    }
    else if (_mode == cEdit)
    {
        if(_itemSelected->isChecked())
            q.prepare( "UPDATE ipsitem "
                       "   SET ipsitem_qty_uom_id=:qty_uom_id,"
                       "       ipsitem_qtybreak=:ipsitem_qtybreak,"
                       "       ipsitem_price_uom_id=:price_uom_id,"
                       "       ipsitem_price=:ipsitem_price "
                       "WHERE (ipsitem_id=:ipsitem_id);" );
        else if(_discountSelected->isChecked())
        {
            if(_dscbyprodcat->isChecked())
            {
                q.prepare( "UPDATE ipsprodcat "
                           "   SET ipsprodcat_qtybreak=:ipsprodcat_qtybreak,"
                           "       ipsprodcat_discntprcnt=:ipsprodcat_discntprcnt,"
                           "       ipsprodcat_fixedamtdiscount=:ipsprodcat_fixedamtdiscount "
                           "WHERE (ipsprodcat_id=:ipsprodcat_id);" );
            }
            else if(_dscbyItem->isChecked())
            {
                q.prepare("UPDATE ipsiteminfo "
                          "SET ipsitem_qtybreak = :ipsitem_qtybreak, "
                          "    ipsitem_discntprcnt = :ipsitem_discntprcnt, "
                          "    ipsitem_fixedamtdiscount = :ipsitem_fixedamtdiscount "
                          "WHERE (ipsitem_id= :ipsitem_id);");
            }
        }
        else if(_freightSelected->isChecked())
            q.prepare( "UPDATE ipsfreight "
                       "   SET ipsfreight_qtybreak=:ipsfreight_qtybreak,"
                       "       ipsfreight_type=:ipsfreight_type,"
                       "       ipsfreight_price=:ipsfreight_price,"
                       "       ipsfreight_warehous_id=:ipsfreight_warehous_id,"
                       "       ipsfreight_shipzone_id=:ipsfreight_shipzone_id,"
                       "       ipsfreight_freightclass_id=:ipsfreight_freightclass_id,"
                       "       ipsfreight_shipvia=:ipsfreight_shipvia "
                       "WHERE (ipsfreight_id=:ipsfreight_id);" );
    }

    q.bindValue(":ipsitem_id", _ipsitemid);
    q.bindValue(":ipsprodcat_id", _ipsprodcatid);
    q.bindValue(":ipsfreight_id", _ipsfreightid);
    q.bindValue(":ipshead_id", _ipsheadid);

    if(_itemSelected->isChecked())
    {
        q.bindValue(":ipsitem_item_id", _item->id());
        q.bindValue(":ipsitem_qtybreak", _qtyBreak->toDouble());
        q.bindValue(":ipsitem_discntprcnt", 0.00);
        q.bindValue(":ipsitem_fixedamtdiscount", 0.00);
        q.bindValue(":ipsitem_price", _price->localValue());
    }
    else if((_discountSelected->isChecked()) && (_dscbyItem->isChecked()))
    {
        q.bindValue(":ipsitem_item_id", _dscitem->id());
        q.bindValue(":ipsitem_qtybreak", _qtyBreakCat->toDouble());
        q.bindValue(":ipsitem_discntprcnt", (_discount->toDouble() / 100.0));
        q.bindValue(":ipsitem_fixedamtdiscount", (_fixedAmtDiscount->localValue()));
        q.bindValue(":ipsitem_price", 0.00);
    }

    q.bindValue(":ipsprodcat_prodcat_id", _prodcat->id());
    q.bindValue(":ipsprodcat_qtybreak", _qtyBreakCat->toDouble());
    q.bindValue(":ipsfreight_qtybreak", _qtyBreakFreight->toDouble());
    q.bindValue(":ipsprodcat_discntprcnt", (_discount->toDouble() / 100.0));
    q.bindValue(":ipsprodcat_fixedamtdiscount", (_fixedAmtDiscount->localValue()));
    q.bindValue(":ipsfreight_price", _priceFreight->localValue());
    q.bindValue(":qty_uom_id", _qtyUOM->id());
    q.bindValue(":price_uom_id", _priceUOM->id());

    if (_flatRateFreight->isChecked())
        q.bindValue(":ipsfreight_type", "F");
    else
        q.bindValue(":ipsfreight_type", "P");
    if (_siteFreight->isSelected())
        q.bindValue(":ipsfreight_warehous_id", _siteFreight->id());
    if (_selectedZoneFreight->isChecked())
        q.bindValue(":ipsfreight_shipzone_id", _zoneFreight->id());
    if (_selectedFreightClass->isChecked())
        q.bindValue(":ipsfreight_freightclass_id", _freightClass->id());
    if (_selectedShipViaFreight->isChecked())
        q.bindValue(":ipsfreight_shipvia", _shipViaFreight->currentText());
    q.exec();
    if (q.lastError().type() != QSqlError::NoError)
    {
        systemError(this, _rejectedMsg.arg(q.lastError().databaseText()),
                    __FILE__, __LINE__);
        done(-1);
    }

    if (pClose)
    {
        if(_itemSelected->isChecked())
            done(_ipsitemid);
        if(_discountSelected->isChecked())
        {
            if(_dscbyItem->isChecked())
                done(_ipsitemid);
            else if(_dscbyprodcat->isChecked())
                done(_ipsprodcatid);
        }
        if(_freightSelected->isChecked())
            done(_ipsfreightid);
    }
    else
    {
        _mode = cEdit;

        _item->setReadOnly(TRUE);
        _prodcat->setEnabled(FALSE);
        _typeGroup->setEnabled(FALSE);
    }

}
示例#4
0
void
main (void)
{

  char_lt_char ();
  char_gt_char ();

  achar0++;
  char_lt_char ();
  char_gt_char ();
  char_gte_char ();
  char_lte_char ();

  achar1 = 0x10;
  char_lt_lit ();
  char_gt_lit ();
  char_lte_lit ();
  char_gte_lit ();


  achar0 = 0;
  achar1 = 0;

  char_lt_char_else ();
  char_gt_char_else ();

  achar0++;
  char_lt_char_else ();
  char_gt_char_else ();
  char_gte_char_else ();
  char_lte_char_else ();

  achar1 = 0x10;
  char_lt_lit_else ();
  char_gt_lit_else ();
  char_lte_lit_else ();
  char_gte_lit_else ();



  int_lt_int ();
  int_gt_int ();

  aint0++;
  int_lt_int ();
  int_gt_int ();
  int_gte_int ();
  int_lte_int ();

  aint1 = 0x10;
  int_lt_lit ();
  int_gt_lit ();
  int_lte_lit ();
  int_gte_lit ();

  aint0=0;
  aint1=0;
  int_lt_int_else ();
  int_gt_int_else ();

  aint0++;
  int_lt_int_else ();
  int_gt_int_else ();
  int_gte_int_else ();
  int_lte_int_else ();

  aint1 = 0x10;
  int_lt_lit_else ();
  int_gt_lit_else ();
  int_lte_lit_else ();
  int_gte_lit_else ();

  success = failures;
  done ();
}
示例#5
0
文件: error.c 项目: AhmadTux/freebsd
void
no_space(void)
{
    fprintf(stderr, "%s: f - out of space\n", myname);
    done(2);
}
void QQuickShapeFillRunnable::run()
{
    QQuickShapeGenericRenderer::triangulateFill(path, fillColor, &fillVertices, &fillIndices, &indexType, supportsElementIndexUint);
    emit done(this);
}
// ok button
void CoinControlDialog::buttonBoxClicked(QAbstractButton* button)
{
    if (ui->buttonBox->buttonRole(button) == QDialogButtonBox::AcceptRole)
        done(QDialog::Accepted); // closes the dialog
}
void traversal_algorithm::add_entry(node_id const& id, udp::endpoint addr, unsigned char flags)
{
	TORRENT_ASSERT(m_node.m_rpc.allocation_size() >= sizeof(find_data_observer));
	void* ptr = m_node.m_rpc.allocate_observer();
	if (ptr == 0)
	{
#ifdef TORRENT_DHT_VERBOSE_LOGGING
		TORRENT_LOG(traversal) << "[" << this << "] failed to allocate memory for observer. aborting!";
#endif
		done();
		return;
	}
	observer_ptr o = new_observer(ptr, addr, id);
	if (id.is_all_zeros())
	{
		o->set_id(generate_random_id());
		o->flags |= observer::flag_no_id;
	}

	o->flags |= flags;

	TORRENT_ASSERT(boost::algorithm::is_sorted(m_results.begin(), m_results.end()
		, boost::bind(
			compare_ref
			, boost::bind(&observer::id, _1)
			, boost::bind(&observer::id, _2)
			, m_target)
		));

	std::vector<observer_ptr>::iterator i = std::lower_bound(
		m_results.begin()
		, m_results.end()
		, o
		, boost::bind(
			compare_ref
			, boost::bind(&observer::id, _1)
			, boost::bind(&observer::id, _2)
			, m_target
		)
	);

	if (i == m_results.end() || (*i)->id() != id)
	{
		if (m_node.settings().restrict_search_ips
			&& !(flags & observer::flag_initial))
		{
			// don't allow multiple entries from IPs very close to each other
			std::vector<observer_ptr>::iterator j = std::find_if(
				m_results.begin(), m_results.end(), boost::bind(&compare_ip_cidr, _1, o));

			if (j != m_results.end())
			{
				// we already have a node in this search with an IP very
				// close to this one. We know that it's not the same, because
				// it claims a different node-ID. Ignore this to avoid attacks
#ifdef TORRENT_DHT_VERBOSE_LOGGING
			TORRENT_LOG(traversal) << "[" << this << "] IGNORING result "
				<< "id: " << o->id()
				<< " address: " << o->target_addr()
				<< " existing node: "
				<< (*j)->id() << " " << (*j)->target_addr()
				<< " distance: " << distance_exp(m_target, o->id())
				<< " type: " << name()
				;
#endif
				return;
			}
		}

		TORRENT_ASSERT(std::find_if(m_results.begin(), m_results.end()
			, boost::bind(&observer::id, _1) == id) == m_results.end());
#ifdef TORRENT_DHT_VERBOSE_LOGGING
		TORRENT_LOG(traversal) << "[" << this << "] ADD id: " << id
			<< " address: " << addr
			<< " distance: " << distance_exp(m_target, id)
			<< " invoke-count: " << m_invoke_count
			<< " type: " << name()
			;
#endif
		i = m_results.insert(i, o);

		TORRENT_ASSERT(boost::algorithm::is_sorted(m_results.begin(), m_results.end()
			, boost::bind(
				compare_ref
				, boost::bind(&observer::id, _1)
				, boost::bind(&observer::id, _2)
				, m_target)
			));
	}

	if (m_results.size() > 100)
	{
#if TORRENT_USE_ASSERTS
		for (int i = 100; i < m_results.size(); ++i)
			m_results[i]->m_was_abandoned = true;
#endif
		m_results.resize(100);
	}
}
// prevent request means that the total number of requests has
// overflown. This query failed because it was the oldest one.
// So, if this is true, don't make another request
void traversal_algorithm::failed(observer_ptr o, int flags)
{
	TORRENT_ASSERT(m_invoke_count >= 0);

	if (m_results.empty()) return;

	TORRENT_ASSERT(o->flags & observer::flag_queried);
	if (flags & short_timeout)
	{
		// short timeout means that it has been more than
		// two seconds since we sent the request, and that
		// we'll most likely not get a response. But, in case
		// we do get a late response, keep the handler
		// around for some more, but open up the slot
		// by increasing the branch factor
		if ((o->flags & observer::flag_short_timeout) == 0)
			++m_branch_factor;
		o->flags |= observer::flag_short_timeout;
#ifdef TORRENT_DHT_VERBOSE_LOGGING
		TORRENT_LOG(traversal) << "[" << this << "] 1ST_TIMEOUT "
			<< " id: " << o->id()
			<< " distance: " << distance_exp(m_target, o->id())
			<< " addr: " << o->target_ep()
			<< " branch-factor: " << m_branch_factor
			<< " invoke-count: " << m_invoke_count
			<< " type: " << name()
			;
#endif
	}
	else
	{
		o->flags |= observer::flag_failed;
		// if this flag is set, it means we increased the
		// branch factor for it, and we should restore it
		if (o->flags & observer::flag_short_timeout)
			--m_branch_factor;

#ifdef TORRENT_DHT_VERBOSE_LOGGING
		TORRENT_LOG(traversal) << "[" << this << "] TIMEOUT "
			<< " id: " << o->id()
			<< " distance: " << distance_exp(m_target, o->id())
			<< " addr: " << o->target_ep()
			<< " branch-factor: " << m_branch_factor
			<< " invoke-count: " << m_invoke_count
			<< " type: " << name()
			;
#endif
		// don't tell the routing table about
		// node ids that we just generated ourself
		if ((o->flags & observer::flag_no_id) == 0)
			m_node.m_table.node_failed(o->id(), o->target_ep());
		++m_timeouts;
		--m_invoke_count;
		TORRENT_ASSERT(m_invoke_count >= 0);
	}

	if (flags & prevent_request)
	{
		--m_branch_factor;
		if (m_branch_factor <= 0) m_branch_factor = 1;
	}
	bool is_done = add_requests();
	if (is_done) done();
}
示例#10
0
void accountingPeriod::sSave()
{
    if (_mode == cNew)
    {
        q.prepare("SELECT createAccountingPeriod(:startDate, :endDate, :yearperiod_id, :quarter) AS _period_id;");
        q.bindValue(":startDate", _startDate->date());
        q.bindValue(":endDate", _endDate->date());
        q.bindValue(":yearperiod_id", _year->id());
        q.bindValue(":quarter", _quarter->value());

        q.exec();
        if (q.first())
        {
            _periodid = q.value("_period_id").toInt();
            if (_periodid < 0)
            {
                systemError(this, storedProcErrorLookup("createAccountingPeriod", _periodid),
                            __FILE__, __LINE__);
                return;
            }
        }
        else if (q.lastError().type() != QSqlError::NoError)
        {
            systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
            return;
        }
    }
    else if (_mode == cEdit)
    {
        if ( (_cachedFrozen) && (!_frozen->isChecked()) )
        {
            q.prepare("SELECT thawAccountingPeriod(:period_id) AS result;");
            q.bindValue(":period_id", _periodid);
            q.exec();
            if (q.first())
            {
                int result = q.value("result").toInt();
                if (result < 0)
                {
                    systemError(this, storedProcErrorLookup("thawAccountingPeriod", result),
                                __FILE__, __LINE__);
                    return;
                }
            }
            else if (q.lastError().type() != QSqlError::NoError)
            {
                systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
                return;
            }
        }

        if ( (_cachedClosed) && (!_closed->isChecked()) )
        {
            bool reallyOpen = false;

            q.prepare("SELECT COUNT(gltrans_sequence) AS count "
                      "FROM gltrans, period "
                      "WHERE ( (NOT gltrans_posted) "
                      "AND (gltrans_date BETWEEN period_start AND period_end) "
                      "AND (period_id=:period_id) );");
            q.bindValue(":period_id", _periodid);
            q.exec();
            if (q.first())
            {
                if (q.value("count").toInt() <= 0)
                    reallyOpen = true;
                else
                {
                    ParameterList params;

                    unpostedGLTransactions newdlg(this, "", true);
                    params.append("period_id", _periodid);
                    newdlg.set(params);

                    reallyOpen = (newdlg.exec() == XDialog::Accepted);
                }
            }
            else if (q.lastError().type() != QSqlError::NoError)
            {
                systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
                return;
            }

            if (reallyOpen)
            {
                q.prepare("SELECT openAccountingPeriod(:period_id) AS result;");
                q.bindValue(":period_id", _periodid);
                q.exec();
                if (q.first())
                {
                    int result = q.value("result").toInt();
                    if (result < 0)
                    {
                        systemError(this, storedProcErrorLookup("openAccountingPeriod", result),
                                    __FILE__, __LINE__);
                        return;
                    }
                }
                else if (q.lastError().type() != QSqlError::NoError)
                {
                    systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
                    return;
                }
            }
            else
                return;
        }

        if ( (_cachedStartDate != _startDate->date()) ||
                (_cachedEndDate != _endDate->date()) )
        {
            q.prepare("SELECT changeAccountingPeriodDates(:period_id, :startDate, :endDate) AS result;");
            q.bindValue(":period_id", _periodid);
            q.bindValue(":startDate", _startDate->date());
            q.bindValue(":endDate", _endDate->date());
            q.exec();
            if (q.first())
            {
                int result = q.value("result").toInt();
                if (result < 0)
                {
                    systemError(this, storedProcErrorLookup("changeAccountingPeriodDates", result),
                                __FILE__, __LINE__);
                    return;
                }
            }
            else if (q.lastError().type() != QSqlError::NoError)
            {
                systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
                return;
            }
        }

        if ( (!_cachedFrozen) && (_frozen->isChecked()) )
        {
            q.prepare("SELECT freezeAccountingPeriod(:period_id) AS result;");
            q.bindValue(":period_id", _periodid);
            q.exec();
            if (q.first())
            {
                int result = q.value("result").toInt();
                if (result < 0)
                {
                    systemError(this, storedProcErrorLookup("freezeAccountingPeriod", result),
                                __FILE__, __LINE__);
                    return;
                }
            }
            else if (q.lastError().type() != QSqlError::NoError)
            {
                systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
                return;
            }
        }

        if ( (!_cachedClosed) && (_closed->isChecked()) )
        {
            q.prepare("SELECT closeAccountingPeriod(:period_id) AS result;");
            q.bindValue(":period_id", _periodid);
            q.exec();
            if (q.first())
            {
                int result = q.value("result").toInt();
                if (result < 0)
                {
                    systemError(this, storedProcErrorLookup("closeAccountingPeriod", result),
                                __FILE__, __LINE__);
                    return;
                }
            }
            else if (q.lastError().type() != QSqlError::NoError)
            {
                systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
                return;
            }
        }
    }

    if( (_cachedName != _name->text()) || (_cachedYearPeriodId != _year->id()) || (_cachedQuarter != _quarter->value()) )
    {
        q.prepare("SELECT yearperiod_id "
                  "FROM yearperiod "
                  "WHERE ((yearperiod_id=:yearperiod_id) "
                  "AND (:startDate>=yearperiod_start) "
                  " AND (:endDate<=yearperiod_end)); ");
        q.bindValue(":yearperiod_id", _year->id());
        q.bindValue(":startDate", _startDate->date());
        q.bindValue(":endDate", _endDate->date());
        q.exec();
        if (q.first())
        {
            q.prepare("UPDATE period SET period_name=:period_name,"
                      "                  period_yearperiod_id=:yearperiod_id,"
                      "                  period_quarter=:quarter"
                      " WHERE (period_id=:period_id); ");
            q.bindValue(":period_id", _periodid);
            q.bindValue(":period_name", _name->text());
            q.bindValue(":yearperiod_id", _year->id());
            q.bindValue(":quarter",	_quarter->value());
            q.exec();
            if (q.lastError().type() != QSqlError::NoError)
            {
                systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
                return;
            }
        }
        else if (q.lastError().type() != QSqlError::NoError)
        {
            systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
            return;
        }
        else
        {
            QMessageBox::critical( this, tr("Cannot Save Period"),
                                   tr("Period dates are outside the selected Fiscal Year.") );
            return;
        }
    }

    done(_periodid);
}
示例#11
0
void
Printer_done( Handle self)
{
	apc_prn_destroy( self);
	inherited done( self);
}
示例#12
0
void salesOrderList::sSelect()
{
  done(_so->id());
}
示例#13
0
void salesOrderList::sClose()
{
  done(_soheadid);
}
示例#14
0
cyclelink(void)
{
    nltype	*nlp;
    nltype	*cyclenlp;
    int			cycle;
    nltype		*memberp;
    arctype		*arcp;

	/*
	 *	Count the number of cycles, and initialze the cycle lists
	 */
    ncycle = 0;
    for ( nlp = nl ; nlp < npe ; nlp++ ) {
	    /*
	     *	this is how you find unattached cycles
	     */
	if ( nlp -> cyclehead == nlp && nlp -> cnext != 0 ) {
	    ncycle += 1;
	}
    }
	/*
	 *	cyclenl is indexed by cycle number:
	 *	i.e. it is origin 1, not origin 0.
	 */
    cyclenl = (nltype *) calloc( ncycle + 1 , sizeof( nltype ) );
    if ( cyclenl == 0 ) {
	warnx("no room for %d bytes of cycle headers",
		   ( ncycle + 1 ) * sizeof( nltype ) );
	done();
    }
	/*
	 *	now link cycles to true cycleheads,
	 *	number them, accumulate the data for the cycle
	 */
    cycle = 0;
    for ( nlp = nl ; nlp < npe ; nlp++ ) {
	if ( !( nlp -> cyclehead == nlp && nlp -> cnext != 0 ) ) {
	    continue;
	}
	cycle += 1;
	cyclenlp = &cyclenl[cycle];
        cyclenlp -> name = 0;		/* the name */
        cyclenlp -> value = 0;		/* the pc entry point */
        cyclenlp -> time = 0.0;		/* ticks in this routine */
        cyclenlp -> childtime = 0.0;	/* cumulative ticks in children */
	cyclenlp -> ncall = 0;		/* how many times called */
	cyclenlp -> selfcalls = 0;	/* how many calls to self */
	cyclenlp -> propfraction = 0.0;	/* what % of time propagates */
	cyclenlp -> propself = 0.0;	/* how much self time propagates */
	cyclenlp -> propchild = 0.0;	/* how much child time propagates */
	cyclenlp -> printflag = TRUE;	/* should this be printed? */
	cyclenlp -> index = 0;		/* index in the graph list */
	cyclenlp -> toporder = DFN_NAN;	/* graph call chain top-sort order */
	cyclenlp -> cycleno = cycle;	/* internal number of cycle on */
	cyclenlp -> cyclehead = cyclenlp;	/* pointer to head of cycle */
	cyclenlp -> cnext = nlp;	/* pointer to next member of cycle */
	cyclenlp -> parents = 0;	/* list of caller arcs */
	cyclenlp -> children = 0;	/* list of callee arcs */
#	ifdef DEBUG
	    if ( debug & CYCLEDEBUG ) {
		printf( "[cyclelink] " );
		printname( nlp );
		printf( " is the head of cycle %d\n" , cycle );
	    }
#	endif /* DEBUG */
	    /*
	     *	link members to cycle header
	     */
	for ( memberp = nlp ; memberp ; memberp = memberp -> cnext ) {
	    memberp -> cycleno = cycle;
	    memberp -> cyclehead = cyclenlp;
	}
	    /*
	     *	count calls from outside the cycle
	     *	and those among cycle members
	     */
	for ( memberp = nlp ; memberp ; memberp = memberp -> cnext ) {
	    for ( arcp=memberp->parents ; arcp ; arcp=arcp->arc_parentlist ) {
		if ( arcp -> arc_parentp == memberp ) {
		    continue;
		}
		if ( arcp -> arc_parentp -> cycleno == cycle ) {
		    cyclenlp -> selfcalls += arcp -> arc_count;
		} else {
		    cyclenlp -> npropcall += arcp -> arc_count;
		}
	    }
	}
    }
}
示例#15
0
void returnAuthCheck::sClose()
{
  done(-1);
}
 void                failed                  (void)          { m_failed = true; done(); }
示例#17
0
void returnAuthCheck::sSave()
{
  XSqlQuery returnSave;
  if (!_date->isValid())
  {
    QMessageBox::warning( this, tr("Cannot Create Miscellaneous Check"),
                          tr("<p>You must enter a date for this check.") );
    _date->setFocus();
    return;
  }

  else if (_amount->isZero())
  {
    QMessageBox::warning( this, tr("Cannot Create Miscellaneous Check"),
                          tr("<p>You must enter an amount for this check.") );
    return;
  }

  else if (!_bankaccnt->isValid())
  {
    QMessageBox::warning( this, tr("Cannot Create Miscellaneous Check"),
                          tr("<p>You must select a bank account for this check.") );
    _date->setFocus();
    return;
  }

  else
  {
    returnSave.prepare("SELECT createCheck(:bankaccnt_id, 'C', :recipid,"
	      "                   :checkDate, :amount, :curr_id, NULL,"
	      "                   NULL, :for, :notes, true, :aropen_id) AS result; ");
    returnSave.bindValue(":bankaccnt_id", _bankaccnt->id());
    returnSave.bindValue(":recipid",	_custid);
    returnSave.bindValue(":checkDate", _date->date());
    returnSave.bindValue(":amount",	_amount->localValue());
    returnSave.bindValue(":curr_id",	_amount->id());
    returnSave.bindValue(":for",	_for->text().trimmed());
    returnSave.bindValue(":notes", _notes->toPlainText().trimmed());
	returnSave.bindValue(":aropen_id", _aropenid);
	returnSave.exec();
    if (returnSave.first())
    {
      _checkid = returnSave.value("result").toInt();
      if (_checkid < 0)
      {
        ErrorReporter::error(QtCriticalMsg, this, tr("Error Retrieving Check Information"),
                               storedProcErrorLookup("createCheck", _checkid),
                               __FILE__, __LINE__);
        return;
      }
      returnSave.prepare( "SELECT checkhead_number "
               "FROM checkhead "
               "WHERE (checkhead_id=:check_id);" );
      returnSave.bindValue(":check_id", _checkid);
      returnSave.exec();
      if (ErrorReporter::error(QtCriticalMsg, this, tr("Error Retrieving Check Information"),
                                    returnSave, __FILE__, __LINE__))
      {
        return;
      }
	  done(true);
	}
    else if (ErrorReporter::error(QtCriticalMsg, this, tr("Error Retrieving Check Information"),
                                  returnSave, __FILE__, __LINE__))
    {
      return;
    }
  }
}
示例#18
0
TCPStreamDialog::TCPStreamDialog(QWidget *parent, capture_file *cf, tcp_graph_type graph_type) :
    QDialog(NULL, Qt::Window),
    ui(new Ui::TCPStreamDialog),
    cap_file_(cf),
    ts_offset_(0),
    ts_origin_conn_(true),
    seq_offset_(0),
    seq_origin_zero_(true),
    title_(NULL),
    base_graph_(NULL),
    tput_graph_(NULL),
    seg_graph_(NULL),
    ack_graph_(NULL),
    rwin_graph_(NULL),
    tracer_(NULL),
    packet_num_(0),
    mouse_drags_(true),
    rubber_band_(NULL),
    num_dsegs_(-1),
    num_acks_(-1),
    num_sack_ranges_(-1)
{
    struct segment current;
    int graph_idx = -1;

    ui->setupUi(this);
    setAttribute(Qt::WA_DeleteOnClose, true);

    graph_.type = GRAPH_UNDEFINED;
    set_address(&graph_.src_address, AT_NONE, 0, NULL);
    graph_.src_port = 0;
    set_address(&graph_.dst_address, AT_NONE, 0, NULL);
    graph_.dst_port = 0;
    graph_.stream = 0;
    graph_.segments = NULL;

    struct tcpheader *header = select_tcpip_session(cap_file_, &current);
    if (!header) {
        done(QDialog::Rejected);
        return;
    }

//#ifdef Q_OS_MAC
//    ui->hintLabel->setAttribute(Qt::WA_MacSmallSize, true);
//#endif

    QComboBox *gtcb = ui->graphTypeComboBox;
    gtcb->setUpdatesEnabled(false);
    gtcb->addItem(ui->actionRoundTripTime->text(), GRAPH_RTT);
    if (graph_type == GRAPH_RTT) graph_idx = gtcb->count() - 1;
    gtcb->addItem(ui->actionThroughput->text(), GRAPH_THROUGHPUT);
    if (graph_type == GRAPH_THROUGHPUT) graph_idx = gtcb->count() - 1;
    gtcb->addItem(ui->actionStevens->text(), GRAPH_TSEQ_STEVENS);
    if (graph_type == GRAPH_TSEQ_STEVENS) graph_idx = gtcb->count() - 1;
    gtcb->addItem(ui->actionTcptrace->text(), GRAPH_TSEQ_TCPTRACE);
    if (graph_type == GRAPH_TSEQ_TCPTRACE) graph_idx = gtcb->count() - 1;
    gtcb->addItem(ui->actionWindowScaling->text(), GRAPH_WSCALE);
    if (graph_type == GRAPH_WSCALE) graph_idx = gtcb->count() - 1;
    gtcb->setUpdatesEnabled(true);

    ui->dragRadioButton->setChecked(mouse_drags_);

    ctx_menu_.addAction(ui->actionZoomIn);
    ctx_menu_.addAction(ui->actionZoomInX);
    ctx_menu_.addAction(ui->actionZoomInY);
    ctx_menu_.addAction(ui->actionZoomOut);
    ctx_menu_.addAction(ui->actionZoomOutX);
    ctx_menu_.addAction(ui->actionZoomOutY);
    ctx_menu_.addAction(ui->actionReset);
    ctx_menu_.addSeparator();
    ctx_menu_.addAction(ui->actionMoveRight10);
    ctx_menu_.addAction(ui->actionMoveLeft10);
    ctx_menu_.addAction(ui->actionMoveUp10);
    ctx_menu_.addAction(ui->actionMoveDown10);
    ctx_menu_.addAction(ui->actionMoveRight1);
    ctx_menu_.addAction(ui->actionMoveLeft1);
    ctx_menu_.addAction(ui->actionMoveUp1);
    ctx_menu_.addAction(ui->actionMoveDown1);
    ctx_menu_.addSeparator();
    ctx_menu_.addAction(ui->actionNextStream);
    ctx_menu_.addAction(ui->actionPreviousStream);
    ctx_menu_.addAction(ui->actionSwitchDirection);
    ctx_menu_.addAction(ui->actionGoToPacket);
    ctx_menu_.addSeparator();
    ctx_menu_.addAction(ui->actionDragZoom);
    ctx_menu_.addAction(ui->actionToggleSequenceNumbers);
    ctx_menu_.addAction(ui->actionToggleTimeOrigin);
    ctx_menu_.addAction(ui->actionCrosshairs);
    ctx_menu_.addSeparator();
    ctx_menu_.addAction(ui->actionRoundTripTime);
    ctx_menu_.addAction(ui->actionThroughput);
    ctx_menu_.addAction(ui->actionStevens);
    ctx_menu_.addAction(ui->actionTcptrace);
    ctx_menu_.addAction(ui->actionWindowScaling);

    memset (&graph_, 0, sizeof(graph_));
    graph_.type = graph_type;
    copy_address(&graph_.src_address, &current.ip_src);
    graph_.src_port = current.th_sport;
    copy_address(&graph_.dst_address, &current.ip_dst);
    graph_.dst_port = current.th_dport;
    graph_.stream = header->th_stream;
    findStream();

    ui->streamNumberSpinBox->blockSignals(true);
    ui->streamNumberSpinBox->setMaximum(get_tcp_stream_count() - 1);
    ui->streamNumberSpinBox->setValue(graph_.stream);
    ui->streamNumberSpinBox->blockSignals(false);

    QCustomPlot *sp = ui->streamPlot;
    QCPPlotTitle *file_title = new QCPPlotTitle(sp, cf_get_display_name(cap_file_));
    file_title->setFont(sp->xAxis->labelFont());
    title_ = new QCPPlotTitle(sp);
    sp->plotLayout()->insertRow(0);
    sp->plotLayout()->addElement(0, 0, file_title);
    sp->plotLayout()->insertRow(0);
    sp->plotLayout()->addElement(0, 0, title_);

    base_graph_ = sp->addGraph(); // All: Selectable segments
    base_graph_->setPen(QPen(QBrush(graph_color_1), 0.25));
    tput_graph_ = sp->addGraph(sp->xAxis, sp->yAxis2); // Throughput: Moving average
    tput_graph_->setPen(QPen(QBrush(graph_color_2), 0.5));
    tput_graph_->setLineStyle(QCPGraph::lsLine);
    seg_graph_ = sp->addGraph(); // tcptrace: fwd segments
    seg_graph_->setErrorType(QCPGraph::etValue);
    seg_graph_->setLineStyle(QCPGraph::lsNone);
    seg_graph_->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssDot, Qt::transparent, 0));
    seg_graph_->setErrorPen(QPen(QBrush(graph_color_1), 0.5));
    seg_graph_->setErrorBarSize(pkt_point_size_);
    ack_graph_ = sp->addGraph(); // tcptrace: rev ACKs
    ack_graph_->setPen(QPen(QBrush(graph_color_2), 0.5));
    ack_graph_->setLineStyle(QCPGraph::lsStepLeft);
    rwin_graph_ = sp->addGraph(); // tcptrace: rev RWIN
    rwin_graph_->setPen(QPen(QBrush(graph_color_3), 0.5));
    rwin_graph_->setLineStyle(QCPGraph::lsStepLeft);

    tracer_ = new QCPItemTracer(sp);
    sp->addItem(tracer_);

    // Triggers fillGraph().
    ui->graphTypeComboBox->setCurrentIndex(graph_idx);

    sp->setMouseTracking(true);

    sp->yAxis->setLabelColor(QColor(graph_color_1));
    sp->yAxis->setTickLabelColor(QColor(graph_color_1));

    tracer_->setVisible(false);
    toggleTracerStyle(true);

    QPushButton *save_bt = ui->buttonBox->button(QDialogButtonBox::Save);
    save_bt->setText(tr("Save As" UTF8_HORIZONTAL_ELLIPSIS));

    QPushButton *close_bt = ui->buttonBox->button(QDialogButtonBox::Close);
    if (close_bt) {
        close_bt->setDefault(true);
    }

    ProgressFrame::addToButtonBox(ui->buttonBox, parent);

    connect(sp, SIGNAL(mousePress(QMouseEvent*)), this, SLOT(graphClicked(QMouseEvent*)));
    connect(sp, SIGNAL(mouseMove(QMouseEvent*)), this, SLOT(mouseMoved(QMouseEvent*)));
    connect(sp, SIGNAL(mouseRelease(QMouseEvent*)), this, SLOT(mouseReleased(QMouseEvent*)));
    connect(sp, SIGNAL(axisClick(QCPAxis*,QCPAxis::SelectablePart,QMouseEvent*)),
            this, SLOT(axisClicked(QCPAxis*,QCPAxis::SelectablePart,QMouseEvent*)));
    connect(sp->yAxis, SIGNAL(rangeChanged(QCPRange)), this, SLOT(transformYRange(QCPRange)));
    disconnect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
    this->setResult(QDialog::Accepted);
}
void QQuickShapeStrokeRunnable::run()
{
    QQuickShapeGenericRenderer::triangulateStroke(path, pen, strokeColor, &strokeVertices, clipSize);
    emit done(this);
}
示例#20
0
void apOpenItem::sSave()
{
  if (_mode == cNew)
  {
    if (!_docDate->isValid())
    {
      QMessageBox::critical( this, tr("Cannot Save A/P Memo"),
                             tr("<p>You must enter a date for this A/P Memo "
                                "before you may save it") );
      _docDate->setFocus();
      return;
    }

    if (!_dueDate->isValid())
    {
      QMessageBox::critical( this, tr("Cannot Save A/P Memo"),
                             tr("<p>You must enter a date for this A/P Memo "
                                "before you may save it") );
      _dueDate->setFocus();
      return;
    }

    if (_amount->isZero())
    {
      QMessageBox::critical( this, tr("Cannot Save A/P Memo"),
                             tr("<p>You must enter an amount for this A/P Memo "
                                "before you may save it") );
      _amount->setFocus();
      return;
    }

    if (_altPrepaid->isChecked() && (!_altAccntid->isValid()))
    {
      QMessageBox::critical( this, tr("Cannot Save A/P Memo"),
                            tr("<p>You must choose a valid Alternate Prepaid "
                               "Account Number for this A/P Memo before you "
                               "may save it.") );
      return;
    }

    QString tmpFunctionName;
    QString queryStr;

    if (_docType->currentIndex() == 0)
      tmpFunctionName = "createAPCreditMemo";
    else if (_docType->currentIndex() == 1)
      tmpFunctionName = "createAPDebitMemo";
    else
    {
      systemError(this,
		  tr("Internal Error: _docType has an invalid document type %1")
		  .arg(_docType->currentIndex()), __FILE__, __LINE__);
      return;
    }

    queryStr = "SELECT " + tmpFunctionName + "( :vend_id, " +
		(_journalNumber->text().isEmpty() ?
		      QString("fetchJournalNumber('AP-MISC')") : _journalNumber->text()) +
	       ", :apopen_docnumber, :apopen_ponumber, :apopen_docdate,"
	       "  :apopen_amount, :apopen_notes, :apopen_accnt_id,"
	       "  :apopen_duedate, :apopen_terms_id, :curr_id ) AS result;";
    q.prepare(queryStr);
    q.bindValue(":vend_id", _vend->id());
    q.bindValue(":apopen_docdate", _docDate->date());
  }
  else if (_mode == cEdit)
  {
    if (_cAmount != _amount->localValue())
      if ( QMessageBox::warning( this, tr("A/P Open Amount Changed"),
                                 tr( "<p>You are changing the open amount of "
                                    "this A/P Open Item.  If you do not post a "
                                    "G/L Transaction to distribute this change "
                                    "then the A/P Open Item total will be out "
                                    "of balance with the A/P Trial Balance(s). "
                                    "Are you sure that you want to save this "
                                    "change?" ),
                                 tr("Yes"), tr("No"), QString::null ) == 1 )
        return;

    q.prepare( "UPDATE apopen "
	       "SET apopen_doctype=:apopen_doctype,"
               "    apopen_ponumber=:apopen_ponumber, apopen_docnumber=:apopen_docnumber,"
               "    apopen_amount=:apopen_amount,"
               "    apopen_terms_id=:apopen_terms_id, "
	       "    apopen_notes=:apopen_notes, "
	       "    apopen_curr_id=:curr_id "
               "WHERE (apopen_id=:apopen_id);" );
    q.bindValue(":apopen_id", _apopenid);
  }

  q.bindValue(":apopen_docnumber", _docNumber->text());
  q.bindValue(":apopen_duedate", _dueDate->date());
  q.bindValue(":apopen_ponumber", _poNumber->text());
  q.bindValue(":apopen_amount", _amount->localValue());
  q.bindValue(":apopen_notes",   _notes->toPlainText());
  q.bindValue(":curr_id", _amount->id());
  q.bindValue(":apopen_terms_id", _terms->id());
  if(_altPrepaid->isChecked())
    q.bindValue(":apopen_accnt_id", _altAccntid->id());
  else
    q.bindValue(":apopen_accnt_id", -1);

  switch (_docType->currentIndex())
  {
    case 0:
      q.bindValue(":apopen_doctype", "C");
      break;

    case 1:
      q.bindValue(":apopen_doctype", "D");
      break;

    case 2:
      q.bindValue(":apopen_doctype", "V");
      break;
  }

  q.exec();
  if (q.first())
  {
    if (_mode == cNew)
    {
      if (q.value("result").toInt() == -1)
      {
        QMessageBox::critical( this, tr("Cannot Create A/P Memo"),
                               tr( "<p>The A/P Memo cannot be created as there "
                                  "are missing A/P Account Assignments for the "
                                  "selected Vendor. You must create an A/P "
                                  "Account Assignment for the selected "
                                  "Vendor's Vendor Type before you may create "
                                  "this A/P Memo." ) );
        return;
      }
    }
  }
  else if (q.lastError().type() != QSqlError::NoError)
  {
    systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
    return;
  }

  if (_mode == cEdit)
    done(_apopenid);
  else
    done(q.value("result").toInt());
}
DosageSenderTester::DosageSenderTester(QObject *parent) :
        QObject(parent)
{
    connect(mfDrugsIO::instance(), SIGNAL(transmissionDone()), this, SLOT(done()));
}
示例#22
0
void subaccount::sSave()
{
  XSqlQuery subaccountSave;
  if (_number->text().length() == 0)
  {
      QMessageBox::warning( this, tr("Cannot Save Sub Account"),
                            tr("You must enter a valid Number.") );
      return;
  }
  
  subaccountSave.prepare("SELECT subaccnt_id"
            "  FROM subaccnt"
            " WHERE((subaccnt_id != :subaccnt_id)"
            "   AND (subaccnt_number=:subaccnt_number))");
  subaccountSave.bindValue(":subaccnt_id", _subaccntid);
  subaccountSave.bindValue(":subaccnt_number", _number->text());
  subaccountSave.exec();
  if(subaccountSave.first())
  {
    QMessageBox::critical(this, tr("Duplicate Sub Account Number"),
      tr("A Sub Account Number already exists for the one specified.") );
    return;
  }

  if (_mode == cNew)
  {
    subaccountSave.exec("SELECT NEXTVAL('subaccnt_subaccnt_id_seq') AS subaccnt_id;");
    if (subaccountSave.first())
      _subaccntid = subaccountSave.value("subaccnt_id").toInt();
    else if (ErrorReporter::error(QtCriticalMsg, this, tr("Error Retrieving Sub Account Information"),
                                  subaccountSave, __FILE__, __LINE__))
    {
      return;
    }
    
    subaccountSave.prepare( "INSERT INTO subaccnt "
               "( subaccnt_id, subaccnt_number, subaccnt_descrip ) "
               "VALUES "
               "( :subaccnt_id, :subaccnt_number, :subaccnt_descrip );" );
  }
  else if (_mode == cEdit)
  {
    if (_number->text() != _cachedNumber &&
        QMessageBox::question(this, tr("Change All Accounts?"),
                              tr("<p>The old Subaccount Number %1 might be "
                                 "used by existing Accounts. Would you like to "
                                 "change all accounts that use it to Subaccount"
                                 " Number %2?<p>If you answer 'No' then change "
                                 "the Number back to %3 and Save again.")
                                .arg(_cachedNumber)
                                .arg(_number->text())
                                .arg(_cachedNumber),
                              QMessageBox::Yes,
                              QMessageBox::No | QMessageBox::Default) == QMessageBox::No)
      return;

    subaccountSave.prepare( "UPDATE subaccnt "
               "SET subaccnt_number=:subaccnt_number,"
               "    subaccnt_descrip=:subaccnt_descrip "
               "WHERE (subaccnt_id=:subaccnt_id);" );
  }
  
  subaccountSave.bindValue(":subaccnt_id", _subaccntid);
  subaccountSave.bindValue(":subaccnt_number", _number->text());
  subaccountSave.bindValue(":subaccnt_descrip", _descrip->toPlainText());
  subaccountSave.exec();
  if (ErrorReporter::error(QtCriticalMsg, this, tr("Error Saving Sub Account Information"),
                                subaccountSave, __FILE__, __LINE__))
  {
    return;
  }
  
  done(_subaccntid);
}
示例#23
0
文件: send.c 项目: dscho/nmh
int
main (int argc, char **argv)
{
    int msgp = 0, distsw = 0, vecp;
    int isdf = 0, mime = 0;
    int msgnum, status;
    char *cp, *dfolder = NULL, *maildir = NULL;
    char buf[BUFSIZ], **ap, **argp, **arguments, *program;
    char *msgs[MAXARGS], **vec;
    struct msgs *mp;
    struct stat st;

    if (nmh_init(argv[0], 1)) { return 1; }

    arguments = getarguments (invo_name, argc, argv, 1);
    argp = arguments;

    vec = argsplit(postproc, &program, &vecp);

    vec[vecp++] = "-library";
    vec[vecp++] = getcpy (m_maildir (""));

    if ((cp = context_find ("fileproc"))) {
	vec[vecp++] = "-fileproc";
	vec[vecp++] = cp;
    }

    if ((cp = context_find ("mhlproc"))) {
	vec[vecp++] = "-mhlproc";
	vec[vecp++] = cp;
    }

    if ((cp = context_find ("credentials"))) {
	/* post doesn't read context so need to pass credentials. */
	vec[vecp++] = "-credentials";
	vec[vecp++] = cp;
    }

    while ((cp = *argp++)) {
	if (*cp == '-') {
	    switch (smatch (++cp, switches)) {
		case AMBIGSW: 
		    ambigsw (cp, switches);
		    done (1);
		case UNKWNSW: 
		    adios (NULL, "-%s unknown\n", cp);

		case HELPSW: 
		    snprintf (buf, sizeof(buf), "%s [file] [switches]", invo_name);
		    print_help (buf, switches, 1);
		    done (0);
		case VERSIONSW:
		    print_version(invo_name);
		    done (0);

		case DRAFTSW: 
		    msgs[msgp++] = draft;
		    continue;

		case DFOLDSW: 
		    if (dfolder)
			adios (NULL, "only one draft folder at a time!");
		    if (!(cp = *argp++) || *cp == '-')
			adios (NULL, "missing argument to %s", argp[-2]);
		    dfolder = path (*cp == '+' || *cp == '@' ? cp + 1 : cp,
			    *cp != '@' ? TFOLDER : TSUBCWF);
		    continue;
		case DMSGSW: 
		    if (!(cp = *argp++) || *cp == '-')
			adios (NULL, "missing argument to %s", argp[-2]);
		    msgs[msgp++] = cp;
		    continue;
		case NDFLDSW: 
		    dfolder = NULL;
		    isdf = NOTOK;
		    continue;

		case PUSHSW: 
		    pushsw++;
		    continue;
		case NPUSHSW: 
		    pushsw = 0;
		    continue;

		case SPLITSW: 
		    if (!(cp = *argp++) || sscanf (cp, "%d", &splitsw) != 1)
			adios (NULL, "missing argument to %s", argp[-2]);
		    continue;

		case UNIQSW: 
		    unique++;
		    continue;
		case NUNIQSW: 
		    unique = 0;
		    continue;

		case FORWSW:
		    forwsw++;
		    continue;
		case NFORWSW:
		    forwsw = 0;
		    continue;

		case VERBSW: 
		    verbsw++;
		    vec[vecp++] = --cp;
		    continue;
		case NVERBSW:
		    verbsw = 0;
		    vec[vecp++] = --cp;
		    continue;

		case MIMESW:
		    mime++;
		    vec[vecp++] = --cp;
		    continue;
		case NMIMESW:
		    mime = 0;
		    vec[vecp++] = --cp;
		    continue;

		case DEBUGSW: 
		    debugsw++;	/* fall */
		case NFILTSW: 
		case FRMTSW: 
		case NFRMTSW: 
		case BITSTUFFSW:
		case NBITSTUFFSW:
		case MSGDSW: 
		case NMSGDSW: 
		case WATCSW: 
		case NWATCSW: 
		case SNOOPSW: 
		case SASLSW:
		case NOSASLSW:
		case TLSSW:
		case INITTLSSW:
		case NTLSSW:
		    vec[vecp++] = --cp;
		    continue;

		case ALIASW: 
		case FILTSW: 
		case WIDTHSW: 
		case CLIESW: 
		case SERVSW: 
		case SASLMECHSW:
		case SASLMXSSFSW:
		case USERSW:
		case PORTSW:
		case MTSSW:
		case MESSAGEIDSW:
		    vec[vecp++] = --cp;
		    if (!(cp = *argp++) || *cp == '-')
			adios (NULL, "missing argument to %s", argp[-2]);
		    vec[vecp++] = cp;
		    continue;
		
		case ATTACHSW:
		    advise(NULL, "The -attach switch is deprecated");
		    continue;
		case NOATTACHSW:
		    advise(NULL, "The -noattach switch is deprecated");
		    continue;

		case ATTACHFORMATSW:
		    advise(NULL, "The -attachformat switch is deprecated");
		    continue;
	    }
	} else {
	    msgs[msgp++] = cp;
	}
    }

    /*
     * check for "Aliasfile:" profile entry
     */
    if ((cp = context_find ("Aliasfile"))) {
	char *dp = NULL;

	for (ap = brkstring(dp = getcpy(cp), " ", "\n"); ap && *ap; ap++) {
	    vec[vecp++] = "-alias";
	    vec[vecp++] = *ap;
	}
    }

    if (dfolder == NULL) {
	if (msgp == 0) {
	    msgs[msgp++] = getcpy (m_draft (NULL, NULL, 1, &isdf));
	    if (stat (msgs[0], &st) == NOTOK)
		adios (msgs[0], "unable to stat draft file");
	    cp = concat ("Use \"", msgs[0], "\"? ", NULL);
	    for (status = LISTDSW; status != YESW;) {
		if (!(argp = getans (cp, anyl)))
		    done (1);
		switch (status = smatch (*argp, anyl)) {
		    case NOSW: 
			done (0);
		    case YESW: 
			break;
		    case LISTDSW: 
			showfile (++argp, msgs[0]);
			break;
		    default:
			advise (NULL, "say what?");
			break;
		}
	    }
	} else {
	    for (msgnum = 0; msgnum < msgp; msgnum++)
		msgs[msgnum] = getcpy (m_maildir (msgs[msgnum]));
	}
    } else {
	if (!context_find ("path"))
	    free (path ("./", TFOLDER));

	if (!msgp)
	    msgs[msgp++] = "cur";
	maildir = m_maildir (dfolder);

	if (chdir (maildir) == NOTOK)
	    adios (maildir, "unable to change directory to");

	/* read folder and create message structure */
	if (!(mp = folder_read (dfolder, 1)))
	    adios (NULL, "unable to read folder %s", dfolder);

	/* check for empty folder */
	if (mp->nummsg == 0)
	    adios (NULL, "no messages in %s", dfolder);

	/* parse all the message ranges/sequences and set SELECTED */
	for (msgnum = 0; msgnum < msgp; msgnum++)
	    if (!m_convert (mp, msgs[msgnum]))
		done (1);
	seq_setprev (mp);	/* set the previous-sequence */

	for (msgp = 0, msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
	    if (is_selected (mp, msgnum)) {
		msgs[msgp++] = getcpy (m_name (msgnum));
		unset_exists (mp, msgnum);
	    }
	}

	mp->msgflags |= SEQMOD;
	seq_save (mp);
    }

#ifdef WHATNOW
go_to_it:
#endif /* WHATNOW */

    if ((cp = getenv ("SIGNATURE")) == NULL || *cp == 0)
	if ((cp = context_find ("signature")) && *cp)
	    m_putenv ("SIGNATURE", cp);

    for (msgnum = 0; msgnum < msgp; msgnum++)
	if (stat (msgs[msgnum], &st) == NOTOK)
	    adios (msgs[msgnum], "unable to stat draft file");

    if ((annotext = getenv ("mhannotate")) == NULL || *annotext == 0)
	annotext = NULL;
    if (annotext && ((cp = getenv ("mhinplace")) != NULL && *cp != 0))
	inplace = atoi (cp);
    if ((altmsg = getenv ("mhaltmsg")) == NULL || *altmsg == 0)
	altmsg = NULL;	/* used by dist interface - see below */

    if ((cp = getenv ("mhdist"))
	    && *cp
	    && (distsw = atoi (cp))
	    && altmsg) {
	vec[vecp++] = "-dist";
	if ((cp = m_mktemp2(altmsg, invo_name, NULL, NULL)) == NULL) {
	    adios(NULL, "unable to create temporary file in %s",
		  get_temp_dir());
	}
	distfile = getcpy (cp);
	(void) m_unlink(distfile);
	if (link (altmsg, distfile) == NOTOK) {
	    /* Cygwin with FAT32 filesystem produces EPERM. */
	    if (errno != EXDEV  &&  errno != EPERM
#ifdef EISREMOTE
		    && errno != EISREMOTE
#endif /* EISREMOTE */
		)
		adios (distfile, "unable to link %s to", altmsg);
	    free (distfile);
	    if ((cp = m_mktemp2(NULL, invo_name, NULL, NULL)) == NULL) {
		adios(NULL, "unable to create temporary file in %s",
		      get_temp_dir());
	    }
	    distfile = getcpy (cp);
	    {
		int in, out;
		struct stat st;

		if ((in = open (altmsg, O_RDONLY)) == NOTOK)
		    adios (altmsg, "unable to open");
		fstat(in, &st);
		if ((out = creat (distfile, (int) st.st_mode & 0777)) == NOTOK)
		    adios (distfile, "unable to write");
		cpydata (in, out, altmsg, distfile);
		close (in);
		close (out);
	    }	
	}
    } else {
	distfile = NULL;
    }

    if (altmsg == NULL || stat (altmsg, &st) == NOTOK) {
	st.st_mtime = 0;
	st.st_dev = 0;
	st.st_ino = 0;
    }
    if (pushsw)
	push ();

    status = 0;
    closefds (3);

    for (msgnum = 0; msgnum < msgp; msgnum++) {
	switch (sendsbr (vec, vecp, program, msgs[msgnum], &st, 1)) {
	    case DONE: 
		done (++status);
	    case NOTOK: 
		status++;	/* fall */
	    case OK:
		break;
	}
    }

    context_save ();	/* save the context file */
    done (status);
    return 1;
}
示例#24
0
void taxZone::sSave()
{
  XSqlQuery taxSave;
  if (_taxZone->text().length() == 0)
  {
      QMessageBox::warning( this, tr("Cannot Save Tax Zone"),
                            tr("You must enter a valid Code.") );
      return;
  }
  
  if (_mode == cEdit)
  {
    taxSave.prepare( "SELECT taxzone_id "
               "FROM taxzone "
               "WHERE ( (taxzone_id<>:taxzone_id)"
               " AND (UPPER(taxzone_code)=UPPER(:taxzone_code)) );");
    taxSave.bindValue(":taxzone_id", _taxzoneid);
  }
  else
  {
    taxSave.prepare( "SELECT taxzone_id "
               "FROM taxzone "
               "WHERE (taxzone_code=:taxzone_code);");
  }
  taxSave.bindValue(":taxzone_code", _taxZone->text().trimmed());
  taxSave.exec();
  if (taxSave.first())
  {
    QMessageBox::critical( this, tr("Cannot Create Tax Zone"),
			   tr( "A Tax Zone with the entered code already exists."
			       "You may not create a Tax Zone with this code." ) );
    _taxZone->setFocus();
    return;
  }
  else if (taxSave.lastError().type() != QSqlError::NoError)
  {
    systemError(this, taxSave.lastError().databaseText(), __FILE__, __LINE__);
    return;
  }

  XSqlQuery rollback;
  rollback.prepare("ROLLBACK;");

  taxSave.exec("BEGIN;");

  if (_mode == cEdit)
  {
    taxSave.prepare( "UPDATE taxzone "
               "SET taxzone_code=:taxzone_code,"
               "    taxzone_descrip=:taxzone_descrip "
               "WHERE (taxzone_id=:taxzone_id);" );
  }
  else if (_mode == cNew)
  {
    taxSave.exec("SELECT NEXTVAL('taxzone_taxzone_id_seq') AS taxzone_id;");
    if (taxSave.first())
      _taxzoneid = taxSave.value("taxzone_id").toInt();
    else if (taxSave.lastError().type() != QSqlError::NoError)
    {
      rollback.exec();
      systemError(this, taxSave.lastError().databaseText(), __FILE__, __LINE__);
      return;
    }

    taxSave.prepare( "INSERT INTO taxzone "
               "(taxzone_id, taxzone_code, taxzone_descrip)" 
               "VALUES "
               "(:taxzone_id, :taxzone_code, :taxzone_descrip);" ); 
  }
  taxSave.bindValue(":taxzone_id", _taxzoneid);
  taxSave.bindValue(":taxzone_code", _taxZone->text().trimmed());
  taxSave.bindValue(":taxzone_descrip", _description->text());
  taxSave.exec();
  if (taxSave.lastError().type() != QSqlError::NoError)
  {
    rollback.exec();
    systemError(this, taxSave.lastError().databaseText(), __FILE__, __LINE__);
    return;
  }

  taxSave.exec("COMMIT;");

  done(_taxzoneid);
}
示例#25
0
文件: error.c 项目: AhmadTux/freebsd
void
open_error(const char *filename)
{
    fprintf(stderr, "%s: f - cannot open \"%s\"\n", myname, filename);
    done(2);
}
示例#26
0
void address::sSave()
{
   internalSave();
   done(_addr->id());
}
示例#27
0
void company::sSave()
{
  XSqlQuery companySave;
  if (_number->text().length() == 0)
  {
      QMessageBox::warning( this, tr("Cannot Save Company"),
                            tr("You must enter a valid Number.") );
      _number->setFocus();
      return;
  }
  
  struct {
    bool	condition;
    QString	msg;
    QWidget*	widget;
  } error[] = {
    { _external->isChecked() && _extServer->text().isEmpty(),
      tr("<p>You must enter a Server if this is an external Company."),
      _extServer
    },
    { _external->isChecked() && _extPort->value() == 0,
      tr("<p>You must enter a Port if this is an external Company."),
      _extPort
    },
    { _external->isChecked() && _extDB->text().isEmpty(),
      tr("<p>You must enter a Database if this is an external Company."),
      _extDB
    },
    { true, "", NULL }
  }; // error[]

  int errIndex;
  for (errIndex = 0; ! error[errIndex].condition; errIndex++)
    ;
  if (! error[errIndex].msg.isEmpty())
  {
    QMessageBox::critical(this, tr("Cannot Save Company"),
			  error[errIndex].msg);
    error[errIndex].widget->setFocus();
    return;
  }

  companySave.prepare("SELECT company_id"
            "  FROM company"
            " WHERE((company_id != :company_id)"
            "   AND (company_number=:company_number))");
  companySave.bindValue(":company_id",       _companyid);
  companySave.bindValue(":company_number",   _number->text());
  companySave.exec();
  if(companySave.first())
  {
    QMessageBox::critical(this, tr("Duplicate Company Number"),
      tr("A Company Number already exists for the one specified.") );
    _number->setFocus();
    return;
  }

  if (_yearend->isValid() &&
      _companyid != _yearend->companyId())
  {
    QMessageBox::critical(this, tr("Company Account Mismatch"),
                          tr("The Retained Earnings Account must belong to this Company.") );
    _yearend->setFocus();
    return;
  }

  if (_gainloss->isValid() &&
      _companyid != _gainloss->companyId())
  {
    QMessageBox::critical(this, tr("Company Account Mismatch"),
                          tr("The Currency Gain/Loss Account must belong to this Company.") );
    _gainloss->setFocus();
    return;
  }

  if (_discrepancy->isValid() &&
      _companyid != _discrepancy->companyId())
  {
    QMessageBox::critical(this, tr("Company Account Mismatch"),
                          tr("The G/L Discrepancy Account must belong to this Company.") );
    _discrepancy->setFocus();
    return;
  }

  if (_unrlzgainloss->isValid() &&
      _companyid != _unrlzgainloss->companyId())
  {
    QMessageBox::critical(this, tr("Company Account Mismatch"),
                          tr("The Unrealized Currency Gain/Loss Account must belong to this Company.") );
    _unrlzgainloss->setFocus();
    return;
  }

  if (_mode == cNew)
  {
    companySave.exec("SELECT NEXTVAL('company_company_id_seq') AS company_id;");
    if (companySave.first())
      _companyid = companySave.value("company_id").toInt();
    else if (companySave.lastError().type() != QSqlError::NoError)
    {
      systemError(this, companySave.lastError().databaseText(), __FILE__, __LINE__);
      return;
    }
    
    companySave.prepare( "INSERT INTO company "
               "( company_id, company_number, company_descrip,"
               "  company_external, company_server, company_port,"
               "  company_database, company_curr_id, company_yearend_accnt_id, "
               "  company_gainloss_accnt_id, company_dscrp_accnt_id, "
               "  company_unrlzgainloss_accnt_id) "
               "VALUES "
               "( :company_id, :company_number, :company_descrip,"
               "  :company_external, :company_server, :company_port, "
               "  :company_database, :company_curr_id, :company_yearend_accnt_id, "
               "  :company_gainloss_accnt_id, :company_dscrp_accnt_id, "
               "  :company_unrlzgainloss_accnt_id);" );
  }
  else if (_mode == cEdit)
  {
    if (_number->text() != _cachedNumber &&
        QMessageBox::question(this, tr("Change All Accounts?"),
                          _external->isChecked() ?
                              tr("<p>The old Company Number %1 might be used "
                                 "by existing Accounts, including Accounts in "
                                 "the %2 child database. Would you like to "
                                 "change all accounts in the current database "
                                 "that use it to Company Number %3?<p>If you "
                                 "answer 'No' then either Cancel or change the "
                                 "Number back to %4 and Save again. If you "
                                 "answer 'Yes' then change the Company Number "
                                 "in the child database as well.")
                                .arg(_cachedNumber)
                                .arg(_extDB->text())
                                .arg(_number->text())
                                .arg(_cachedNumber)
                            :
                              tr("<p>The old Company Number %1 might be used "
                                 "by existing Accounts. Would you like to "
                                 "change all accounts that use it to Company "
                                 "Number %2?<p>If you answer 'No' then either "
                                 "Cancel or change "
                                 "the Number back to %3 and Save again.")
                                .arg(_cachedNumber)
                                .arg(_number->text())
                                .arg(_cachedNumber),
                              QMessageBox::Yes,
                              QMessageBox::No | QMessageBox::Default) == QMessageBox::No)
      return;

    companySave.prepare( "UPDATE company "
               "SET company_number=:company_number,"
               "    company_descrip=:company_descrip,"
               "    company_external=:company_external,"
               "    company_server=:company_server,"
               "    company_port=:company_port,"
               "    company_database=:company_database, "
               "    company_curr_id=:company_curr_id, "
               "    company_yearend_accnt_id=:company_yearend_accnt_id, "
               "    company_gainloss_accnt_id=:company_gainloss_accnt_id, "
               "    company_dscrp_accnt_id=:company_dscrp_accnt_id, "
               "    company_unrlzgainloss_accnt_id=:company_unrlzgainloss_accnt_id "
               "WHERE (company_id=:company_id);" );
  }
  
  companySave.bindValue(":company_id",       _companyid);
  companySave.bindValue(":company_number",   _number->text());
  companySave.bindValue(":company_descrip",  _descrip->toPlainText());
  companySave.bindValue(":company_external", _external->isChecked());
  companySave.bindValue(":company_server",   _extServer->text());
  companySave.bindValue(":company_port",     _extPort->cleanText());
  companySave.bindValue(":company_database", _extDB->text());
  if (_gainloss->isValid())
    companySave.bindValue(":company_gainloss_accnt_id", _gainloss->id());
  if (_discrepancy->isValid())
    companySave.bindValue(":company_dscrp_accnt_id", _discrepancy->id());
  if (_yearend->isValid())
    companySave.bindValue(":company_yearend_accnt_id", _yearend->id());
  if (_external->isChecked())
  {
    companySave.bindValue(":company_curr_id", _currency->id());
    if (_unrlzgainloss->isValid())
      companySave.bindValue(":company_unrlzgainloss_accnt_id", _unrlzgainloss->id());
  }
  companySave.exec();
  if (companySave.lastError().type() != QSqlError::NoError)
  {
    systemError(this, companySave.lastError().databaseText(), __FILE__, __LINE__);
    return;
  }

  if ((!_yearend->isValid()) ||
     (!_gainloss->isValid()) ||
     (!_discrepancy->isValid()) ||
     (_external->isChecked() &&
      _currency->id() != CurrCluster::baseId() &&
      !_unrlzgainloss->isValid()))
  {
    QMessageBox::warning( this, tr("Accounts Required"),
                          tr("You will need to return to this window to set "
                             "required Accounts before you can use Accounts "
                             "for this company in the system.") );
  }
  
  done(_companyid);
}
示例#28
0
void plannedOrder::sCreate()
{
  XSqlQuery plannedCreate;

  QList<GuiErrorCheck> errors;
  errors << GuiErrorCheck(!_item->isValid(), _item,
                          tr("You must enter or select a valid Item number before creating this Planned Order"))
         << GuiErrorCheck(!_qty->text().length(), _qty,
                          tr("You must enter a valid Qty. Ordered before creating this Planned Order"))
         << GuiErrorCheck(!_dueDate->isValid(), _dueDate,
                          tr("You must enter a valid Due Date before creating this Planned Order"))
     ;

  plannedCreate.prepare( "SELECT itemsite_id "
                         "FROM itemsite "
                         "WHERE ( (itemsite_item_id=:item_id)"
                         " AND (itemsite_warehous_id=:warehous_id) );" );
  plannedCreate.bindValue(":item_id", _item->id());
  plannedCreate.bindValue(":warehous_id", _warehouse->id());
  plannedCreate.exec();
  if (!plannedCreate.first())
  {
    errors << GuiErrorCheck(true, _item,
                            tr("The Item and Site entered is an invalid Item Site combination.")  );
  }

  int itemsiteid = plannedCreate.value("itemsite_id").toInt();
  int _supplyItemsiteId = -1;
  if (_toButton->isChecked())
  {
    plannedCreate.prepare("SELECT itemsite_id "
                          "FROM itemsite "
                          "WHERE ( (itemsite_item_id=:item_id)"
                          "  AND   (itemsite_warehous_id=:warehous_id) ); ");
    plannedCreate.bindValue(":item_id", _item->id());
    plannedCreate.bindValue(":warehous_id", _fromWarehouse->id());
    plannedCreate.exec();
    if (plannedCreate.first())
    {
      if (plannedCreate.value("itemsite_id").toInt() == itemsiteid)
      { 
        errors << GuiErrorCheck(true, _item,
                                tr("The Supplied From Site must be different from the Transfer To Site.") );
      }
      else
        _supplyItemsiteId = plannedCreate.value("itemsite_id").toInt();
    }
    else
    { 
      errors << GuiErrorCheck(true, _item,
                              tr("Cannot find Supplied From Item Site.") );
    }
  }

  if (GuiErrorCheck::reportErrors(this, tr("Cannot Save Planned Order"), errors))
    return;

  int foid = 0;

  if(cEdit == _mode)
    plannedCreate.prepare( "UPDATE planord "
               "SET planord_number=:planord_number, "
               "    planord_type=:planord_type, "
               "    planord_itemsite_id=:planord_itemsite_id, "
               "    planord_supply_itemsite_id=:planord_supply_itemsite_id, "
               "    planord_comments=:planord_comments, "
               "    planord_qty=:planord_qty, "
               "    planord_duedate=:planord_duedate, "
               "    planord_startdate=COALESCE(:planord_startdate, date(:planord_duedate) - :planord_leadtime) "
               "WHERE (planord_id=:planord_id);" );
  else
    plannedCreate.prepare( "SELECT createPlannedOrder( :planord_number, :planord_itemsite_id, :planord_qty, "
               "                   COALESCE(:planord_startdate, date(:planord_duedate) - :planord_leadtime), :planord_duedate, "
               "                   :planord_type, :planord_supply_itemsite_id, :planord_comments) AS result;" );

  plannedCreate.bindValue(":planord_number", _number->text().toInt());
  plannedCreate.bindValue(":planord_itemsite_id", itemsiteid);
  if (_poButton->isChecked())
    plannedCreate.bindValue(":planord_type", "P");
  else if (_woButton->isChecked())
    plannedCreate.bindValue(":planord_type", "W");
  else if (_toButton->isChecked())
  {
    plannedCreate.bindValue(":planord_type", "T");
    plannedCreate.bindValue(":planord_supply_itemsite_id", _supplyItemsiteId);
  }
  plannedCreate.bindValue(":planord_qty", _qty->toDouble());
  plannedCreate.bindValue(":planord_duedate", _dueDate->date());
  plannedCreate.bindValue(":planord_startdate", _startDate->date());
  plannedCreate.bindValue(":planord_leadtime", _leadTime->value());
  plannedCreate.bindValue(":planord_comments", _notes->toPlainText());
  plannedCreate.bindValue(":planord_id", _planordid);

  plannedCreate.exec();
  if (plannedCreate.lastError().type() != QSqlError::NoError)
  {
    systemError(this, plannedCreate.lastError().databaseText(), __FILE__, __LINE__);
    return;
  }

  if(cEdit == _mode)
  {
    plannedCreate.prepare( "SELECT explodePlannedOrder( :planord_id, true) AS result;" );
    plannedCreate.bindValue(":planord_id", _planordid);
    plannedCreate.exec();
    if (plannedCreate.first())
    {
      double result = plannedCreate.value("result").toDouble();
      if (result < 0.0)
      {
        systemError(this, tr("ExplodePlannedOrder returned %, indicating an "
                             "error occurred.").arg(result),
                    __FILE__, __LINE__);
        return;
      }
    }
    else if (plannedCreate.lastError().type() != QSqlError::NoError)
    {
      systemError(this, plannedCreate.lastError().databaseText(), __FILE__, __LINE__);
      return;
    }
  }
  else
  {
    if (!plannedCreate.first())
    {
      systemError( this, tr("A System Error occurred at %1::%2.")
                         .arg(__FILE__)
                         .arg(__LINE__) );
      return;
    }

    foid = XDialog::Rejected;
    switch (plannedCreate.value("result").toInt())
    {
      case -1:
        QMessageBox::critical( this, tr("Planned Order not Exploded"),
                               tr( "The Planned Order was created but not Exploded as there is no valid Bill of Materials for the selected Item.\n"
                                   "You must create a valid Bill of Materials before you may explode this Planned Order." ));
        break;
  
      case -2:
        QMessageBox::critical( this, tr("Planned Order not Exploded"),
                               tr( "The Planned Order was created but not Exploded as Component Items defined in the Bill of Materials\n"
                                   "for the selected Planned Order Item do not exist in the selected Planned Order Site.\n"
                                   "You must create Item Sites for these Component Items before you may explode this Planned Order." ));
        break;

      default:
        foid = plannedCreate.value("result").toInt();
        break;
    }
  }

  if (_captive)
    done(foid);
  else
  {
    populateFoNumber();
    _item->setId(-1);
    _typeGroup->setEnabled(FALSE);
    _qty->clear();
    _dueDate->setNull();
    _leadTime->setValue(0);
    _startDate->setNull();
    _notes->clear();
    _close->setText(tr("&Close"));

    _item->setFocus();
  }
}
示例#29
0
void itemPricingScheduleItem::populate()
{
    if(_itemSelected->isChecked())
    {
        q.prepare( "SELECT ipsitem_ipshead_id,"
                   "       ipsitem_item_id,"
                   "       ipsitem_qty_uom_id,"
                   "       ipsitem_qtybreak,"
                   "       ipsitem_price_uom_id,"
                   "       ipsitem_price "
                   "FROM ipsitem "
                   "WHERE (ipsitem_id=:ipsitem_id);" );
        q.bindValue(":ipsitem_id", _ipsitemid);
        q.exec();
        if (q.first())
        {
            _ipsheadid=q.value("ipsitem_ipshead_id").toInt();
            _item->setId(q.value("ipsitem_item_id").toInt());
            _qtyBreak->setDouble(q.value("ipsitem_qtybreak").toDouble());
            _price->setLocalValue(q.value("ipsitem_price").toDouble());
            _qtyUOM->setId(q.value("ipsitem_qty_uom_id").toInt());
            _priceUOM->setId(q.value("ipsitem_price_uom_id").toInt());

            sUpdateMargins();
        }
        else if (q.lastError().type() != QSqlError::NoError)
        {
            systemError(this, _rejectedMsg.arg(q.lastError().databaseText()),
                        __FILE__, __LINE__);
            done(-1);
        }
    }
    else if(_discountSelected->isChecked())
    {
        if(_dscbyprodcat->isChecked())
        {
            q.prepare( "SELECT ipsprodcat_prodcat_id,"
                       "       ipsprodcat_qtybreak AS qty_brk,"
                       "       (ipsprodcat_discntprcnt * 100) AS discntprcnt,"
                       "       ipsprodcat_fixedamtdiscount AS fxd_amnt "
                       "FROM ipsprodcat "
                       "WHERE (ipsprodcat_id=:ipsprodcat_id);" );
            q.bindValue(":ipsprodcat_id", _ipsprodcatid);
        }
        else if(_dscbyItem->isChecked())
        {
            q.prepare( "SELECT ipsitem_item_id,"
                       "       ipsitem_qtybreak AS qty_brk,"
                       "       (ipsitem_discntprcnt * 100) AS discntprcnt,"
                       "       ipsitem_fixedamtdiscount AS fxd_amnt "
                       "FROM ipsiteminfo "
                       "WHERE (ipsitem_id=:ipsitem_id);" );
            q.bindValue(":ipsitem_id", _ipsitemid);
        }
        q.exec();
        if (q.first())
        {
            if(_dscbyprodcat->isChecked())
                _prodcat->setId(q.value("ipsprodcat_prodcat_id").toInt());
            else if(_dscbyItem->isChecked())
                _dscitem->setId(q.value("ipsitem_item_id").toInt());

            _qtyBreakCat->setDouble(q.value("qty_brk").toDouble());
            _discount->setDouble(q.value("discntprcnt").toDouble());
            _fixedAmtDiscount->setLocalValue(q.value("fxd_amnt").toDouble());
        }
        else if (q.lastError().type() != QSqlError::NoError)
        {
            systemError(this, _rejectedMsg.arg(q.lastError().databaseText()),
                        __FILE__, __LINE__);
            done(-1);
        }
    }
    else if(_freightSelected->isChecked())
    {
        q.prepare( "SELECT ipsfreight.* "
                   "FROM ipsfreight "
                   "WHERE (ipsfreight_id=:ipsfreight_id);" );
        q.bindValue(":ipsfreight_id", _ipsfreightid);
        q.exec();
        if (q.first())
        {
            _qtyBreakFreight->setDouble(q.value("ipsfreight_qtybreak").toDouble());
            _priceFreight->setLocalValue(q.value("ipsfreight_price").toDouble());
            if (q.value("ipsfreight_type").toString() == "F")
            {
                _flatRateFreight->setChecked(true);
                _qtyBreakFreight->setEnabled(false);
            }
            else
                _perUOMFreight->setChecked(true);
            if (q.value("ipsfreight_warehous_id").toInt() > 0)
                _siteFreight->setId(q.value("ipsfreight_warehous_id").toInt());
            else
                _siteFreight->setAll();
            if (q.value("ipsfreight_shipzone_id").toInt() > 0)
            {
                _selectedZoneFreight->setChecked(true);
                _zoneFreight->setId(q.value("ipsfreight_shipzone_id").toInt());
            }
            else
                _allZonesFreight->setChecked(true);
            if (q.value("ipsfreight_freightclass_id").toInt() > 0)
            {
                _selectedFreightClass->setChecked(true);
                _freightClass->setId(q.value("ipsfreight_freightclass_id").toInt());
            }
            else
                _allFreightClasses->setChecked(true);
            //  Handle the free-form Ship Via
            _shipViaFreight->setCurrentIndex(-1);
            QString shipvia = q.value("ipsfreight_shipvia").toString();
            if (shipvia.trimmed().length() != 0)
            {
                _selectedShipViaFreight->setChecked(true);
                for (int counter = 0; counter < _shipViaFreight->count(); counter++)
                    if (_shipViaFreight->itemText(counter) == shipvia)
                        _shipViaFreight->setCurrentIndex(counter);

                if (_shipViaFreight->id() == -1)
                {
                    _shipViaFreight->addItem(shipvia);
                    _shipViaFreight->setCurrentIndex(_shipViaFreight->count() - 1);
                }
            }
            else
                _allShipViasFreight->setChecked(true);
        }
        else if (q.lastError().type() != QSqlError::NoError)
        {
            systemError(this, _rejectedMsg.arg(q.lastError().databaseText()),
                        __FILE__, __LINE__);
            done(-1);
        }
    }
    sFillList();
}
示例#30
0
文件: WDialog.C 项目: pluggulp/wt
void WDialog::reject()
{
  done(Rejected);
}