Exemple #1
0
void ContactCluster::sSearch()
{
    ContactSearch* newdlg = new ContactSearch(this);
    if (newdlg)
    {
	int id = newdlg->exec();
	setId(id);
    }
    else
	QMessageBox::critical(this, tr("A System Error Occurred at %1::%2.")
				      .arg(__FILE__)
				      .arg(__LINE__),
			      tr("Could not instantiate a Search Dialog"));
}
Exemple #2
0
void ContactWidget::sSearch()
{
    ContactSearch* newdlg = new ContactSearch(this);
    if (newdlg)
    {
        ParameterList params;
        params.append("searchAcctId", _searchAcctId);
        newdlg->set(params);
	int id = newdlg->exec();
        if (id > 0)
	  setId(id);
    }
    else
	QMessageBox::critical(this, tr("A System Error Occurred at %1::%2.")
				      .arg(__FILE__)
				      .arg(__LINE__),
			      tr("Could not instantiate a Search Dialog"));
}
Exemple #3
0
void ContactClusterLineEdit::sSearch()
{
  ContactSearch* newdlg = searchFactory();
  if (newdlg)
  {
    ParameterList params;
    params.append("titalPlural", tr("Contacts"));
    if (_searchAcctId != -1)
      params.append("searchAcctId", _searchAcctId);
    newdlg->set(params);
    int id = newdlg->exec();
    setId(id);
  }
  else
    QMessageBox::critical(this, tr("A System Error Occurred at %1::%2.")
                          .arg(__FILE__)
                          .arg(__LINE__),
                          tr("Could not instantiate a Search Dialog"));
}
Exemple #4
0
void ContactWidget::findDuplicates()
{
  if (_first->text().isEmpty() && _last->text().isEmpty())
    return;
    
  QString msg;
  XSqlQuery r;
  
  r.prepare(  "SELECT cntct_id, COALESCE(cntct_crmacct_id,0) AS cntct_crmacct_id "
              "FROM cntct "
              "WHERE ( ( cntct_first_name ~~* :first) "
              " AND (cntct_last_name ~~* :last) );");
  r.bindValue(":first", _first->text());
  r.bindValue(":last", _last->text());
  r.bindValue(":crmacct_id", _searchAcctId);
  r.exec();
  if (r.size() == 1)
  { 
    r.first();
    msg = tr("A contact exists with the same first and last name");
    if (_searchAcctId > 0 && r.value("cntct_crmacct_id").toInt() == 0)
      msg += tr(" not associated with any CRM Account");
    else if (_searchAcctId == r.value("cntct_crmacct_id").toInt())
      msg += tr(" on the current CRM Account");
    else if (_searchAcctId > 0)
      msg += tr(" associated with another CRM Account");
    msg += tr(". Would you like to use the existing contact?");
    
    if (QMessageBox::question(this, tr("Existing Contact"), msg,
                             QMessageBox::Yes | QMessageBox::Default,
                             QMessageBox::No  | QMessageBox::Escape) == QMessageBox::Yes)
    {
      r.first();
      setId(r.value("cntct_id").toInt());
    }
  }
  else if (r.size() > 1)
  {
    if (_searchAcctId > 0)
    {
      int cnt = 0;
      int cntctid = 0;
      while (r.next())
      {
        if (r.value("cntct_crmacct_id").toInt() == _searchAcctId)
        {
          cnt += 1;
          cntctid = r.value("cntct_id").toInt();
        }
      }
      if (cnt == 1)
      {
         msg = tr("A contact exists with the same first and last name "
                  "on the current CRM Account. "
                  "Would you like to use the existing contact?");
        if (QMessageBox::question(this, tr("Existing Contact"), msg,
                             QMessageBox::Yes | QMessageBox::Default,
                             QMessageBox::No  | QMessageBox::Escape) == QMessageBox::Yes)
          setId(cntctid);
        return;
      }
      if (cnt == 0)
        _searchAcctId = -1;
    }

    QString msg = tr("Multple contacts exist with the same first and last name");
    msg += tr(". Would you like to view all the existing contacts?");
    
    if (QMessageBox::question(this, tr("Existing Contacts"), msg,
                             QMessageBox::Yes | QMessageBox::Default,
                             QMessageBox::No  | QMessageBox::Escape) == QMessageBox::Yes)
    {
      ContactSearch* newdlg = new ContactSearch(this);
      if (newdlg)
      {
        newdlg->_searchFirst->setChecked(true);
        newdlg->_searchLast->setChecked(true);
        newdlg->_search->setText(_first->text() + " " + _last->text());
        newdlg->sFillList();
	      int id = newdlg->exec();
	      setId(id);
      }
      else
	       QMessageBox::critical(this, tr("A System Error Occurred at %1::%2.")
			      .arg(__FILE__)
				    .arg(__LINE__),
			    tr("Could not instantiate a Search Dialog"));
    }
  }
  else if (r.lastError().type() != QSqlError::NoError)
    QMessageBox::critical(this, tr("A System Error Occurred at %1::%2.")
                                        .arg(__FILE__)
                                        .arg(__LINE__),
                                r.lastError().databaseText());

}