コード例 #1
0
        private void SearchData(object sender, EventArgs e)
        {
            //searching record or customer using foreing key
            int n         = 0;
            var purchases = new BusinessLayer.CustomerProducts();

            purchases.GetByCustomerId(Convert.ToInt32(SearchCustomerId.Text)); //giving and converting the id from textbox

            foreach (BusinessLayer.CustomerProduct purchase in purchases)
            {
                //FCutomerId and FProduct is being used as a foreing Key
                dataGridView4.Rows[n].Cells[0].Value = purchase.FCustomerId.CustomerId;
                dataGridView4.Rows[n].Cells[1].Value = purchase.FCustomerId.FirstName;
                dataGridView4.Rows[n].Cells[2].Value = purchase.FCustomerId.LastName;
                dataGridView6.Rows[n].Cells[0].Value = purchase.FProductId.ProductId;
                dataGridView6.Rows[n].Cells[1].Value = purchase.FProductId.ProductName;
                dataGridView6.Rows[n].Cells[2].Value = purchase.FProductId.WholesaleCost;
                dataGridView6.Rows[n].Cells[3].Value = purchase.FProductId.SaleCost;
            }
        }
コード例 #2
0
        private void btnShow(object sender, EventArgs e)
        {
            //// TODO: This line of code loads data into the 'fooEnterprisesDataSet2.Product' table. You can move, or remove it, as needed.
            //this.productTableAdapter.Fill(this.fooEnterprisesDataSet2.Product);
            //// TODO: This line of code loads data into the 'fooEnterprisesDataSet1.CustomerProduct' table. You can move, or remove it, as needed.
            //this.customerProductTableAdapter.Fill(this.fooEnterprisesDataSet1.CustomerProduct);
            //// TODO: This line of code loads data into the 'fooEnterprisesDataSet.Customer' table. You can move, or remove it, as needed.
            //this.customerTableAdapter.Fill(this.fooEnterprisesDataSet.Customer);


            //showing data through layerGen
            var customers = new BusinessLayer.Customers(true);
            var products  = new BusinessLayer.Products(true);
            var purchases = new BusinessLayer.CustomerProducts(true);
            int n         = 0;
            int o         = 0;
            int p         = 0;

            customers.GetAll();
            products.GetAll();
            purchases.GetAll();
            //showing data of customer in customer table
            foreach (BusinessLayer.Customer customer in customers)
            {
                if (count1 <= customers.Count)
                {
                    dataGridView1.Rows.Add();
                    count1++;
                }

                dataGridView1.Rows[n].Cells[0].Value = customer.CustomerId;
                dataGridView1.Rows[n].Cells[1].Value = customer.FirstName;
                dataGridView1.Rows[n].Cells[2].Value = customer.LastName;
                n++;
            }
            //showing data of customerproduct in customerproduct table
            foreach (BusinessLayer.CustomerProduct purchase in purchases)
            {
                if (count2 <= customers.Count)
                {
                    dataGridView2.Rows.Add();
                    count2++;
                }

                dataGridView2.Rows[p].Cells[0].Value = purchase.CustomerProductId;
                dataGridView2.Rows[p].Cells[1].Value = purchase.CustomerId;
                dataGridView2.Rows[p].Cells[2].Value = purchase.ProductId;
                p++;
            }
            //showing data of product in product table
            foreach (BusinessLayer.Product product in products)
            {
                if (count3 <= customers.Count)
                {
                    dataGridView3.Rows.Add();
                    count3++;
                }
                dataGridView3.Rows[o].Cells[0].Value = product.ProductId;
                dataGridView3.Rows[o].Cells[1].Value = product.ProductName;
                dataGridView3.Rows[o].Cells[2].Value = product.WholesaleCost;
                dataGridView3.Rows[o].Cells[3].Value = product.SaleCost;
                o++;
            }
        }