using Casic.Birmm.RbFreqStandMeasure.tools; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace Casic.Birmm.RbFreqStandMeasure.info { public partial class DataBackupDlg : Form { public DataBackupDlg() { InitializeComponent(); } public Action HideMaskAction { get; set; } private void btnCancel_Click(object sender, EventArgs e) { this.Close(); } private void btnExit_Click(object sender, EventArgs e) { this.HideMaskAction(); } private void btn_cancle_Click(object sender, EventArgs e) { this.HideMaskAction(); } private void btn_save_Click(object sender, EventArgs e) { if (rdDataBackup.Checked) { DataHelper.Backup(textBoxX1.Text); } else if (rdDataRecover.Checked) { DataHelper.Restore(textBoxX1.Text); } this.HideMaskAction(); } private void rdDataRecover_CheckedChanged(object sender, EventArgs e) { if (rdDataRecover.Checked) { labelX1.Text = "请选择文件进行还原:"; btn_save.Text = "开始还原"; } else { labelX1.Text = "请选择备份文件存放路径:"; btn_save.Text = "开始备份"; } } private void button1_Click(object sender, EventArgs e) { // 备份 if (rdDataBackup.Checked) { SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Title = "数据备份文件另存为"; saveFileDialog.RestoreDirectory = true; saveFileDialog.Filter = "sql 数据库文件(*.sql)|*.sql"; saveFileDialog.FileName = DateTime.Now.ToString("yyyy-MM-dd");//设置默认文件名 saveFileDialog.CheckPathExists = true;//检查目录 if (saveFileDialog.ShowDialog() == DialogResult.OK) { string strSaveFileLocation = saveFileDialog.FileName;//文件路径 textBoxX1.Text = strSaveFileLocation; } } // 备份 else if (rdDataRecover.Checked) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Title = "请选择文件"; openFileDialog.RestoreDirectory = true; openFileDialog.Filter = "sql 数据库文件(*.sql)|*.sql"; openFileDialog.CheckPathExists = true;//检查目录 if (openFileDialog.ShowDialog() == DialogResult.OK) { string strSaveFileLocation = openFileDialog.FileName;//文件路径 textBoxX1.Text = strSaveFileLocation; } } } } }