private void CustomersGV_CellClick(object sender, DataGridViewCellEventArgs e) { var purchases = new BusinessLayer.FooEnterprises.CustomerProducts(); var customers = new BusinessLayer.FooEnterprises.Customers(); if (e.RowIndex >= 0) { int prk = Convert.ToInt32(CustomersGV.SelectedCells[0].Value); purchases.GetByCustomerId(prk); foreach (BusinessLayer.FooEnterprises.CustomerProduct purchase in purchases) { if (c4 <= purchases.Count()) { dataGridView1.Rows.Add(); c4++; } dataGridView1.Rows[0].Cells[0].Value = purchase.CustomerProductId; dataGridView1.Rows[0].Cells[1].Value = purchase.FCustomerId.FirstName; dataGridView1.Rows[0].Cells[2].Value = purchase.FCustomerId.LastName; dataGridView1.Rows[0].Cells[3].Value = purchase.FProductId.ProductName; dataGridView1.Rows[0].Cells[4].Value = purchase.FProductId.WholesaleCost; dataGridView1.Rows[0].Cells[5].Value = purchase.FProductId.SaleCost; } } }
private void Show_Click(object sender, EventArgs e) { var customers = new BusinessLayer.FooEnterprises.Customers(); var products = new BusinessLayer.FooEnterprises.Products(); var purchases = new BusinessLayer.FooEnterprises.CustomerProducts(); customers.GetAll(); products.GetAll(); purchases.GetAll(); int n = 0; foreach (BusinessLayer.FooEnterprises.Customer customer in customers) { if (c1 <= customers.Count()) { CustomersGV.Rows.Add(); c1++; } CustomersGV.Rows[n].Cells[0].Value = customer.CustomerId; CustomersGV.Rows[n].Cells[1].Value = customer.FirstName; CustomersGV.Rows[n].Cells[2].Value = customer.LastName; n++; } n = 0; foreach (BusinessLayer.FooEnterprises.Product product in products) { if (c2 <= products.Count()) { ProductGV.Rows.Add(); c2++; } ProductGV.Rows[n].Cells[0].Value = product.ProductId; ProductGV.Rows[n].Cells[1].Value = product.ProductName; ProductGV.Rows[n].Cells[2].Value = product.WholesaleCost; ProductGV.Rows[n].Cells[3].Value = product.SaleCost; n++; } n = 0; foreach (BusinessLayer.FooEnterprises.CustomerProduct purchase in purchases) { if (c3 <= purchases.Count()) { CustomerProductGV.Rows.Add(); c3++; } CustomerProductGV.Rows[n].Cells[0].Value = purchase.CustomerProductId; CustomerProductGV.Rows[n].Cells[1].Value = purchase.CustomerId; CustomerProductGV.Rows[n].Cells[2].Value = purchase.ProductId; n++; } }