Пример #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            //initializes the data set with two tables
            clsBookData = new BookData();
            bookDataSet = clsBookData.GetDataSet();

            //initializes the sources and references the table customers
            customerSource            = new BindingSource();
            customerSource.DataSource = bookDataSet;
            customerSource.DataMember = "Customers";

            //initializes the source and references the table invoices
            invoiceSource            = new BindingSource();
            invoiceSource.DataSource = bookDataSet;
            invoiceSource.DataMember = "Invoices";

            //the data source
            txtName.DataSource    = bookDataSet.Tables[0];
            txtName.DisplayMember = "Name";
            txtName.ValueMember   = "CustomerID";

            txtCustomerID.DataBindings.Add("Text", customerSource, "CustomerID");
            txtAddress.DataBindings.Add("Text", customerSource, "Address");
            txtCity.DataBindings.Add("Text", customerSource, "City");
            txtState.DataBindings.Add("Text", customerSource, "State");
            txtZip.DataBindings.Add("Text", customerSource, "ZipCode");

            txtName_SelectionChangeCommitted(txtName, e);
        }
Пример #2
0
        public MMABooksDataSet GetDataSet()
        {
            customerAdapter = new MMABooksDataSetTableAdapters.CustomersTableAdapter();
            invoiceAdapter  = new MMABooksDataSetTableAdapters.InvoicesTableAdapter();
            dataSet         = new MMABooksDataSet();

            customerAdapter.Fill(dataSet.Customers);
            invoiceAdapter.Fill(dataSet.Invoices);

            return(dataSet);
        }