diff --git a/DataDomain/BackupRegister.cs b/DataDomain/BackupRegister.cs
new file mode 100644
index 0000000..1b476b7
--- /dev/null
+++ b/DataDomain/BackupRegister.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DataDomain
+{
+ public class BackupRegister
+ {
+ public int Id { get; set; }
+ public DateTime BackedUp { get; set; }
+ public string DbName { get; set; }
+ public string BackupDbName { get; set; }
+ public string BackupPath { get; set; }
+ }
+}
diff --git a/DatamodelLibrary/Migrations/20210316200448_backupregister.Designer.cs b/DatamodelLibrary/Migrations/20210316200448_backupregister.Designer.cs
new file mode 100644
index 0000000..277cad6
--- /dev/null
+++ b/DatamodelLibrary/Migrations/20210316200448_backupregister.Designer.cs
@@ -0,0 +1,174 @@
+//
+using System;
+using DatamodelLibrary;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+namespace DatamodelLibrary.Migrations
+{
+ [DbContext(typeof(StockContext))]
+ [Migration("20210316200448_backupregister")]
+ partial class backupregister
+ {
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "5.0.3");
+
+ modelBuilder.Entity("DataDomain.Address", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("Destination")
+ .HasColumnType("TEXT");
+
+ b.Property("Nation")
+ .HasColumnType("TEXT");
+
+ b.Property("Street")
+ .HasColumnType("TEXT");
+
+ b.Property("Street2")
+ .HasColumnType("TEXT");
+
+ b.Property("Zipcode")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.ToTable("Addresses");
+ });
+
+ modelBuilder.Entity("DataDomain.BackupRegister", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("BackedUp")
+ .HasColumnType("TEXT");
+
+ b.Property("BackupDbName")
+ .HasColumnType("TEXT");
+
+ b.Property("BackupPath")
+ .HasColumnType("TEXT");
+
+ b.Property("DbName")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.ToTable("BackupRegings");
+ });
+
+ modelBuilder.Entity("DataDomain.Person", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("AccountNo")
+ .HasColumnType("INTEGER");
+
+ b.Property("Born")
+ .HasColumnType("TEXT");
+
+ b.Property("ClearingNo")
+ .HasColumnType("INTEGER");
+
+ b.Property("Comments")
+ .HasColumnType("TEXT");
+
+ b.Property("FirstName")
+ .HasColumnType("TEXT");
+
+ b.Property("HomeAddress")
+ .HasColumnType("INTEGER");
+
+ b.Property("InvoiceAddress")
+ .HasColumnType("INTEGER");
+
+ b.Property("LastName")
+ .HasColumnType("TEXT");
+
+ b.Property("NickName")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.ToTable("Persons");
+ });
+
+ modelBuilder.Entity("DataDomain.PersonStock", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("Comment")
+ .HasColumnType("TEXT");
+
+ b.Property("PersonId")
+ .HasColumnType("INTEGER");
+
+ b.Property("StockId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.ToTable("PersonStocks");
+ });
+
+ modelBuilder.Entity("DataDomain.StockMember", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("ActAmount")
+ .HasColumnType("INTEGER");
+
+ b.Property("ActDate")
+ .HasColumnType("TEXT");
+
+ b.Property("ActValue")
+ .HasColumnType("TEXT");
+
+ b.Property("BuyDate")
+ .HasColumnType("TEXT");
+
+ b.Property("BuyValue")
+ .HasColumnType("TEXT");
+
+ b.Property("Comment")
+ .HasColumnType("TEXT");
+
+ b.Property("PostAmount")
+ .HasColumnType("INTEGER");
+
+ b.Property("SoldDate")
+ .HasColumnType("TEXT");
+
+ b.Property("SoldValue")
+ .HasColumnType("TEXT");
+
+ b.Property("StockExtId")
+ .HasColumnType("TEXT");
+
+ b.Property("StockId")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.ToTable("Stocks");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/DatamodelLibrary/Migrations/20210316200448_backupregister.cs b/DatamodelLibrary/Migrations/20210316200448_backupregister.cs
new file mode 100644
index 0000000..4843482
--- /dev/null
+++ b/DatamodelLibrary/Migrations/20210316200448_backupregister.cs
@@ -0,0 +1,33 @@
+using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+
+namespace DatamodelLibrary.Migrations
+{
+ public partial class backupregister : Migration
+ {
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.CreateTable(
+ name: "BackupRegings",
+ columns: table => new
+ {
+ Id = table.Column(type: "INTEGER", nullable: false)
+ .Annotation("Sqlite:Autoincrement", true),
+ BackedUp = table.Column(type: "TEXT", nullable: false),
+ DbName = table.Column(type: "TEXT", nullable: true),
+ BackupDbName = table.Column(type: "TEXT", nullable: true),
+ BackupPath = table.Column(type: "TEXT", nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_BackupRegings", x => x.Id);
+ });
+ }
+
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable(
+ name: "BackupRegings");
+ }
+ }
+}
diff --git a/DatamodelLibrary/Migrations/StockContextModelSnapshot.cs b/DatamodelLibrary/Migrations/StockContextModelSnapshot.cs
index 9e5046e..0b733a7 100644
--- a/DatamodelLibrary/Migrations/StockContextModelSnapshot.cs
+++ b/DatamodelLibrary/Migrations/StockContextModelSnapshot.cs
@@ -42,6 +42,29 @@ namespace DatamodelLibrary.Migrations
b.ToTable("Addresses");
});
+ modelBuilder.Entity("DataDomain.BackupRegister", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("BackedUp")
+ .HasColumnType("TEXT");
+
+ b.Property("BackupDbName")
+ .HasColumnType("TEXT");
+
+ b.Property("BackupPath")
+ .HasColumnType("TEXT");
+
+ b.Property("DbName")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.ToTable("BackupRegings");
+ });
+
modelBuilder.Entity("DataDomain.Person", b =>
{
b.Property("Id")
diff --git a/DatamodelLibrary/StockContext.cs b/DatamodelLibrary/StockContext.cs
index d58a887..6bce6ae 100644
--- a/DatamodelLibrary/StockContext.cs
+++ b/DatamodelLibrary/StockContext.cs
@@ -14,6 +14,7 @@ namespace DatamodelLibrary
public DbSet Persons { get; set; }
public DbSet Addresses { get; set; }
public DbSet PersonStocks { get; set; }
+ public DbSet BackupRegings { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder options)
=> options.UseSqlite("Data Source=Stocks.db");
diff --git a/SqliteBackups/BackupRoutines.cs b/SqliteBackups/BackupRoutines.cs
new file mode 100644
index 0000000..3e7dbc8
--- /dev/null
+++ b/SqliteBackups/BackupRoutines.cs
@@ -0,0 +1,22 @@
+using SqliteBackups.Interfaces;
+using System;
+using System.Collections.Generic;
+using System.Data.SQLite;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SqliteBackups
+{
+ public class BackupRoutines : IBackupRoutines
+ {
+ public void BackupSqliteDb(string fromDb, string toDb)
+ {
+ using var source = new SQLiteConnection($"Data Source={fromDb}; Version=3;");
+ using var destination = new SQLiteConnection($"Data Source={toDb}; Version=3;");
+ source.Open();
+ destination.Open();
+ source.BackupDatabase(destination, "main", "main", -1, null, 0);
+ }
+ }
+}
diff --git a/SqliteBackups/Interfaces/IBackupRoutines.cs b/SqliteBackups/Interfaces/IBackupRoutines.cs
new file mode 100644
index 0000000..ca94ef1
--- /dev/null
+++ b/SqliteBackups/Interfaces/IBackupRoutines.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SqliteBackups.Interfaces
+{
+ public interface IBackupRoutines
+ {
+ void BackupSqliteDb(string fromDb, string toDb);
+ }
+}
diff --git a/SqliteBackups/SqliteBackups.csproj b/SqliteBackups/SqliteBackups.csproj
new file mode 100644
index 0000000..596e5c1
--- /dev/null
+++ b/SqliteBackups/SqliteBackups.csproj
@@ -0,0 +1,11 @@
+
+
+
+ net5.0
+
+
+
+
+
+
+
diff --git a/StockDAL/BackupRepository.cs b/StockDAL/BackupRepository.cs
new file mode 100644
index 0000000..30fcf90
--- /dev/null
+++ b/StockDAL/BackupRepository.cs
@@ -0,0 +1,50 @@
+using DataDomain;
+using DatamodelLibrary;
+using StockDAL.Interface;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StockDAL
+{
+ public class BackupRepository : IBackupRepository
+ {
+ public BackupRegister SaveBackupReging(BackupRegister backupRegister)
+ {
+ using var context = new StockContext();
+ var entity = (from brr in context.BackupRegings
+ where brr.Id == backupRegister.Id
+ select brr).FirstOrDefault();
+ if(entity == null)
+ {
+ entity = new BackupRegister
+ {
+ BackedUp = DateTime.Now,
+ DbName = "Stocks.db",
+ BackupDbName = backupRegister.BackupDbName,
+ BackupPath = backupRegister.BackupPath
+ };
+ context.BackupRegings.Add(entity);
+ }
+ else
+ {
+ entity.BackedUp = backupRegister.BackedUp;
+ entity.DbName = backupRegister.DbName;
+ entity.BackupDbName = backupRegister.BackupDbName;
+ entity.BackupPath = backupRegister.BackupPath;
+ }
+
+ context.SaveChanges();
+ return entity;
+ }
+
+ public IEnumerable GetAllBackupRegisters()
+ {
+ using var context = new StockContext();
+ var entities = context.BackupRegings;
+ return entities.ToList();
+ }
+ }
+}
diff --git a/StockDBEFApp.sln b/StockDBEFApp.sln
index 4114206..f958ae6 100644
--- a/StockDBEFApp.sln
+++ b/StockDBEFApp.sln
@@ -15,9 +15,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StockInfo", "StockInfo\Stoc
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Helpers", "Helpers\Helpers.csproj", "{5FEE920E-07B8-4185-A41F-1587643ECC26}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StockBL", "StockBL\StockBL.csproj", "{C8801F5F-1C4F-4067-ADA2-A2DA299A54A8}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StockBL", "StockBL\StockBL.csproj", "{C8801F5F-1C4F-4067-ADA2-A2DA299A54A8}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StockBL.Interface", "StockBL.Interface\StockBL.Interface.csproj", "{BFF16A7B-9962-430B-A665-03F4174A289D}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StockBL.Interface", "StockBL.Interface\StockBL.Interface.csproj", "{BFF16A7B-9962-430B-A665-03F4174A289D}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SqliteBackups", "SqliteBackups\SqliteBackups.csproj", "{2BD170F4-1F7D-4067-980E-284CEEC2232D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -57,6 +59,10 @@ Global
{BFF16A7B-9962-430B-A665-03F4174A289D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BFF16A7B-9962-430B-A665-03F4174A289D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BFF16A7B-9962-430B-A665-03F4174A289D}.Release|Any CPU.Build.0 = Release|Any CPU
+ {2BD170F4-1F7D-4067-980E-284CEEC2232D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {2BD170F4-1F7D-4067-980E-284CEEC2232D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {2BD170F4-1F7D-4067-980E-284CEEC2232D}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {2BD170F4-1F7D-4067-980E-284CEEC2232D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/StockDal.Interface/IBackupRepository.cs b/StockDal.Interface/IBackupRepository.cs
new file mode 100644
index 0000000..370b281
--- /dev/null
+++ b/StockDal.Interface/IBackupRepository.cs
@@ -0,0 +1,15 @@
+using DataDomain;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StockDAL.Interface
+{
+ public interface IBackupRepository
+ {
+ IEnumerable GetAllBackupRegisters();
+ BackupRegister SaveBackupReging(BackupRegister backupRegister);
+ }
+}
diff --git a/StockInfo/Program.cs b/StockInfo/Program.cs
index e6fec06..ce3f959 100644
--- a/StockInfo/Program.cs
+++ b/StockInfo/Program.cs
@@ -1,4 +1,6 @@
using Autofac;
+using SqliteBackups;
+using SqliteBackups.Interfaces;
using StockBL;
using StockBL.Interface;
using StockDal;
@@ -32,6 +34,8 @@ namespace StockInfo
Container.Resolve(),
Container.Resolve(),
Container.Resolve(),
+ Container.Resolve(),
+ Container.Resolve(),
Container.Resolve()
));
}
@@ -44,6 +48,8 @@ namespace StockInfo
builder.RegisterType().As();
builder.RegisterType().As();
builder.RegisterType().As();
+ builder.RegisterType().As();
+ builder.RegisterType().As();
builder.RegisterType().As();
builder.RegisterType();
return builder.Build();
diff --git a/StockInfo/StockInfo.csproj b/StockInfo/StockInfo.csproj
index 2d037a9..ef3d9f9 100644
--- a/StockInfo/StockInfo.csproj
+++ b/StockInfo/StockInfo.csproj
@@ -26,6 +26,7 @@
+
@@ -52,7 +53,14 @@
- PreserveNewest
+ Never
+
+
+
+
+
+
+ Never
diff --git a/StockInfo/Stocks.db b/StockInfo/Stocks.db
index c9189fa..c9b5007 100644
Binary files a/StockInfo/Stocks.db and b/StockInfo/Stocks.db differ
diff --git a/StockInfo/Stocks.db-wal b/StockInfo/Stocks.db-wal
deleted file mode 100644
index e69de29..0000000
diff --git a/StockInfo/frmBackup.Designer.cs b/StockInfo/frmBackup.Designer.cs
new file mode 100644
index 0000000..dba5b60
--- /dev/null
+++ b/StockInfo/frmBackup.Designer.cs
@@ -0,0 +1,127 @@
+
+namespace StockInfo
+{
+ partial class frmBackup
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.label1 = new System.Windows.Forms.Label();
+ this.sfdChoosePlaceAndFile = new System.Windows.Forms.SaveFileDialog();
+ this.btnChooseBackupDest = new System.Windows.Forms.Button();
+ this.txtBackupPath = new System.Windows.Forms.TextBox();
+ this.txtBackupFile = new System.Windows.Forms.TextBox();
+ this.lstBackups = new System.Windows.Forms.ListBox();
+ this.btnClose = new System.Windows.Forms.Button();
+ this.SuspendLayout();
+ //
+ // label1
+ //
+ this.label1.AutoSize = true;
+ this.label1.Location = new System.Drawing.Point(13, 13);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(226, 15);
+ this.label1.TabIndex = 0;
+ this.label1.Text = "Backup Local database to where you wish";
+ //
+ // sfdChoosePlaceAndFile
+ //
+ this.sfdChoosePlaceAndFile.Title = "Choose path and filename";
+ //
+ // btnChooseBackupDest
+ //
+ this.btnChooseBackupDest.Location = new System.Drawing.Point(13, 31);
+ this.btnChooseBackupDest.Name = "btnChooseBackupDest";
+ this.btnChooseBackupDest.Size = new System.Drawing.Size(152, 23);
+ this.btnChooseBackupDest.TabIndex = 1;
+ this.btnChooseBackupDest.Text = "Choose BU destination";
+ this.btnChooseBackupDest.UseVisualStyleBackColor = true;
+ this.btnChooseBackupDest.Click += new System.EventHandler(this.btnChooseBackupDest_Click);
+ //
+ // txtBackupPath
+ //
+ this.txtBackupPath.Location = new System.Drawing.Point(171, 32);
+ this.txtBackupPath.Name = "txtBackupPath";
+ this.txtBackupPath.ReadOnly = true;
+ this.txtBackupPath.Size = new System.Drawing.Size(148, 23);
+ this.txtBackupPath.TabIndex = 2;
+ //
+ // txtBackupFile
+ //
+ this.txtBackupFile.Location = new System.Drawing.Point(325, 31);
+ this.txtBackupFile.Name = "txtBackupFile";
+ this.txtBackupFile.ReadOnly = true;
+ this.txtBackupFile.Size = new System.Drawing.Size(100, 23);
+ this.txtBackupFile.TabIndex = 3;
+ //
+ // lstBackups
+ //
+ this.lstBackups.FormattingEnabled = true;
+ this.lstBackups.ItemHeight = 15;
+ this.lstBackups.Location = new System.Drawing.Point(13, 70);
+ this.lstBackups.Name = "lstBackups";
+ this.lstBackups.Size = new System.Drawing.Size(214, 184);
+ this.lstBackups.TabIndex = 4;
+ //
+ // btnClose
+ //
+ this.btnClose.Location = new System.Drawing.Point(350, 259);
+ this.btnClose.Name = "btnClose";
+ this.btnClose.Size = new System.Drawing.Size(75, 23);
+ this.btnClose.TabIndex = 5;
+ this.btnClose.Text = "Close";
+ this.btnClose.UseVisualStyleBackColor = true;
+ //
+ // frmBackup
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(438, 294);
+ this.Controls.Add(this.btnClose);
+ this.Controls.Add(this.lstBackups);
+ this.Controls.Add(this.txtBackupFile);
+ this.Controls.Add(this.txtBackupPath);
+ this.Controls.Add(this.btnChooseBackupDest);
+ this.Controls.Add(this.label1);
+ this.Name = "frmBackup";
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
+ this.Text = "frmBackup";
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.SaveFileDialog sfdChoosePlaceAndFile;
+ private System.Windows.Forms.Button btnChooseBackupDest;
+ private System.Windows.Forms.TextBox txtBackupPath;
+ private System.Windows.Forms.TextBox txtBackupFile;
+ private System.Windows.Forms.ListBox lstBackups;
+ private System.Windows.Forms.Button btnClose;
+ }
+}
\ No newline at end of file
diff --git a/StockInfo/frmBackup.cs b/StockInfo/frmBackup.cs
new file mode 100644
index 0000000..7b337aa
--- /dev/null
+++ b/StockInfo/frmBackup.cs
@@ -0,0 +1,54 @@
+using DataDomain;
+using Helpers;
+using SqliteBackups.Interfaces;
+using StockDAL.Interface;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Diagnostics;
+using System.Drawing;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace StockInfo
+{
+ public partial class frmBackup : Form
+ {
+ private readonly IBackupRepository _backupRepository;
+ private readonly IBackupRoutines _backupRoutines;
+
+ public frmBackup(IBackupRepository backupRepository,IBackupRoutines backupRoutines)
+ {
+ InitializeComponent();
+ _backupRepository = backupRepository;
+ _backupRoutines = backupRoutines;
+ }
+
+ private void btnChooseBackupDest_Click(object sender, EventArgs e)
+ {
+ sfdChoosePlaceAndFile.Filter = "Database files (*.db)|*.db|All files (*.*)|*.*";
+ if (sfdChoosePlaceAndFile.ShowDialog() == DialogResult.OK)
+ {
+ var wholeFile = sfdChoosePlaceAndFile.FileName;
+ var lastBackslash = wholeFile.LastIndexOf('\\') + 1;
+ var dir = wholeFile.Substring(0, lastBackslash);
+ var file = wholeFile.Substring(lastBackslash, wholeFile.Length - lastBackslash);
+ //Debug.WriteLine($"Chosen file:{wholeFile}");
+ //Debug.WriteLine($"Path: {dir} , File {file}");
+ BackupRegister reg = new();
+ reg.BackupDbName = file;
+ reg.BackupPath = dir;
+ reg = _backupRepository.SaveBackupReging(reg);
+ _backupRoutines.BackupSqliteDb(reg.DbName, Path.Combine(dir, file));
+ var cmbItem = new ComboboxItem(wholeFile, reg.Id);
+ lstBackups.Items.Add(cmbItem);
+
+ };
+
+ }
+ }
+}
diff --git a/StockInfo/frmBackup.resx b/StockInfo/frmBackup.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/StockInfo/frmBackup.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/StockInfo/frmInitial.Designer.cs b/StockInfo/frmInitial.Designer.cs
index 4f38db6..bf50f65 100644
--- a/StockInfo/frmInitial.Designer.cs
+++ b/StockInfo/frmInitial.Designer.cs
@@ -32,6 +32,8 @@ namespace StockInfo
this.dataGridView = new System.Windows.Forms.DataGridView();
this.lblTotalRecords = new System.Windows.Forms.Label();
this.gB1 = new System.Windows.Forms.GroupBox();
+ this.btnRestoreAll = new System.Windows.Forms.Button();
+ this.btnBackupAll = new System.Windows.Forms.Button();
this.chkEnableBackRes = new System.Windows.Forms.CheckBox();
this.btnRestoreShares = new System.Windows.Forms.Button();
this.btnBackupShares = new System.Windows.Forms.Button();
@@ -65,7 +67,7 @@ namespace StockInfo
this.dataGridView.Location = new System.Drawing.Point(12, 16);
this.dataGridView.Name = "dataGridView";
this.dataGridView.RowTemplate.Height = 25;
- this.dataGridView.Size = new System.Drawing.Size(829, 360);
+ this.dataGridView.Size = new System.Drawing.Size(871, 360);
this.dataGridView.TabIndex = 0;
//
// lblTotalRecords
@@ -81,17 +83,38 @@ namespace StockInfo
// gB1
//
this.gB1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
+ this.gB1.Controls.Add(this.btnRestoreAll);
+ this.gB1.Controls.Add(this.btnBackupAll);
this.gB1.Controls.Add(this.chkEnableBackRes);
this.gB1.Controls.Add(this.btnRestoreShares);
this.gB1.Controls.Add(this.btnBackupShares);
this.gB1.Controls.Add(this.btnReload);
this.gB1.Location = new System.Drawing.Point(157, 385);
this.gB1.Name = "gB1";
- this.gB1.Size = new System.Drawing.Size(203, 144);
+ this.gB1.Size = new System.Drawing.Size(245, 144);
this.gB1.TabIndex = 3;
this.gB1.TabStop = false;
this.gB1.Text = "Sharelist";
//
+ // btnRestoreAll
+ //
+ this.btnRestoreAll.Location = new System.Drawing.Point(130, 111);
+ this.btnRestoreAll.Name = "btnRestoreAll";
+ this.btnRestoreAll.Size = new System.Drawing.Size(105, 23);
+ this.btnRestoreAll.TabIndex = 7;
+ this.btnRestoreAll.Text = "Restore All";
+ this.btnRestoreAll.UseVisualStyleBackColor = true;
+ //
+ // btnBackupAll
+ //
+ this.btnBackupAll.Location = new System.Drawing.Point(130, 82);
+ this.btnBackupAll.Name = "btnBackupAll";
+ this.btnBackupAll.Size = new System.Drawing.Size(105, 23);
+ this.btnBackupAll.TabIndex = 6;
+ this.btnBackupAll.Text = "Backup All";
+ this.btnBackupAll.UseVisualStyleBackColor = true;
+ this.btnBackupAll.Click += new System.EventHandler(this.btnBackupAll_Click);
+ //
// chkEnableBackRes
//
this.chkEnableBackRes.AutoSize = true;
@@ -174,7 +197,7 @@ namespace StockInfo
this.gbStockMgmnt.Controls.Add(this.btnStockSale);
this.gbStockMgmnt.Controls.Add(this.btnValueView);
this.gbStockMgmnt.Controls.Add(this.btnStockReg);
- this.gbStockMgmnt.Location = new System.Drawing.Point(366, 385);
+ this.gbStockMgmnt.Location = new System.Drawing.Point(408, 385);
this.gbStockMgmnt.Name = "gbStockMgmnt";
this.gbStockMgmnt.Size = new System.Drawing.Size(216, 144);
this.gbStockMgmnt.TabIndex = 8;
@@ -232,7 +255,7 @@ namespace StockInfo
this.gpOwners.Controls.Add(this.btnConnShares);
this.gpOwners.Controls.Add(this.btnEditPerson);
this.gpOwners.Controls.Add(this.cmbOwners);
- this.gpOwners.Location = new System.Drawing.Point(589, 385);
+ this.gpOwners.Location = new System.Drawing.Point(630, 385);
this.gpOwners.Name = "gpOwners";
this.gpOwners.Size = new System.Drawing.Size(252, 141);
this.gpOwners.TabIndex = 10;
@@ -274,7 +297,7 @@ namespace StockInfo
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(853, 538);
+ this.ClientSize = new System.Drawing.Size(895, 538);
this.Controls.Add(this.gpOwners);
this.Controls.Add(this.lblStockRows);
this.Controls.Add(this.gbStockMgmnt);
@@ -324,6 +347,8 @@ namespace StockInfo
private System.Windows.Forms.Button btnConnShares;
private System.Windows.Forms.Button btnEditPerson;
private System.Windows.Forms.ComboBox cmbOwners;
+ private System.Windows.Forms.Button btnRestoreAll;
+ private System.Windows.Forms.Button btnBackupAll;
}
}
diff --git a/StockInfo/frmInitial.cs b/StockInfo/frmInitial.cs
index 8d9e963..a5aed95 100644
--- a/StockInfo/frmInitial.cs
+++ b/StockInfo/frmInitial.cs
@@ -14,6 +14,7 @@ using System.Text.Json;
using System.IO;
using Helpers;
using StockBL.Interface;
+using SqliteBackups.Interfaces;
namespace StockInfo
{
@@ -24,12 +25,15 @@ namespace StockInfo
private readonly IPersonRepository _personRepository;
private readonly IAddressRepository _addressRepository;
private readonly IStockPersonConnect _stockPersonConnect;
+ private readonly IBackupRepository _backupRepository;
+ private readonly IBackupRoutines _backupRoutines;
private readonly IPersonStockFacade _personStockFacade;
private frmRegisterStock regWindow;
private frmMyStocks stockWindow;
private frmSelling sellWindow;
private frmPerson personWindow;
private frmPersonShareConnect personShareConnect;
+ private frmBackup backupWindow;
public int SelectedPersonId { get; set; } = 0;
public frmInitial(
@@ -38,7 +42,9 @@ namespace StockInfo
IPersonRepository personRepository,
IAddressRepository addressRepository,
IStockPersonConnect stockPersonConnect,
- IPersonStockFacade personStockFacade)
+ IBackupRepository backupRepository,
+ IBackupRoutines backupRoutines,
+ IPersonStockFacade personStockFacade)
{
InitializeComponent();
_stockRepository = stockMemberRepository;
@@ -46,6 +52,8 @@ namespace StockInfo
_personRepository = personRepository;
_addressRepository = addressRepository;
_stockPersonConnect = stockPersonConnect;
+ _backupRepository = backupRepository;
+ _backupRoutines = backupRoutines;
_personStockFacade = personStockFacade;
}
@@ -55,6 +63,8 @@ namespace StockInfo
btnRestoreShares.Enabled = false;
btnBackupShares.Enabled = false;
btnReloadShares.Enabled = false;
+ btnRestoreAll.Enabled = false;
+ btnBackupAll.Enabled = false;
}
private void ReloadData()
@@ -135,11 +145,15 @@ namespace StockInfo
{
btnRestoreShares.Enabled = true;
btnBackupShares.Enabled = true;
+ btnBackupAll.Enabled = true;
+ btnRestoreAll.Enabled = true;
}
else
{
btnRestoreShares.Enabled = false;
btnBackupShares.Enabled = false;
+ btnBackupAll.Enabled = false;
+ btnRestoreAll.Enabled = false;
}
}
@@ -235,5 +249,11 @@ namespace StockInfo
{
SelectedPersonId = ((ComboboxItem)cmbOwners.SelectedItem).HiddenValue;
}
+
+ private void btnBackupAll_Click(object sender, EventArgs e)
+ {
+ backupWindow = new frmBackup(_backupRepository,_backupRoutines);
+ backupWindow.ShowDialog();
+ }
}
}
diff --git a/StockInfo/Stocks.db-shm b/X_Backup/Stocks.db
similarity index 79%
rename from StockInfo/Stocks.db-shm
rename to X_Backup/Stocks.db
index fe9ac28..31da3e8 100644
Binary files a/StockInfo/Stocks.db-shm and b/X_Backup/Stocks.db differ