summaryrefslogtreecommitdiff
path: root/kurier
diff options
context:
space:
mode:
Diffstat (limited to 'kurier')
-rw-r--r--kurier/Form1.Designer.cs1
-rw-r--r--kurier/Form1.cs21
-rw-r--r--kurier/MySQL.cs10
-rw-r--r--kurier/kurier.csproj5
4 files changed, 36 insertions, 1 deletions
diff --git a/kurier/Form1.Designer.cs b/kurier/Form1.Designer.cs
index 47549f4..c9a2934 100644
--- a/kurier/Form1.Designer.cs
+++ b/kurier/Form1.Designer.cs
@@ -103,6 +103,7 @@
this.bSave.Size = new System.Drawing.Size(140, 140);
this.bSave.TabIndex = 4;
this.bSave.UseVisualStyleBackColor = true;
+ this.bSave.Click += new System.EventHandler(this.bSave_Click);
//
// Form1
//
diff --git a/kurier/Form1.cs b/kurier/Form1.cs
index a8bd7eb..86754e5 100644
--- a/kurier/Form1.cs
+++ b/kurier/Form1.cs
@@ -6,6 +6,7 @@ using System.Drawing;
using System.Text;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
+using System.IO;
namespace kurier
{
@@ -51,5 +52,25 @@ namespace kurier
this.cbDatabaseName.SelectedIndex = 0;
dbs.Close();
}
+
+ private void bSave_Click(object sender, EventArgs e)
+ {
+ FolderBrowserDialog fd = new FolderBrowserDialog();
+ if (fd.ShowDialog() == DialogResult.OK)
+ {
+ string filePath = Path.Combine(fd.SelectedPath, this.cbDatabaseName.SelectedItem.ToString() + DateTime.Now.ToString("-yyyyMMdd-HHmmss") + ".sql");
+ try
+ {
+ MySQL c = new MySQL(this.cbDatabaseName.SelectedItem.ToString());
+ c.backup(filePath);
+ c.close();
+ MessageBox.Show("Wyeksportowano pomyślnie do pliku: " + filePath, "Sukces eksportu!", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Błąd eksportu!", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
}
}
diff --git a/kurier/MySQL.cs b/kurier/MySQL.cs
index 81a3a0b..88b4fbf 100644
--- a/kurier/MySQL.cs
+++ b/kurier/MySQL.cs
@@ -8,6 +8,7 @@ namespace kurier
public class MySQL
{
private MySqlConnection conn;
+ private MySqlCommand cmd;
private string database;
public MySQL(string database)
@@ -72,5 +73,14 @@ namespace kurier
public static string getPass() { return Properties.Settings.Default.PASS; }
public static string getPort() { return Properties.Settings.Default.PORT; }
public static bool getConfigured() { return Properties.Settings.Default.CONFIGURED; }
+
+ internal void backup(string filePath)
+ {
+ cmd = new MySqlCommand();
+ cmd.Connection = conn;
+ MySqlBackup backup = new MySqlBackup(cmd);
+ backup.ExportInfo.AddCreateDatabase = true;
+ backup.ExportToFile(filePath);
+ }
}
}
diff --git a/kurier/kurier.csproj b/kurier/kurier.csproj
index 02fde5e..a6caf88 100644
--- a/kurier/kurier.csproj
+++ b/kurier/kurier.csproj
@@ -54,7 +54,10 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\res\MySql.Data.dll</HintPath>
</Reference>
- <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="MySqlBackup">
+ <HintPath>..\res\MySqlBackup.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />