BacupFunctionality

This commit is contained in:
2021-03-17 08:33:02 +01:00
parent 0d8f884544
commit 154f8cc07a
21 changed files with 674 additions and 9 deletions

View File

@ -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; }
}
}

View File

@ -0,0 +1,174 @@
// <auto-generated />
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<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Destination")
.HasColumnType("TEXT");
b.Property<string>("Nation")
.HasColumnType("TEXT");
b.Property<string>("Street")
.HasColumnType("TEXT");
b.Property<string>("Street2")
.HasColumnType("TEXT");
b.Property<int>("Zipcode")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.ToTable("Addresses");
});
modelBuilder.Entity("DataDomain.BackupRegister", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateTime>("BackedUp")
.HasColumnType("TEXT");
b.Property<string>("BackupDbName")
.HasColumnType("TEXT");
b.Property<string>("BackupPath")
.HasColumnType("TEXT");
b.Property<string>("DbName")
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("BackupRegings");
});
modelBuilder.Entity("DataDomain.Person", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<long>("AccountNo")
.HasColumnType("INTEGER");
b.Property<string>("Born")
.HasColumnType("TEXT");
b.Property<int>("ClearingNo")
.HasColumnType("INTEGER");
b.Property<string>("Comments")
.HasColumnType("TEXT");
b.Property<string>("FirstName")
.HasColumnType("TEXT");
b.Property<int>("HomeAddress")
.HasColumnType("INTEGER");
b.Property<int>("InvoiceAddress")
.HasColumnType("INTEGER");
b.Property<string>("LastName")
.HasColumnType("TEXT");
b.Property<string>("NickName")
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Persons");
});
modelBuilder.Entity("DataDomain.PersonStock", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Comment")
.HasColumnType("TEXT");
b.Property<int>("PersonId")
.HasColumnType("INTEGER");
b.Property<int>("StockId")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.ToTable("PersonStocks");
});
modelBuilder.Entity("DataDomain.StockMember", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<long>("ActAmount")
.HasColumnType("INTEGER");
b.Property<DateTime?>("ActDate")
.HasColumnType("TEXT");
b.Property<decimal>("ActValue")
.HasColumnType("TEXT");
b.Property<DateTime>("BuyDate")
.HasColumnType("TEXT");
b.Property<decimal>("BuyValue")
.HasColumnType("TEXT");
b.Property<string>("Comment")
.HasColumnType("TEXT");
b.Property<long>("PostAmount")
.HasColumnType("INTEGER");
b.Property<DateTime?>("SoldDate")
.HasColumnType("TEXT");
b.Property<decimal?>("SoldValue")
.HasColumnType("TEXT");
b.Property<string>("StockExtId")
.HasColumnType("TEXT");
b.Property<string>("StockId")
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Stocks");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -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<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
BackedUp = table.Column<DateTime>(type: "TEXT", nullable: false),
DbName = table.Column<string>(type: "TEXT", nullable: true),
BackupDbName = table.Column<string>(type: "TEXT", nullable: true),
BackupPath = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_BackupRegings", x => x.Id);
});
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "BackupRegings");
}
}
}

View File

@ -42,6 +42,29 @@ namespace DatamodelLibrary.Migrations
b.ToTable("Addresses");
});
modelBuilder.Entity("DataDomain.BackupRegister", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateTime>("BackedUp")
.HasColumnType("TEXT");
b.Property<string>("BackupDbName")
.HasColumnType("TEXT");
b.Property<string>("BackupPath")
.HasColumnType("TEXT");
b.Property<string>("DbName")
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("BackupRegings");
});
modelBuilder.Entity("DataDomain.Person", b =>
{
b.Property<int>("Id")

View File

@ -14,6 +14,7 @@ namespace DatamodelLibrary
public DbSet<Person> Persons { get; set; }
public DbSet<Address> Addresses { get; set; }
public DbSet<PersonStock> PersonStocks { get; set; }
public DbSet<BackupRegister> BackupRegings { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder options)
=> options.UseSqlite("Data Source=Stocks.db");

View File

@ -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);
}
}
}

View File

@ -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);
}
}

View File

@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Data.SQLite" Version="1.0.113.7" />
</ItemGroup>
</Project>

View File

@ -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<BackupRegister> GetAllBackupRegisters()
{
using var context = new StockContext();
var entities = context.BackupRegings;
return entities.ToList();
}
}
}

View File

@ -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

View File

@ -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<BackupRegister> GetAllBackupRegisters();
BackupRegister SaveBackupReging(BackupRegister backupRegister);
}
}

View File

@ -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<IPersonRepository>(),
Container.Resolve<IAddressRepository>(),
Container.Resolve<IStockPersonConnect>(),
Container.Resolve<IBackupRepository>(),
Container.Resolve<IBackupRoutines>(),
Container.Resolve<IPersonStockFacade>()
));
}
@ -44,6 +48,8 @@ namespace StockInfo
builder.RegisterType<PersonRepository>().As<IPersonRepository>();
builder.RegisterType<AddressRepository>().As<IAddressRepository>();
builder.RegisterType<StockPersonConnect>().As<IStockPersonConnect>();
builder.RegisterType<BackupRepository>().As<IBackupRepository>();
builder.RegisterType<BackupRoutines>().As<IBackupRoutines>();
builder.RegisterType<PersonStockFacade>().As<IPersonStockFacade>();
builder.RegisterType<frmInitial>();
return builder.Build();

View File

@ -26,6 +26,7 @@
<ItemGroup>
<ProjectReference Include="..\DataDomain\DataDomain.csproj" />
<ProjectReference Include="..\Helpers\Helpers.csproj" />
<ProjectReference Include="..\SqliteBackups\SqliteBackups.csproj" />
<ProjectReference Include="..\StockBL.Interface\StockBL.Interface.csproj" />
<ProjectReference Include="..\StockBL\StockBL.csproj" />
<ProjectReference Include="..\StockDal.Interface\StockDAL.Interface.csproj" />
@ -52,7 +53,14 @@
<ItemGroup>
<None Update="Stocks.db">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<None Include="bin\Debug\net5.0-windows\Stocks.db">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</None>
</ItemGroup>

Binary file not shown.

127
StockInfo/frmBackup.Designer.cs generated Normal file
View File

@ -0,0 +1,127 @@

namespace StockInfo
{
partial class frmBackup
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
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;
}
}

54
StockInfo/frmBackup.cs Normal file
View File

@ -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);
};
}
}
}

60
StockInfo/frmBackup.resx Normal file
View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -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;
}
}

View File

@ -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();
}
}
}