pull master into branch

* Migrated projects to dotnet8

migrated all projects over to .net8
incomplete feature for gui shipments

* Amazon inventory ledger testing and implementation

Tested what I can until more data for the Amazon Ledger Detail table comes in

* amazon settlement amounts now set to tax inclusive when exporting to invoice

* Some updates to the COM lib to attempt to get it to work on .net 8. Unfinished, porting all Access functions over to vs instead

* feature exchange rate update automation

Automated downloading exchange rates from HMRC and updating the database. Added function call to the console and form applications.

Also added a form to show the console output in form application.
This commit is contained in:
Bobbie Hodgetts
2025-06-09 21:23:42 +01:00
committed by GitHub
parent a0c669f1d4
commit 30174290cf
41 changed files with 1370 additions and 415 deletions

72
src/bnhtrade.gui/FormConsole.Designer.cs generated Normal file
View File

@@ -0,0 +1,72 @@
namespace bnhtrade.gui
{
partial class FormConsole
{
/// <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()
{
button1 = new Button();
txtConsole = new TextBox();
SuspendLayout();
//
// button1
//
button1.Location = new Point(610, 389);
button1.Name = "button1";
button1.Size = new Size(152, 49);
button1.TabIndex = 2;
button1.Text = "Close";
button1.UseVisualStyleBackColor = true;
button1.Click += button1_Click;
//
// txtConsole
//
txtConsole.Location = new Point(53, 41);
txtConsole.Multiline = true;
txtConsole.Name = "txtConsole";
txtConsole.Size = new Size(709, 337);
txtConsole.TabIndex = 3;
//
// FormConsole
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(txtConsole);
Controls.Add(button1);
Name = "FormConsole";
Text = "Form1";
Load += FormConsole_Load;
ResumeLayout(false);
PerformLayout();
}
#endregion
private Button button1;
private TextBox txtConsole;
}
}

View File

@@ -0,0 +1,44 @@
using ConsoleRedirection;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace bnhtrade.gui
{
public partial class FormConsole : Form
{
// That's our custom TextWriter class
TextWriter _writer = null;
public FormConsole()
{
InitializeComponent();
}
private void FormConsole_Load(object sender, EventArgs e)
{
// Instantiate the writer
_writer = new TextBoxStreamWriter(txtConsole);
// Redirect the out Console stream
Console.SetOut(_writer);
}
// This is called when the "Say Hello" button is clicked
private void txtSayHello_Click(object sender, EventArgs e)
{
// Writing to the Console now causes the text to be displayed in the text box.
Console.WriteLine("Hello world");
}
private void button1_Click(object sender, EventArgs e)
{
this.Close();
}
}
}

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<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

