From a56a97031aa78b2f16d89b74f401843bd06d087e Mon Sep 17 00:00:00 2001 From: Bobbie Hodgetts Date: Sat, 11 May 2024 09:46:47 +0100 Subject: [PATCH] wip --- .../Account/PurchaseInvoiceLineSummary.cs | 2 +- .../Model/Credentials/bnhtradeDB.cs | 17 ++- src/bnhtrade.gui/Form1.Designer.cs | 140 ++++++++++-------- src/bnhtrade.gui/Form1.cs | 36 ++++- 4 files changed, 128 insertions(+), 67 deletions(-) diff --git a/src/bnhtrade.Core/Data/Database/Account/PurchaseInvoiceLineSummary.cs b/src/bnhtrade.Core/Data/Database/Account/PurchaseInvoiceLineSummary.cs index 4c17f9b..1b4e20f 100644 --- a/src/bnhtrade.Core/Data/Database/Account/PurchaseInvoiceLineSummary.cs +++ b/src/bnhtrade.Core/Data/Database/Account/PurchaseInvoiceLineSummary.cs @@ -54,7 +54,7 @@ namespace bnhtrade.Core.Data.Database.Account using (SqlCommand cmd = new SqlCommand(sql, conn)) { cmd.Parameters.AddWithValue("@purchaseDate", periodTo); - if (descriptionSearch.Any()) + if (lineStatus != null) { cmd.Parameters.AddWithValue("@purchaseLineStatus", lineStatus); } diff --git a/src/bnhtrade.Core/Model/Credentials/bnhtradeDB.cs b/src/bnhtrade.Core/Model/Credentials/bnhtradeDB.cs index 2155c85..6071447 100644 --- a/src/bnhtrade.Core/Model/Credentials/bnhtradeDB.cs +++ b/src/bnhtrade.Core/Model/Credentials/bnhtradeDB.cs @@ -9,24 +9,35 @@ namespace bnhtrade.Core.Model.Credentials public class bnhtradeDB { public string DataSource { get; private set; } + public string UserId { get; private set; } + public string UserPassword { get; private set; } + public string InitialCatalog { get; private set; } = "e2A"; + public bool PersistSecurityInfo { get; private set; } = true; + public bool MultipleActiveResultSets { get; private set; } = true; + + public uint ConnectionTimeout { get; private set; } + public string ConnectionString - { get + { + get { return "Data Source=" + DataSource + ";Initial Catalog=" + InitialCatalog + ";Persist Security Info=" + PersistSecurityInfo.ToString() - + ";User ID=" + UserId + ";Password=" + UserPassword + ";MultipleActiveResultSets=" + MultipleActiveResultSets.ToString(); + + ";User ID=" + UserId + ";Password=" + UserPassword + ";MultipleActiveResultSets=" + MultipleActiveResultSets.ToString() + + ";Connect Timeout=" + ConnectionTimeout; } } - public bnhtradeDB (string source, string userId, string userPassword) + public bnhtradeDB (string source, string userId, string userPassword, uint connectionTimeout = 30) { this.DataSource = source; this.UserId = userId; this.UserPassword = userPassword; + this.ConnectionTimeout = connectionTimeout; } } } diff --git a/src/bnhtrade.gui/Form1.Designer.cs b/src/bnhtrade.gui/Form1.Designer.cs index f18f498..1ad7482 100644 --- a/src/bnhtrade.gui/Form1.Designer.cs +++ b/src/bnhtrade.gui/Form1.Designer.cs @@ -33,7 +33,14 @@ tabPage1 = new TabPage(); tabPage2 = new TabPage(); Receiving = new TabPage(); + labelDataGridCount = new Label(); dataGridView1 = new DataGridView(); + purchaseNumberDataGridViewTextBoxColumn = new DataGridViewTextBoxColumn(); + purchaseDateDataGridViewTextBoxColumn = new DataGridViewTextBoxColumn(); + itemDescriptionDataGridViewTextBoxColumn = new DataGridViewTextBoxColumn(); + purchaseLineIdDataGridViewTextBoxColumn = new DataGridViewTextBoxColumn(); + lineStatusDataGridViewTextBoxColumn = new DataGridViewTextBoxColumn(); + purchaseIdDataGridViewTextBoxColumn = new DataGridViewTextBoxColumn(); bindingSource1 = new BindingSource(components); buttonSearch = new Button(); comboBox1 = new ComboBox(); @@ -41,12 +48,6 @@ dateTimeOrderSearch = new DateTimePicker(); label1 = new Label(); textboxOrderSearch = new TextBox(); - purchaseNumberDataGridViewTextBoxColumn = new DataGridViewTextBoxColumn(); - purchaseDateDataGridViewTextBoxColumn = new DataGridViewTextBoxColumn(); - itemDescriptionDataGridViewTextBoxColumn = new DataGridViewTextBoxColumn(); - purchaseLineIdDataGridViewTextBoxColumn = new DataGridViewTextBoxColumn(); - lineStatusDataGridViewTextBoxColumn = new DataGridViewTextBoxColumn(); - purchaseIdDataGridViewTextBoxColumn = new DataGridViewTextBoxColumn(); tabControl1.SuspendLayout(); Receiving.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit(); @@ -90,6 +91,7 @@ // // Receiving // + Receiving.Controls.Add(labelDataGridCount); Receiving.Controls.Add(dataGridView1); Receiving.Controls.Add(buttonSearch); Receiving.Controls.Add(comboBox1); @@ -105,71 +107,30 @@ Receiving.UseVisualStyleBackColor = true; Receiving.Click += tabPage3_Click; // + // labelDataGridCount + // + labelDataGridCount.Anchor = AnchorStyles.Right; + labelDataGridCount.ImageAlign = ContentAlignment.MiddleRight; + labelDataGridCount.Location = new Point(845, 70); + labelDataGridCount.Name = "labelDataGridCount"; + labelDataGridCount.RightToLeft = RightToLeft.Yes; + labelDataGridCount.Size = new Size(129, 21); + labelDataGridCount.TabIndex = 6; + labelDataGridCount.Text = "labelListCount"; + labelDataGridCount.TextAlign = ContentAlignment.MiddleLeft; + // // dataGridView1 // + dataGridView1.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; dataGridView1.AutoGenerateColumns = false; dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; dataGridView1.Columns.AddRange(new DataGridViewColumn[] { purchaseNumberDataGridViewTextBoxColumn, purchaseDateDataGridViewTextBoxColumn, itemDescriptionDataGridViewTextBoxColumn, purchaseLineIdDataGridViewTextBoxColumn, lineStatusDataGridViewTextBoxColumn, purchaseIdDataGridViewTextBoxColumn }); dataGridView1.DataSource = bindingSource1; dataGridView1.Location = new Point(31, 94); dataGridView1.Name = "dataGridView1"; - dataGridView1.Size = new Size(925, 396); + dataGridView1.Size = new Size(943, 396); dataGridView1.TabIndex = 5; // - // bindingSource1 - // - bindingSource1.DataSource = typeof(Core.Model.Account.PurchaseInvoiceLineSummary); - // - // buttonSearch - // - buttonSearch.Location = new Point(847, 46); - buttonSearch.Name = "buttonSearch"; - buttonSearch.Size = new Size(109, 25); - buttonSearch.TabIndex = 4; - buttonSearch.Text = "Search"; - buttonSearch.UseVisualStyleBackColor = true; - buttonSearch.Click += buttonSearch_Click; - // - // comboBox1 - // - comboBox1.DataSource = purchaseLineStatusBindingSource; - comboBox1.DisplayMember = "PurchaseLineStatusName"; - comboBox1.FormattingEnabled = true; - comboBox1.Location = new Point(195, 46); - comboBox1.Name = "comboBox1"; - comboBox1.Size = new Size(189, 23); - comboBox1.TabIndex = 3; - comboBox1.ValueMember = "PurchaseLineStatusId"; - comboBox1.SelectedIndexChanged += comboBox1_SelectedIndexChanged; - // - // purchaseLineStatusBindingSource - // - purchaseLineStatusBindingSource.DataSource = typeof(Core.Model.Purchase.PurchaseLineStatus); - purchaseLineStatusBindingSource.CurrentChanged += purchaseLineStatusBindingSource_CurrentChanged; - // - // dateTimeOrderSearch - // - dateTimeOrderSearch.Location = new Point(31, 46); - dateTimeOrderSearch.Name = "dateTimeOrderSearch"; - dateTimeOrderSearch.Size = new Size(131, 23); - dateTimeOrderSearch.TabIndex = 2; - // - // label1 - // - label1.AutoSize = true; - label1.Location = new Point(31, 28); - label1.Name = "label1"; - label1.Size = new Size(75, 15); - label1.TabIndex = 1; - label1.Text = "Order Search"; - // - // textboxOrderSearch - // - textboxOrderSearch.Location = new Point(417, 46); - textboxOrderSearch.Name = "textboxOrderSearch"; - textboxOrderSearch.Size = new Size(415, 23); - textboxOrderSearch.TabIndex = 0; - // // purchaseNumberDataGridViewTextBoxColumn // purchaseNumberDataGridViewTextBoxColumn.DataPropertyName = "PurchaseNumber"; @@ -207,6 +168,62 @@ purchaseIdDataGridViewTextBoxColumn.HeaderText = "PurchaseId"; purchaseIdDataGridViewTextBoxColumn.Name = "purchaseIdDataGridViewTextBoxColumn"; // + // bindingSource1 + // + bindingSource1.DataSource = typeof(Core.Model.Account.PurchaseInvoiceLineSummary); + // + // buttonSearch + // + buttonSearch.Location = new Point(865, 37); + buttonSearch.Name = "buttonSearch"; + buttonSearch.Size = new Size(109, 25); + buttonSearch.TabIndex = 4; + buttonSearch.Text = "Search"; + buttonSearch.UseVisualStyleBackColor = true; + buttonSearch.Click += buttonSearch_Click; + // + // comboBox1 + // + comboBox1.DataSource = purchaseLineStatusBindingSource; + comboBox1.DisplayMember = "PurchaseLineStatusName"; + comboBox1.FormattingEnabled = true; + comboBox1.Location = new Point(195, 39); + comboBox1.Name = "comboBox1"; + comboBox1.Size = new Size(189, 23); + comboBox1.TabIndex = 3; + comboBox1.ValueMember = "PurchaseLineStatusId"; + comboBox1.SelectedIndexChanged += comboBox1_SelectedIndexChanged; + // + // purchaseLineStatusBindingSource + // + purchaseLineStatusBindingSource.DataSource = typeof(Core.Model.Purchase.PurchaseLineStatus); + purchaseLineStatusBindingSource.CurrentChanged += purchaseLineStatusBindingSource_CurrentChanged; + // + // dateTimeOrderSearch + // + dateTimeOrderSearch.Location = new Point(31, 39); + dateTimeOrderSearch.Name = "dateTimeOrderSearch"; + dateTimeOrderSearch.Size = new Size(131, 23); + dateTimeOrderSearch.TabIndex = 2; + dateTimeOrderSearch.ValueChanged += dateTimeOrderSearch_ValueChanged; + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(31, 21); + label1.Name = "label1"; + label1.Size = new Size(75, 15); + label1.TabIndex = 1; + label1.Text = "Order Search"; + // + // textboxOrderSearch + // + textboxOrderSearch.Location = new Point(417, 39); + textboxOrderSearch.Name = "textboxOrderSearch"; + textboxOrderSearch.Size = new Size(415, 23); + textboxOrderSearch.TabIndex = 0; + textboxOrderSearch.KeyPress += textboxOrderSearch_KeyPress; + // // Form1 // AutoScaleDimensions = new SizeF(7F, 15F); @@ -245,5 +262,6 @@ private DataGridViewTextBoxColumn purchaseLineIdDataGridViewTextBoxColumn; private DataGridViewTextBoxColumn lineStatusDataGridViewTextBoxColumn; private DataGridViewTextBoxColumn purchaseIdDataGridViewTextBoxColumn; + private Label labelDataGridCount; } } diff --git a/src/bnhtrade.gui/Form1.cs b/src/bnhtrade.gui/Form1.cs index 2bb0e5b..201889c 100644 --- a/src/bnhtrade.gui/Form1.cs +++ b/src/bnhtrade.gui/Form1.cs @@ -33,14 +33,18 @@ namespace bnhtrade.gui private void InitialiseTabReceiving() { + Cursor.Current = Cursors.WaitCursor; purchaseLineStatusBindingSource.DataSource = new Core.Logic.Account.PurchaseInvoice().ReadLineStatusToList(); comboBox1.SelectedIndex = 3; + ListBoxQuery(); initTabReceiving = true; + Cursor.Current = Cursors.Default; } private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { - + ListBoxQuery(); + textboxOrderSearch.Select(); } private void purchaseLineStatusBindingSource_CurrentChanged(object sender, EventArgs e) @@ -49,19 +53,47 @@ namespace bnhtrade.gui } private void buttonSearch_Click(object sender, EventArgs e) + { + ListBoxQuery(); + } + + private void textboxOrderSearch_KeyPress(object sender, KeyPressEventArgs e) + { + if (e.KeyChar == Convert.ToChar(Keys.Enter)) + { + ListBoxQuery(); + e.Handled = true; + } + } + + private void ListBoxQuery() { char[] separator = { ' ' }; var searchList = textboxOrderSearch.Text.Split(separator).ToList(); + string comboBox = null; + if (comboBox1.Text != "All") + { + comboBox = comboBox1.Text; + } + bindingSource1.DataSource = new Core.Logic.Account.PurchaseInvoice().GetLineSummary( dateTimeOrderSearch.Value - , comboBox1.Text + , comboBox , searchList); + + labelDataGridCount.Text = bindingSource1.Count.ToString(); } private void bindingSource1_CurrentChanged(object sender, EventArgs e) { } + + private void dateTimeOrderSearch_ValueChanged(object sender, EventArgs e) + { + ListBoxQuery(); + textboxOrderSearch.Select(); + } } }