Esempio n. 1
0
    public static void LoadStaticCache()
    {
        // Get suppliers - cache using a static member variable
        SuppliersBLL suppliersBLL = new SuppliersBLL();

        suppliers = suppliersBLL.GetSuppliers();
    }
Esempio n. 2
0
    public bool UpdateSupplierAddress(int supplierID, string address, string city, string country)
    {
        Northwind.SuppliersDataTable suppliers = Adapter.GetSupplierBySupplierID(supplierID);
        if (suppliers.Count == 0)
        {
            // no matching record found, return false
            return(false);
        }
        else
        {
            Northwind.SuppliersRow supplier = suppliers[0];

            if (address == null)
            {
                supplier.SetAddressNull();
            }
            else
            {
                supplier.Address = address;
            }
            if (city == null)
            {
                supplier.SetCityNull();
            }
            else
            {
                supplier.City = city;
            }
            if (country == null)
            {
                supplier.SetCountryNull();
            }
            else
            {
                supplier.Country = country;
            }

            // Update the product record
            int rowsAffected = Adapter.Update(supplier);

            // Return true if precisely one row was updated, otherwise false
            return(rowsAffected == 1);
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        NorthwindTableAdapters.SuppliersTableAdapter suppliersAdapter = new NorthwindTableAdapters.SuppliersTableAdapter();

        // Get all of the suppliers
        Northwind.SuppliersDataTable suppliers = suppliersAdapter.GetSuppliers();

        // Enumerate the suppliers
        foreach (Northwind.SuppliersRow supplier in suppliers)
        {
            Response.Write("Supplier: " + supplier.CompanyName);
            Response.Write("<ul>");

            // List the products for this supplier
            Northwind.ProductsDataTable products = supplier.GetProducts();
            foreach (Northwind.ProductsRow product in products)
            {
                Response.Write("<li>" + product.ProductName + "</li>");
            }

            Response.Write("</ul><p>&nbsp;</p>");
        }
    }