private void btnAdd_Click(object sender, RoutedEventArgs e) { wndDevice WndDevice = new wndDevice(); if (WndDevice.ShowDialog() == true) { Members.Device dev = new Members.Device(); dev.Name = WndDevice.DevName; dev.IP = WndDevice.IP; dev.WorkToTO = WndDevice.WorkToTo; dev.IsComm = false; Devices.Add(dev); ent.Devices.Add(new MonitoringDGU.Devices() { Name = dev.Name, IP = dev.IP, FullWork = 0, WorkToTO = dev.WorkToTO }); ent.SaveChanges(); } }
private void btnEdit_Click(object sender, RoutedEventArgs e) { if (SelectedDevice != null) { wndDevice WndDevice = new wndDevice(); WndDevice.DevName = SelectedDevice.Name; WndDevice.IP = SelectedDevice.IP; WndDevice.WorkToTo = SelectedDevice.WorkToTO; if (WndDevice.ShowDialog() == true) { SelectedDevice.Name = WndDevice.DevName; SelectedDevice.IP = WndDevice.IP; SelectedDevice.WorkToTO = WndDevice.WorkToTo; var dev = ent.Devices.FirstOrDefault(d => d.ID == SelectedDevice.ID); //измененя в базе dev.Name = SelectedDevice.Name; dev.IP = SelectedDevice.IP; dev.WorkToTO = SelectedDevice.WorkToTO; ent.SaveChanges(); } } }