예제 #1
0
파일: Form1.cs 프로젝트: Mikhail174/DZUrok8
 public void button1_Click(object sender, EventArgs e)
 {
     System.Windows.Forms.DialogResult result = new AddCustomerDialog(customers).ShowDialog();
     commandBuilder         = new SqlCommandBuilder(adapter1);
     adapter1.UpdateCommand = commandBuilder.GetUpdateCommand();
     label1.Text            = commandBuilder.GetUpdateCommand().CommandText;
     adapter1.Update(shopDB, "Customers");
     customers.Clear();
     adapter1.Fill(shopDB);
 }
예제 #2
0
        // Helper
        private void OpenAddCustomerDialog(string obj)
        {
            var addCustomerDialog = new AddCustomerDialog(db);

            if (addCustomerDialog.ShowDialog() == true)
            {
                addCustomerDialog.AddCustomer();
                Customers = db.Customers.AsObservableCollection();
            }
        }
        /// <summary>
        /// Event handler when the user clicks the "add customer" button.
        /// Opens an <see cref="Dialogs.AddCustomerDialog"/> and saves/updates data as necessary.
        /// </summary>
        /// <param name="sender">the sender of this event</param>
        /// <param name="e">the event arguments of this event</param>
        private void AddCustomerButton_OnClick(object sender, RoutedEventArgs e)
        {
            SaveChanges();

            var newCustomerDialog = new AddCustomerDialog(clients);
            var dialogResult      = newCustomerDialog.ShowDialog();

            if (dialogResult == true)
            {
                filter = new Filter()
                {
                    IdValue = newCustomerDialog.CreatedCustomerID.ToString()
                };
                ClearFilterButtonActive = true;

                UpdateData();
            }
        }