コード例 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            // Save data or call delegate

            try
            {
                CustomersEntities ce = new CustomersEntities();
                ce.Customers.Add(new Customers
                {
                    Firstname   = FirstNameTextBox.Text,
                    Lastname    = LastNameTextBox.Text,
                    Address     = AddressTextBox.Text,
                    CountryCode = (string)CountryListcomboBox.SelectedValue
                });
                ce.SaveChanges();   //Doesn't actually save. Might need to use an adapter or a 'real' SQL server than .mdf

                MessageBox.Show("New customer added (or at least want you to think so)");

                this.DialogResult = DialogResult.OK;
            }
            catch (Exception exp)
            {
                //TODO: Validations, and proper error handling
                MessageBox.Show("An error occoured: " + exp.Message);
            }
        }
コード例 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            // Save data or call delegate

            try
            {
                CustomersEntities ce = new CustomersEntities();
                ce.Customers.Add(new Customers
                {
                    Firstname = FirstNameTextBox.Text,
                    Lastname = LastNameTextBox.Text,
                    Address = AddressTextBox.Text,
                    CountryCode = (string)CountryListcomboBox.SelectedValue
                });
                ce.SaveChanges();   //Doesn't actually save. Might need to use an adapter or a 'real' SQL server than .mdf

                MessageBox.Show("New customer added (or at least want you to think so)");

                this.DialogResult = DialogResult.OK;
            }
            catch (Exception exp)
            {
                //TODO: Validations, and proper error handling
                MessageBox.Show("An error occoured: " + exp.Message);
            }
        }