예제 #1
0
void getRecordPageOperDtls(RM_TableData *rel, Record *rec,
		recordTableInfo *table, BM_PageHandle *ph, int pageNum, int slot) {
	char *stringRecord = NULL;
	Record *recCopy = NULL;
	stringRecord = (char *) calloc(table->slotSize, sizeof(char));
	if (true)
		if (pinPage(table->bufferManager, ph, pageNum) == RC_OK)
			strncpy(stringRecord, ph->data + ((slot) * table->slotSize),
					sizeof(char) * table->slotSize);
	unpinPage(table->bufferManager, ph);
	recCopy = delRecord(rel, stringRecord, 0);
	rec->data = recCopy->data;
	free(recCopy);
	free(ph);
}
예제 #2
0
void
CmdInterface::run(PhoneBook & pb)
{
    cout << "==============Phone Book 0.1 By JackalDire==============\n";
    
    main_menu();

    string cmd;
    do
    {
        cout << "cmd>";
        cin >> cmd;
        if (cmd.size() > 1)
        {
            cout << "Error Command!\n";
            cin.clear();
            cin.sync();
            cmd[0] = 1;
            continue;
        }

        switch (cmd[0])
        {
            case '1': addRecord(pb); main_menu(); break;
            case '2': editRecord(); main_menu(); break;
            case '3': searchRecord(); main_menu(); break;
            case '4': delRecord(); main_menu(); break;
            case '5': show(pb); main_menu(); break;
            case '9': main_menu(); break;
            case '0': cout << "Exit.\n"; break;
            default:
                cout << "Error Command!\n";
                cin.clear();
                cin.sync();
                break;

        }
    }
    while(cmd[0] != '0');
}
예제 #3
0
TractionTypeView::TractionTypeView(Configuration *cfg, QObject *parent) :
    QObject(parent)
{
    m_parent = parent;
    config = Configuration::instance();
    //sql->setConfig(config);
    sql = SQL::instance();
    mainWindow* myParent = qobject_cast<mainWindow*>(m_parent);
    tableView = myParent->ui->tblTractionTypes;
    tableView->verticalHeader()->resize(2,20);

    QSqlDatabase db = QSqlDatabase::database();
    qDebug()<<db.databaseName();
    connect(tableView->verticalHeader(), SIGNAL(sectionCountChanged(int,int)), this, SLOT(Resize(int,int)));
    tableView->setAlternatingRowColors(true);

    model = new MyTractionTypesTableModel(this, db);
    model->setTable("TractionTypes");
    model->setEditStrategy(QSqlTableModel::OnFieldChange);
    model->query().setForwardOnly(false);
    model->select();
    QString name = model->record(0).value("description").toString();
    tableView->setModel(model);

    menu = new QMenu();
    addAct = new QAction(tr("Add Traction Type"),this);
    addAct->setToolTip(tr("Add a new traction type"));
    connect(addAct, SIGNAL(triggered()), this, SLOT(newRecord()));
    delAct = new QAction(tr("Delete Traction Type"),this);
    delAct->setToolTip(tr("Delete an existing traction type"));
    connect(delAct, SIGNAL(triggered()), this, SLOT(delRecord()));

    tableView->setContextMenuPolicy(Qt::CustomContextMenu);
    connect(tableView, SIGNAL(customContextMenuRequested( const QPoint& )), this, SLOT(tablev_customContextMenu( const QPoint& )));

    tableView->show();
}
예제 #4
0
void history::createGUI()
{
    mainWidget = new QWidget(this);
    mainWidget->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Expanding);
    setCentralWidget(mainWidget);

    model = new QSqlTableModel(mainWidget);
    model->setTable("complains");
    model->setEditStrategy(QSqlTableModel::OnManualSubmit);

    model->select();

    //hiding or removing columns that are not required
    model->removeColumns(2,4);
    model->removeColumns(3,3);

    //renaming the headers for cleaner look
    model->setHeaderData(0, Qt::Horizontal, tr("ID"));
    model->setHeaderData(1, Qt::Horizontal, tr("Date"));
    model->setHeaderData(2, Qt::Horizontal, tr("Complain"));
    model->setHeaderData(3, Qt::Horizontal, tr("Status"));
    model->setHeaderData(4, Qt::Horizontal, tr("Code"));

    view = new QTableView;

    view->setEditTriggers(QAbstractItemView::NoEditTriggers);
    //view->setSelectionMode(QAbstractItemView::MultiSelection);
    view->setSelectionMode(QAbstractItemView::SingleSelection);
    view->setSelectionBehavior(QAbstractItemView::SelectRows);

    view->setModel(model);
    view->resizeColumnsToContents();

    btnDetail = new QPushButton(tr("Detail"));
    btnUpdateStatus = new QPushButton(tr("Update Status"));
    btnDeleteRecord = new QPushButton(tr("Delete"));

    connect(btnDetail, SIGNAL(clicked()), this, SLOT(viewDetail()));
    connect(btnUpdateStatus, SIGNAL(clicked()), this, SLOT(updateRecord()));
    connect(btnDeleteRecord, SIGNAL(clicked()), this, SLOT(delRecord()));

//    submitButton = new QPushButton(tr("Submit"));
//    submitButton->setDefault(true);
//    revertButton = new QPushButton(tr("&Revert"));
//    quitButton = new QPushButton(tr("Quit"));

    buttonBox = new QDialogButtonBox(Qt::Horizontal);
    buttonBox->addButton(btnDetail, QDialogButtonBox::ActionRole);
    buttonBox->addButton(btnUpdateStatus, QDialogButtonBox::ActionRole);
    buttonBox->addButton(btnDeleteRecord, QDialogButtonBox::ActionRole);

//    buttonBox->addButton(submitButton, QDialogButtonBox::ActionRole);
//    buttonBox->addButton(revertButton, QDialogButtonBox::ActionRole);
//    buttonBox->addButton(quitButton, QDialogButtonBox::RejectRole);

//    connect(submitButton, SIGNAL(clicked()), this, SLOT(submit()));
//    connect(revertButton, SIGNAL(clicked()), model, SLOT(revertAll()));
//    connect(quitButton, SIGNAL(clicked()), this, SLOT(close()));

    QVBoxLayout *mainLayout = new QVBoxLayout(mainWidget);
    mainLayout->addWidget(view);
    mainLayout->addWidget(buttonBox);
    //setLayout(mainLayout);

    setWindowTitle(tr("Complain History"));
}