//一个填充Northwind数据库中产品和供应商到DataSet中去的函数
 protected void FillDataSet()
 {
     ProductsTableAdapter productadapter = new ProductsTableAdapter();
     productadapter.Fill(ds.Products);
     SuppliersTableAdapter supplieradapter = new SuppliersTableAdapter();
     supplieradapter.Fill(ds.Suppliers);
 }
    //一个填充Northwind数据库中产品和供应商到DataSet中去的函数
    protected void FillDataSet()
    {
        ProductsTableAdapter productadapter = new ProductsTableAdapter();

        productadapter.Fill(ds.Products);
        SuppliersTableAdapter supplieradapter = new SuppliersTableAdapter();

        supplieradapter.Fill(ds.Suppliers);
    }
示例#3
0
        //connection to the database
        private void get_data()
        {
            ds = new DataSet1();

            st = new InventoryTableAdapter();
            st.Fill(ds.Inventory);

            ct = new SuppliersTableAdapter();
            ct.Fill(ds.Suppliers);

            et = new EmployeesTableAdapter();
            et.Fill(ds.Employees);
        }
        private void CopySuppliers(IOdb odb)
        {
            //Processing Suppliers
            LogMessage("Reading Suppliers...", false);
            var adapter1 = new SuppliersTableAdapter();
            var table1   = adapter1.GetData();

            LogMessage("processing " + table1.Count.ToString() + " rows", true);
            foreach (var row in table1)
            {
                LogMessage("Supplier: " + row.SupplierID.ToString() + " ...", false);

                var s = new Supplier
                {
                    SupplierID   = row.SupplierID,
                    CompanyName  = row.CompanyName,
                    ContactName  = row.IsContactNameNull() ? null : row.ContactName,
                    ContactTitle = row.IsContactTitleNull() ? null : row.ContactTitle,
                    Address      = row.IsAddressNull() ? null : row.Address,
                    City         = row.IsCityNull() ? null : row.City,
                    Region       = row.IsRegionNull() ? null : row.Region,
                    PostalCode   = row.IsPostalCodeNull() ? null : row.PostalCode,
                    Country      = row.IsCountryNull() ? null : row.Country,
                    Phone        = row.IsPhoneNull() ? null : row.Phone,
                    Fax          = row.IsFaxNull() ? null : row.Fax,
                    HomePage     = row.IsHomePageNull() ? null : row.HomePage
                };

                odb.Store(s);
                LogMessage("saved", true);
            }
            odb.Commit();

            LogMessage("Commit done, starting create index ...", false);
            odb.IndexManagerFor <Supplier>().AddUniqueIndexOn("Supplier_SupplierID_PK_index", Supplier.PK);
            odb.Commit();
            LogMessage(" index created.", true);

            long objectCount = NDbUtil.GetAllInstances <Supplier>(odb).Count;

            if (table1.Count == objectCount)
            {
                LogMessage(table1.Count + " objects saved", true);
            }
            else
            {
                LogMessage("Error: " + table1.Count + " rows retrieved but " + objectCount + " objects were saved", true);
            }
            LogMessage("Done with Suppliers" + Environment.NewLine, true);
        }
示例#5
0
        private void BindWorksheetToDataSource()
        {
            dataSet = new NWindDataSet();
            adapter = new SuppliersTableAdapter();
            // Populate the "Suppliers" data table with data.
            adapter.Fill(dataSet.Suppliers);

            IWorkbook workbook = spreadsheetControl.Document;

            // Load the template document into the SpreadsheetControl.
            workbook.LoadDocument("Documents\\Suppliers_template.xlsx", DocumentFormat.Xlsx);
            Worksheet sheet = workbook.Worksheets[0];

            // Load data from the "Suppliers" data table into the worksheet starting from the cell "B12".
            sheet.DataBindings.BindToDataSource(dataSet.Suppliers, 11, 1);
        }
示例#6
0
        /*
         * Function get_data()
         * Fills database tables using DataSet.
         */
        private void get_data()
        {
            ds   = new DataSet1();
            mt   = new MenuTableAdapter();
            it   = new InventoryTableAdapter();
            et   = new EmployeesTableAdapter();
            ot   = new OrdersTableAdapter();
            olt  = new OrderlineTableAdapter();
            st   = new SuppliersTableAdapter();
            pot  = new PurchaseOrdersTableAdapter();
            polt = new PurchaseOrderlineTableAdapter();

            mt.Fill(ds.Menu);
            it.Fill(ds.Inventory);
            et.Fill(ds.Employees);
            ot.Fill(ds.Orders);
            olt.Fill(ds.Orderline);
            st.Fill(ds.Suppliers);
            pot.Fill(ds.PurchaseOrders);
            polt.Fill(ds.PurchaseOrderline);
        }