@@ -48,11 +48,14 @@
dateTimeOrderSearch = new DateTimePicker();
label1 = new Label();
textboxOrderSearch = new TextBox();
tabAccounts = new TabPage();
btnExchangeRate = new Button();
tabControl1.SuspendLayout();
Receiving.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
((System.ComponentModel.ISupportInitialize)bsReceivingLines).BeginInit();
((System.ComponentModel.ISupportInitialize)purchaseLineStatusBindingSource).BeginInit();
tabAccounts.SuspendLayout();
SuspendLayout();
//
// tabControl1
@@ -61,19 +64,22 @@
tabControl1.Controls.Add(tabPage1);
tabControl1.Controls.Add(tabPage2);
tabControl1.Controls.Add(Receiving);
tabControl1.Location = new Point(12, 12);
tabControl1.Controls.Add(tabAccounts);
tabControl1.Location = new Point(14, 16);
tabControl1.Margin = new Padding(3, 4, 3, 4);
tabControl1.Name = "tabControl1";
tabControl1.SelectedIndex = 0;
tabControl1.Size = new Size(1022, 533);
tabControl1.Size = new Size(1168, 711);
tabControl1.TabIndex = 0;
tabControl1.SelectedIndexChanged += tabControl1_SelectedIndexChanged;
//
// tabPage1
//
tabPage1.Location = new Point(4, 24);
tabPage1.Location = new Point(4, 29);
tabPage1.Margin = new Padding(3, 4, 3, 4);
tabPage1.Name = "tabPage1";
tabPage1.Padding = new Padding(3);
tabPage1.Size = new Size(1014, 505);
tabPage1.Padding = new Padding(3, 4, 3, 4);
tabPage1.Size = new Size(1160, 678);
tabPage1.TabIndex = 0;
tabPage1.Text = "Home";
tabPage1.UseVisualStyleBackColor = true;
@@ -81,10 +87,11 @@
// tabPage2
//
tabPage2.AccessibleName = "";
tabPage2.Location = new Point(4, 24);
tabPage2.Location = new Point(4, 29);
tabPage2.Margin = new Padding(3, 4, 3, 4);
tabPage2.Name = "tabPage2";
tabPage2.Padding = new Padding(3);
tabPage2.Size = new Size(1014, 505);
tabPage2.Padding = new Padding(3, 4, 3, 4);
tabPage2.Size = new Size(1160, 678);
tabPage2.TabIndex = 1;
tabPage2.Text = "FBA Shipments";
tabPage2.UseVisualStyleBackColor = true;
@@ -98,10 +105,11 @@
Receiving.Controls.Add(dateTimeOrderSearch);
Receiving.Controls.Add(label1);
Receiving.Controls.Add(textboxOrderSearch);
Receiving.Location = new Point(4, 24);
Receiving.Location = new Point(4, 29);
Receiving.Margin = new Padding(3, 4, 3, 4);
Receiving.Name = "Receiving";
Receiving.Padding = new Padding(3);
Receiving.Size = new Size(1014, 505);
Receiving.Padding = new Padding(3, 4, 3, 4);
Receiving.Size = new Size(1160, 678);
Receiving.TabIndex = 2;
Receiving.Text = "Receiving";
Receiving.UseVisualStyleBackColor = true;
@@ -111,10 +119,10 @@
//
labelDataGridCount.Anchor = AnchorStyles.Right;
labelDataGridCount.ImageAlign = ContentAlignment.MiddleRight;
labelDataGridCount.Location = new Point(857, 70);
labelDataGridCount.Location = new Point(979, 93);
labelDataGridCount.Name = "labelDataGridCount";
labelDataGridCount.RightToLeft = RightToLeft.Yes;
labelDataGridCount.Size = new Size(129, 21);
labelDataGridCount.Size = new Size(147, 28);
labelDataGridCount.TabIndex = 6;
labelDataGridCount.Text = "labelListCount";
labelDataGridCount.TextAlign = ContentAlignment.MiddleLeft;
@@ -126,11 +134,13 @@
dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView1.Columns.AddRange(new DataGridViewColumn[] { purchaseNumberDataGridViewTextBoxColumn, purchaseDateDataGridViewTextBoxColumn, itemDescriptionDataGridViewTextBoxColumn, purchaseLineIdDataGridViewTextBoxColumn, lineStatusDataGridViewTextBoxColumn, purchaseIdDataGridViewTextBoxColumn });
dataGridView1.DataSource = bsReceivingLines;
dataGridView1.Location = new Point(31, 94);
dataGridView1.Location = new Point(35, 125);
dataGridView1.Margin = new Padding(3, 4, 3, 4);
dataGridView1.MultiSelect = false;
dataGridView1.Name = "dataGridView1";
dataGridView1.RowHeadersWidth = 51;
dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView1.Size = new Size(955, 396);
dataGridView1.Size = new Size(1091, 528);
dataGridView1.TabIndex = 5;
dataGridView1.DoubleClick += dataGridView1_DoubleClick;
//
@@ -138,18 +148,23 @@
//
purchaseNumberDataGridViewTextBoxColumn.DataPropertyName = "PurchaseNumber";
purchaseNumberDataGridViewTextBoxColumn.HeaderText = "PurchaseNumber";
purchaseNumberDataGridViewTextBoxColumn.MinimumWidth = 6;
purchaseNumberDataGridViewTextBoxColumn.Name = "purchaseNumberDataGridViewTextBoxColumn";
purchaseNumberDataGridViewTextBoxColumn.Width = 125;
//
// purchaseDateDataGridViewTextBoxColumn
//
purchaseDateDataGridViewTextBoxColumn.DataPropertyName = "PurchaseDate";
purchaseDateDataGridViewTextBoxColumn.HeaderText = "PurchaseDate";
purchaseDateDataGridViewTextBoxColumn.MinimumWidth = 6;
purchaseDateDataGridViewTextBoxColumn.Name = "purchaseDateDataGridViewTextBoxColumn";
purchaseDateDataGridViewTextBoxColumn.Width = 125;
//
// itemDescriptionDataGridViewTextBoxColumn
//
itemDescriptionDataGridViewTextBoxColumn.DataPropertyName = "ItemDescription";
itemDescriptionDataGridViewTextBoxColumn.HeaderText = "ItemDescription";
itemDescriptionDataGridViewTextBoxColumn.MinimumWidth = 6;
itemDescriptionDataGridViewTextBoxColumn.Name = "itemDescriptionDataGridViewTextBoxColumn";
itemDescriptionDataGridViewTextBoxColumn.Width = 500;
//
@@ -157,19 +172,25 @@
//
purchaseLineIdDataGridViewTextBoxColumn.DataPropertyName = "PurchaseLineId";
purchaseLineIdDataGridViewTextBoxColumn.HeaderText = "PurchaseLineId";
purchaseLineIdDataGridViewTextBoxColumn.MinimumWidth = 6;
purchaseLineIdDataGridViewTextBoxColumn.Name = "purchaseLineIdDataGridViewTextBoxColumn";
purchaseLineIdDataGridViewTextBoxColumn.Width = 125;
//
// lineStatusDataGridViewTextBoxColumn
//
lineStatusDataGridViewTextBoxColumn.DataPropertyName = "LineStatus";
lineStatusDataGridViewTextBoxColumn.HeaderText = "LineStatus";
lineStatusDataGridViewTextBoxColumn.MinimumWidth = 6;
lineStatusDataGridViewTextBoxColumn.Name = "lineStatusDataGridViewTextBoxColumn";
lineStatusDataGridViewTextBoxColumn.Width = 125;
//
// purchaseIdDataGridViewTextBoxColumn
//
purchaseIdDataGridViewTextBoxColumn.DataPropertyName = "PurchaseId";
purchaseIdDataGridViewTextBoxColumn.HeaderText = "PurchaseId";
purchaseIdDataGridViewTextBoxColumn.MinimumWidth = 6;
purchaseIdDataGridViewTextBoxColumn.Name = "purchaseIdDataGridViewTextBoxColumn";
purchaseIdDataGridViewTextBoxColumn.Width = 125;
//
// bsReceivingLines
//
@@ -177,9 +198,10 @@
//
// buttonSearch
//
buttonSearch.Location = new Point(865, 37);
buttonSearch.Location = new Point(989, 49);
buttonSearch.Margin = new Padding(3, 4, 3, 4);
buttonSearch.Name = "buttonSearch";
buttonSearch.Size = new Size(109, 25);
buttonSearch.Size = new Size(125, 33);
buttonSearch.TabIndex = 4;
buttonSearch.Text = "Search";
buttonSearch.UseVisualStyleBackColor = true;
@@ -190,9 +212,10 @@
comboBox1.DataSource = purchaseLineStatusBindingSource;
comboBox1.DisplayMember = "PurchaseLineStatusName";
comboBox1.FormattingEnabled = true;
comboBox1.Location = new Point(195, 39);
comboBox1.Location = new Point(223, 52);
comboBox1.Margin = new Padding(3, 4, 3, 4);
comboBox1.Name = "comboBox1";
comboBox1.Size = new Size(189, 23);
comboBox1.Size = new Size(215, 28);
comboBox1.TabIndex = 3;
comboBox1.ValueMember = "PurchaseLineStatusId";
comboBox1.SelectedIndexChanged += comboBox1_SelectedIndexChanged;
@@ -204,35 +227,59 @@
//
// dateTimeOrderSearch
//
dateTimeOrderSearch.Location = new Point(31, 39);
dateTimeOrderSearch.Location = new Point(35, 52);
dateTimeOrderSearch.Margin = new Padding(3, 4, 3, 4);
dateTimeOrderSearch.Name = "dateTimeOrderSearch";
dateTimeOrderSearch.Size = new Size(131, 23);
dateTimeOrderSearch.Size = new Size(149, 27);
dateTimeOrderSearch.TabIndex = 2;
dateTimeOrderSearch.ValueChanged += dateTimeOrderSearch_ValueChanged;
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(31, 21);
label1.Location = new Point(35, 28);
label1.Name = "label1";
label1.Size = new Size(75, 15);
label1.Size = new Size(95, 20);
label1.TabIndex = 1;
label1.Text = "Order Search";
//
// textboxOrderSearch
//
textboxOrderSearch.Location = new Point(417, 39);
textboxOrderSearch.Location = new Point(477, 52);
textboxOrderSearch.Margin = new Padding(3, 4, 3, 4);
textboxOrderSearch.Name = "textboxOrderSearch";
textboxOrderSearch.Size = new Size(415, 23);
textboxOrderSearch.Size = new Size(474, 27);
textboxOrderSearch.TabIndex = 0;
textboxOrderSearch.KeyPress += textboxOrderSearch_KeyPress;
//
// tabAccounts
//
tabAccounts.Controls.Add(btnExchangeRate);
tabAccounts.Location = new Point(4, 29);
tabAccounts.Name = "tabAccounts";
tabAccounts.Padding = new Padding(3);
tabAccounts.Size = new Size(1160, 678);
tabAccounts.TabIndex = 3;
tabAccounts.Text = "Accounts";
tabAccounts.UseVisualStyleBackColor = true;
//
// btnExchangeRate
//
btnExchangeRate.Location = new Point(48, 50);
btnExchangeRate.Name = "btnExchangeRate";
btnExchangeRate.Size = new Size(237, 50);
btnExchangeRate.TabIndex = 0;
btnExchangeRate.Text = "Update exchange rates";
btnExchangeRate.UseVisualStyleBackColor = true;
btnExchangeRate.Click += btnExchangeRate_Click;
//
// Home
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1046, 557);
ClientSize = new Size(1195, 743);
Controls.Add(tabControl1);
Margin = new Padding(3, 4, 3, 4);
Name = "Home";
Text = "Form1";
Load += Form1_Load;
@@ -242,6 +289,7 @@
((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
((System.ComponentModel.ISupportInitialize)bsReceivingLines).EndInit();
((System.ComponentModel.ISupportInitialize)purchaseLineStatusBindingSource).EndInit();
tabAccounts.ResumeLayout(false);
ResumeLayout(false);
}
@@ -266,5 +314,7 @@
private DataGridViewTextBoxColumn lineStatusDataGridViewTextBoxColumn;
private DataGridViewTextBoxColumn purchaseIdDataGridViewTextBoxColumn;
private Label labelDataGridCount;
private TabPage tabAccounts;
private Button btnExchangeRate;
}
}

View File

@@ -110,5 +110,12 @@ namespace bnhtrade.gui
var form = new PurchaseInvoice(purchaseInvoice);
form.Show();
}
private void btnExchangeRate_Click(object sender, EventArgs e)
{
var myForm = new FormConsole();
myForm.Show();
new bnhtrade.Core.Logic.Account.Currency().UpdateHmrcExchageRates();
}
}
}

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Microsoft ResX Schema
Version 2.0
@@ -48,7 +48,7 @@
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter

View File

@@ -0,0 +1,28 @@
using System;
using System.Text;
using System.IO;
using System.Windows.Forms;
namespace ConsoleRedirection
{
public class TextBoxStreamWriter : TextWriter
{
TextBox _output = null;
public TextBoxStreamWriter(TextBox output)
{
_output = output;
}
public override void Write(char value)
{
base.Write(value);
_output.AppendText(value.ToString()); // When character data is written, append it to the text box.
}
public override Encoding Encoding
{
get { return System.Text.Encoding.UTF8; }
}
}
}