diff --git a/BealeEngineering/BealeEngineering.Accounts/BealeEngineering.Accounts.csproj b/BealeEngineering/BealeEngineering.Accounts/BealeEngineering.Accounts.csproj index 216656d..de7cfe7 100644 --- a/BealeEngineering/BealeEngineering.Accounts/BealeEngineering.Accounts.csproj +++ b/BealeEngineering/BealeEngineering.Accounts/BealeEngineering.Accounts.csproj @@ -12,6 +12,22 @@ 512 true true + false + C:\Users\Bobbie\Desktop\jjjjjjjjjjjjjjjjjjjjjj\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 1 + 1.0.0.%2a + false + true + true AnyCPU @@ -32,6 +48,18 @@ prompt 4 + + 2380E7895746C9FBBC0797D8269D9B8D56612ECE + + + BealeEngineering.Accounts_TemporaryKey.pfx + + + true + + + true + @@ -52,6 +80,12 @@ True BealeEngDataSet.xsd + + Form + + + frmClientPurchaseOrder.cs + Form @@ -60,6 +94,9 @@ + + frmClientPurchaseOrder.cs + Form1.cs @@ -83,6 +120,9 @@ BealeEngDataSet.xsd + + + @@ -104,5 +144,17 @@ BealeEngineering.Core + + + False + Microsoft .NET Framework 4.7.2 %28x86 and x64%29 + true + + + False + .NET Framework 3.5 SP1 + false + + \ No newline at end of file diff --git a/BealeEngineering/BealeEngineering.Accounts/Form1.Designer.cs b/BealeEngineering/BealeEngineering.Accounts/Form1.Designer.cs index 4009c3a..42b2634 100644 --- a/BealeEngineering/BealeEngineering.Accounts/Form1.Designer.cs +++ b/BealeEngineering/BealeEngineering.Accounts/Form1.Designer.cs @@ -29,42 +29,39 @@ private void InitializeComponent() { this.components = new System.ComponentModel.Container(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); this.tabControl1 = new System.Windows.Forms.TabControl(); this.tabPage1 = new System.Windows.Forms.TabPage(); this.splitContainer3 = new System.Windows.Forms.SplitContainer(); - this.button2 = new System.Windows.Forms.Button(); + this.btnAutoMatch = new System.Windows.Forms.Button(); + this.btnOpenPurchaseOrder = new System.Windows.Forms.Button(); + this.btnAddPurchaseOrder = new System.Windows.Forms.Button(); this.button1 = new System.Windows.Forms.Button(); this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.textBox1 = new System.Windows.Forms.TextBox(); this.txtUnallocatedCount = new System.Windows.Forms.TextBox(); this.dataGridView1 = new System.Windows.Forms.DataGridView(); + this.purchaseOrderAllocationBindingSource = new System.Windows.Forms.BindingSource(this.components); this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.importToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.xeroInvoiceToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.testToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.testItToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.exportToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.xeroInvoiceToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); - this.contactNameDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.projectTitleDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.purchaseOrderDateDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.purchaseOrderReferenceDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.purchaseOrderLineNumberDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.purchaseOrderLineDescriptionDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.purchaseOrderLineNetAmountDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.jobNumberDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.invoicedAmountDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.purchaseOrderLineFacilityDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.purchaseOrderIsClosedDataGridViewCheckBoxColumn = new System.Windows.Forms.DataGridViewCheckBoxColumn(); - this.jobTitleDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.jobDescriptionDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.purchaseOrderAllocationBindingSource = new System.Windows.Forms.BindingSource(this.components); + this.testToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.testItToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.ContactName = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.ProjectTitle = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.PurchaseOrderDate = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.PurchaseOrderReference = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.PurchaseOrderLineNumber = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.PurchaseOrderLineDescription = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.PurchaseOrderLineNetAmount = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.InvoicedAmount = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.PurchaseOrderLineFacility = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.JobNumber = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.PurchaseOrderIsClosed = new System.Windows.Forms.DataGridViewCheckBoxColumn(); + this.PurchaseOrderLineID = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.tabControl1.SuspendLayout(); this.tabPage1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer3)).BeginInit(); @@ -72,8 +69,8 @@ this.splitContainer3.Panel2.SuspendLayout(); this.splitContainer3.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); - this.menuStrip1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.purchaseOrderAllocationBindingSource)).BeginInit(); + this.menuStrip1.SuspendLayout(); this.SuspendLayout(); // // tabControl1 @@ -106,7 +103,9 @@ // // splitContainer3.Panel1 // - this.splitContainer3.Panel1.Controls.Add(this.button2); + this.splitContainer3.Panel1.Controls.Add(this.btnAutoMatch); + this.splitContainer3.Panel1.Controls.Add(this.btnOpenPurchaseOrder); + this.splitContainer3.Panel1.Controls.Add(this.btnAddPurchaseOrder); this.splitContainer3.Panel1.Controls.Add(this.button1); this.splitContainer3.Panel1.Controls.Add(this.label1); this.splitContainer3.Panel1.Controls.Add(this.label2); @@ -121,15 +120,37 @@ this.splitContainer3.SplitterDistance = 93; this.splitContainer3.TabIndex = 0; // - // button2 + // btnAutoMatch // - this.button2.Location = new System.Drawing.Point(197, 56); - this.button2.Name = "button2"; - this.button2.Size = new System.Drawing.Size(76, 20); - this.button2.TabIndex = 9; - this.button2.Text = "Refresh"; - this.button2.UseVisualStyleBackColor = true; - this.button2.Click += new System.EventHandler(this.button2_Click); + this.btnAutoMatch.Location = new System.Drawing.Point(198, 56); + this.btnAutoMatch.Name = "btnAutoMatch"; + this.btnAutoMatch.Size = new System.Drawing.Size(75, 20); + this.btnAutoMatch.TabIndex = 10; + this.btnAutoMatch.Text = "Auto Match"; + this.btnAutoMatch.UseVisualStyleBackColor = true; + this.btnAutoMatch.Click += new System.EventHandler(this.btnAutoMatch_Click); + // + // btnOpenPurchaseOrder + // + this.btnOpenPurchaseOrder.Anchor = System.Windows.Forms.AnchorStyles.Right; + this.btnOpenPurchaseOrder.Location = new System.Drawing.Point(521, 55); + this.btnOpenPurchaseOrder.Name = "btnOpenPurchaseOrder"; + this.btnOpenPurchaseOrder.Size = new System.Drawing.Size(160, 20); + this.btnOpenPurchaseOrder.TabIndex = 11; + this.btnOpenPurchaseOrder.Text = "Open Purchase Order"; + this.btnOpenPurchaseOrder.UseVisualStyleBackColor = true; + this.btnOpenPurchaseOrder.Click += new System.EventHandler(this.btnOpenPurchaseOrder_Click); + // + // btnAddPurchaseOrder + // + this.btnAddPurchaseOrder.Anchor = System.Windows.Forms.AnchorStyles.Right; + this.btnAddPurchaseOrder.Location = new System.Drawing.Point(325, 56); + this.btnAddPurchaseOrder.Name = "btnAddPurchaseOrder"; + this.btnAddPurchaseOrder.Size = new System.Drawing.Size(160, 20); + this.btnAddPurchaseOrder.TabIndex = 10; + this.btnAddPurchaseOrder.Text = "Add Purchase Order"; + this.btnAddPurchaseOrder.UseVisualStyleBackColor = true; + this.btnAddPurchaseOrder.Click += new System.EventHandler(this.btnAddPurchaseOrder_Click); // // button1 // @@ -187,19 +208,18 @@ this.dataGridView1.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.None; this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { - this.contactNameDataGridViewTextBoxColumn, - this.projectTitleDataGridViewTextBoxColumn, - this.purchaseOrderDateDataGridViewTextBoxColumn, - this.purchaseOrderReferenceDataGridViewTextBoxColumn, - this.purchaseOrderLineNumberDataGridViewTextBoxColumn, - this.purchaseOrderLineDescriptionDataGridViewTextBoxColumn, - this.purchaseOrderLineNetAmountDataGridViewTextBoxColumn, - this.jobNumberDataGridViewTextBoxColumn, - this.invoicedAmountDataGridViewTextBoxColumn, - this.purchaseOrderLineFacilityDataGridViewTextBoxColumn, - this.purchaseOrderIsClosedDataGridViewCheckBoxColumn, - this.jobTitleDataGridViewTextBoxColumn, - this.jobDescriptionDataGridViewTextBoxColumn}); + this.ContactName, + this.ProjectTitle, + this.PurchaseOrderDate, + this.PurchaseOrderReference, + this.PurchaseOrderLineNumber, + this.PurchaseOrderLineDescription, + this.PurchaseOrderLineNetAmount, + this.InvoicedAmount, + this.PurchaseOrderLineFacility, + this.JobNumber, + this.PurchaseOrderIsClosed, + this.PurchaseOrderLineID}); this.dataGridView1.DataSource = this.purchaseOrderAllocationBindingSource; this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill; this.dataGridView1.Location = new System.Drawing.Point(0, 0); @@ -212,6 +232,11 @@ this.dataGridView1.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellContentClick); this.dataGridView1.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellDoubleClick); // + // purchaseOrderAllocationBindingSource + // + this.purchaseOrderAllocationBindingSource.AllowNew = false; + this.purchaseOrderAllocationBindingSource.DataSource = typeof(BealeEngineering.Core.Model.Client.PurchaseOrderAllocation); + // // menuStrip1 // this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -246,6 +271,21 @@ this.xeroInvoiceToolStripMenuItem.Text = "Xero Invoice"; this.xeroInvoiceToolStripMenuItem.Click += new System.EventHandler(this.xeroInvoiceToolStripMenuItem_Click); // + // exportToolStripMenuItem + // + this.exportToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.xeroInvoiceToolStripMenuItem1}); + this.exportToolStripMenuItem.Name = "exportToolStripMenuItem"; + this.exportToolStripMenuItem.Size = new System.Drawing.Size(53, 20); + this.exportToolStripMenuItem.Text = "Export"; + // + // xeroInvoiceToolStripMenuItem1 + // + this.xeroInvoiceToolStripMenuItem1.Name = "xeroInvoiceToolStripMenuItem1"; + this.xeroInvoiceToolStripMenuItem1.Size = new System.Drawing.Size(139, 22); + this.xeroInvoiceToolStripMenuItem1.Text = "Xero Invoice"; + this.xeroInvoiceToolStripMenuItem1.Click += new System.EventHandler(this.xeroInvoiceToolStripMenuItem1_Click); + // // testToolStripMenuItem // this.testToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -261,167 +301,124 @@ this.testItToolStripMenuItem.Text = "Test it!"; this.testItToolStripMenuItem.Click += new System.EventHandler(this.testItToolStripMenuItem_Click); // - // exportToolStripMenuItem + // ContactName // - this.exportToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.xeroInvoiceToolStripMenuItem1}); - this.exportToolStripMenuItem.Name = "exportToolStripMenuItem"; - this.exportToolStripMenuItem.Size = new System.Drawing.Size(53, 20); - this.exportToolStripMenuItem.Text = "Export"; + this.ContactName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.ContactName.DataPropertyName = "ContactName"; + this.ContactName.FillWeight = 150F; + this.ContactName.HeaderText = "Client"; + this.ContactName.MinimumWidth = 100; + this.ContactName.Name = "ContactName"; + this.ContactName.ReadOnly = true; // - // xeroInvoiceToolStripMenuItem1 + // ProjectTitle // - this.xeroInvoiceToolStripMenuItem1.Name = "xeroInvoiceToolStripMenuItem1"; - this.xeroInvoiceToolStripMenuItem1.Size = new System.Drawing.Size(180, 22); - this.xeroInvoiceToolStripMenuItem1.Text = "Xero Invoice"; - this.xeroInvoiceToolStripMenuItem1.Click += new System.EventHandler(this.xeroInvoiceToolStripMenuItem1_Click); + this.ProjectTitle.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.ProjectTitle.DataPropertyName = "ProjectTitle"; + this.ProjectTitle.FillWeight = 200F; + this.ProjectTitle.HeaderText = "Project"; + this.ProjectTitle.MinimumWidth = 100; + this.ProjectTitle.Name = "ProjectTitle"; + this.ProjectTitle.ReadOnly = true; // - // contactNameDataGridViewTextBoxColumn + // PurchaseOrderDate // - this.contactNameDataGridViewTextBoxColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; - this.contactNameDataGridViewTextBoxColumn.DataPropertyName = "ContactName"; - this.contactNameDataGridViewTextBoxColumn.FillWeight = 150F; - this.contactNameDataGridViewTextBoxColumn.HeaderText = "Client"; - this.contactNameDataGridViewTextBoxColumn.Name = "contactNameDataGridViewTextBoxColumn"; - this.contactNameDataGridViewTextBoxColumn.ReadOnly = true; + this.PurchaseOrderDate.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.PurchaseOrderDate.DataPropertyName = "PurchaseOrderDate"; + this.PurchaseOrderDate.FillWeight = 30.59646F; + this.PurchaseOrderDate.HeaderText = "PO Date"; + this.PurchaseOrderDate.MinimumWidth = 80; + this.PurchaseOrderDate.Name = "PurchaseOrderDate"; + this.PurchaseOrderDate.ReadOnly = true; // - // projectTitleDataGridViewTextBoxColumn + // PurchaseOrderReference // - this.projectTitleDataGridViewTextBoxColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; - this.projectTitleDataGridViewTextBoxColumn.DataPropertyName = "ProjectTitle"; - this.projectTitleDataGridViewTextBoxColumn.FillWeight = 200F; - this.projectTitleDataGridViewTextBoxColumn.HeaderText = "Project"; - this.projectTitleDataGridViewTextBoxColumn.Name = "projectTitleDataGridViewTextBoxColumn"; - this.projectTitleDataGridViewTextBoxColumn.ReadOnly = true; + this.PurchaseOrderReference.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.PurchaseOrderReference.DataPropertyName = "PurchaseOrderReference"; + this.PurchaseOrderReference.FillWeight = 30.59646F; + this.PurchaseOrderReference.HeaderText = "PO Number"; + this.PurchaseOrderReference.MinimumWidth = 100; + this.PurchaseOrderReference.Name = "PurchaseOrderReference"; + this.PurchaseOrderReference.ReadOnly = true; // - // purchaseOrderDateDataGridViewTextBoxColumn + // PurchaseOrderLineNumber // - this.purchaseOrderDateDataGridViewTextBoxColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; - this.purchaseOrderDateDataGridViewTextBoxColumn.DataPropertyName = "PurchaseOrderDate"; - this.purchaseOrderDateDataGridViewTextBoxColumn.FillWeight = 30.59646F; - this.purchaseOrderDateDataGridViewTextBoxColumn.HeaderText = "PO Date"; - this.purchaseOrderDateDataGridViewTextBoxColumn.MinimumWidth = 80; - this.purchaseOrderDateDataGridViewTextBoxColumn.Name = "purchaseOrderDateDataGridViewTextBoxColumn"; - this.purchaseOrderDateDataGridViewTextBoxColumn.ReadOnly = true; + this.PurchaseOrderLineNumber.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.PurchaseOrderLineNumber.DataPropertyName = "PurchaseOrderLineNumber"; + this.PurchaseOrderLineNumber.FillWeight = 30.59646F; + this.PurchaseOrderLineNumber.HeaderText = "Line No"; + this.PurchaseOrderLineNumber.MinimumWidth = 50; + this.PurchaseOrderLineNumber.Name = "PurchaseOrderLineNumber"; + this.PurchaseOrderLineNumber.ReadOnly = true; // - // purchaseOrderReferenceDataGridViewTextBoxColumn + // PurchaseOrderLineDescription // - this.purchaseOrderReferenceDataGridViewTextBoxColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; - this.purchaseOrderReferenceDataGridViewTextBoxColumn.DataPropertyName = "PurchaseOrderReference"; - this.purchaseOrderReferenceDataGridViewTextBoxColumn.FillWeight = 30.59646F; - this.purchaseOrderReferenceDataGridViewTextBoxColumn.HeaderText = "PO Number"; - this.purchaseOrderReferenceDataGridViewTextBoxColumn.MinimumWidth = 100; - this.purchaseOrderReferenceDataGridViewTextBoxColumn.Name = "purchaseOrderReferenceDataGridViewTextBoxColumn"; - this.purchaseOrderReferenceDataGridViewTextBoxColumn.ReadOnly = true; + this.PurchaseOrderLineDescription.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.PurchaseOrderLineDescription.DataPropertyName = "PurchaseOrderLineDescription"; + this.PurchaseOrderLineDescription.FillWeight = 300F; + this.PurchaseOrderLineDescription.HeaderText = "Description"; + this.PurchaseOrderLineDescription.MinimumWidth = 242; + this.PurchaseOrderLineDescription.Name = "PurchaseOrderLineDescription"; + this.PurchaseOrderLineDescription.ReadOnly = true; // - // purchaseOrderLineNumberDataGridViewTextBoxColumn + // PurchaseOrderLineNetAmount // - this.purchaseOrderLineNumberDataGridViewTextBoxColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; - this.purchaseOrderLineNumberDataGridViewTextBoxColumn.DataPropertyName = "PurchaseOrderLineNumber"; - this.purchaseOrderLineNumberDataGridViewTextBoxColumn.FillWeight = 30.59646F; - this.purchaseOrderLineNumberDataGridViewTextBoxColumn.HeaderText = "Line No."; - this.purchaseOrderLineNumberDataGridViewTextBoxColumn.MinimumWidth = 50; - this.purchaseOrderLineNumberDataGridViewTextBoxColumn.Name = "purchaseOrderLineNumberDataGridViewTextBoxColumn"; - this.purchaseOrderLineNumberDataGridViewTextBoxColumn.ReadOnly = true; + this.PurchaseOrderLineNetAmount.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.PurchaseOrderLineNetAmount.DataPropertyName = "PurchaseOrderLineNetAmount"; + this.PurchaseOrderLineNetAmount.FillWeight = 50F; + this.PurchaseOrderLineNetAmount.HeaderText = "Line Amount"; + this.PurchaseOrderLineNetAmount.MinimumWidth = 80; + this.PurchaseOrderLineNetAmount.Name = "PurchaseOrderLineNetAmount"; + this.PurchaseOrderLineNetAmount.ReadOnly = true; // - // purchaseOrderLineDescriptionDataGridViewTextBoxColumn + // InvoicedAmount // - this.purchaseOrderLineDescriptionDataGridViewTextBoxColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; - this.purchaseOrderLineDescriptionDataGridViewTextBoxColumn.DataPropertyName = "PurchaseOrderLineDescription"; - this.purchaseOrderLineDescriptionDataGridViewTextBoxColumn.FillWeight = 300F; - this.purchaseOrderLineDescriptionDataGridViewTextBoxColumn.HeaderText = "Description"; - this.purchaseOrderLineDescriptionDataGridViewTextBoxColumn.Name = "purchaseOrderLineDescriptionDataGridViewTextBoxColumn"; - this.purchaseOrderLineDescriptionDataGridViewTextBoxColumn.ReadOnly = true; + this.InvoicedAmount.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.InvoicedAmount.DataPropertyName = "InvoicedAmount"; + this.InvoicedAmount.FillWeight = 50F; + this.InvoicedAmount.HeaderText = "Invoiced"; + this.InvoicedAmount.MinimumWidth = 80; + this.InvoicedAmount.Name = "InvoicedAmount"; + this.InvoicedAmount.ReadOnly = true; // - // purchaseOrderLineNetAmountDataGridViewTextBoxColumn + // PurchaseOrderLineFacility // - this.purchaseOrderLineNetAmountDataGridViewTextBoxColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; - this.purchaseOrderLineNetAmountDataGridViewTextBoxColumn.DataPropertyName = "PurchaseOrderLineNetAmount"; - dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight; - dataGridViewCellStyle1.Format = "C2"; - dataGridViewCellStyle1.NullValue = null; - this.purchaseOrderLineNetAmountDataGridViewTextBoxColumn.DefaultCellStyle = dataGridViewCellStyle1; - this.purchaseOrderLineNetAmountDataGridViewTextBoxColumn.FillWeight = 50F; - this.purchaseOrderLineNetAmountDataGridViewTextBoxColumn.HeaderText = "Line Amount"; - this.purchaseOrderLineNetAmountDataGridViewTextBoxColumn.MinimumWidth = 80; - this.purchaseOrderLineNetAmountDataGridViewTextBoxColumn.Name = "purchaseOrderLineNetAmountDataGridViewTextBoxColumn"; - this.purchaseOrderLineNetAmountDataGridViewTextBoxColumn.ReadOnly = true; + this.PurchaseOrderLineFacility.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.PurchaseOrderLineFacility.DataPropertyName = "PurchaseOrderLineFacility"; + this.PurchaseOrderLineFacility.FillWeight = 50F; + this.PurchaseOrderLineFacility.HeaderText = "Facility"; + this.PurchaseOrderLineFacility.MinimumWidth = 80; + this.PurchaseOrderLineFacility.Name = "PurchaseOrderLineFacility"; + this.PurchaseOrderLineFacility.ReadOnly = true; // - // jobNumberDataGridViewTextBoxColumn + // JobNumber // - this.jobNumberDataGridViewTextBoxColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; - this.jobNumberDataGridViewTextBoxColumn.DataPropertyName = "JobNumber"; - dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight; - dataGridViewCellStyle2.Format = "C2"; - dataGridViewCellStyle2.NullValue = null; - this.jobNumberDataGridViewTextBoxColumn.DefaultCellStyle = dataGridViewCellStyle2; - this.jobNumberDataGridViewTextBoxColumn.FillWeight = 30.59646F; - this.jobNumberDataGridViewTextBoxColumn.HeaderText = "Job Number"; - this.jobNumberDataGridViewTextBoxColumn.MinimumWidth = 80; - this.jobNumberDataGridViewTextBoxColumn.Name = "jobNumberDataGridViewTextBoxColumn"; - this.jobNumberDataGridViewTextBoxColumn.ReadOnly = true; + this.JobNumber.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.JobNumber.DataPropertyName = "JobNumber"; + this.JobNumber.FillWeight = 30.59646F; + this.JobNumber.HeaderText = "Job Number"; + this.JobNumber.MinimumWidth = 80; + this.JobNumber.Name = "JobNumber"; + this.JobNumber.ReadOnly = true; // - // invoicedAmountDataGridViewTextBoxColumn + // PurchaseOrderIsClosed // - this.invoicedAmountDataGridViewTextBoxColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; - this.invoicedAmountDataGridViewTextBoxColumn.DataPropertyName = "InvoicedAmount"; - dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight; - dataGridViewCellStyle3.Format = "C2"; - dataGridViewCellStyle3.NullValue = null; - this.invoicedAmountDataGridViewTextBoxColumn.DefaultCellStyle = dataGridViewCellStyle3; - this.invoicedAmountDataGridViewTextBoxColumn.FillWeight = 50F; - this.invoicedAmountDataGridViewTextBoxColumn.HeaderText = "Invoiced"; - this.invoicedAmountDataGridViewTextBoxColumn.MinimumWidth = 80; - this.invoicedAmountDataGridViewTextBoxColumn.Name = "invoicedAmountDataGridViewTextBoxColumn"; - this.invoicedAmountDataGridViewTextBoxColumn.ReadOnly = true; + this.PurchaseOrderIsClosed.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; + this.PurchaseOrderIsClosed.DataPropertyName = "PurchaseOrderIsClosed"; + this.PurchaseOrderIsClosed.FillWeight = 30.59646F; + this.PurchaseOrderIsClosed.HeaderText = "Archived"; + this.PurchaseOrderIsClosed.MinimumWidth = 50; + this.PurchaseOrderIsClosed.Name = "PurchaseOrderIsClosed"; + this.PurchaseOrderIsClosed.ReadOnly = true; + this.PurchaseOrderIsClosed.Width = 60; // - // purchaseOrderLineFacilityDataGridViewTextBoxColumn + // PurchaseOrderLineID // - this.purchaseOrderLineFacilityDataGridViewTextBoxColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; - this.purchaseOrderLineFacilityDataGridViewTextBoxColumn.DataPropertyName = "PurchaseOrderLineFacility"; - dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight; - dataGridViewCellStyle4.Format = "C2"; - dataGridViewCellStyle4.NullValue = null; - this.purchaseOrderLineFacilityDataGridViewTextBoxColumn.DefaultCellStyle = dataGridViewCellStyle4; - this.purchaseOrderLineFacilityDataGridViewTextBoxColumn.FillWeight = 50F; - this.purchaseOrderLineFacilityDataGridViewTextBoxColumn.HeaderText = "Facility"; - this.purchaseOrderLineFacilityDataGridViewTextBoxColumn.MinimumWidth = 80; - this.purchaseOrderLineFacilityDataGridViewTextBoxColumn.Name = "purchaseOrderLineFacilityDataGridViewTextBoxColumn"; - this.purchaseOrderLineFacilityDataGridViewTextBoxColumn.ReadOnly = true; - // - // purchaseOrderIsClosedDataGridViewCheckBoxColumn - // - this.purchaseOrderIsClosedDataGridViewCheckBoxColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; - this.purchaseOrderIsClosedDataGridViewCheckBoxColumn.DataPropertyName = "PurchaseOrderIsClosed"; - this.purchaseOrderIsClosedDataGridViewCheckBoxColumn.FillWeight = 30.59646F; - this.purchaseOrderIsClosedDataGridViewCheckBoxColumn.HeaderText = "Archived"; - this.purchaseOrderIsClosedDataGridViewCheckBoxColumn.MinimumWidth = 50; - this.purchaseOrderIsClosedDataGridViewCheckBoxColumn.Name = "purchaseOrderIsClosedDataGridViewCheckBoxColumn"; - this.purchaseOrderIsClosedDataGridViewCheckBoxColumn.ReadOnly = true; - this.purchaseOrderIsClosedDataGridViewCheckBoxColumn.Width = 60; - // - // jobTitleDataGridViewTextBoxColumn - // - this.jobTitleDataGridViewTextBoxColumn.DataPropertyName = "JobTitle"; - this.jobTitleDataGridViewTextBoxColumn.HeaderText = "JobTitle"; - this.jobTitleDataGridViewTextBoxColumn.Name = "jobTitleDataGridViewTextBoxColumn"; - this.jobTitleDataGridViewTextBoxColumn.ReadOnly = true; - this.jobTitleDataGridViewTextBoxColumn.Visible = false; - // - // jobDescriptionDataGridViewTextBoxColumn - // - this.jobDescriptionDataGridViewTextBoxColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; - this.jobDescriptionDataGridViewTextBoxColumn.DataPropertyName = "JobDescription"; - this.jobDescriptionDataGridViewTextBoxColumn.FillWeight = 300F; - this.jobDescriptionDataGridViewTextBoxColumn.HeaderText = "Description"; - this.jobDescriptionDataGridViewTextBoxColumn.Name = "jobDescriptionDataGridViewTextBoxColumn"; - this.jobDescriptionDataGridViewTextBoxColumn.ReadOnly = true; - this.jobDescriptionDataGridViewTextBoxColumn.Visible = false; - // - // purchaseOrderAllocationBindingSource - // - this.purchaseOrderAllocationBindingSource.AllowNew = false; - this.purchaseOrderAllocationBindingSource.DataSource = typeof(BealeEngineering.Core.Model.Client.PurchaseOrderAllocation); + this.PurchaseOrderLineID.DataPropertyName = "PurchaseOrderLineID"; + this.PurchaseOrderLineID.HeaderText = "PurchaseOrderLineID"; + this.PurchaseOrderLineID.Name = "PurchaseOrderLineID"; + this.PurchaseOrderLineID.ReadOnly = true; + this.PurchaseOrderLineID.Visible = false; // // Form1 // @@ -442,9 +439,9 @@ ((System.ComponentModel.ISupportInitialize)(this.splitContainer3)).EndInit(); this.splitContainer3.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.purchaseOrderAllocationBindingSource)).EndInit(); this.menuStrip1.ResumeLayout(false); this.menuStrip1.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.purchaseOrderAllocationBindingSource)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -455,7 +452,6 @@ private System.Windows.Forms.TabControl tabControl1; private System.Windows.Forms.TabPage tabPage1; private System.Windows.Forms.SplitContainer splitContainer3; - private System.Windows.Forms.Button button2; private System.Windows.Forms.Button button1; private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label2; @@ -468,21 +464,23 @@ private System.Windows.Forms.ToolStripMenuItem xeroInvoiceToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem testToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem testItToolStripMenuItem; - private System.Windows.Forms.DataGridViewTextBoxColumn contactNameDataGridViewTextBoxColumn; - private System.Windows.Forms.DataGridViewTextBoxColumn projectTitleDataGridViewTextBoxColumn; - private System.Windows.Forms.DataGridViewTextBoxColumn purchaseOrderDateDataGridViewTextBoxColumn; - private System.Windows.Forms.DataGridViewTextBoxColumn purchaseOrderReferenceDataGridViewTextBoxColumn; - private System.Windows.Forms.DataGridViewTextBoxColumn purchaseOrderLineNumberDataGridViewTextBoxColumn; - private System.Windows.Forms.DataGridViewTextBoxColumn purchaseOrderLineDescriptionDataGridViewTextBoxColumn; - private System.Windows.Forms.DataGridViewTextBoxColumn purchaseOrderLineNetAmountDataGridViewTextBoxColumn; - private System.Windows.Forms.DataGridViewTextBoxColumn jobNumberDataGridViewTextBoxColumn; - private System.Windows.Forms.DataGridViewTextBoxColumn invoicedAmountDataGridViewTextBoxColumn; - private System.Windows.Forms.DataGridViewTextBoxColumn purchaseOrderLineFacilityDataGridViewTextBoxColumn; - private System.Windows.Forms.DataGridViewCheckBoxColumn purchaseOrderIsClosedDataGridViewCheckBoxColumn; - private System.Windows.Forms.DataGridViewTextBoxColumn jobTitleDataGridViewTextBoxColumn; - private System.Windows.Forms.DataGridViewTextBoxColumn jobDescriptionDataGridViewTextBoxColumn; private System.Windows.Forms.ToolStripMenuItem exportToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem xeroInvoiceToolStripMenuItem1; + private System.Windows.Forms.Button btnAutoMatch; + private System.Windows.Forms.Button btnAddPurchaseOrder; + private System.Windows.Forms.Button btnOpenPurchaseOrder; + private System.Windows.Forms.DataGridViewTextBoxColumn ContactName; + private System.Windows.Forms.DataGridViewTextBoxColumn ProjectTitle; + private System.Windows.Forms.DataGridViewTextBoxColumn PurchaseOrderDate; + private System.Windows.Forms.DataGridViewTextBoxColumn PurchaseOrderReference; + private System.Windows.Forms.DataGridViewTextBoxColumn PurchaseOrderLineNumber; + private System.Windows.Forms.DataGridViewTextBoxColumn PurchaseOrderLineDescription; + private System.Windows.Forms.DataGridViewTextBoxColumn PurchaseOrderLineNetAmount; + private System.Windows.Forms.DataGridViewTextBoxColumn InvoicedAmount; + private System.Windows.Forms.DataGridViewTextBoxColumn PurchaseOrderLineFacility; + private System.Windows.Forms.DataGridViewTextBoxColumn JobNumber; + private System.Windows.Forms.DataGridViewCheckBoxColumn PurchaseOrderIsClosed; + private System.Windows.Forms.DataGridViewTextBoxColumn PurchaseOrderLineID; } } diff --git a/BealeEngineering/BealeEngineering.Accounts/Form1.cs b/BealeEngineering/BealeEngineering.Accounts/Form1.cs index f8239c7..b2b2437 100644 --- a/BealeEngineering/BealeEngineering.Accounts/Form1.cs +++ b/BealeEngineering/BealeEngineering.Accounts/Form1.cs @@ -27,7 +27,6 @@ namespace BealeEngineering.Accounts private void Form1_Load(object sender, EventArgs e) { UpdateTable(); - button2_Click(null, null); } private void button1_Click(object sender, EventArgs e) @@ -37,23 +36,40 @@ namespace BealeEngineering.Accounts private void UpdateTable() { + // update text box + var dataRead = new Core.Data.Database.Client.ReadSaleInvoiceAllocation(sqlConnectionString); + txtUnallocatedCount.Text = dataRead.GetUnallocatedInvoiceCount().ToString(); + var readData = new Core.Data.Database.Client.ReadPurchaseOrderAllocation(sqlConnectionString); var data = readData.Read(); - //dataGridView1.Rows.AddRange() - purchaseOrderAllocationBindingSource.DataSource = data; - //dataGridView1.DataSource = data; + purchaseOrderAllocationBindingSource.DataSource = data.OrderBy(x => x.JobNumber).ThenBy(x => x.PurchaseOrderDate); + + //purchaseOrderAllocationBindingSource.DataSource = data; + + //sort order + //dataGridView1.Sort(dataGridView1.Columns["purchaseOrderDate"], ListSortDirection.Ascending); + //dataGridView1.Sort(dataGridView1.Columns["jobNumber"], ListSortDirection.Ascending); // high light over invoiced lines + int facilityIndex = dataGridView1.Columns["PurchaseOrderLineFacility"].Index; + int lineAmountIndex = dataGridView1.Columns["PurchaseOrderLineNetAmount"].Index; for (var i = 0; i < dataGridView1.Rows.Count; i++) { - decimal facility = (decimal)dataGridView1[9, i].Value; + decimal facility = (decimal)dataGridView1[facilityIndex, i].Value; + decimal lineAmount = (decimal)dataGridView1[lineAmountIndex, i].Value; if (facility == 0) { // code to grey out line dataGridView1.Rows[i].DefaultCellStyle.ForeColor = Color.Gray; dataGridView1.Rows[i].DefaultCellStyle.BackColor = Color.White; } + else if (facility == lineAmount) + { + // code to green + dataGridView1.Rows[i].DefaultCellStyle.ForeColor = Color.Green; + dataGridView1.Rows[i].DefaultCellStyle.BackColor = Color.White; + } else if (facility < 0) { // red line @@ -100,12 +116,6 @@ namespace BealeEngineering.Accounts } - private void button2_Click(object sender, EventArgs e) - { - var dataRead = new Core.Data.Database.Client.ReadSaleInvoiceAllocation(sqlConnectionString); - txtUnallocatedCount.Text = dataRead.GetUnallocatedInvoiceCount().ToString(); - } - private void splitContainer1_Panel1_Paint(object sender, PaintEventArgs e) { @@ -176,5 +186,46 @@ namespace BealeEngineering.Accounts MessageBox.Show(dialogText); } } + + private void btnAutoMatch_Click(object sender, EventArgs e) + { + string dialogText = "Autoallocate unmatched invoices to purchase order lines?"; + + DialogResult dialogResult = MessageBox.Show(dialogText, "Auto allocate", MessageBoxButtons.OKCancel); + if (dialogResult == DialogResult.OK) + { + var autoMatch = new Core.Logic.Client.PurchaseOrderAutoAllocate(sqlConnectionString); + autoMatch.Execute(); + + dialogText = "Operation complete." + Environment.NewLine + Environment.NewLine + + autoMatch.InvoiceMatched + " invoice(s) matched" + Environment.NewLine + + autoMatch.InvoiceUnmatched + " invoice(s) unmatched" + Environment.NewLine + + autoMatch.InvoiceProcessed + " invoice(s) processed" + Environment.NewLine; + + MessageBox.Show(dialogText); + } + UpdateTable(); + } + + private void purchaseOrderAllocationBindingSource_CurrentChanged(object sender, EventArgs e) + { + + } + + private void btnAddPurchaseOrder_Click(object sender, EventArgs e) + { + var frmCLient = new frmClientPurchaseOrder(null); + frmCLient.ShowDialog(); + } + + private void btnOpenPurchaseOrder_Click(object sender, EventArgs e) + { + int idIndex = dataGridView1.Columns["PurchaseOrderLineID"].Index; + int lineId = (int)dataGridView1[idIndex, dataGridView1.CurrentCell.RowIndex].Value; + var po = new Core.Data.Database.Client.ReadPurchaseOrder(sqlConnectionString).ByPurchaseOrderLineId(lineId); + + var frmPo = new frmClientPurchaseOrder(po); + frmPo.ShowDialog(); + } } } diff --git a/BealeEngineering/BealeEngineering.Accounts/Form1.resx b/BealeEngineering/BealeEngineering.Accounts/Form1.resx index 192dcc1..a363f7b 100644 --- a/BealeEngineering/BealeEngineering.Accounts/Form1.resx +++ b/BealeEngineering/BealeEngineering.Accounts/Form1.resx @@ -117,6 +117,12 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + True + + + True + 24, 20 diff --git a/BealeEngineering/BealeEngineering.Accounts/Properties/DataSources/BealeEngineering.Core.Model.Client.PurchaseOrder+PurchaseOrderLine.datasource b/BealeEngineering/BealeEngineering.Accounts/Properties/DataSources/BealeEngineering.Core.Model.Client.PurchaseOrder+PurchaseOrderLine.datasource new file mode 100644 index 0000000..b4d8acc --- /dev/null +++ b/BealeEngineering/BealeEngineering.Accounts/Properties/DataSources/BealeEngineering.Core.Model.Client.PurchaseOrder+PurchaseOrderLine.datasource @@ -0,0 +1,10 @@ + + + + BealeEngineering.Core.Model.Client.PurchaseOrder+PurchaseOrderLine, BealeEngineering.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/BealeEngineering/BealeEngineering.Accounts/Properties/DataSources/BealeEngineering.Core.Model.Client.PurchaseOrder.datasource b/BealeEngineering/BealeEngineering.Accounts/Properties/DataSources/BealeEngineering.Core.Model.Client.PurchaseOrder.datasource new file mode 100644 index 0000000..e97ffe5 --- /dev/null +++ b/BealeEngineering/BealeEngineering.Accounts/Properties/DataSources/BealeEngineering.Core.Model.Client.PurchaseOrder.datasource @@ -0,0 +1,10 @@ + + + + BealeEngineering.Core.Model.Client.PurchaseOrder, BealeEngineering.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/BealeEngineering/BealeEngineering.Accounts/frmClientPurchaseOrder.Designer.cs b/BealeEngineering/BealeEngineering.Accounts/frmClientPurchaseOrder.Designer.cs new file mode 100644 index 0000000..2205e85 --- /dev/null +++ b/BealeEngineering/BealeEngineering.Accounts/frmClientPurchaseOrder.Designer.cs @@ -0,0 +1,328 @@ +namespace BealeEngineering.Accounts +{ + partial class frmClientPurchaseOrder + { + /// + /// 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.components = new System.ComponentModel.Container(); + System.Windows.Forms.Label clientReferenceLabel; + System.Windows.Forms.Label orderTotalLabel; + System.Windows.Forms.Label requestorEmailLabel; + System.Windows.Forms.Label purchaseOrderDateLabel; + System.Windows.Forms.Label contactNameLabel; + System.Windows.Forms.Label isClosedLabel; + this.dataGridView1 = new System.Windows.Forms.DataGridView(); + this.lineNumber = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.description = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.lineNetAmount = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.clientPurchaseOrderLineIDDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.clientPurchaseOrderIDDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.projectJobIDDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.orderLineListBindingSource = new System.Windows.Forms.BindingSource(this.components); + this.purchaseOrderBindingSource = new System.Windows.Forms.BindingSource(this.components); + this.splitContainer1 = new System.Windows.Forms.SplitContainer(); + this.isClosedCheckBox = new System.Windows.Forms.CheckBox(); + this.contactNameTextBox = new System.Windows.Forms.TextBox(); + this.purchaseOrderDateDateTimePicker = new System.Windows.Forms.DateTimePicker(); + this.requestorEmailTextBox = new System.Windows.Forms.TextBox(); + this.orderTotalTextBox = new System.Windows.Forms.TextBox(); + this.clientReferenceTextBox = new System.Windows.Forms.TextBox(); + this.btnAdd = new System.Windows.Forms.Button(); + clientReferenceLabel = new System.Windows.Forms.Label(); + orderTotalLabel = new System.Windows.Forms.Label(); + requestorEmailLabel = new System.Windows.Forms.Label(); + purchaseOrderDateLabel = new System.Windows.Forms.Label(); + contactNameLabel = new System.Windows.Forms.Label(); + isClosedLabel = new System.Windows.Forms.Label(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.orderLineListBindingSource)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.purchaseOrderBindingSource)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); + this.splitContainer1.Panel1.SuspendLayout(); + this.splitContainer1.Panel2.SuspendLayout(); + this.splitContainer1.SuspendLayout(); + this.SuspendLayout(); + // + // clientReferenceLabel + // + clientReferenceLabel.AutoSize = true; + clientReferenceLabel.Location = new System.Drawing.Point(83, 113); + clientReferenceLabel.Name = "clientReferenceLabel"; + clientReferenceLabel.Size = new System.Drawing.Size(89, 13); + clientReferenceLabel.TabIndex = 12; + clientReferenceLabel.Text = "Client Reference:"; + // + // orderTotalLabel + // + orderTotalLabel.AutoSize = true; + orderTotalLabel.Location = new System.Drawing.Point(109, 165); + orderTotalLabel.Name = "orderTotalLabel"; + orderTotalLabel.Size = new System.Drawing.Size(63, 13); + orderTotalLabel.TabIndex = 14; + orderTotalLabel.Text = "Order Total:"; + // + // requestorEmailLabel + // + requestorEmailLabel.AutoSize = true; + requestorEmailLabel.Location = new System.Drawing.Point(85, 139); + requestorEmailLabel.Name = "requestorEmailLabel"; + requestorEmailLabel.Size = new System.Drawing.Size(87, 13); + requestorEmailLabel.TabIndex = 15; + requestorEmailLabel.Text = "Requestor Email:"; + // + // purchaseOrderDateLabel + // + purchaseOrderDateLabel.AutoSize = true; + purchaseOrderDateLabel.Location = new System.Drawing.Point(62, 88); + purchaseOrderDateLabel.Name = "purchaseOrderDateLabel"; + purchaseOrderDateLabel.Size = new System.Drawing.Size(110, 13); + purchaseOrderDateLabel.TabIndex = 16; + purchaseOrderDateLabel.Text = "Purchase Order Date:"; + // + // contactNameLabel + // + contactNameLabel.AutoSize = true; + contactNameLabel.Location = new System.Drawing.Point(94, 61); + contactNameLabel.Name = "contactNameLabel"; + contactNameLabel.Size = new System.Drawing.Size(78, 13); + contactNameLabel.TabIndex = 17; + contactNameLabel.Text = "Contact Name:"; + // + // isClosedLabel + // + isClosedLabel.AutoSize = true; + isClosedLabel.Location = new System.Drawing.Point(119, 193); + isClosedLabel.Name = "isClosedLabel"; + isClosedLabel.Size = new System.Drawing.Size(53, 13); + isClosedLabel.TabIndex = 18; + isClosedLabel.Text = "Is Closed:"; + // + // dataGridView1 + // + this.dataGridView1.AllowUserToOrderColumns = true; + this.dataGridView1.AutoGenerateColumns = false; + this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.lineNumber, + this.description, + this.lineNetAmount, + this.clientPurchaseOrderLineIDDataGridViewTextBoxColumn, + this.clientPurchaseOrderIDDataGridViewTextBoxColumn, + this.projectJobIDDataGridViewTextBoxColumn}); + this.dataGridView1.DataSource = this.orderLineListBindingSource; + this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill; + this.dataGridView1.Location = new System.Drawing.Point(0, 0); + this.dataGridView1.Name = "dataGridView1"; + this.dataGridView1.Size = new System.Drawing.Size(823, 371); + this.dataGridView1.TabIndex = 14; + // + // lineNumber + // + this.lineNumber.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; + this.lineNumber.DataPropertyName = "LineNumber"; + this.lineNumber.Frozen = true; + this.lineNumber.HeaderText = "Line Number"; + this.lineNumber.MinimumWidth = 100; + this.lineNumber.Name = "lineNumber"; + // + // description + // + this.description.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.description.DataPropertyName = "Description"; + this.description.HeaderText = "Description"; + this.description.Name = "description"; + // + // lineNetAmount + // + this.lineNetAmount.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; + this.lineNetAmount.DataPropertyName = "LineNetAmount"; + this.lineNetAmount.HeaderText = "Line Amount"; + this.lineNetAmount.MinimumWidth = 100; + this.lineNetAmount.Name = "lineNetAmount"; + // + // clientPurchaseOrderLineIDDataGridViewTextBoxColumn + // + this.clientPurchaseOrderLineIDDataGridViewTextBoxColumn.DataPropertyName = "ClientPurchaseOrderLineID"; + this.clientPurchaseOrderLineIDDataGridViewTextBoxColumn.HeaderText = "ClientPurchaseOrderLineID"; + this.clientPurchaseOrderLineIDDataGridViewTextBoxColumn.Name = "clientPurchaseOrderLineIDDataGridViewTextBoxColumn"; + this.clientPurchaseOrderLineIDDataGridViewTextBoxColumn.Visible = false; + // + // clientPurchaseOrderIDDataGridViewTextBoxColumn + // + this.clientPurchaseOrderIDDataGridViewTextBoxColumn.DataPropertyName = "ClientPurchaseOrderID"; + this.clientPurchaseOrderIDDataGridViewTextBoxColumn.HeaderText = "ClientPurchaseOrderID"; + this.clientPurchaseOrderIDDataGridViewTextBoxColumn.Name = "clientPurchaseOrderIDDataGridViewTextBoxColumn"; + this.clientPurchaseOrderIDDataGridViewTextBoxColumn.Visible = false; + // + // projectJobIDDataGridViewTextBoxColumn + // + this.projectJobIDDataGridViewTextBoxColumn.DataPropertyName = "ProjectJobID"; + this.projectJobIDDataGridViewTextBoxColumn.HeaderText = "ProjectJobID"; + this.projectJobIDDataGridViewTextBoxColumn.Name = "projectJobIDDataGridViewTextBoxColumn"; + this.projectJobIDDataGridViewTextBoxColumn.Visible = false; + // + // orderLineListBindingSource + // + this.orderLineListBindingSource.DataMember = "OrderLineList"; + this.orderLineListBindingSource.DataSource = this.purchaseOrderBindingSource; + // + // purchaseOrderBindingSource + // + this.purchaseOrderBindingSource.DataSource = typeof(BealeEngineering.Core.Model.Client.PurchaseOrder); + // + // splitContainer1 + // + this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitContainer1.Location = new System.Drawing.Point(0, 0); + this.splitContainer1.Name = "splitContainer1"; + this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal; + // + // splitContainer1.Panel1 + // + this.splitContainer1.Panel1.AutoScroll = true; + this.splitContainer1.Panel1.Controls.Add(this.btnAdd); + this.splitContainer1.Panel1.Controls.Add(isClosedLabel); + this.splitContainer1.Panel1.Controls.Add(this.isClosedCheckBox); + this.splitContainer1.Panel1.Controls.Add(contactNameLabel); + this.splitContainer1.Panel1.Controls.Add(this.contactNameTextBox); + this.splitContainer1.Panel1.Controls.Add(purchaseOrderDateLabel); + this.splitContainer1.Panel1.Controls.Add(this.purchaseOrderDateDateTimePicker); + this.splitContainer1.Panel1.Controls.Add(requestorEmailLabel); + this.splitContainer1.Panel1.Controls.Add(this.requestorEmailTextBox); + this.splitContainer1.Panel1.Controls.Add(orderTotalLabel); + this.splitContainer1.Panel1.Controls.Add(this.orderTotalTextBox); + this.splitContainer1.Panel1.Controls.Add(clientReferenceLabel); + this.splitContainer1.Panel1.Controls.Add(this.clientReferenceTextBox); + // + // splitContainer1.Panel2 + // + this.splitContainer1.Panel2.Controls.Add(this.dataGridView1); + this.splitContainer1.Size = new System.Drawing.Size(823, 749); + this.splitContainer1.SplitterDistance = 374; + this.splitContainer1.TabIndex = 15; + // + // isClosedCheckBox + // + this.isClosedCheckBox.DataBindings.Add(new System.Windows.Forms.Binding("CheckState", this.purchaseOrderBindingSource, "IsClosed", true)); + this.isClosedCheckBox.Location = new System.Drawing.Point(178, 188); + this.isClosedCheckBox.Name = "isClosedCheckBox"; + this.isClosedCheckBox.Size = new System.Drawing.Size(104, 24); + this.isClosedCheckBox.TabIndex = 19; + this.isClosedCheckBox.Text = "checkBox1"; + this.isClosedCheckBox.UseVisualStyleBackColor = true; + // + // contactNameTextBox + // + this.contactNameTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.purchaseOrderBindingSource, "ContactName", true)); + this.contactNameTextBox.Location = new System.Drawing.Point(178, 58); + this.contactNameTextBox.Name = "contactNameTextBox"; + this.contactNameTextBox.Size = new System.Drawing.Size(200, 20); + this.contactNameTextBox.TabIndex = 18; + // + // purchaseOrderDateDateTimePicker + // + this.purchaseOrderDateDateTimePicker.DataBindings.Add(new System.Windows.Forms.Binding("Value", this.purchaseOrderBindingSource, "PurchaseOrderDate", true)); + this.purchaseOrderDateDateTimePicker.Location = new System.Drawing.Point(178, 84); + this.purchaseOrderDateDateTimePicker.Name = "purchaseOrderDateDateTimePicker"; + this.purchaseOrderDateDateTimePicker.Size = new System.Drawing.Size(200, 20); + this.purchaseOrderDateDateTimePicker.TabIndex = 17; + // + // requestorEmailTextBox + // + this.requestorEmailTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.purchaseOrderBindingSource, "RequestorEmail", true)); + this.requestorEmailTextBox.Location = new System.Drawing.Point(178, 136); + this.requestorEmailTextBox.Name = "requestorEmailTextBox"; + this.requestorEmailTextBox.Size = new System.Drawing.Size(200, 20); + this.requestorEmailTextBox.TabIndex = 16; + // + // orderTotalTextBox + // + this.orderTotalTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.purchaseOrderBindingSource, "OrderTotal", true)); + this.orderTotalTextBox.Location = new System.Drawing.Point(178, 162); + this.orderTotalTextBox.Name = "orderTotalTextBox"; + this.orderTotalTextBox.Size = new System.Drawing.Size(100, 20); + this.orderTotalTextBox.TabIndex = 15; + this.orderTotalTextBox.TextChanged += new System.EventHandler(this.orderTotalTextBox_TextChanged); + // + // clientReferenceTextBox + // + this.clientReferenceTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.purchaseOrderBindingSource, "ClientReference", true)); + this.clientReferenceTextBox.Location = new System.Drawing.Point(178, 110); + this.clientReferenceTextBox.Name = "clientReferenceTextBox"; + this.clientReferenceTextBox.Size = new System.Drawing.Size(200, 20); + this.clientReferenceTextBox.TabIndex = 13; + // + // btnAdd + // + this.btnAdd.Location = new System.Drawing.Point(703, 36); + this.btnAdd.Name = "btnAdd"; + this.btnAdd.Size = new System.Drawing.Size(108, 24); + this.btnAdd.TabIndex = 20; + this.btnAdd.Text = "Add"; + this.btnAdd.UseVisualStyleBackColor = true; + this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click); + // + // frmClientPurchaseOrder + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(823, 749); + this.Controls.Add(this.splitContainer1); + this.Name = "frmClientPurchaseOrder"; + this.Text = "ClientPurchaseOrder"; + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.orderLineListBindingSource)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.purchaseOrderBindingSource)).EndInit(); + this.splitContainer1.Panel1.ResumeLayout(false); + this.splitContainer1.Panel1.PerformLayout(); + this.splitContainer1.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); + this.splitContainer1.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + private System.Windows.Forms.DataGridView dataGridView1; + private System.Windows.Forms.DataGridViewTextBoxColumn lineNumber; + private System.Windows.Forms.DataGridViewTextBoxColumn description; + private System.Windows.Forms.DataGridViewTextBoxColumn lineNetAmount; + private System.Windows.Forms.DataGridViewTextBoxColumn clientPurchaseOrderLineIDDataGridViewTextBoxColumn; + private System.Windows.Forms.DataGridViewTextBoxColumn clientPurchaseOrderIDDataGridViewTextBoxColumn; + private System.Windows.Forms.DataGridViewTextBoxColumn projectJobIDDataGridViewTextBoxColumn; + private System.Windows.Forms.SplitContainer splitContainer1; + private System.Windows.Forms.DateTimePicker purchaseOrderDateDateTimePicker; + private System.Windows.Forms.BindingSource purchaseOrderBindingSource; + private System.Windows.Forms.TextBox requestorEmailTextBox; + private System.Windows.Forms.TextBox orderTotalTextBox; + private System.Windows.Forms.TextBox clientReferenceTextBox; + private System.Windows.Forms.BindingSource orderLineListBindingSource; + private System.Windows.Forms.CheckBox isClosedCheckBox; + private System.Windows.Forms.TextBox contactNameTextBox; + private System.Windows.Forms.Button btnAdd; + } +} \ No newline at end of file diff --git a/BealeEngineering/BealeEngineering.Accounts/frmClientPurchaseOrder.cs b/BealeEngineering/BealeEngineering.Accounts/frmClientPurchaseOrder.cs new file mode 100644 index 0000000..1b66957 --- /dev/null +++ b/BealeEngineering/BealeEngineering.Accounts/frmClientPurchaseOrder.cs @@ -0,0 +1,41 @@ +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 BealeEngineering.Accounts +{ + public partial class frmClientPurchaseOrder : Form + { + public frmClientPurchaseOrder(Core.Model.Client.PurchaseOrder purchaseOrder) + { + InitializeComponent(); + + if (purchaseOrder != null) + { + purchaseOrderBindingSource.DataSource = purchaseOrder; + orderLineListBindingSource.DataSource = purchaseOrder.OrderLineList; + } + } + + private void label1_Click(object sender, EventArgs e) + { + + } + + private void orderTotalTextBox_TextChanged(object sender, EventArgs e) + { + + } + + private void btnAdd_Click(object sender, EventArgs e) + { + + } + } +} diff --git a/BealeEngineering/BealeEngineering.Accounts/frmClientPurchaseOrder.resx b/BealeEngineering/BealeEngineering.Accounts/frmClientPurchaseOrder.resx new file mode 100644 index 0000000..eb0b53f --- /dev/null +++ b/BealeEngineering/BealeEngineering.Accounts/frmClientPurchaseOrder.resx @@ -0,0 +1,147 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + False + + + False + + + False + + + False + + + False + + + False + + + 253, 29 + + + 37, 27 + + + 37, 27 + + \ No newline at end of file diff --git a/BealeEngineering/BealeEngineering.Core/Data/Database/Client/ReadPurchaseOrder.cs b/BealeEngineering/BealeEngineering.Core/Data/Database/Client/ReadPurchaseOrder.cs index d6c17c3..cd6985f 100644 --- a/BealeEngineering/BealeEngineering.Core/Data/Database/Client/ReadPurchaseOrder.cs +++ b/BealeEngineering/BealeEngineering.Core/Data/Database/Client/ReadPurchaseOrder.cs @@ -15,16 +15,11 @@ namespace BealeEngineering.Core.Data.Database.Client { } - public List PurchaseOrderHeader { get; set; } - public bool PurchaseOrderHeaderIsSet - { - get - { - if (PurchaseOrderHeader == null || !PurchaseOrderHeader.Any()) { return false; } - else { return true; } - } - } - public new List GetByClientPurchaseOrderId(List orderIdList) + + /// + /// Any filters set will be ignored + /// + public new List ByPurchaseOrderId(List orderIdList) { ClientPurchaseOrderIdList = orderIdList; try @@ -40,6 +35,29 @@ namespace BealeEngineering.Core.Data.Database.Client ClientPurchaseOrderIdList = null; } } + + /// + /// Any filters set will be ignored + /// + public Model.Client.PurchaseOrder ByPurchaseOrderLineId(int orderLineId) + { + purchaseOrderLineId = orderLineId; + try + { + var result = GetByFilters(); + if (result == null) { return null; } + else { return result[0]; } + } + catch (Exception ex) + { + throw ex; + } + finally + { + purchaseOrderLineId = null; + } + } + public new List GetByFilters() { // build the sql string and dapper parameters @@ -48,6 +66,7 @@ namespace BealeEngineering.Core.Data.Database.Client SELECT ClientPurchaseOrder.ClientPurchaseOrderID ,ClientPurchaseOrder.PurchaseOrderDate ,ClientPurchaseOrder.ContactID + ,Contact.ContactName ,ClientPurchaseOrder.ClientReference ,ClientPurchaseOrder.RequestorEmail ,ClientPurchaseOrder.OrderTotal @@ -58,8 +77,9 @@ namespace BealeEngineering.Core.Data.Database.Client ,ClientPurchaseOrderLine.Description ,ClientPurchaseOrderLine.LineNetAmount FROM ClientPurchaseOrder - LEFT OUTER JOIN ClientPurchaseOrderLine ON ClientPurchaseOrder.ClientPurchaseOrderID = ClientPurchaseOrderLine.ClientPurchaseOrderID"; - + INNER JOIN Contact ON ClientPurchaseOrder.ContactID = Contact.ContactID + LEFT OUTER JOIN ClientPurchaseOrderLine ON ClientPurchaseOrder.ClientPurchaseOrderID = ClientPurchaseOrderLine.ClientPurchaseOrderID + "; AddSqlWhereString(ref sqlString, ref parameters); sqlString = sqlString + @" diff --git a/BealeEngineering/BealeEngineering.Core/Data/Database/Client/ReadPurchaseOrderAllocation.cs b/BealeEngineering/BealeEngineering.Core/Data/Database/Client/ReadPurchaseOrderAllocation.cs index cebdf66..1495e4b 100644 --- a/BealeEngineering/BealeEngineering.Core/Data/Database/Client/ReadPurchaseOrderAllocation.cs +++ b/BealeEngineering/BealeEngineering.Core/Data/Database/Client/ReadPurchaseOrderAllocation.cs @@ -26,6 +26,7 @@ namespace BealeEngineering.Core.Data.Database.Client ,ProjectJob.JobTitle ,ProjectJob.JobDescription ,ClientPurchaseOrder.ClientReference AS PurchaseOrderReference + ,ClientPurchaseOrderLine.ClientPurchaseOrderLineID AS PurchaseOrderLineID ,ClientPurchaseOrderLine.LineNumber AS PurchaseOrderLineNumber ,ClientPurchaseOrderLine.Description AS PurchaseOrderLineDescription ,ClientPurchaseOrderLine.LineNetAmount AS PurchaseOrderLineNetAmount @@ -55,7 +56,6 @@ namespace BealeEngineering.Core.Data.Database.Client var purchaseOrders = conn.Query(sqlString, parameters).ToList(); return purchaseOrders; } - } } } diff --git a/BealeEngineering/BealeEngineering.Core/Data/Database/Client/ReadPurchaseOrderHeader.cs b/BealeEngineering/BealeEngineering.Core/Data/Database/Client/ReadPurchaseOrderHeader.cs index a2f696d..9427092 100644 --- a/BealeEngineering/BealeEngineering.Core/Data/Database/Client/ReadPurchaseOrderHeader.cs +++ b/BealeEngineering/BealeEngineering.Core/Data/Database/Client/ReadPurchaseOrderHeader.cs @@ -10,14 +10,18 @@ namespace BealeEngineering.Core.Data.Database.Client { public class ReadPurchaseOrderHeader : Connection { + protected int? purchaseOrderLineId = null; + public ReadPurchaseOrderHeader(string sqlConnectionString) : base(sqlConnectionString) { } + /// - /// Setting this will override he other filters, within the sql statement. + /// Any filters set will be ignored /// protected List ClientPurchaseOrderIdList { get; set; } + private bool ClientPurchaseOrderIdListIsSet { get @@ -26,7 +30,9 @@ namespace BealeEngineering.Core.Data.Database.Client else { return true; } } } + public DateTime DateFrom { get; set; } + public bool DateFromIsSet { get @@ -35,7 +41,9 @@ namespace BealeEngineering.Core.Data.Database.Client else { return true; } } } + public DateTime DateTo { get; set; } + public bool DateToIsSet { get @@ -44,7 +52,9 @@ namespace BealeEngineering.Core.Data.Database.Client else { return true; } } } + public List Reference { get; set; } + public bool ReferenceIsSet { get @@ -53,8 +63,10 @@ namespace BealeEngineering.Core.Data.Database.Client else { return true; } } } + public bool ReturnIsClosed { get; set; } = true; - public List GetByClientPurchaseOrderId(List orderIdList) + + public List ByPurchaseOrderId(List orderIdList) { ClientPurchaseOrderIdList = orderIdList; try @@ -70,6 +82,7 @@ namespace BealeEngineering.Core.Data.Database.Client ClientPurchaseOrderIdList = null; } } + protected void AddSqlWhereString(ref string sqlString, ref DynamicParameters parameters) { if (string.IsNullOrWhiteSpace(sqlString)) @@ -85,6 +98,13 @@ namespace BealeEngineering.Core.Data.Database.Client parameters.Add("@purchaseOrderId", ClientPurchaseOrderIdList); } + else if (purchaseOrderLineId != null) + { + sqlString = sqlString + @" + AND ClientPurchaseOrderLine.ClientPurchaseOrderLineID = @lineId"; + + parameters.Add("@lineId", (int)purchaseOrderLineId); + } else { if (DateFromIsSet) @@ -117,19 +137,22 @@ namespace BealeEngineering.Core.Data.Database.Client } } } + public List GetByFilters() { // build the sql string and dapper parameters var parameters = new DynamicParameters(); string sqlString = @" - SELECT ClientPurchaseOrderID - ,PurchaseOrderDate - ,ContactID - ,ClientReference - ,RequestorEmail - ,OrderTotal - ,IsClosed - FROM ClientPurchaseOrder"; + SELECT ClientPurchaseOrder.ClientPurchaseOrderID + ,ClientPurchaseOrder.PurchaseOrderDate + ,ClientPurchaseOrder.ClientReference + ,ClientPurchaseOrder.RequestorEmail + ,ClientPurchaseOrder.OrderTotal + ,ClientPurchaseOrder.IsClosed + ,Contact.ContactName + FROM ClientPurchaseOrder + INNER JOIN Contact ON ClientPurchaseOrder.ContactID = Contact.ContactID + "; AddSqlWhereString(ref sqlString, ref parameters); diff --git a/BealeEngineering/BealeEngineering.Core/Logic/Client/PurchaseOrderAutoAllocate.cs b/BealeEngineering/BealeEngineering.Core/Logic/Client/PurchaseOrderAutoAllocate.cs index cbf4eba..3f109c8 100644 --- a/BealeEngineering/BealeEngineering.Core/Logic/Client/PurchaseOrderAutoAllocate.cs +++ b/BealeEngineering/BealeEngineering.Core/Logic/Client/PurchaseOrderAutoAllocate.cs @@ -91,7 +91,7 @@ namespace BealeEngineering.Core.Logic.Client // match contact ID foreach (var po in clientPoList) { - if (po.Contact.ContactName == lookupList[i].Item1.ContactName) + if (po.ContactName == lookupList[i].Item1.ContactName) { // match PO reference string reference = lookupList[i].Item2; diff --git a/BealeEngineering/BealeEngineering.Core/Model/Client/PurchaseOrder.cs b/BealeEngineering/BealeEngineering.Core/Model/Client/PurchaseOrder.cs index 67bb1ae..45d6c82 100644 --- a/BealeEngineering/BealeEngineering.Core/Model/Client/PurchaseOrder.cs +++ b/BealeEngineering/BealeEngineering.Core/Model/Client/PurchaseOrder.cs @@ -1,7 +1,9 @@ using BealeEngineering.Core.Logic.Utilities; using System; using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; using System.Text; +using System.Linq; namespace BealeEngineering.Core.Model.Client { @@ -15,7 +17,9 @@ namespace BealeEngineering.Core.Model.Client else { return OrderLineList.Count; } } } + public List OrderLineList { get; set; } + public class PurchaseOrderLine { public int ClientPurchaseOrderLineID { get; set; } @@ -25,5 +29,17 @@ namespace BealeEngineering.Core.Model.Client public string Description { get; set; } public decimal LineNetAmount { get; set; } } + + public override IEnumerable Validate(ValidationContext validationContext) + { + var results = base.Validate(validationContext).ToList(); + + if (OrderLineCount == 0) + { + var result = new ValidationResult("Quantity must be greater than zero."); + results.Add(result); + } + throw new NotImplementedException(); + } } } diff --git a/BealeEngineering/BealeEngineering.Core/Model/Client/PurchaseOrderAllocation.cs b/BealeEngineering/BealeEngineering.Core/Model/Client/PurchaseOrderAllocation.cs index cf81dad..570f64e 100644 --- a/BealeEngineering/BealeEngineering.Core/Model/Client/PurchaseOrderAllocation.cs +++ b/BealeEngineering/BealeEngineering.Core/Model/Client/PurchaseOrderAllocation.cs @@ -15,6 +15,7 @@ namespace BealeEngineering.Core.Model.Client public string JobTitle { get; set; } public string JobDescription { get; set; } public string PurchaseOrderReference { get; set; } + public int PurchaseOrderLineID { get; set; } public int PurchaseOrderLineNumber { get; set; } public string PurchaseOrderLineDescription { get; set; } public decimal PurchaseOrderLineNetAmount { get; set; } diff --git a/BealeEngineering/BealeEngineering.Core/Model/Client/PurchaseOrderHeader.cs b/BealeEngineering/BealeEngineering.Core/Model/Client/PurchaseOrderHeader.cs index 2556435..298ca3d 100644 --- a/BealeEngineering/BealeEngineering.Core/Model/Client/PurchaseOrderHeader.cs +++ b/BealeEngineering/BealeEngineering.Core/Model/Client/PurchaseOrderHeader.cs @@ -1,20 +1,39 @@ using BealeEngineering.Core.Logic.Utilities; using System; using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; using System.Linq; using System.Text; using System.Threading.Tasks; namespace BealeEngineering.Core.Model.Client { - public class PurchaseOrderHeader + public class PurchaseOrderHeader : IValidatableObject { public int ClientPurchaseOrderID { get; set; } + + [Required()] public DateTime PurchaseOrderDate { get; set; } - public Model.Contact.Contact Contact { get; set; } + + [Required(), StringLength(100)] + public string ContactName { get; set; } + + [Required(), StringLength(50)] public string ClientReference { get; set; } + + [EmailAddress()] public string RequestorEmail { get; set; } + + [Required()] public decimal OrderTotal { get; set; } + + [Required()] public bool IsClosed { get; set; } + + public virtual IEnumerable Validate(ValidationContext validationContext) + { + var results = new List(); + return results; + } } } diff --git a/BealeEngineering/BealeEngineering.Core/Model/Sale/Invoice.cs b/BealeEngineering/BealeEngineering.Core/Model/Sale/Invoice.cs index 84dad91..c7ab2d6 100644 --- a/BealeEngineering/BealeEngineering.Core/Model/Sale/Invoice.cs +++ b/BealeEngineering/BealeEngineering.Core/Model/Sale/Invoice.cs @@ -87,7 +87,7 @@ namespace BealeEngineering.Core.Model.Sale ValidationResults.Add(result); } - lineTotal = lineTotal + line.LineAmount ; + lineTotal = lineTotal + line.LineAmount; lineTaxTotal = lineTaxTotal + line.TaxAmount; } if (lineTotal + lineTaxTotal != InvoiceTotal) diff --git a/BealeEngineering/BealeEngineering.Core/Model/Sale/InvoiceHeader.cs b/BealeEngineering/BealeEngineering.Core/Model/Sale/InvoiceHeader.cs index 83273c1..4f74420 100644 --- a/BealeEngineering/BealeEngineering.Core/Model/Sale/InvoiceHeader.cs +++ b/BealeEngineering/BealeEngineering.Core/Model/Sale/InvoiceHeader.cs @@ -11,10 +11,10 @@ namespace BealeEngineering.Core.Model.Sale { public int SaleInvoiceID { get; set; } - [Required(AllowEmptyStrings = false)] + [Required()] public string ContactName { get; set; } - [Required(AllowEmptyStrings = false), StringLength(50)] + [Required(), StringLength(50)] public string SaleInvoiceNumber { get; set; } [Required()] @@ -25,8 +25,7 @@ namespace BealeEngineering.Core.Model.Sale [StringLength(50)] public string Reference { get; set; } - [Required(AllowEmptyStrings = false)] - [StringLength(3, MinimumLength = 3)] + [Required(), StringLength(3, MinimumLength = 3)] public string CurrencyCode { get; set; } [Required()] diff --git a/BealeEngineering/BealeEngineering.Core/Model/ValidateModel.cs b/BealeEngineering/BealeEngineering.Core/Model/ValidateModel.cs index c3a099b..03bd0a7 100644 --- a/BealeEngineering/BealeEngineering.Core/Model/ValidateModel.cs +++ b/BealeEngineering/BealeEngineering.Core/Model/ValidateModel.cs @@ -10,6 +10,7 @@ namespace BealeEngineering.Core.Model public abstract class ValidateModel : IValidatableObject { public List ValidationResults { get; protected set; } + public bool IsValid() { ValidationResults = new List(); @@ -19,6 +20,7 @@ namespace BealeEngineering.Core.Model else { return false; } } + /// /// Standard checks on class properties. Use 'override' if you wish to add additional checks in a derived classes /// diff --git a/BealeEngineering/BealeEngineering.Core/Test/Client/PurchaseOrder.cs b/BealeEngineering/BealeEngineering.Core/Test/Client/PurchaseOrder.cs index 16cfb6b..29c8ded 100644 --- a/BealeEngineering/BealeEngineering.Core/Test/Client/PurchaseOrder.cs +++ b/BealeEngineering/BealeEngineering.Core/Test/Client/PurchaseOrder.cs @@ -22,7 +22,7 @@ namespace BealeEngineering.Core.Test.Client public void GetPurchaseOrderById() { var inst = new Core.Data.Database.Client.ReadPurchaseOrder(SqlConnectionString); - var newList = inst.GetByClientPurchaseOrderId(PurchaseOrderIdList); + var newList = inst.ByPurchaseOrderId(PurchaseOrderIdList); } public void AllocateInvoicesToPurchaseOrders() {