This commit is contained in:
Bobbie Hodgetts
2024-05-11 09:46:47 +01:00
parent 960579b0b2
commit a56a97031a
4 changed files with 128 additions and 67 deletions

View File

@@ -54,7 +54,7 @@ namespace bnhtrade.Core.Data.Database.Account
using (SqlCommand cmd = new SqlCommand(sql, conn)) using (SqlCommand cmd = new SqlCommand(sql, conn))
{ {
cmd.Parameters.AddWithValue("@purchaseDate", periodTo); cmd.Parameters.AddWithValue("@purchaseDate", periodTo);
if (descriptionSearch.Any()) if (lineStatus != null)
{ {
cmd.Parameters.AddWithValue("@purchaseLineStatus", lineStatus); cmd.Parameters.AddWithValue("@purchaseLineStatus", lineStatus);
} }

View File

@@ -9,24 +9,35 @@ namespace bnhtrade.Core.Model.Credentials
public class bnhtradeDB public class bnhtradeDB
{ {
public string DataSource { get; private set; } public string DataSource { get; private set; }
public string UserId { get; private set; } public string UserId { get; private set; }
public string UserPassword { get; private set; } public string UserPassword { get; private set; }
public string InitialCatalog { get; private set; } = "e2A"; public string InitialCatalog { get; private set; } = "e2A";
public bool PersistSecurityInfo { get; private set; } = true; public bool PersistSecurityInfo { get; private set; } = true;
public bool MultipleActiveResultSets { get; private set; } = true; public bool MultipleActiveResultSets { get; private set; } = true;
public uint ConnectionTimeout { get; private set; }
public string ConnectionString public string ConnectionString
{ get {
get
{ {
return "Data Source=" + DataSource + ";Initial Catalog=" + InitialCatalog + ";Persist Security Info=" + PersistSecurityInfo.ToString() 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.DataSource = source;
this.UserId = userId; this.UserId = userId;
this.UserPassword = userPassword; this.UserPassword = userPassword;
this.ConnectionTimeout = connectionTimeout;
} }
} }
} }

View File

@@ -33,7 +33,14 @@
tabPage1 = new TabPage(); tabPage1 = new TabPage();
tabPage2 = new TabPage(); tabPage2 = new TabPage();
Receiving = new TabPage(); Receiving = new TabPage();
labelDataGridCount = new Label();
dataGridView1 = new DataGridView(); 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); bindingSource1 = new BindingSource(components);
buttonSearch = new Button(); buttonSearch = new Button();
comboBox1 = new ComboBox(); comboBox1 = new ComboBox();
@@ -41,12 +48,6 @@
dateTimeOrderSearch = new DateTimePicker(); dateTimeOrderSearch = new DateTimePicker();
label1 = new Label(); label1 = new Label();
textboxOrderSearch = new TextBox(); textboxOrderSearch = new TextBox();
purchaseNumberDataGridViewTextBoxColumn = new DataGridViewTextBoxColumn();
purchaseDateDataGridViewTextBoxColumn = new DataGridViewTextBoxColumn();
itemDescriptionDataGridViewTextBoxColumn = new DataGridViewTextBoxColumn();
purchaseLineIdDataGridViewTextBoxColumn = new DataGridViewTextBoxColumn();
lineStatusDataGridViewTextBoxColumn = new DataGridViewTextBoxColumn();
purchaseIdDataGridViewTextBoxColumn = new DataGridViewTextBoxColumn();
tabControl1.SuspendLayout(); tabControl1.SuspendLayout();
Receiving.SuspendLayout(); Receiving.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit(); ((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
@@ -90,6 +91,7 @@
// //
// Receiving // Receiving
// //
Receiving.Controls.Add(labelDataGridCount);
Receiving.Controls.Add(dataGridView1); Receiving.Controls.Add(dataGridView1);
Receiving.Controls.Add(buttonSearch); Receiving.Controls.Add(buttonSearch);
Receiving.Controls.Add(comboBox1); Receiving.Controls.Add(comboBox1);
@@ -105,71 +107,30 @@
Receiving.UseVisualStyleBackColor = true; Receiving.UseVisualStyleBackColor = true;
Receiving.Click += tabPage3_Click; 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
// //
dataGridView1.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
dataGridView1.AutoGenerateColumns = false; dataGridView1.AutoGenerateColumns = false;
dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView1.Columns.AddRange(new DataGridViewColumn[] { purchaseNumberDataGridViewTextBoxColumn, purchaseDateDataGridViewTextBoxColumn, itemDescriptionDataGridViewTextBoxColumn, purchaseLineIdDataGridViewTextBoxColumn, lineStatusDataGridViewTextBoxColumn, purchaseIdDataGridViewTextBoxColumn }); dataGridView1.Columns.AddRange(new DataGridViewColumn[] { purchaseNumberDataGridViewTextBoxColumn, purchaseDateDataGridViewTextBoxColumn, itemDescriptionDataGridViewTextBoxColumn, purchaseLineIdDataGridViewTextBoxColumn, lineStatusDataGridViewTextBoxColumn, purchaseIdDataGridViewTextBoxColumn });
dataGridView1.DataSource = bindingSource1; dataGridView1.DataSource = bindingSource1;
dataGridView1.Location = new Point(31, 94); dataGridView1.Location = new Point(31, 94);
dataGridView1.Name = "dataGridView1"; dataGridView1.Name = "dataGridView1";
dataGridView1.Size = new Size(925, 396); dataGridView1.Size = new Size(943, 396);
dataGridView1.TabIndex = 5; 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
// //
purchaseNumberDataGridViewTextBoxColumn.DataPropertyName = "PurchaseNumber"; purchaseNumberDataGridViewTextBoxColumn.DataPropertyName = "PurchaseNumber";
@@ -207,6 +168,62 @@
purchaseIdDataGridViewTextBoxColumn.HeaderText = "PurchaseId"; purchaseIdDataGridViewTextBoxColumn.HeaderText = "PurchaseId";
purchaseIdDataGridViewTextBoxColumn.Name = "purchaseIdDataGridViewTextBoxColumn"; 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 // Form1
// //
AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleDimensions = new SizeF(7F, 15F);
@@ -245,5 +262,6 @@
private DataGridViewTextBoxColumn purchaseLineIdDataGridViewTextBoxColumn; private DataGridViewTextBoxColumn purchaseLineIdDataGridViewTextBoxColumn;
private DataGridViewTextBoxColumn lineStatusDataGridViewTextBoxColumn; private DataGridViewTextBoxColumn lineStatusDataGridViewTextBoxColumn;
private DataGridViewTextBoxColumn purchaseIdDataGridViewTextBoxColumn; private DataGridViewTextBoxColumn purchaseIdDataGridViewTextBoxColumn;
private Label labelDataGridCount;
} }
} }

