diff --git a/AyaNovaQBI/Form1.Designer.cs b/AyaNovaQBI/Form1.Designer.cs index 1cb7a00..6d87857 100644 --- a/AyaNovaQBI/Form1.Designer.cs +++ b/AyaNovaQBI/Form1.Designer.cs @@ -56,7 +56,7 @@ this.wonumber = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.servicedate = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.project = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.linked = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.linked = new System.Windows.Forms.DataGridViewCheckBoxColumn(); this.menuStrip1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.grid)).BeginInit(); this.SuspendLayout(); @@ -228,6 +228,7 @@ this.grid.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.grid.Size = new System.Drawing.Size(765, 359); this.grid.TabIndex = 3; + this.grid.CellFormatting += new System.Windows.Forms.DataGridViewCellFormattingEventHandler(this.grid_CellFormatting); // // status // @@ -291,6 +292,8 @@ this.linked.HeaderText = "Linked"; this.linked.Name = "linked"; this.linked.ReadOnly = true; + this.linked.Resizable = System.Windows.Forms.DataGridViewTriState.True; + this.linked.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic; this.linked.Visible = false; this.linked.Width = 64; // @@ -345,7 +348,7 @@ private System.Windows.Forms.DataGridViewTextBoxColumn wonumber; private System.Windows.Forms.DataGridViewTextBoxColumn servicedate; private System.Windows.Forms.DataGridViewTextBoxColumn project; - private System.Windows.Forms.DataGridViewTextBoxColumn linked; + private System.Windows.Forms.DataGridViewCheckBoxColumn linked; } } diff --git a/AyaNovaQBI/Form1.cs b/AyaNovaQBI/Form1.cs index dab3a2f..4610d53 100644 --- a/AyaNovaQBI/Form1.cs +++ b/AyaNovaQBI/Form1.cs @@ -23,5 +23,24 @@ namespace AyaNovaQBI cbCustomersWithInvoiceableWorkorders.DisplayMember = "Name"; grid.DataSource = util.GetInvoiceableItems(); } + + private void grid_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) + { + if (e.ColumnIndex == grid.Columns["Status"].Index + && e.Value != null) + { + var isLinked = (bool)grid.Rows[e.RowIndex].Cells["linked"].Value; + + if (!isLinked) + { + grid.Rows[e.RowIndex].Cells["wonumber"].ErrorText = "Not invoiceable: use \"Invoice\" -> \"Fix problems\" to resolve"; + }else + { + grid.Rows[e.RowIndex].Cells["wonumber"].ErrorText = null; + } + + } + + } } } diff --git a/AyaNovaQBI/util.cs b/AyaNovaQBI/util.cs index 4f210a0..b9bea8b 100644 --- a/AyaNovaQBI/util.cs +++ b/AyaNovaQBI/util.cs @@ -11,9 +11,10 @@ namespace AyaNovaQBI public static List GetInvoiceableItems() { + var random = new Random(); var l = new List(); for (int i = 0; i < 10; i++) - l.Add(new InvoiceableItem { CustomerId = 1, Linked = true, Project = "project blah", ServiceDate = DateTime.Now.ToString("s"), ServiceNumber = "44", Status = "Waiting to be invoiced and just sitting there otherwise", StatusColor = "FF00FFAA", WorkorderId = 4 }); + l.Add(new InvoiceableItem { CustomerId = 1, Linked = random.Next(2) == 1, Project = "project blah", ServiceDate = DateTime.Now.ToString("s"), ServiceNumber = (40+i).ToString(), Status = "Waiting to be invoiced and just sitting there otherwise", StatusColor = "FF00FFAA", WorkorderId = 4 }); return l; }