void userDialog_t::acceptEdit(void) { userInfo_t ui; ui.username = m_username->text(); ui.password = m_password->text(); ui.name = m_name->text(); ui.phone = m_phone->text(); ui.email = m_email->text(); ui.street = m_street->text(); ui.city = m_city->text(); ui.state = m_state->text(); ui.country = m_country->text(); ui.postal = m_postal->text(); ui.domain = m_domain->currentText(); ui.algorithm = m_algorithm->currentText(); if (ui.username.isEmpty() || ui.password.isEmpty()) { QMessageBox::warning(this, "Error", "Adding a new user requires at least a username and password.", QMessageBox::Ok); return; } emit editUser(m_oldUser, ui); QDialog::accept(); deleteLater(); return; }
void DialogUsers::on_tableWidget_customContextMenuRequested(const QPoint &pos) { QTableWidgetItem *q = ui->tableWidget->itemAt(pos); if ( q == NULL ) return; ui->tableWidget->selectRow(q->row()); // fix bug with quick right click contextTableMenu->actions().at(2)->setEnabled( ( QVariant(ui->tableWidget->item(q->row(),0)->data(DataRole::deleted)).toInt() == 0 ) and Act::userPermission(Act::editDirection,currentUserRights)); contextTableMenu->actions().at(4)->setEnabled( ( QVariant(ui->tableWidget->item(q->row(),0)->data(DataRole::deleted)).toInt() == 1 ) and Act::userPermission(Act::editDirection,currentUserRights)); QAction* selectedItem = contextTableMenu->exec(QCursor::pos()); if ( !selectedItem ) return; if ( selectedItem->text() == "Добавить") { addNewUser(); } else if ( selectedItem->text() == "Править") { ui->tableWidget->setCurrentCell(q->row(),q->column()); editUser(); } else if ( selectedItem->text() == "Удалить") { ui->tableWidget->setCurrentCell(q->row(),q->column()); deleteUser(); } else if ( selectedItem->text() == "Восстановить") { ui->tableWidget->setCurrentCell(q->row(),q->column()); restoreUser(); } }
void DialogUsers::on_pushButtonEdit_clicked() { if ( ui->tableWidget->selectedItems().count() ) editUser(); else QMessageBox::information(this, tr("Внимание!"), "Необходимо выбрать строку для редактирования."); }
UserDialog::UserDialog(QSqlRelationalTableModel *model, QSqlRecord &record, int row, QWidget *parent) :QDialog(parent), userModel(model), userRecord(record), userRow(row) { initSetup(); fillFieldInputs(); connect(okButton, SIGNAL(clicked()), this, SLOT(editUser())); }
RegistrationApp::RegistrationApp(QWidget* parent) : m_team_table_wnd( new Ui::team_table_wnd ), m_user_table_wnd(new Ui::user_table_wnd), m_user_edit_wnd(new Ui::user_edit_wnd), m_sql(SqlUtil::getInstance()) { bool ok; QString text = QInputDialog::getText(this, tr("Database Directory"), tr("Database Path:"), QLineEdit::Normal, QDir::home().dirName(), &ok); if (!text.isEmpty()) m_sql.init(text); this->hide(); m_team_table_w = new QDialog(this); m_team_table_wnd->setupUi(m_team_table_w); m_team_table_w->show(); m_user_table_w = new QDialog(this); m_user_table_wnd->setupUi(m_user_table_w); m_user_table_w->hide(); m_user_edit_w = new QDialog(this); m_user_edit_wnd->setupUi(m_user_edit_w); m_user_edit_w->hide(); //network? //connecting stuff //connections for the buttons //team table connect(m_team_table_wnd->add_team_btn, SIGNAL(clicked()), this, SLOT(addTeam())); connect(m_team_table_wnd->team_edit_btn, SIGNAL(clicked()), this, SLOT(goToEditTeam())); connect(m_team_table_wnd->team_delete_btn, SIGNAL(clicked()), this, SLOT(deleteTeam())); //user table connect(m_user_table_wnd->edit_school_btn, SIGNAL(clicked()), this, SLOT(editTeamSchool())); connect(m_user_table_wnd->add_user_btn, SIGNAL(clicked()), this, SLOT(addUser())); connect(m_user_table_wnd->edit_user_btn, SIGNAL(clicked()), this, SLOT(editUser())); connect(m_user_table_wnd->delete_user_btn, SIGNAL(clicked()), this, SLOT(deleteUser())); connect(m_user_table_wnd->backtoteams_btn, SIGNAL(clicked()), this, SLOT(backToTeam())); //user edit connect(m_user_edit_wnd->save_userchange_btn, SIGNAL(clicked()), this, SLOT(saveUserEdit())); connect(m_user_edit_wnd->backtouser_btn, SIGNAL(clicked()), this, SLOT(backToUser())); bool result = SqlUtil::getInstance().init ( text ); if ( !result ) { QMessageBox msg ( this ); msg.setText ( "Failed to load database" ); msg.exec(); } }
void promptEdit() { contact *ptr; char data[32]; char number[8]; memset(number, 0, 8); ptr = findContact(); if(ptr == NULL) { puts("No such contact."); return; } editUser(ptr); }
void promptShow() { contact *ptr; char office[8]; char useraction[2]; ptr = findContact(); if(ptr == NULL) { puts("No such contact."); return; } memset(useraction, 0, 2); useraction[0] = 's'; while(useraction[0] != 'q') { memset(office, 0, 6); puts("****************************************"); put("First name:\t"); puts(ptr->first); put("Last name:\t"); puts(ptr->last); put("Phone num:\t"); puts(ptr->phone); itoa(office, ptr->officenum, 6); put("Office Number:\t"); puts(office); put("Gender:\t\t"); printGender(ptr->gender); if(ptr->hacker == 'y') { puts("[\x1B[31m!\x1B[0m]This user known to be a hacker[\x1B[31m!\x1B[0m]"); } puts("****************************************"); recvUntil(useraction, 2, '\n'); switch(useraction[0]) { case 'q': break; case 'd': if(ptr->next == NULL && ptr->prev == NULL) { remove(ptr); puts("No more contacts. Leaving detail view."); useraction[0]='q'; } else if (ptr->next == NULL) { ptr = ptr->prev; remove(ptr->next); } else { ptr = ptr->next; remove(ptr->prev); } break; case 'e': editUser(ptr); break; case 'n': if(ptr->next != NULL) ptr = ptr->next; else puts("No next contact."); break; case 'p': if(ptr->prev != NULL) ptr = ptr->prev; else puts("No previous contact."); } } }
main() { char *data = getenv("QUERY_STRING"); char choice[50]; //char *data ="add_username=5555&add_password=2222&add_usertype=3333&Submit=Submit+Query"; char *p1,*p2; char user[50], password[50], type[50]; char newUser[50], newPassword[50], newType[50]; char buffer[500]; if (strstr(data, "group1=system_AddNewUser")!=NULL) { addNewUserForm(); } else if (strstr(data, "group1=system_ChangeCurrentUser")!=NULL) { editForm(); } else if (strstr(data, "group1=system_ListInventory")!=NULL) { listInventory(); } else if (strstr(data, "add_")!=NULL) { p1 = strstr(data, "add_username="******"add_password="******"add_usertype="); p2 = strchr(p1,'&'); strncpy(type,p1+13,p2-p1-13); type[p2-p1-13] = '\0'; //printf ("user=%s, password=%s, type=%s\n",user, password, type); //return; addNewUser(user,password,type); } else if (strstr(data, "edit_")!=NULL) { p1 = strstr(data, "edit_oldusername="******"edit_oldpassword="******"edit_oldtype="); p2 = strchr(p1,'&'); strncpy(type,p1+13,p2-p1-13); type[p2-p1-13] = '\0'; p1 = strstr(data, "edit_newusername="******"edit_newpassword="******"edit_newtype="); p2 = strchr(p1,'&'); strncpy(newType,p1+13,p2-p1-13); newType[p2-p1-13] = '\0'; //printf ("user=%s, password=%s, type=%s\n",user, password, type); //printf ("newuser=%s, newpassword=%s, newtype=%s\n",newUser, newPassword, newType); //return; editUser(user,password, type, newUser,newPassword, newType); } else { sprintf (buffer,"Query String: %s is not correct", data); showMessagePage(buffer); } }
void DialogUsers::on_tableWidget_doubleClicked(const QModelIndex &index) { Q_UNUSED(index); editUser(); }