1 Star 0 Fork 2

downloadproject / PropertyManagementSystem

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backupsql.cpp 1.99 KB
一键复制 编辑 原始数据 按行查看 历史
zhfy 提交于 2019-02-26 18:43 . PropertyManagementSystem
#include "backupsql.h"
#include "ui_backupsql.h"
#include <QFileDialog>
#include <QProcess>
#include <QDesktopServices>
#include <QMessageBox>
#include <QSettings>
backupSQL::backupSQL(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::backupSQL)
{
ui->setupUi(this);
}
backupSQL::~backupSQL()
{
delete ui;
}
void backupSQL::on_pushButton_clicked()
{
//备份数据库
QString name = ui->lineEdit_count->text();
QString pwd = ui->lineEdit_pwd->text();
QSettings *configIniRead = new QSettings(":/config/databaseConfig.ini",QSettings::IniFormat);
QString user_name = configIniRead->value("/databaseConfig/username").toString();
QString password = configIniRead->value("/databaseConfig/password").toString();
if(name == user_name){
if(pwd == password){
QString Cmd = QString("mysqldump.exe --add-drop-table -u%1 -p%2 test")
.arg(name,pwd);
QString fileName = QFileDialog::getSaveFileName(this,
"备份数据库",
QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation),
"sql 文件(*.Sql)");//选择保存路径
if(fileName.isEmpty()){
return;
}else {
QString path = QString("%1").arg(fileName);
QProcess *pro = new QProcess;
pro->setStandardOutputFile(path);
pro->start(Cmd);
QMessageBox::information(this,"提示",
"数据库已成功备份!");
}
}else {
QMessageBox::warning(this,"错误!",
"数据库登录密码输入错误!请重新输入!");
}
}else {
QMessageBox::warning(this,"错误!",
"数据库登录账户输入错误!请重新输入!");
}
}
1
https://gitee.com/projectdownload/PropertyManagementSystem.git
git@gitee.com:projectdownload/PropertyManagementSystem.git
projectdownload
PropertyManagementSystem
PropertyManagementSystem
master

搜索帮助