diff --git a/AyaNovaQBI/Form1.Designer.cs b/AyaNovaQBI/Form1.Designer.cs index d5a87d1..805c299 100644 --- a/AyaNovaQBI/Form1.Designer.cs +++ b/AyaNovaQBI/Form1.Designer.cs @@ -28,6 +28,8 @@ /// private void InitializeComponent() { + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm)); this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.invoicesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -46,14 +48,13 @@ this.technicalsupportToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.cbCustomersWithInvoiceableWorkorders = new System.Windows.Forms.ComboBox(); - this.label1 = new System.Windows.Forms.Label(); this.grid = new System.Windows.Forms.DataGridView(); + this.wonumber = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.customer = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.status = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.statuscolor = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.workorderid = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.customerid = new System.Windows.Forms.DataGridViewTextBoxColumn(); - 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.DataGridViewCheckBoxColumn(); @@ -188,89 +189,98 @@ this.exitToolStripMenuItem.Text = "E&xit"; this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click); // - // cbCustomersWithInvoiceableWorkorders - // - this.cbCustomersWithInvoiceableWorkorders.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.cbCustomersWithInvoiceableWorkorders.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.cbCustomersWithInvoiceableWorkorders.FormattingEnabled = true; - this.cbCustomersWithInvoiceableWorkorders.Location = new System.Drawing.Point(13, 54); - this.cbCustomersWithInvoiceableWorkorders.Name = "cbCustomersWithInvoiceableWorkorders"; - this.cbCustomersWithInvoiceableWorkorders.Size = new System.Drawing.Size(765, 21); - this.cbCustomersWithInvoiceableWorkorders.TabIndex = 1; - this.cbCustomersWithInvoiceableWorkorders.SelectedIndexChanged += new System.EventHandler(this.cbCustomersWithInvoiceableWorkorders_SelectedIndexChanged); - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(13, 35); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(187, 13); - this.label1.TabIndex = 2; - this.label1.Text = "Customers with invoicable work orders"; - // // grid // - this.grid.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.grid.AllowUserToAddRows = false; + this.grid.AllowUserToDeleteRows = false; + dataGridViewCellStyle1.BackColor = System.Drawing.Color.WhiteSmoke; + this.grid.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; this.grid.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.AllCells; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.grid.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle2; this.grid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.grid.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.wonumber, + this.customer, this.status, this.statuscolor, this.workorderid, this.customerid, - this.wonumber, this.servicedate, this.project, this.linked}); - this.grid.Location = new System.Drawing.Point(13, 103); + this.grid.Dock = System.Windows.Forms.DockStyle.Fill; + this.grid.EnableHeadersVisualStyles = false; + this.grid.Location = new System.Drawing.Point(0, 24); this.grid.Name = "grid"; + this.grid.ReadOnly = true; this.grid.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; - this.grid.Size = new System.Drawing.Size(765, 359); + this.grid.Size = new System.Drawing.Size(790, 450); this.grid.TabIndex = 3; this.grid.CellFormatting += new System.Windows.Forms.DataGridViewCellFormattingEventHandler(this.grid_CellFormatting); // - // status - // - this.status.DataPropertyName = "Status"; - this.status.HeaderText = "Status"; - this.status.Name = "status"; - this.status.ReadOnly = true; - this.status.Width = 62; - // - // statuscolor - // - this.statuscolor.DataPropertyName = "StatusColor"; - this.statuscolor.HeaderText = "statuscolor"; - this.statuscolor.Name = "statuscolor"; - this.statuscolor.Visible = false; - this.statuscolor.Width = 83; - // - // workorderid - // - this.workorderid.DataPropertyName = "WorkorderId"; - this.workorderid.HeaderText = "workorderid"; - this.workorderid.Name = "workorderid"; - this.workorderid.Visible = false; - this.workorderid.Width = 87; - // - // customerid - // - this.customerid.DataPropertyName = "CustomerId"; - this.customerid.HeaderText = "customerid"; - this.customerid.Name = "customerid"; - this.customerid.Visible = false; - this.customerid.Width = 83; - // // wonumber // this.wonumber.DataPropertyName = "ServiceNumber"; this.wonumber.HeaderText = "Service number"; this.wonumber.Name = "wonumber"; this.wonumber.ReadOnly = true; - this.wonumber.Width = 97; + this.wonumber.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; + this.wonumber.Width = 78; + // + // customer + // + this.customer.DataPropertyName = "Customer"; + this.customer.HeaderText = "Customer"; + this.customer.Name = "customer"; + this.customer.ReadOnly = true; + this.customer.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; + this.customer.Width = 57; + // + // status + // + this.status.DataPropertyName = "Status"; + this.status.HeaderText = "Status"; + this.status.Name = "status"; + this.status.ReadOnly = true; + this.status.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; + this.status.Width = 43; + // + // statuscolor + // + this.statuscolor.DataPropertyName = "StatusColor"; + this.statuscolor.HeaderText = "statuscolor"; + this.statuscolor.Name = "statuscolor"; + this.statuscolor.ReadOnly = true; + this.statuscolor.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; + this.statuscolor.Visible = false; + this.statuscolor.Width = 64; + // + // workorderid + // + this.workorderid.DataPropertyName = "WorkorderId"; + this.workorderid.HeaderText = "workorderid"; + this.workorderid.Name = "workorderid"; + this.workorderid.ReadOnly = true; + this.workorderid.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; + this.workorderid.Visible = false; + this.workorderid.Width = 68; + // + // customerid + // + this.customerid.DataPropertyName = "CustomerId"; + this.customerid.HeaderText = "customerid"; + this.customerid.Name = "customerid"; + this.customerid.ReadOnly = true; + this.customerid.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; + this.customerid.Visible = false; + this.customerid.Width = 64; // // servicedate // @@ -278,7 +288,8 @@ this.servicedate.HeaderText = "Service date"; this.servicedate.Name = "servicedate"; this.servicedate.ReadOnly = true; - this.servicedate.Width = 85; + this.servicedate.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; + this.servicedate.Width = 66; // // project // @@ -286,7 +297,8 @@ this.project.HeaderText = "Project"; this.project.Name = "project"; this.project.ReadOnly = true; - this.project.Width = 65; + this.project.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; + this.project.Width = 46; // // linked // @@ -295,9 +307,8 @@ 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; + this.linked.Width = 45; // // MainForm // @@ -305,8 +316,6 @@ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(790, 474); this.Controls.Add(this.grid); - this.Controls.Add(this.label1); - this.Controls.Add(this.cbCustomersWithInvoiceableWorkorders); this.Controls.Add(this.menuStrip1); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.MainMenuStrip = this.menuStrip1; @@ -340,14 +349,13 @@ private System.Windows.Forms.ToolStripMenuItem technicalsupportToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem; - private System.Windows.Forms.ComboBox cbCustomersWithInvoiceableWorkorders; - private System.Windows.Forms.Label label1; private System.Windows.Forms.DataGridView grid; + private System.Windows.Forms.DataGridViewTextBoxColumn wonumber; + private System.Windows.Forms.DataGridViewTextBoxColumn customer; private System.Windows.Forms.DataGridViewTextBoxColumn status; private System.Windows.Forms.DataGridViewTextBoxColumn statuscolor; private System.Windows.Forms.DataGridViewTextBoxColumn workorderid; private System.Windows.Forms.DataGridViewTextBoxColumn customerid; - private System.Windows.Forms.DataGridViewTextBoxColumn wonumber; private System.Windows.Forms.DataGridViewTextBoxColumn servicedate; private System.Windows.Forms.DataGridViewTextBoxColumn project; private System.Windows.Forms.DataGridViewCheckBoxColumn linked; diff --git a/AyaNovaQBI/Form1.cs b/AyaNovaQBI/Form1.cs index 67bb6f9..a4f541e 100644 --- a/AyaNovaQBI/Form1.cs +++ b/AyaNovaQBI/Form1.cs @@ -19,9 +19,8 @@ namespace AyaNovaQBI private void MainForm_Load(object sender, EventArgs e) { - cbCustomersWithInvoiceableWorkorders.DataSource = util.GetCustomersWithInvoiceableItems(); - cbCustomersWithInvoiceableWorkorders.DisplayMember = "Name"; - // grid.DataSource = util.GetInvoiceableItems(); + + grid.DataSource = util.GetInvoiceableItems(); } private void grid_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) @@ -33,10 +32,10 @@ namespace AyaNovaQBI if (!isLinked) { - grid.Rows[e.RowIndex].Cells["wonumber"].ErrorText = "Not invoiceable: use \"Invoice\" -> \"Fix problems\" to resolve"; + grid.Rows[e.RowIndex].ErrorText = "Not invoiceable: use \"Invoice\" -> \"Fix problems\" to resolve"; }else { - grid.Rows[e.RowIndex].Cells["wonumber"].ErrorText = null; + grid.Rows[e.RowIndex].ErrorText = null; } } @@ -48,15 +47,6 @@ namespace AyaNovaQBI Close(); } - private void cbCustomersWithInvoiceableWorkorders_SelectedIndexChanged(object sender, EventArgs e) - { - if (cbCustomersWithInvoiceableWorkorders.SelectedValue != null) - { - var selectedNameIdItem = cbCustomersWithInvoiceableWorkorders.SelectedValue as NameIdItem; - grid.DataSource = util.GetInvoiceableItems(selectedNameIdItem.Name); - } - else - grid.DataSource = null; - } + } } diff --git a/AyaNovaQBI/Form1.resx b/AyaNovaQBI/Form1.resx index 0099a85..1c65a24 100644 --- a/AyaNovaQBI/Form1.resx +++ b/AyaNovaQBI/Form1.resx @@ -120,6 +120,12 @@ 17, 17 + + True + + + True + True @@ -132,9 +138,6 @@ True - - True - True diff --git a/AyaNovaQBI/InvoiceableItem.cs b/AyaNovaQBI/InvoiceableItem.cs index 3bc66e1..5144d88 100644 --- a/AyaNovaQBI/InvoiceableItem.cs +++ b/AyaNovaQBI/InvoiceableItem.cs @@ -8,7 +8,8 @@ namespace AyaNovaQBI { internal class InvoiceableItem { - public string Status { get; set; } + public string Customer { get; set; } + public string Status { get; set; } public string ServiceNumber { get; set; } public string ServiceDate { get; set; } public string Project { get; set; } diff --git a/AyaNovaQBI/util.cs b/AyaNovaQBI/util.cs index 0ff96ac..4753583 100644 --- a/AyaNovaQBI/util.cs +++ b/AyaNovaQBI/util.cs @@ -9,23 +9,19 @@ namespace AyaNovaQBI internal class util { - public static List GetInvoiceableItems(string customerName) + public static List GetInvoiceableItems() { var random = new Random(); var l = new List(); - for (int i = 1; i < random.Next(3,100); i++) - l.Add(new InvoiceableItem { CustomerId = 1, Linked = random.Next(2) == 1, Project = $"project {i}", ServiceDate = DateTime.Now.ToString("s"), ServiceNumber = (40+i).ToString(), Status = $"Waiting to be invoiced ({customerName})", StatusColor = "FF00FFAA", WorkorderId = 4 }); + for (int i = 1; i < random.Next(25, 100); i++) + l.Add(new InvoiceableItem { Customer = $"Customer {random.Next(1, 5)}", Linked = random.Next(2) == 1, Project = $"project {i}", ServiceDate = DateTime.Now.ToString("s"), ServiceNumber = (40 + i).ToString(), Status = $"Waiting to be invoiced", StatusColor = "FF00FFAA", WorkorderId = 4 }); + + return l.OrderBy(x => x.Customer) + .ThenBy(x => x.ServiceNumber) + .ToList(); - return l; } - public static List GetCustomersWithInvoiceableItems() - { - var random = new Random(); - var l = new List(); - for (int i = 1; i < random.Next(5,100); i++) - l.Add(new NameIdItem { Id = i, Name = $"Customer {i}"}); - return l; - } + } }