View File

@@ -33,14 +33,18 @@ namespace bnhtrade.gui
private void InitialiseTabReceiving() private void InitialiseTabReceiving()
{ {
Cursor.Current = Cursors.WaitCursor;
purchaseLineStatusBindingSource.DataSource = new Core.Logic.Account.PurchaseInvoice().ReadLineStatusToList(); purchaseLineStatusBindingSource.DataSource = new Core.Logic.Account.PurchaseInvoice().ReadLineStatusToList();
comboBox1.SelectedIndex = 3; comboBox1.SelectedIndex = 3;
ListBoxQuery();
initTabReceiving = true; initTabReceiving = true;
Cursor.Current = Cursors.Default;
} }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{ {
ListBoxQuery();
textboxOrderSearch.Select();
} }
private void purchaseLineStatusBindingSource_CurrentChanged(object sender, EventArgs e) private void purchaseLineStatusBindingSource_CurrentChanged(object sender, EventArgs e)
@@ -49,19 +53,47 @@ namespace bnhtrade.gui
} }
private void buttonSearch_Click(object sender, EventArgs e) 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 = { ' ' }; char[] separator = { ' ' };
var searchList = textboxOrderSearch.Text.Split(separator).ToList(); 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( bindingSource1.DataSource = new Core.Logic.Account.PurchaseInvoice().GetLineSummary(
dateTimeOrderSearch.Value dateTimeOrderSearch.Value
, comboBox1.Text , comboBox
, searchList); , searchList);
labelDataGridCount.Text = bindingSource1.Count.ToString();
} }
private void bindingSource1_CurrentChanged(object sender, EventArgs e) private void bindingSource1_CurrentChanged(object sender, EventArgs e)
{ {
} }
private void dateTimeOrderSearch_ValueChanged(object sender, EventArgs e)
{
ListBoxQuery();
textboxOrderSearch.Select();
}
} }
} }