Beispiel #1
0
void employee::sAttachGroup()
{
  if (!sSave(false))
    return;

  int empgrpid = EmpGroupClusterLineEdit::idFromList(this);
  if (empgrpid != XDialog::Rejected && empgrpid != -1)
  {
    XSqlQuery grpq;
    grpq.prepare("SELECT * FROM empgrpitem"
              " WHERE((empgrpitem_empgrp_id=:empgrpid)"
              "   AND (empgrpitem_emp_id=:empid));");
    grpq.bindValue(":empgrpid", empgrpid);
    grpq.bindValue(":empid",    _empid);
    grpq.exec();
    if(grpq.first())
    {
      QMessageBox::information(this, tr("Employee in Group"),
        tr("The employee is already in the selected group.") );
      return;
    }
    grpq.prepare("INSERT INTO empgrpitem (empgrpitem_empgrp_id, empgrpitem_emp_id)"
              " VALUES "
              "(:empgrpid, :empid);");
    grpq.bindValue(":empgrpid", empgrpid);
    grpq.bindValue(":empid",    _empid);
    grpq.exec();
    if (ErrorReporter::error(QtCriticalMsg, this,
                             tr("Error attaching to Employee Group"),
                             grpq, __FILE__, __LINE__))
      return;
    sFillGroupsList();
  }
}
Beispiel #2
0
void employee::sAttachGroup()
{
  if (!sSave(false))
    return;

  int empgrpid = EmpGroupClusterLineEdit::idFromList(this);
  if (empgrpid != XDialog::Rejected && empgrpid != -1)
  {
    q.prepare("SELECT * FROM empgrpitem"
              " WHERE((empgrpitem_empgrp_id=:empgrpid)"
              "   AND (empgrpitem_emp_id=:empid));");
    q.bindValue(":empgrpid", empgrpid);
    q.bindValue(":empid",    _empid);
    q.exec();
    if(q.first())
    {
      QMessageBox::information(this, tr("Employee in Group"),
        tr("The employee is already in the selected group.") );
      return;
    }
    q.prepare("INSERT INTO empgrpitem (empgrpitem_empgrp_id, empgrpitem_emp_id)"
              " VALUES "
              "(:empgrpid, :empid);");
    q.bindValue(":empgrpid", empgrpid);
    q.bindValue(":empid",    _empid);
    q.exec();
    if (q.lastError().type() != QSqlError::NoError)
    {
      systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
      return;
    }
    sFillGroupsList();
  }
}
Beispiel #3
0
void employee::sEditGroup()
{
  ParameterList params;
  params.append("mode", "edit");
  params.append("empgrp_id", _groups->id());

  empGroup newdlg(this, "", TRUE);
  newdlg.set(params);
  newdlg.exec();
  sFillGroupsList();
}
Beispiel #4
0
void employee::sDetachGroup()
{
  q.prepare("DELETE FROM empgrpitem "
            "WHERE ((empgrpitem_empgrp_id=:grpid)"
            "  AND  (empgrpitem_emp_id=:empid));");
  q.bindValue(":grpid", _groups->id());
  q.bindValue(":empid", _empid);
  q.exec();
  if (q.lastError().type() != QSqlError::NoError)
  {
    systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
    return;
  }
  sFillGroupsList();
}
Beispiel #5
0
void employee::sDetachGroup()
{
  XSqlQuery detq;
  detq.prepare("DELETE FROM empgrpitem "
            "WHERE ((empgrpitem_empgrp_id=:grpid)"
            "  AND  (empgrpitem_emp_id=:empid));");
  detq.bindValue(":grpid", _groups->id());
  detq.bindValue(":empid", _empid);
  detq.exec();
  if (ErrorReporter::error(QtCriticalMsg, this,
                           tr("Error detaching from Employee Group"),
                           detq, __FILE__, __LINE__))
    return;
  sFillGroupsList();
}
Beispiel #6
0
void employee::sPopulate()
{
  q.prepare("SELECT *, curr_id, curr_abbr "
            "FROM api.employee LEFT OUTER JOIN"
            "     curr_symbol ON (wage_currency = curr_abbr) "
            "WHERE (code=:code);");
  q.bindValue(":code", _empcode);
  q.exec();
  if (q.first())
  {
    _code->setText(q.value("code").toString());
    _number->setText(q.value("number").toString());
    _active->setChecked(q.value("active").toBool());
	_startDate->setDate(q.value("start_date").toDate());
    _contact->setNumber(q.value("contact_number").toString());
    _contact->setHonorific(q.value("honorific").toString());
    _contact->setFirst(q.value("first").toString());
    _contact->setLast(q.value("last").toString());
    _contact->setTitle(q.value("job_title").toString());
    _contact->setPhone(q.value("voice").toString());
    _contact->setPhone2(q.value("alternate").toString());
    _contact->setFax(q.value("fax").toString());
    _contact->setEmailAddress(q.value("email").toString());
    _contact->setWebAddress(q.value("web").toString());
    _contact->addressWidget()->setLine1(q.value("address1").toString());
    _contact->addressWidget()->setLine2(q.value("address2").toString());
    _contact->addressWidget()->setLine3(q.value("address3").toString());
    _contact->addressWidget()->setCity(q.value("city").toString());
    _contact->addressWidget()->setState(q.value("state").toString());
    _contact->addressWidget()->setPostalCode(q.value("postalcode").toString());
    _contact->addressWidget()->setCountry(q.value("country").toString());
    _site->setCode(q.value("site").toString());
    _mgr->setNumber(q.value("manager_code").toString());
    _wagetype->setCode(q.value("wage_type").toString());
    _rate->set(q.value("wage").toDouble(),
               q.value("curr_id").toInt(),
               QDate::currentDate());
    _externalRate->set(q.value("rate").toDouble(),
               q.value("curr_id").toInt(),
               QDate::currentDate());
	_currabbr = q.value("curr_abbr").toString();
    _per->setCode(q.value("wage_period").toString());
    _perExt->setCode(q.value("billing_period").toString());
	_dept->setNumber(q.value("department").toString());
    _shift->setNumber(q.value("shift").toString());

    _user->setChecked(q.value("is_user").toBool());
    _salesrep->setChecked(q.value("is_salesrep").toBool());
    _vendor->setChecked(q.value("is_vendor").toBool());
	_notes->setText(q.value("notes").toString());
    _image->setNumber(q.value("image").toString());

    _user->setEnabled(_createUsers && ! _user->isChecked());
    _userButton->setEnabled(_privileges->check("MaintainUsers") &&
                            _user->isChecked());

    _salesrep->setEnabled(_privileges->check("MaintainSalesReps") &&
                          ! _salesrep->isChecked());
    _salesrepButton->setEnabled((_privileges->check("MaintainSalesReps") ||
                                 _privileges->check("ViewSalesReps")) &&
                                _salesrep->isChecked());

	_vendor->setEnabled(_privileges->check("MaintainVendors") &&
                          ! _vendor->isChecked());
    _vendorButton->setEnabled((_privileges->check("MaintainVendors") ||
                                 _privileges->check("ViewVendors")) &&
                                _vendor->isChecked());


    if (DEBUG)
      qDebug("image %s and %s",
             qPrintable(q.value("image").toString()),
             qPrintable(_image->number()));

    sFillCharassList();
    sFillGroupsList();
    _comments->setId(_empid);
    _comments->setReadOnly(_empid==-1);
    emit populated();
  }
  else if (q.lastError().type() != QSqlError::NoError)
  {
    systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
    return;
  }
}
Beispiel #7
0
bool employee::sPopulate()
{
  XSqlQuery getq;
  if (_empid > 0)
  {
    getq.prepare("SELECT emp.*, crmacct_id, crmacct_owner_username,"
                 "       crmacct_salesrep_id, crmacct_usr_username, crmacct_vend_id"
                 "  FROM emp JOIN crmacct ON (emp_id=crmacct_emp_id)"
                 " WHERE (emp_id=:id);");
    getq.bindValue(":id", _empid);
  }
  else if (_crmacctid > 0)
  {
    getq.prepare("SELECT crmacct_number     AS emp_code, NULL AS emp_number,"
                 "       crmacct_name       AS emp_name,"
                 "       crmacct_active     AS emp_active,"
                 "       crmacct_cntct_id_1 AS emp_cntct_id,"
                 "       NULL AS emp_startdate,      NULL AS emp_mgr_emp_id,"
                 "       NULL AS emp_warehous_id,    NULL AS emp_wage_type,"
                 "       NULL AS emp_wage,           NULL AS emp_wage_curr_id,"
                 "       NULL AS emp_extrate,        NULL AS emp_wage_period,"
                 "       NULL AS emp_extrate_period, NULL AS emp_dept_id,"
                 "       NULL AS emp_shift_id,       NULL AS emp_notes,"
                 "       NULL AS emp_image_id,"
                 "crmacct_id, crmacct_owner_username"
                 "  FROM crmacct"
                 " WHERE (crmacct_id=:id);");
    getq.bindValue(":id", _crmacctid);
  }

  getq.exec();
  if (getq.first())
  {
    _code->setText(getq.value("emp_code").toString());
    _name->setText(getq.value("emp_name").toString());
    _number->setText(getq.value("emp_number").toString());
    _active->setChecked(getq.value("emp_active").toBool());
    _startDate->setDate(getq.value("emp_startdate").toDate());
    _contact->setId(getq.value("emp_cntct_id").toInt());
    _site->setId(getq.value("emp_warehous_id").toInt());
    _mgr->setId(getq.value("emp_mgr_emp_id").toInt());
    _wagetype->setCode(getq.value("emp_wage_type").toString());
    _rate->set(getq.value("emp_wage").toDouble(),
               getq.value("emp_wage_curr_id").toInt(),
               QDate::currentDate());
    _externalRate->set(getq.value("emp_extrate").toDouble(),
                       getq.value("emp_wage_curr_id").toInt(),
                       QDate::currentDate());
    _per->setCode(getq.value("emp_wage_period").toString());
    _perExt->setCode(getq.value("emp_extrate_period").toString());
    _dept->setId(getq.value("emp_dept_id").toInt());
    _shift->setId(getq.value("emp_shift_id").toInt());
    _notes->setText(getq.value("emp_notes").toString());
    _image->setId(getq.value("emp_image_id").toInt());

    _crmacctid  = getq.value("crmacct_id").toInt();
    _crmowner   = getq.value("crmacct_owner_username").toString();

    if (DEBUG)
      qDebug("image %s and %s",
             qPrintable(getq.value("image").toString()),
             qPrintable(_image->number()));

    sFillCharassList();
    sFillGroupsList();
    _comments->setId(_empid);
    _comments->setReadOnly(_empid==-1);
    emit populated();
  }
  else if (ErrorReporter::error(QtCriticalMsg, this,
                                tr("Error getting Employee"),
                                getq, __FILE__, __LINE__))
    return false;

  sHandleButtons();
  return true;
}