private void Button_Click(object sender, RoutedEventArgs e) { AddClientForm addClientForm = new AddClientForm(userId); if (addClientForm.ShowDialog() == true) { this.DataContext = new AppViewModel(userId); } //AddClientForm f = new AddClientForm(); ////DialogResult result = f.ShowDialog(this); ////if (result == DialogResult.Cancel) //// return; //Client client = new Client(); //client.Phones = f.txtPhones.Text; //client.Passport = f.txtPas.Text; //client.FIO = f.txtFIO.Text; //client.Address = f.txtAdd.Text; //// client.ID_client = 3; //client.ID_user_FK = 1; //dbcontext.Client.Add(client); //dataGrid1.Items.Refresh(); //db.SaveChanges(); //MessageBox.Show("Новый объект добавлен"); }
private void dataGrid1_SelectionChanged(object sender, SelectionChangedEventArgs e) { //ClientsForm clientsForm = new ClientsForm(); //clientsForm.Show(); if (dataGrid1.SelectedItems.Count == 1) { var selectedClient = (dataGrid1.SelectedItems[0] as Client); //System.Windows.MessageBox.Show(selectedRealtyId); AddClientForm addClientForm = new AddClientForm(selectedClient); if (addClientForm.ShowDialog() == true) { this.DataContext = new AppViewModel(userId); } } }