diff --git a/BealeEngineering/BealeEngineering.Accounts/BealeEngineering.Accounts.csproj b/BealeEngineering/BealeEngineering.Accounts/BealeEngineering.Accounts.csproj index 832e5a8..8b2d770 100644 --- a/BealeEngineering/BealeEngineering.Accounts/BealeEngineering.Accounts.csproj +++ b/BealeEngineering/BealeEngineering.Accounts/BealeEngineering.Accounts.csproj @@ -95,6 +95,12 @@ + + Form + + + ProjectWorkSelect.cs + Form @@ -111,6 +117,9 @@ frmMain.cs + + ProjectWorkSelect.cs + ResXFileCodeGenerator Resources.Designer.cs diff --git a/BealeEngineering/BealeEngineering.Accounts/ProjectWorkSelect.Designer.cs b/BealeEngineering/BealeEngineering.Accounts/ProjectWorkSelect.Designer.cs new file mode 100644 index 0000000..e2f4796 --- /dev/null +++ b/BealeEngineering/BealeEngineering.Accounts/ProjectWorkSelect.Designer.cs @@ -0,0 +1,160 @@ +namespace BealeEngineering.Accounts +{ + partial class ProjectWorkSelect + { + /// + /// 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(); + this.btnCancel = new System.Windows.Forms.Button(); + this.btnOkay = new System.Windows.Forms.Button(); + this.dataGridView1 = new System.Windows.Forms.DataGridView(); + this.projectWorkItemBindingSource = new System.Windows.Forms.BindingSource(this.components); + this.workNumberDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.workItemClientDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.projectTitleDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.workItemTitleDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.workItemIsArchivedDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewCheckBoxColumn(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.projectWorkItemBindingSource)).BeginInit(); + this.SuspendLayout(); + // + // btnCancel + // + this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.btnCancel.Location = new System.Drawing.Point(725, 412); + this.btnCancel.Name = "btnCancel"; + this.btnCancel.Size = new System.Drawing.Size(88, 26); + this.btnCancel.TabIndex = 4; + this.btnCancel.Text = "Cancel"; + this.btnCancel.UseVisualStyleBackColor = true; + this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); + // + // btnOkay + // + this.btnOkay.Location = new System.Drawing.Point(819, 412); + this.btnOkay.Name = "btnOkay"; + this.btnOkay.Size = new System.Drawing.Size(88, 26); + this.btnOkay.TabIndex = 3; + this.btnOkay.Text = "OK"; + this.btnOkay.UseVisualStyleBackColor = true; + this.btnOkay.Click += new System.EventHandler(this.btnOkay_Click); + // + // dataGridView1 + // + this.dataGridView1.AutoGenerateColumns = false; + this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.workNumberDataGridViewTextBoxColumn, + this.workItemClientDataGridViewTextBoxColumn, + this.projectTitleDataGridViewTextBoxColumn, + this.workItemTitleDataGridViewTextBoxColumn, + this.workItemIsArchivedDataGridViewTextBoxColumn}); + this.dataGridView1.DataSource = this.projectWorkItemBindingSource; + this.dataGridView1.Location = new System.Drawing.Point(12, 12); + this.dataGridView1.Name = "dataGridView1"; + this.dataGridView1.ReadOnly = true; + this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.dataGridView1.Size = new System.Drawing.Size(895, 394); + this.dataGridView1.TabIndex = 5; + this.dataGridView1.DoubleClick += new System.EventHandler(this.dataGridView1_DoubleClick); + // + // projectWorkItemBindingSource + // + this.projectWorkItemBindingSource.DataSource = typeof(BealeEngineering.Core.Model.Project.ProjectWorkItem); + // + // workNumberDataGridViewTextBoxColumn + // + this.workNumberDataGridViewTextBoxColumn.DataPropertyName = "WorkNumber"; + this.workNumberDataGridViewTextBoxColumn.HeaderText = "Work Number"; + this.workNumberDataGridViewTextBoxColumn.MinimumWidth = 80; + this.workNumberDataGridViewTextBoxColumn.Name = "workNumberDataGridViewTextBoxColumn"; + this.workNumberDataGridViewTextBoxColumn.Width = 80; + // + // workItemClientDataGridViewTextBoxColumn + // + this.workItemClientDataGridViewTextBoxColumn.DataPropertyName = "WorkItemClient"; + this.workItemClientDataGridViewTextBoxColumn.FillWeight = 75F; + this.workItemClientDataGridViewTextBoxColumn.HeaderText = "Client"; + this.workItemClientDataGridViewTextBoxColumn.MinimumWidth = 180; + this.workItemClientDataGridViewTextBoxColumn.Name = "workItemClientDataGridViewTextBoxColumn"; + this.workItemClientDataGridViewTextBoxColumn.Width = 180; + // + // projectTitleDataGridViewTextBoxColumn + // + this.projectTitleDataGridViewTextBoxColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.projectTitleDataGridViewTextBoxColumn.DataPropertyName = "ProjectTitle"; + this.projectTitleDataGridViewTextBoxColumn.HeaderText = "Project"; + this.projectTitleDataGridViewTextBoxColumn.MinimumWidth = 100; + this.projectTitleDataGridViewTextBoxColumn.Name = "projectTitleDataGridViewTextBoxColumn"; + // + // workItemTitleDataGridViewTextBoxColumn + // + this.workItemTitleDataGridViewTextBoxColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.workItemTitleDataGridViewTextBoxColumn.DataPropertyName = "WorkItemTitle"; + this.workItemTitleDataGridViewTextBoxColumn.HeaderText = "Work Item"; + this.workItemTitleDataGridViewTextBoxColumn.MinimumWidth = 100; + this.workItemTitleDataGridViewTextBoxColumn.Name = "workItemTitleDataGridViewTextBoxColumn"; + // + // workItemIsArchivedDataGridViewTextBoxColumn + // + this.workItemIsArchivedDataGridViewTextBoxColumn.DataPropertyName = "WorkItemIsArchived"; + this.workItemIsArchivedDataGridViewTextBoxColumn.HeaderText = "Archived"; + this.workItemIsArchivedDataGridViewTextBoxColumn.MinimumWidth = 70; + this.workItemIsArchivedDataGridViewTextBoxColumn.Name = "workItemIsArchivedDataGridViewTextBoxColumn"; + this.workItemIsArchivedDataGridViewTextBoxColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True; + this.workItemIsArchivedDataGridViewTextBoxColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic; + this.workItemIsArchivedDataGridViewTextBoxColumn.Width = 70; + // + // ProjectWorkSelect + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(919, 450); + this.Controls.Add(this.dataGridView1); + this.Controls.Add(this.btnCancel); + this.Controls.Add(this.btnOkay); + this.Name = "ProjectWorkSelect"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Select Work Number"; + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.projectWorkItemBindingSource)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + private System.Windows.Forms.Button btnCancel; + private System.Windows.Forms.Button btnOkay; + private System.Windows.Forms.DataGridView dataGridView1; + private System.Windows.Forms.BindingSource projectWorkItemBindingSource; + private System.Windows.Forms.DataGridViewTextBoxColumn workNumberDataGridViewTextBoxColumn; + private System.Windows.Forms.DataGridViewTextBoxColumn workItemClientDataGridViewTextBoxColumn; + private System.Windows.Forms.DataGridViewTextBoxColumn projectTitleDataGridViewTextBoxColumn; + private System.Windows.Forms.DataGridViewTextBoxColumn workItemTitleDataGridViewTextBoxColumn; + private System.Windows.Forms.DataGridViewCheckBoxColumn workItemIsArchivedDataGridViewTextBoxColumn; + } +} \ No newline at end of file diff --git a/BealeEngineering/BealeEngineering.Accounts/ProjectWorkSelect.cs b/BealeEngineering/BealeEngineering.Accounts/ProjectWorkSelect.cs new file mode 100644 index 0000000..0baf56e --- /dev/null +++ b/BealeEngineering/BealeEngineering.Accounts/ProjectWorkSelect.cs @@ -0,0 +1,59 @@ +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 ProjectWorkSelect : Form + { + string sqlConnectionString; + + public ProjectWorkSelect(string sqlConnectionString) + { + InitializeComponent(); + this.sqlConnectionString = sqlConnectionString; + var data = new Core.Data.Database.Project.ReadProjectWorkItem(sqlConnectionString); + data.ReturnIsArchived = false; + dataGridView1.DataSource = data.Read(); + } + + public Core.Model.Project.ProjectWorkItem SelectedRowObject { get; set; } + + private void btnOkay_Click(object sender, EventArgs e) + { + if (dataGridView1.SelectedRows.Count > 0) + { + SelectedRowObject = (Core.Model.Project.ProjectWorkItem)dataGridView1.SelectedRows[0].DataBoundItem; + + //int rowINdex = dataGridView1.CurrentCell.RowIndex; + //int clientIndex = dataGridView1.Columns["workItemClientDataGridViewTextBoxColumn"].Index; + //SelectedWorkNumber = dataGridView1.Rows[rowINdex].Cells[0].Value.ToString(); + //SelectedWorkClient = dataGridView1.Rows[rowINdex].Cells[clientIndex].Value.ToString(); + } + else + { + SelectedRowObject = null; + } + this.DialogResult = DialogResult.OK; + this.Close(); + } + + private void btnCancel_Click(object sender, EventArgs e) + { + SelectedRowObject = null; + this.DialogResult = DialogResult.Cancel; + this.Close(); + } + + private void dataGridView1_DoubleClick(object sender, EventArgs e) + { + btnOkay_Click(null, null); + } + } +} diff --git a/BealeEngineering/BealeEngineering.Accounts/ProjectWorkSelect.resx b/BealeEngineering/BealeEngineering.Accounts/ProjectWorkSelect.resx new file mode 100644 index 0000000..c1f15de --- /dev/null +++ b/BealeEngineering/BealeEngineering.Accounts/ProjectWorkSelect.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + 17, 17 + + \ No newline at end of file diff --git a/BealeEngineering/BealeEngineering.Accounts/frmClientPurchaseOrder.Designer.cs b/BealeEngineering/BealeEngineering.Accounts/frmClientPurchaseOrder.Designer.cs index 8877175..662873e 100644 --- a/BealeEngineering/BealeEngineering.Accounts/frmClientPurchaseOrder.Designer.cs +++ b/BealeEngineering/BealeEngineering.Accounts/frmClientPurchaseOrder.Designer.cs @@ -37,7 +37,14 @@ System.Windows.Forms.Label label1; System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); this.dataGridView1 = new System.Windows.Forms.DataGridView(); + this.clientPurchaseOrderLineIDDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.lineNumber = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.description = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.lineNetAmount = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.facility = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.ProjectWorkNumber = 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.linkStatus = new System.Windows.Forms.LinkLabel(); this.StatusTextBox = new System.Windows.Forms.TextBox(); @@ -49,12 +56,6 @@ this.txtRequestorEmail = new System.Windows.Forms.TextBox(); this.txtOrderTotal = new System.Windows.Forms.TextBox(); this.txtClientReference = new System.Windows.Forms.TextBox(); - this.purchaseOrderBindingSource = new System.Windows.Forms.BindingSource(this.components); - this.clientPurchaseOrderLineIDDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.lineNumber = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.description = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.lineNetAmount = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.facility = new System.Windows.Forms.DataGridViewTextBoxColumn(); clientReferenceLabel = new System.Windows.Forms.Label(); orderTotalLabel = new System.Windows.Forms.Label(); requestorEmailLabel = new System.Windows.Forms.Label(); @@ -63,11 +64,11 @@ label1 = 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(); - ((System.ComponentModel.ISupportInitialize)(this.purchaseOrderBindingSource)).BeginInit(); this.SuspendLayout(); // // clientReferenceLabel @@ -136,7 +137,8 @@ this.lineNumber, this.description, this.lineNetAmount, - this.facility}); + this.facility, + this.ProjectWorkNumber}); this.dataGridView1.DataSource = this.orderLineListBindingSource; this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill; this.dataGridView1.Location = new System.Drawing.Point(0, 0); @@ -144,12 +146,68 @@ this.dataGridView1.Size = new System.Drawing.Size(823, 525); this.dataGridView1.TabIndex = 14; this.dataGridView1.CellFormatting += new System.Windows.Forms.DataGridViewCellFormattingEventHandler(this.dataGridView1_CellFormatting); + this.dataGridView1.DoubleClick += new System.EventHandler(this.dataGridView1_DoubleClick); + // + // clientPurchaseOrderLineIDDataGridViewTextBoxColumn + // + this.clientPurchaseOrderLineIDDataGridViewTextBoxColumn.DataPropertyName = "ClientPurchaseOrderLineID"; + this.clientPurchaseOrderLineIDDataGridViewTextBoxColumn.HeaderText = "ClientPurchaseOrderLineID"; + this.clientPurchaseOrderLineIDDataGridViewTextBoxColumn.Name = "clientPurchaseOrderLineIDDataGridViewTextBoxColumn"; + this.clientPurchaseOrderLineIDDataGridViewTextBoxColumn.Visible = false; + // + // lineNumber + // + this.lineNumber.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; + this.lineNumber.DataPropertyName = "LineNumber"; + this.lineNumber.HeaderText = "Line Number"; + this.lineNumber.MinimumWidth = 60; + this.lineNumber.Name = "lineNumber"; + this.lineNumber.Width = 60; + // + // description + // + this.description.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.description.DataPropertyName = "Description"; + dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.description.DefaultCellStyle = dataGridViewCellStyle1; + 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 = 80; + this.lineNetAmount.Name = "lineNetAmount"; + this.lineNetAmount.Width = 80; + // + // facility + // + this.facility.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; + this.facility.HeaderText = "Facility"; + this.facility.MinimumWidth = 80; + this.facility.Name = "facility"; + this.facility.Width = 80; + // + // ProjectWorkNumber + // + this.ProjectWorkNumber.DataPropertyName = "ProjectWorkNumber"; + this.ProjectWorkNumber.HeaderText = "Work Number"; + this.ProjectWorkNumber.MinimumWidth = 80; + this.ProjectWorkNumber.Name = "ProjectWorkNumber"; + this.ProjectWorkNumber.ReadOnly = true; + this.ProjectWorkNumber.Width = 80; // // 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; @@ -279,49 +337,6 @@ this.txtClientReference.Size = new System.Drawing.Size(200, 20); this.txtClientReference.TabIndex = 13; // - // purchaseOrderBindingSource - // - this.purchaseOrderBindingSource.DataSource = typeof(BealeEngineering.Core.Model.Client.PurchaseOrder); - // - // clientPurchaseOrderLineIDDataGridViewTextBoxColumn - // - this.clientPurchaseOrderLineIDDataGridViewTextBoxColumn.DataPropertyName = "ClientPurchaseOrderLineID"; - this.clientPurchaseOrderLineIDDataGridViewTextBoxColumn.HeaderText = "ClientPurchaseOrderLineID"; - this.clientPurchaseOrderLineIDDataGridViewTextBoxColumn.Name = "clientPurchaseOrderLineIDDataGridViewTextBoxColumn"; - this.clientPurchaseOrderLineIDDataGridViewTextBoxColumn.Visible = false; - // - // lineNumber - // - this.lineNumber.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; - this.lineNumber.DataPropertyName = "LineNumber"; - 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"; - dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.description.DefaultCellStyle = dataGridViewCellStyle1; - 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"; - // - // facility - // - this.facility.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; - this.facility.HeaderText = "Facility"; - this.facility.MinimumWidth = 100; - this.facility.Name = "facility"; - // // frmClientPurchaseOrder // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -335,12 +350,12 @@ 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); - ((System.ComponentModel.ISupportInitialize)(this.purchaseOrderBindingSource)).EndInit(); this.ResumeLayout(false); } @@ -367,5 +382,6 @@ private System.Windows.Forms.DataGridViewTextBoxColumn description; private System.Windows.Forms.DataGridViewTextBoxColumn lineNetAmount; private System.Windows.Forms.DataGridViewTextBoxColumn facility; + private System.Windows.Forms.DataGridViewTextBoxColumn ProjectWorkNumber; } } \ No newline at end of file diff --git a/BealeEngineering/BealeEngineering.Accounts/frmClientPurchaseOrder.cs b/BealeEngineering/BealeEngineering.Accounts/frmClientPurchaseOrder.cs index f2f881a..007cd6d 100644 --- a/BealeEngineering/BealeEngineering.Accounts/frmClientPurchaseOrder.cs +++ b/BealeEngineering/BealeEngineering.Accounts/frmClientPurchaseOrder.cs @@ -14,7 +14,8 @@ namespace BealeEngineering.Accounts { Core.Model.Client.PurchaseOrder purchaseOrder = null; string sqlConnectionString; - bool isNew = false; + bool newForm = false; + bool editForm = false; Core.Data.Database.Client.ReadPurchaseOrderLineFacility lineFacility; public frmClientPurchaseOrder(string sqlConnectionString, Core.Model.Client.PurchaseOrder purchaseOrder) @@ -25,16 +26,19 @@ namespace BealeEngineering.Accounts if (purchaseOrder == null) { - FormEditEnable(); PurchaseOrder = new Core.Model.Client.PurchaseOrder(); PurchaseOrder.IsClosed = false; - SetStatus(PurchaseOrder.IsClosed); - isNew = true; + updateStatusButton(); + newForm = true; + editForm = true; + SetFormMode(); } else { PurchaseOrder = purchaseOrder; - FormEditDisable(); + newForm = false; + editForm = false; + SetFormMode(); } } @@ -49,11 +53,11 @@ namespace BealeEngineering.Accounts purchaseOrder = value; purchaseOrderBindingSource.DataSource = purchaseOrder; orderLineListBindingSource.DataSource = purchaseOrder.OrderLineList; - SetStatus(PurchaseOrder.IsClosed); + updateStatusButton(); } } - private void RefreshData() + private void DatabaseRequery() { if (PurchaseOrder.ClientPurchaseOrderIDIsSet) { @@ -62,44 +66,68 @@ namespace BealeEngineering.Accounts } } - private void FormEditDisable() + private void SetFormMode() { - txtClientReference.ReadOnly = true; - txtOrderTotal.ReadOnly = true; - pickerPurchaseOrderDateDate.Enabled = false; - txtRequestorEmail.ReadOnly = true; - dataGridView1.ReadOnly = true; - linkUpdate.Visible = false; - btnEdit.Text = "Edit"; - btnDelete.Visible = false; - } - - private void FormEditEnable() - { - txtClientReference.ReadOnly = false; - txtOrderTotal.ReadOnly = false; - pickerPurchaseOrderDateDate.Enabled = true; - txtRequestorEmail.ReadOnly = false; - dataGridView1.ReadOnly = false; - linkUpdate.Visible = true; - btnEdit.Text = "Save"; - if (isNew == false) { btnDelete.Visible = true; } - } - - private void SetStatus (bool isClosed) - { - if (purchaseOrder.IsClosed) - { - StatusTextBox.Text = " CLOSED"; - linkStatus.Text = "Reopen"; + if (newForm) + { + editForm = true; } - else - { - StatusTextBox.Text = " OPEN"; - linkStatus.Text = "Close"; + + if (editForm) + { + if (newForm == false) + { + btnDelete.Visible = true; + } + + txtClientReference.ReadOnly = false; + txtOrderTotal.ReadOnly = false; + pickerPurchaseOrderDateDate.Enabled = true; + txtRequestorEmail.ReadOnly = false; + dataGridView1.ReadOnly = false; + linkUpdate.Visible = true; + btnEdit.Text = "Save"; + dataGridView1.Columns["ProjectWorkNumber"].ReadOnly = true; + } + else + { + txtClientReference.ReadOnly = true; + txtOrderTotal.ReadOnly = true; + pickerPurchaseOrderDateDate.Enabled = false; + txtRequestorEmail.ReadOnly = true; + dataGridView1.ReadOnly = true; + linkUpdate.Visible = false; + btnEdit.Text = "Edit"; + btnDelete.Visible = false; } } + //private void FormEditDisable() + //{ + // editMode = false; + // txtClientReference.ReadOnly = true; + // txtOrderTotal.ReadOnly = true; + // pickerPurchaseOrderDateDate.Enabled = false; + // txtRequestorEmail.ReadOnly = true; + // dataGridView1.ReadOnly = true; + // linkUpdate.Visible = false; + // btnEdit.Text = "Edit"; + // btnDelete.Visible = false; + //} + + //private void FormEditEnable() + //{ + // editMode = true; + // txtClientReference.ReadOnly = false; + // txtOrderTotal.ReadOnly = false; + // pickerPurchaseOrderDateDate.Enabled = true; + // txtRequestorEmail.ReadOnly = false; + // dataGridView1.ReadOnly = false; + // linkUpdate.Visible = true; + // btnEdit.Text = "Save"; + // if (isNew == false) { btnDelete.Visible = true; } + //} + private void orderTotalTextBox_TextChanged(object sender, EventArgs e) { @@ -107,9 +135,9 @@ namespace BealeEngineering.Accounts private void btnEdit_Click(object sender, EventArgs e) { - if (btnEdit.Text == "Save") + if (editForm || newForm) { - if (isNew) + if (newForm) { new Core.Data.Database.Client.UpdatePurchaseOrder(sqlConnectionString).Create(purchaseOrder); this.Close(); @@ -122,8 +150,9 @@ namespace BealeEngineering.Accounts } else { - FormEditEnable(); + editForm = true; } + SetFormMode(); } private void contactNameTextBox_DoubleClick(object sender, EventArgs e) @@ -162,12 +191,35 @@ namespace BealeEngineering.Accounts private void linkStatus_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { - bool isClosed = !purchaseOrder.IsClosed; + bool newValue = !purchaseOrder.IsClosed; - new Core.Data.Database.Client.UpdatePurchaseOrder(sqlConnectionString) - .UpdateIsClosed(purchaseOrder.ClientPurchaseOrderID, isClosed); + if (editForm || newForm) + { + purchaseOrder.IsClosed = newValue; + } + else + { + new Core.Data.Database.Client.UpdatePurchaseOrder(sqlConnectionString) + .UpdateIsClosed(purchaseOrder.ClientPurchaseOrderID, newValue); - RefreshData(); + DatabaseRequery(); + } + + updateStatusButton(); + } + + private void updateStatusButton() + { + if (purchaseOrder.IsClosed) + { + StatusTextBox.Text = " CLOSED"; + linkStatus.Text = "Reopen"; + } + else + { + StatusTextBox.Text = " OPEN"; + linkStatus.Text = "Close"; + } } private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) @@ -181,5 +233,33 @@ namespace BealeEngineering.Accounts } } } + + private void dataGridView1_DoubleClick(object sender, EventArgs e) + { + if (editForm || newForm) + { + if (dataGridView1.CurrentCell.OwningColumn.Name == "ProjectWorkNumber") + { + var selectForm = new ProjectWorkSelect(sqlConnectionString); + selectForm.ShowDialog(); + if (selectForm.SelectedRowObject != null) + { + if (purchaseOrder != null && selectForm.SelectedRowObject.WorkItemClient != purchaseOrder.ContactName) + { + var responce = MessageBox.Show("The work item client does not match to cantact on the purchase order, is this correct?" + , "Insurficent facility" + , MessageBoxButtons.OKCancel + , MessageBoxIcon.Question + , MessageBoxDefaultButton.Button2); + + if (responce != DialogResult.OK) + { return; } + } + + dataGridView1.CurrentCell.Value = selectForm.SelectedRowObject.WorkNumber; + } + } + } + } } } diff --git a/BealeEngineering/BealeEngineering.Accounts/frmClientPurchaseOrder.resx b/BealeEngineering/BealeEngineering.Accounts/frmClientPurchaseOrder.resx index 2376474..51a38f9 100644 --- a/BealeEngineering/BealeEngineering.Accounts/frmClientPurchaseOrder.resx +++ b/BealeEngineering/BealeEngineering.Accounts/frmClientPurchaseOrder.resx @@ -138,6 +138,9 @@ True + + True + 253, 29 diff --git a/BealeEngineering/BealeEngineering.Accounts/frmMain.Designer.cs b/BealeEngineering/BealeEngineering.Accounts/frmMain.Designer.cs index 7fd5c3a..6fffe9e 100644 --- a/BealeEngineering/BealeEngineering.Accounts/frmMain.Designer.cs +++ b/BealeEngineering/BealeEngineering.Accounts/frmMain.Designer.cs @@ -29,8 +29,8 @@ private void InitializeComponent() { this.components = new System.ComponentModel.Container(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle(); this.invoiceHeaderBindingSource1 = new System.Windows.Forms.BindingSource(this.components); this.bindingSourceSaleInvoice = new System.Windows.Forms.BindingSource(this.components); this.menuStrip1 = new System.Windows.Forms.MenuStrip(); @@ -84,17 +84,6 @@ this.label2 = new System.Windows.Forms.Label(); this.txtInvoiceImportDt = new System.Windows.Forms.TextBox(); this.dataGridView1 = new System.Windows.Forms.DataGridView(); - this.PurchaseOrderLineID = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.ContactName = 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.WorkNumber = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.ProjectTitle = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.purchaseOrderAllocationBindingSource = new System.Windows.Forms.BindingSource(this.components); this.tabControl1 = new System.Windows.Forms.TabControl(); this.tabProjectWork = new System.Windows.Forms.TabPage(); @@ -124,6 +113,17 @@ this.taxTotalDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.isCreditNoteDataGridViewCheckBoxColumn = new System.Windows.Forms.DataGridViewCheckBoxColumn(); this.statusDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.PurchaseOrderLineID = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.ContactName = 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.WorkNumber = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.WorkTitle = new System.Windows.Forms.DataGridViewTextBoxColumn(); ((System.ComponentModel.ISupportInitialize)(this.invoiceHeaderBindingSource1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.bindingSourceSaleInvoice)).BeginInit(); this.menuStrip1.SuspendLayout(); @@ -541,8 +541,8 @@ // TotalAndCurrency // this.TotalAndCurrency.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; - dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight; - this.TotalAndCurrency.DefaultCellStyle = dataGridViewCellStyle3; + dataGridViewCellStyle7.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight; + this.TotalAndCurrency.DefaultCellStyle = dataGridViewCellStyle7; this.TotalAndCurrency.HeaderText = "InvoiceTotal"; this.TotalAndCurrency.MinimumWidth = 120; this.TotalAndCurrency.Name = "TotalAndCurrency"; @@ -553,8 +553,8 @@ // this.status.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; this.status.DataPropertyName = "Status"; - dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - this.status.DefaultCellStyle = dataGridViewCellStyle4; + dataGridViewCellStyle8.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + this.status.DefaultCellStyle = dataGridViewCellStyle8; this.status.HeaderText = "Status"; this.status.MinimumWidth = 100; this.status.Name = "status"; @@ -713,7 +713,7 @@ this.InvoicedAmount, this.PurchaseOrderLineFacility, this.WorkNumber, - this.ProjectTitle}); + this.WorkTitle}); this.dataGridView1.DataSource = this.purchaseOrderAllocationBindingSource; this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill; this.dataGridView1.Location = new System.Drawing.Point(0, 0); @@ -726,112 +726,6 @@ this.dataGridView1.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellContentClick); this.dataGridView1.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellDoubleClick); // - // PurchaseOrderLineID - // - this.PurchaseOrderLineID.DataPropertyName = "PurchaseOrderLineID"; - this.PurchaseOrderLineID.HeaderText = "PurchaseOrderLineID"; - this.PurchaseOrderLineID.Name = "PurchaseOrderLineID"; - this.PurchaseOrderLineID.ReadOnly = true; - this.PurchaseOrderLineID.Visible = false; - // - // ContactName - // - this.ContactName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; - this.ContactName.DataPropertyName = "ContactName"; - this.ContactName.FillWeight = 150F; - this.ContactName.HeaderText = "Client"; - this.ContactName.MinimumWidth = 90; - this.ContactName.Name = "ContactName"; - this.ContactName.ReadOnly = true; - // - // PurchaseOrderDate - // - 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; - // - // PurchaseOrderReference - // - 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; - // - // PurchaseOrderLineNumber - // - 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; - // - // PurchaseOrderLineDescription - // - 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; - // - // PurchaseOrderLineNetAmount - // - 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; - // - // InvoicedAmount - // - 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; - // - // PurchaseOrderLineFacility - // - 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; - // - // WorkNumber - // - this.WorkNumber.DataPropertyName = "WorkNumber"; - this.WorkNumber.HeaderText = "WorkNumber"; - this.WorkNumber.MinimumWidth = 80; - this.WorkNumber.Name = "WorkNumber"; - this.WorkNumber.ReadOnly = true; - // - // ProjectTitle - // - 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; - // // purchaseOrderAllocationBindingSource // this.purchaseOrderAllocationBindingSource.AllowNew = false; @@ -1098,6 +992,118 @@ this.statusDataGridViewTextBoxColumn.Name = "statusDataGridViewTextBoxColumn"; this.statusDataGridViewTextBoxColumn.ReadOnly = true; // + // PurchaseOrderLineID + // + this.PurchaseOrderLineID.DataPropertyName = "PurchaseOrderLineID"; + this.PurchaseOrderLineID.HeaderText = "PurchaseOrderLineID"; + this.PurchaseOrderLineID.Name = "PurchaseOrderLineID"; + this.PurchaseOrderLineID.ReadOnly = true; + this.PurchaseOrderLineID.Visible = false; + // + // ContactName + // + this.ContactName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.ContactName.DataPropertyName = "ContactName"; + this.ContactName.FillWeight = 150F; + this.ContactName.HeaderText = "Client"; + this.ContactName.MinimumWidth = 90; + this.ContactName.Name = "ContactName"; + this.ContactName.ReadOnly = true; + // + // PurchaseOrderDate + // + this.PurchaseOrderDate.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; + 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; + this.PurchaseOrderDate.Width = 80; + // + // PurchaseOrderReference + // + 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; + // + // PurchaseOrderLineNumber + // + this.PurchaseOrderLineNumber.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; + 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; + this.PurchaseOrderLineNumber.Width = 50; + // + // PurchaseOrderLineDescription + // + 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; + // + // PurchaseOrderLineNetAmount + // + this.PurchaseOrderLineNetAmount.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; + 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; + this.PurchaseOrderLineNetAmount.Width = 80; + // + // InvoicedAmount + // + this.InvoicedAmount.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; + this.InvoicedAmount.DataPropertyName = "InvoicedAmount"; + this.InvoicedAmount.FillWeight = 50F; + this.InvoicedAmount.HeaderText = "Invoiced"; + this.InvoicedAmount.MinimumWidth = 80; + this.InvoicedAmount.Name = "InvoicedAmount"; + this.InvoicedAmount.ReadOnly = true; + this.InvoicedAmount.Width = 80; + // + // PurchaseOrderLineFacility + // + this.PurchaseOrderLineFacility.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; + this.PurchaseOrderLineFacility.DataPropertyName = "PurchaseOrderLineFacility"; + this.PurchaseOrderLineFacility.FillWeight = 50F; + this.PurchaseOrderLineFacility.HeaderText = "Facility"; + this.PurchaseOrderLineFacility.MinimumWidth = 80; + this.PurchaseOrderLineFacility.Name = "PurchaseOrderLineFacility"; + this.PurchaseOrderLineFacility.ReadOnly = true; + this.PurchaseOrderLineFacility.Width = 80; + // + // WorkNumber + // + this.WorkNumber.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; + this.WorkNumber.DataPropertyName = "WorkNumber"; + this.WorkNumber.HeaderText = "WorkNumber"; + this.WorkNumber.MinimumWidth = 80; + this.WorkNumber.Name = "WorkNumber"; + this.WorkNumber.ReadOnly = true; + this.WorkNumber.Width = 80; + // + // WorkTitle + // + this.WorkTitle.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.WorkTitle.DataPropertyName = "WorkTitle"; + this.WorkTitle.FillWeight = 200F; + this.WorkTitle.HeaderText = "Work Item"; + this.WorkTitle.MinimumWidth = 100; + this.WorkTitle.Name = "WorkTitle"; + this.WorkTitle.ReadOnly = true; + // // frmMain // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -1231,6 +1237,15 @@ private System.Windows.Forms.DataGridViewTextBoxColumn dateEndDataGridViewTextBoxColumn; private System.Windows.Forms.DataGridViewTextBoxColumn isArchivedDataGridViewTextBoxColumn; private System.Windows.Forms.BindingSource projectWorkItemBindingSource; + private System.Windows.Forms.DataGridViewTextBoxColumn workNumberDataGridViewTextBoxColumn; + private System.Windows.Forms.DataGridViewTextBoxColumn workItemClientDataGridViewTextBoxColumn; + private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn1; + private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn3; + private System.Windows.Forms.DataGridViewTextBoxColumn workItemTitleDataGridViewTextBoxColumn; + private System.Windows.Forms.DataGridViewTextBoxColumn workItemDateStartDataGridViewTextBoxColumn; + private System.Windows.Forms.DataGridViewTextBoxColumn workItemDateEndDataGridViewTextBoxColumn; + private System.Windows.Forms.DataGridViewTextBoxColumn workItemIsArchivedDataGridViewTextBoxColumn; + private System.Windows.Forms.ToolStripMenuItem xeroNewInvoiceToolStripMenuItem; private System.Windows.Forms.DataGridViewTextBoxColumn PurchaseOrderLineID; private System.Windows.Forms.DataGridViewTextBoxColumn ContactName; private System.Windows.Forms.DataGridViewTextBoxColumn PurchaseOrderDate; @@ -1241,16 +1256,7 @@ private System.Windows.Forms.DataGridViewTextBoxColumn InvoicedAmount; private System.Windows.Forms.DataGridViewTextBoxColumn PurchaseOrderLineFacility; private System.Windows.Forms.DataGridViewTextBoxColumn WorkNumber; - private System.Windows.Forms.DataGridViewTextBoxColumn ProjectTitle; - private System.Windows.Forms.DataGridViewTextBoxColumn workNumberDataGridViewTextBoxColumn; - private System.Windows.Forms.DataGridViewTextBoxColumn workItemClientDataGridViewTextBoxColumn; - private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn1; - private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn3; - private System.Windows.Forms.DataGridViewTextBoxColumn workItemTitleDataGridViewTextBoxColumn; - private System.Windows.Forms.DataGridViewTextBoxColumn workItemDateStartDataGridViewTextBoxColumn; - private System.Windows.Forms.DataGridViewTextBoxColumn workItemDateEndDataGridViewTextBoxColumn; - private System.Windows.Forms.DataGridViewTextBoxColumn workItemIsArchivedDataGridViewTextBoxColumn; - private System.Windows.Forms.ToolStripMenuItem xeroNewInvoiceToolStripMenuItem; + private System.Windows.Forms.DataGridViewTextBoxColumn WorkTitle; } } diff --git a/BealeEngineering/BealeEngineering.Accounts/frmMain.cs b/BealeEngineering/BealeEngineering.Accounts/frmMain.cs index 5f76bcd..07c97ca 100644 --- a/BealeEngineering/BealeEngineering.Accounts/frmMain.cs +++ b/BealeEngineering/BealeEngineering.Accounts/frmMain.cs @@ -229,7 +229,7 @@ namespace BealeEngineering.Accounts MessageBox.Show(dialogText); } - + UpdateInvoiceImportText(); TabSetAllIsDirty(); } diff --git a/BealeEngineering/BealeEngineering.Accounts/frmMain.resx b/BealeEngineering/BealeEngineering.Accounts/frmMain.resx index 1179737..b5c5410 100644 --- a/BealeEngineering/BealeEngineering.Accounts/frmMain.resx +++ b/BealeEngineering/BealeEngineering.Accounts/frmMain.resx @@ -147,13 +147,7 @@ True - - 24, 20 - - - True - - + True diff --git a/BealeEngineering/BealeEngineering.Core/Data/Database/Client/CreatePurchaseOrder.cs b/BealeEngineering/BealeEngineering.Core/Data/Database/Client/CreatePurchaseOrder.cs index 4ca299f..bb572be 100644 --- a/BealeEngineering/BealeEngineering.Core/Data/Database/Client/CreatePurchaseOrder.cs +++ b/BealeEngineering/BealeEngineering.Core/Data/Database/Client/CreatePurchaseOrder.cs @@ -106,6 +106,7 @@ namespace BealeEngineering.Core.Data.Database.Client ,LineNumber ,Description ,LineNetAmount + ,ProjectWorkID ) OUTPUT INSERTED.ClientPurchaseOrderLineID VALUES @@ -114,6 +115,11 @@ namespace BealeEngineering.Core.Data.Database.Client ,@lineNumber ,@description ,@lineNetAmount + ,(SELECT ProjectWorkID + FROM ProjectWork + WHERE WorkNumber = @workNumber + ) + ) ", conn)) { @@ -122,6 +128,7 @@ namespace BealeEngineering.Core.Data.Database.Client if (string.IsNullOrWhiteSpace(description)) { cmd.Parameters.AddWithValue("@description", DBNull.Value); } else { cmd.Parameters.AddWithValue("@description", description); } cmd.Parameters.AddWithValue("@lineNetAmount", lineNetAmount); + cmd.Parameters.AddWithValue("@workNumber", projectWorkNo); return (int)cmd.ExecuteScalar(); } diff --git a/BealeEngineering/BealeEngineering.Core/Data/Database/Client/UpdatePurchaseOrder.cs b/BealeEngineering/BealeEngineering.Core/Data/Database/Client/UpdatePurchaseOrder.cs index a0c1fe2..593e300 100644 --- a/BealeEngineering/BealeEngineering.Core/Data/Database/Client/UpdatePurchaseOrder.cs +++ b/BealeEngineering/BealeEngineering.Core/Data/Database/Client/UpdatePurchaseOrder.cs @@ -236,11 +236,17 @@ namespace BealeEngineering.Core.Data.Database.Client SET LineNumber = @lineNumber ,Description = @description ,LineNetAmount = @lineNetAmount + ,ProjectWorkID = + ( + SELECT ProjectWorkID + FROM ProjectWork + WHERE WorkNumber = @workNumber + ) WHERE ClientPurchaseOrderLineID = @purchaseOrderLineId ", conn)) { cmd.Parameters.AddWithValue("@lineNumber", lineNumber); - //cmd.Parameters.AddWithValue("@projectWorkNo", projectWorkNo); + cmd.Parameters.AddWithValue("@workNumber", projectWorkNo); if (string.IsNullOrWhiteSpace(description)) { cmd.Parameters.AddWithValue("@description", DBNull.Value); } else { cmd.Parameters.AddWithValue("@description", description); } cmd.Parameters.AddWithValue("@lineNetAmount", lineNetAmount); diff --git a/BealeEngineering/BealeEngineering.Core/Data/Xero/ReadXeroInvoiceFlatFile.cs b/BealeEngineering/BealeEngineering.Core/Data/Xero/ReadXeroInvoiceFlatFile.cs index d143e0f..dad05e6 100644 --- a/BealeEngineering/BealeEngineering.Core/Data/Xero/ReadXeroInvoiceFlatFile.cs +++ b/BealeEngineering/BealeEngineering.Core/Data/Xero/ReadXeroInvoiceFlatFile.cs @@ -14,12 +14,12 @@ namespace BealeEngineering.Core.Data.Xero.FlatFile { public ReadXeroInvoiceFlatFile() { - FileInputPath = - Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) - + @"\Dropbox\Beale Engineering Services Ltd\BE Accounts\Xero-Export-Invoices.csv"; - FileOutputPath = - Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) - + @"\Downloads\MyNewTextFile.txt"; + //FileInputPath = + // Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + // + @"\Dropbox\Beale Engineering Services Ltd\BE Accounts\Xero-Export-Invoices.csv"; + //FileOutputPath = + // Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + // + @"\Downloads\MyNewTextFile.txt"; } private StringBuilder IntermediateCsv { get; set; } @@ -41,6 +41,7 @@ namespace BealeEngineering.Core.Data.Xero.FlatFile /// Dictionary, Invoice numbers against data. public List ByFilePath(string filePath) { + FileInputPath = filePath; /* So here's the rub. Any field in a CSV doc that has a double quote wihtin, must be enclosed by double quotes and * the double quote within must be 'escaped' by a double quote. * However, in that situation, Xero flat file doesn't enclose the field or escape the double quote. @@ -58,7 +59,7 @@ namespace BealeEngineering.Core.Data.Xero.FlatFile // first off, get a RFC4180 compliant csv string var csvRFC = new Logic.Utilities.CSVGetRFC4180Compliant(); - csvRFC.ByFilePath(filePath); + csvRFC.ByFilePath(FileInputPath); if (!csvRFC.OutputStringIsSet) { throw new Exception("CSV Error."); } diff --git a/BealeEngineering/BealeEngineering.Core/Logic/Export/XeroInvoiceFlatFile.cs b/BealeEngineering/BealeEngineering.Core/Logic/Export/XeroInvoiceFlatFile.cs index 2a20ed8..ed1a1ff 100644 --- a/BealeEngineering/BealeEngineering.Core/Logic/Export/XeroInvoiceFlatFile.cs +++ b/BealeEngineering/BealeEngineering.Core/Logic/Export/XeroInvoiceFlatFile.cs @@ -48,7 +48,7 @@ namespace BealeEngineering.Core.Logic.Export var xeroInvoiceDtoList = new Logic.Adapter.ExportXeroInvoiceFlatFileDTO().BySaleInvoice(invoiceList); // create flatfile from dto - using (var writer = new StreamWriter(FileOutputPath)) + using (var writer = new StreamWriter(FileOutputPath, false, Encoding.UTF8)) using (var csv = new CsvWriter(writer, new Data.CurrencyFormat().ReadCulture("GBP"))) { csv.WriteRecords(xeroInvoiceDtoList); diff --git a/BealeEngineering/BealeEngineering.Core/Logic/Sale/SaleInvoiceAssign.cs b/BealeEngineering/BealeEngineering.Core/Logic/Sale/SaleInvoiceAssign.cs index 8136467..b1803c8 100644 --- a/BealeEngineering/BealeEngineering.Core/Logic/Sale/SaleInvoiceAssign.cs +++ b/BealeEngineering/BealeEngineering.Core/Logic/Sale/SaleInvoiceAssign.cs @@ -50,7 +50,7 @@ namespace BealeEngineering.Core.Logic.Sale = new Data.Database.Client.ReadPurchaseOrder(sqlConnectionString).ByPurchaseOrderLineId(purchaseOrderLineId); var updateInvoice = new Data.Database.Sale.UpdateInvoice(sqlConnectionString); - if (facilityNet >= invoice.InvoiceNetTotal && SplitInvoice) + if (facilityNet >= invoice.InvoiceNetTotal) { invoice.Reference = poHeader.ClientReference; invoice.Status = statusModified; @@ -165,8 +165,8 @@ namespace BealeEngineering.Core.Logic.Sale newInvoice.SaleInvoiceNumber = new Data.Database.Sale.ReadNextInvoiceNumber(sqlConnectionString).Read(newInvoice.IsCreditNote); splitText = splitText - + invoice.SaleInvoiceNumber + " = " + splitAmount1.ToString("F") + " " + invoice.CurrencyCode - + Environment.NewLine + newInvoice.SaleInvoiceNumber + " = " + splitAmount2.ToString("F") + " " + newInvoice.CurrencyCode; + + invoice.SaleInvoiceNumber + " = " + splitAmount1.ToString("C", culture) + + Environment.NewLine + newInvoice.SaleInvoiceNumber + " = " + splitAmount2.ToString("C", culture); invoice.InvoiceLineList[i].Description += splitText; newInvoice.InvoiceLineList[0].Description += splitText;