示例#1
0
        private void Button2_Click(object sender, EventArgs e)
        {
            NewCustomer newCustomer = new NewCustomer();

            if (newCustomer.ShowDialog() == DialogResult.OK)
            {
                Customer customer = new Customer
                {
                    CustomerID  = newCustomer.textBox1.Text,
                    CompanyName = newCustomer.textBox2.Text,
                    ContactName = newCustomer.textBox3.Text,
                    Address     = newCustomer.textBox4.Text,
                    City        = newCustomer.textBox5.Text,
                    PostalCode  = newCustomer.textBox6.Text,
                    Country     = newCustomer.textBox7.Text
                };

                dal.InsertCustomer(customer);
                dataGridView1.DataSource = dal.GetDataAsTable("Customers");
            }
        }