Question: In C# i created a invoice, which has a list view with these columns in this order, Customer, Invoice id, Invoice date, invoice total. When

In C# i created a invoice, which has a list view with these columns in this order, Customer, Invoice id, Invoice date, invoice total. When i run the program the info is dsplayed under the wron coulmn heading, Under the customer heading its diplaying the toatal, under the invoice id its dispalying the customer name, under invoice date its showig the id and under the invoice total its showing the date. not sure what i did wrong here is the code,

public partial class Form1 : Form { public Form1() { InitializeComponent(); }

private void Form1_Load(object sender, EventArgs e) // get invoice method { List customerList = CustomerDB.GetCustomers(); List invoiceList = InvoiceDB.GetInvoices();

// store list in varible

var invoices = from Invoice in invoiceList join customer in customerList on Invoice.CustomerID equals customer.CustomerID orderby customer.Name, Invoice.InvoiceTotal descending select new { customer.Name, Invoice.InvoiceID, Invoice.InvoiceDate, Invoice.InvoiceTotal };

string customerName = ""; int i = 0;

// foreach statment to execute the query

foreach (var invoice in invoices) { if (invoice.Name != customerName) { lvlnvoices.Items.Add(invoice.Name); customerName = invoice.Name; } else { lvlnvoices.Items.Add(""); } lvlnvoices.Items[i].SubItems.Add(invoice.InvoiceID.ToString()); lvlnvoices.Items[i].SubItems.Add( Convert.ToDateTime(invoice.InvoiceDate).ToShortDateString()); lvlnvoices.Items[i].SubItems.Add(invoice.InvoiceTotal.ToString("c")); i += 1; } } } // end of class } // end of name space

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!