Exemple #1
0
void people::save(){
    QString error;
    if (ui.lineEdit_face->text().isEmpty()){
        error.append("Введите данные сотрудника!");
    } else {
        if (id == 0){
            QSqlQuery query("insert into people (fam, name, otc, face) "
                            "values (?, ?, ?, ?) ");
            query.bindValue(0, ui.lineEdit_fam->text());
            query.bindValue(1, ui.lineEdit_name->text());
            query.bindValue(2, ui.lineEdit_otc->text());
            query.bindValue(3, ui.lineEdit_face->text());
            query.exec();
            error.append(query.lastError().text());
        } else if (id > 0){
            QSqlQuery query(QString("update people set fam = \'%1\', name = \'%2\', otc=\'%3\', face = \'%4\' "
                                    "where people.id = \'%5\' ")
                            .arg(ui.lineEdit_fam->text())
                            .arg(ui.lineEdit_name->text())
                            .arg(ui.lineEdit_otc->text())
                            .arg(ui.lineEdit_face->text())
                            .arg(id));
            query.exec();
            error.append(query.lastError().text());
        }
    }
    if (error.size() > 2){
        makeStatus(error);
    } else {
        makeStatus("Сохранено!");
        load();
        add();
    }
}
Exemple #2
0
void material::save(){
    QString error;
    if (ui.lineEdit_art->text().isEmpty()){
        error.append("Введите артикульный номер материала!");
    } else {
        if (ui.lineEdit_name->text().isEmpty()){
            error.append("Введите наименование материала!");
        } else {
            if (ui.comboBox_units->currentIndex() == -1){
                error.append("Выберите единицу измерения материала!");
            } else {
                QSqlQuery queryIDUnits(QString("select units.id from units where units.name = \'%1\'")
                                       .arg(ui.comboBox_units->currentText()));
                queryIDUnits.next();
                QSqlQuery query(QString("update material set articul = \'%1\', name = \'%2\', units = \'%3\' "
                                        "where material.id = \'%4\' ")
                                .arg(ui.lineEdit_art->text())
                                .arg(ui.lineEdit_name->text())
                                .arg(queryIDUnits.value(0).toString())
                                .arg(id));
                query.exec();
                error.append(query.lastError().text());
            }
        }
    }
    if (error.size() > 3){
        makeStatus(error);
    } else {
        makeStatus("Сохранено!");
        ui.groupBox_card->hide();
    }
}
Exemple #3
0
XMPP::Status makeLastStatus(int x)
{
	PsiOptions* o = PsiOptions::instance();
	if (lastPriorityNotEmpty()) {
		return makeStatus(x, o->getOption("options.status.last-message").toString(), o->getOption("options.status.last-priority").toInt());
	}
	else {
		return makeStatus(x, o->getOption("options.status.last-message").toString());
	}
}
Exemple #4
0
bool LCDbWorkEntry::updateStatus( LQuery central, LDbWorkEntry::Stage result )
{
	String update = "set status = :sts, buddy_read = :brf, time_stamp = 'now'";
	if( getResultID() != 0 )
		update = update + ", buddy_result_id = " + getResultID();

	central.setSQL( "update c_buddy_worklist " + update + " where record_no = :rno" );
	switch( result )
	{
		case LDbStage::L0_HELD:
			central.setParam( "brf", LCDbWorkEntry::HELD );
			break;

		case LDbStage::TRANSMITTED:
		case LDbStage::DELETED:
			central.setParam( "brf", LCDbWorkEntry::FINISHED );
			break;

		default:
			central.setParam( "brf", LCDbWorkEntry::COPIED );
	}

	central.setParam( "rno", getID() );
	central.setParam( "sts", makeStatus( result ) );
	if( central.execSQL() != 1 )
		return false;
	else
	{	setStage( result );
		setTimeStamp( Now() );
		return true;
	}
}
Exemple #5
0
XMPP::Status makeStatus(int x, const QString &str, int priority)
{
	XMPP::Status s = makeStatus(x,str);
	if (priority > 127)
		s.setPriority(127);
	else if (priority < -128)
		s.setPriority(-128);
	else
		s.setPriority(priority);
	return s;
}
Exemple #6
0
void people::del(){
    QString error;
    if (ui.tableWidget_people->rowCount() > 0){
        crow = -1;
        for (int r = 0; r < ui.tableWidget_people->rowCount(); r++){
            if (ui.tableWidget_people->item(r, 0)->isSelected()){
                crow = r;
                id = ui.tableWidget_people->item(crow, 0)->text().toInt();
                break;
            }
        }
        if (crow == -1){
            error.append("Выберите сотрудника!");
        } else if (crow > -1){
            int test = ui.tableWidget_people->item(crow, 2)->text().toInt();
            if (test == 0){
                QSqlQuery query(QString("delete from people where people.id = \'%1\'")
                                .arg(id));
                query.exec();
                error.append(query.lastError().text());
            } else {
                error.append("Данного сотрудника удалить нельзя!");
            }
        }
    } else {
        error.append("Нет сотрудников для удаления!");
    }
    if (error.size() > 2){
        makeStatus(error);
    } else {
        makeStatus(QString("Сотрудник (id:%1) удален!").arg(id));
        ui.groupBox_card->hide();
        load();
    }

}
HRESULT STDMETHODCALLTYPE
OMGSFIStorage::StgCreateStorageEx( const TCHAR FAR* in_filename,
				OMFile::OMAccessMode in_accessMode,
				void **out_storage,
				ULONG in_sectorSize)
{
	TRACE("OMGSFIStorage::StgCreateStorageEx");
	PRECONDITION("Valid access mode", in_accessMode == OMFile::writeOnlyMode);
	GsfStorage *storage = 0;
	*out_storage = 0;
	char storageName[FILENAME_MAX];

#ifndef OM_UNICODE_APIS
	strncpy (storageName, in_filename, sizeof(storageName) -1);
	storageName[sizeof(storageName) -1] = '\0';
#else
	 convertWideStringToString (storageName, in_filename, FILENAME_MAX);
#endif

	int status = GSTG_OK;
	GError *err;

	GsfOutput  *output = GSF_OUTPUT (gsf_output_stdio_new (storageName, &err));

	if (output != NULL)
	{
		storage = GSF_OUTFILE (gsf_outfile_msole_new_full (
									output,
									in_sectorSize,	// sector size - 512 or 4096 bytes
									64));			// mini-sector size always 64 bytes
		g_object_unref (G_OBJECT (output));
	}
	else
		status = GSTG_ERROR;

	if (status == GSTG_OK)
	{
		OMGSFIStorage *newStorage = new OMGSFIStorage (storage, GSF_WRITE, storageName);
		*out_storage = newStorage;
	}
	return makeStatus(status);
}
HRESULT STDMETHODCALLTYPE
OMGSFIStorage::StgOpenStorageEx( const TCHAR FAR* in_filename,
				OMFile::OMAccessMode in_accessMode,
				void **out_storage)
{
	TRACE("OMGSFIStorage::StgOpenStorageEx");
	PRECONDITION("Valid access mode", in_accessMode == OMFile::readOnlyMode);
	GsfStorage *storage = 0;
	*out_storage = 0;
	char storageName[FILENAME_MAX];

#ifndef OM_UNICODE_APIS
	strncpy (storageName, in_filename, sizeof(storageName) -1);
	storageName[sizeof(storageName) -1] = '\0';
#else
	convertWideStringToString (storageName, in_filename, FILENAME_MAX);
#endif

	GError *err;

	int status = GSTG_OK;

	GsfInput  *input = GSF_INPUT (gsf_input_stdio_new (storageName, &err));

	if (input != NULL)
	{
		input = gsf_input_uncompress (input);
		storage = GSF_INFILE (gsf_infile_msole_new (input, &err));
		g_object_unref (G_OBJECT (input));
	}
	else
		status = GSTG_ERROR;

	if (status == GSTG_OK)
	{
		OMGSFIStorage *newStorage = new OMGSFIStorage (storage, GSF_READ, storageName);
		*out_storage = newStorage;
	}

	return makeStatus(status);
}
Exemple #9
0
bool LBDbWorkEntry::updateRecord( LQuery cluster, LDbWorkEntry::Stage result )
{
	LBDbWorkEntry * cached = LBDbWorkList::records().find( *this );
	TDateTime when = Now();

	String update = "set status = :sts, time_stamp = :ts";
	if( !isQC() && getCategoryID() != 0 )
		update = update + ", category_id = " + getCategoryID();
	if( resultID != 0 && resultID != duplicate )
		update = update + ", duplicate = " + resultID;

	String condition = "test_id = :tid and duplicate = :did and barcode = :bar";
	if( duplicate == 0 ) {
		int analyser = limits.getAnalyserID();
		if( analyser == 0 )
			condition += " and machine_cid in (" + listMachineIDs() + ")";
		else
			condition += " and machine_cid = " + String( analyser );
	}

	cluster.setSQL( "update buddy_worklist " + update + " where " + condition );
	cluster.setParam( "bar", getBarcode() );
	cluster.setParam( "did", duplicate );
	cluster.setParam( "tid", limits.getID() );
	cluster.setParam( "sts", makeStatus( result ) );
	cluster.setParam( "ts", when );
	if( cluster.execSQL() != 1 ) {
		return false;
	}
	setStage( result );
	setTimeStamp( when );
	if( resultID != 0 )
		duplicate = resultID;
	if( cached != NULL )
		*cached = *this;
	else
		LBDbWorkList::records().insert( *this );
	return true;
}
Exemple #10
0
bool LBDbWorkEntry::createRecord( LQuery cluster, String reason )
{
	int machine = limits.getAnalyserID();
	if( machine == 0 )
	{
		// QCs should stay on the same analyser; others on cluster
		machine = LCDbAnalysers::getCurrentID();
		const LCDbAnalyser * an = LCDbAnalysers::records().findByID( machine );
		if( an != NULL && !isQC() )
		{
			std::set< int > machineIDs = an -> getClusterIDs();
			if( !machineIDs.empty() )
				machine = *(machineIDs.begin());
		}
		limits.setAnalyserID( machine );
	}

	if( reason.IsEmpty() && getProfileID() != 0 )
	{
		const LPDbProfiles & profiles = LPDbProfiles::records( getProjectID() );
		const LPDbProfile * pp = profiles.findByID( getProfileID() );
		if( pp != NULL )
			reason = pp -> getName();
	}

	setTimeStamp( Now() );
	char fromCentral = LCDbWorkEntry::NEW_RECORD;
	switch( getStage() )
	{
		case NEW_ENTRY:
			break;

		case RE_RUN:
			resultID = nextRerun --;
			break;

		case TRIGGERED:
			resultID = TRIGGER_ID;
			break;

		default:
			fromCentral = LCDbWorkEntry::COPIED;
	}

	cluster.setSQL( "Insert into buddy_worklist (machine_cid, barcode, duplicate, test_name, test_id,"
					" sample_id, range_set, min_value, max_value, status, project_cid, profile_name,"
					" buddy_read, in_date, time_stamp, lower_warning, upper_warning, trigger_id,"
					" trigger_lower_limit, trigger_upper_limit, private_result, delete_status, category_id)"
				   " values ( :mid, :bar, :dup, :tnm, :tid, :aid, :rs, :min, :max, :sts, :prj,"
							" :prn, :brd, :ind, :dts, :wlo, :wup, :trd, :tlo, :tup, :prv, 0, :cat )" );
	cluster.setParam( "mid", machine );
	cluster.setParam( "bar", getBarcode() );
	cluster.setParam( "dup", resultID );

	std::pair< int, int > specimen = getSpecimen();
	cluster.setParam( "prj", specimen.first );
	cluster.setParam( "aid", specimen.second );

	const LCDbTest & test = LCDbTests::records().get( limits.getID() );
	cluster.setParam( "tid", test.getID() );
	cluster.setParam( "tnm", test.getName() );
	cluster.setParam( "prn", reason );

	std::pair< double, double > range = limits.getRange().asDoubles();
	cluster.setParam( "min", range.first );
	cluster.setParam( "max", range.second );
	cluster.setParam( "rs", (range.first == 0 && range.second == 0) ? 'N' : 'Y' );

	cluster.setParam( "sts", makeStatus( getStage() ) );
	cluster.setParam( "brd", fromCentral );
	cluster.setParam( "ind", getInDate() );
	cluster.setParam( "dts", getTimeStamp() );

	cluster.setParam( "trd", limits.getTriggerProfile() );
	if( limits.getTriggerProfile() == 0 )
	{
		cluster.setParam( "tup", "0" );
		cluster.setParam( "tlo", "0" );
	}
	else
	{	range = limits.getTriggerLimits().asDoubles();
		cluster.setParam( "tlo", range.first );
		cluster.setParam( "tup", range.second );
	}

	range = limits.getWarnLevels().asDoubles();
	cluster.setParam( "wlo", range.first );
	cluster.setParam( "wup", range.second );
	cluster.setParam( "prv", limits.isPrivate() ? 'Y' : 'N' );
	cluster.setParam( "cat", getCategoryID() );

	if( cluster.execSQL() != 1 ) {
		return false;
	}
	duplicate = resultID;
	LBDbWorkList::records().insert( *this );
	return true;
}
Exemple #11
0
void material::import(){
    ui.progressBar->setValue(0);
    int inU = 0;
    int inM = 0;
    int upM = 0;
    QString error;
    QString messa;
    if (ui.tableWidget_import->rowCount() > 0){
        // import units
        for (int row = 0; row < ui.tableWidget_import->rowCount(); row++){
            QSqlQuery qTestUnits(QString("select units.id from units where units.name = \'%1\' ")
                                 .arg(ui.tableWidget_import->item(row, 2)->text()));
            qTestUnits.next();
            if (!qTestUnits.isValid()){
                QSqlQuery query("insert into units (name) values (?) ");
                query.bindValue(0, ui.tableWidget_import->item(row, 2)->text());
                query.exec();
                inU++;
            }
        }
        messa.append("Добавлено: ");
        if (inU > 0){
            messa.append(QString("Ед. изм. - %1;").arg(inU));
        }
        //import materials
        for (int row = 0; row < ui.tableWidget_import->rowCount(); row++){
            int art = ui.tableWidget_import->item(row, 1)->text().toInt();
            QSqlQuery qUnit(QString("select units.id from units where units.name = \'%1\' ")
                            .arg(ui.tableWidget_import->item(row, 2)->text()));
            qUnit.next();
            QSqlQuery query(QString("select material.id from material where material.articul = \'%1\' ").arg(art));
            query.next();
            if (!query.isValid()){
                QSqlQuery qInMaterial("insert into material (name, articul, units) "
                                      "values (?, ?, ?)");
                qInMaterial.bindValue(0, ui.tableWidget_import->item(row, 0)->text());
                qInMaterial.bindValue(1, ui.tableWidget_import->item(row, 1)->text());
                qInMaterial.bindValue(2, qUnit.value(0).toString());
                qInMaterial.exec();
                inM++;
            } else {
                QSqlQuery qUpMaterial(QString("update material set name = \'%1\', articul = \'%2\', units = \'%3\' "
                                              "where material.id = \'%4\'")
                                      .arg(ui.tableWidget_import->item(row, 0)->text())
                                      .arg(ui.tableWidget_import->item(row, 1)->text())
                                      .arg(qUnit.value(0).toString())
                                      .arg(query.value(0).toString()));
                qUpMaterial.exec();
                upM++;
            }
            double x = (row * 100) / ui.tableWidget_import->rowCount();
            ui.progressBar->setValue(qRound(x));
        }
        if (inM > 0){
            messa.append(QString("Материалов - %1;").arg(inM));
        }
        if (upM > 0){
            messa.append(QString("Обновлено: Материалов - %1;").arg(upM));
        }

    } else {
        error.append("Нет данных для импортирования!");
    }
    ui.progressBar->setValue(0);
    if (error.size() > 2){
        makeStatus(error);
    } else {
        makeStatus(messa);
    }

}