示例#7
0
 public Form1()
 {
     InitializeComponent();
     dataSet = new NWindDataSet();
     adapter = new SuppliersTableAdapter();
 }
示例#8
0
        public void CopySuppliers()
        {
            //Processing Suppliers
            LogMessage("Reading Suppliers...", false);
            SuppliersTableAdapter adapter1 = new SuppliersTableAdapter();
            NorthwindDb4o.NorthwindDataSet.SuppliersDataTable table1 = adapter1.GetData();
            LogMessage("processing " + table1.Count.ToString() + " rows", true);
            foreach (NorthwindDb4o.NorthwindDataSet.SuppliersRow row in table1)
            {
                LogMessage("Supplier: " + row.SupplierID.ToString() + " ...", false);

                Supplier s = new Supplier();

                s.SupplierID = row.SupplierID;
                s.CompanyName = row.CompanyName;
                s.ContactName = row.IsContactNameNull() ? null : row.ContactName;
                s.ContactTitle = row.IsContactTitleNull() ? null : row.ContactTitle;
                s.Address = row.IsAddressNull() ? null : row.Address;
                s.City = row.IsCityNull() ? null : row.City;
                s.Region = row.IsRegionNull() ? null : row.Region;
                s.PostalCode = row.IsPostalCodeNull() ? null : row.PostalCode;
                s.Country = row.IsCountryNull() ? null : row.Country;
                s.Phone = row.IsPhoneNull() ? null : row.Phone;
                s.Fax = row.IsFaxNull() ? null : row.Fax;
                s.HomePage = row.IsHomePageNull() ? null : row.HomePage;

                container.Store(s);
                LogMessage("saved", true);
            }
            container.Commit();
            long objectCount = Db4oUtil.GetAllInstances(container, typeof(Supplier)).Count;
            if (table1.Count == objectCount)
                LogMessage(table1.Count + " objects saved", true);
            else
                LogMessage("Error: " + table1.Count + " rows retrieved but " + objectCount + " objects were saved", true);
            LogMessage("Done with Suppliers" + Environment.NewLine, true);
        }
示例#9
0
        private void CopySuppliers(IOdb odb)
        {
            //Processing Suppliers
            LogMessage("Reading Suppliers...", false);
            var adapter1 = new SuppliersTableAdapter();
            var table1 = adapter1.GetData();
            LogMessage("processing " + table1.Count.ToString() + " rows", true);
            foreach (var row in table1)
            {
                LogMessage("Supplier: " + row.SupplierID.ToString() + " ...", false);

                var s = new Supplier
                            {
                                SupplierID = row.SupplierID,
                                CompanyName = row.CompanyName,
                                ContactName = row.IsContactNameNull() ? null : row.ContactName,
                                ContactTitle = row.IsContactTitleNull() ? null : row.ContactTitle,
                                Address = row.IsAddressNull() ? null : row.Address,
                                City = row.IsCityNull() ? null : row.City,
                                Region = row.IsRegionNull() ? null : row.Region,
                                PostalCode = row.IsPostalCodeNull() ? null : row.PostalCode,
                                Country = row.IsCountryNull() ? null : row.Country,
                                Phone = row.IsPhoneNull() ? null : row.Phone,
                                Fax = row.IsFaxNull() ? null : row.Fax,
                                HomePage = row.IsHomePageNull() ? null : row.HomePage
                            };

                odb.Store(s);
                LogMessage("saved", true);
            }
            odb.Commit();

            LogMessage("Commit done, starting create index ...", false);
            odb.IndexManagerFor<Supplier>().AddUniqueIndexOn("Supplier_SupplierID_PK_index", Supplier.PK);
            odb.Commit();
            LogMessage(" index created.", true);

            long objectCount = NDbUtil.GetAllInstances<Supplier>(odb).Count;
            if (table1.Count == objectCount)
                LogMessage(table1.Count + " objects saved", true);
            else
                LogMessage("Error: " + table1.Count + " rows retrieved but " + objectCount + " objects were saved", true);
            LogMessage("Done with Suppliers" + Environment.NewLine, true);
        }