public static int targetButton = 0; // numer z którego korzysta FanDetails odnośnie zdarzenia public Fan() { InitializeComponent(); var ctx = new IDoveEntities(); DataGrid.ItemsSource = ctx.Fancier.ToList(); }
public Pig() { InitializeComponent(); var ctx = new IDoveEntities(); DataGrid.ItemsSource = ctx.Pigeon.ToList(); }
public FlgR() { InitializeComponent(); var ctx = new IDoveEntities(); DataGrid.ItemsSource = ctx.FlightResult.ToList(); }
private void DeletePigeon_Click(object sender, RoutedEventArgs e) { var selectedItem = DataGrid.SelectedItem; if (selectedItem != null) { string fan_id = (DataGrid.SelectedItem as Fancier).IdFancier; var ctx = new IDoveEntities(); Fancier fan = (from f in ctx.Fancier where f.IdFancier == fan_id select f).SingleOrDefault(); ctx.Fancier.Remove(fan); ctx.SaveChanges(); DataGrid.ItemsSource = ctx.Fancier.ToList(); } }
private void DeletePigeon_Click(object sender, RoutedEventArgs e) { var selectedItem = DataGrid.SelectedItem; if (selectedItem != null) { string pig_id = (DataGrid.SelectedItem as Pigeon).IdPigeon; var ctx = new IDoveEntities(); Pigeon pig = (from p in ctx.Pigeon where p.IdPigeon == pig_id select p).SingleOrDefault(); ctx.Pigeon.Remove(pig); ctx.SaveChanges(); DataGrid.ItemsSource = ctx.Pigeon.ToList(); } }
private void TX_Complete_Click(object sender, RoutedEventArgs e) { switch (Fan.targetButton) { case 1: { Fancier fancier = new Fancier() { IdFancier = TX_IdFancier.Text, IdSection = Convert.ToInt32(TX_IdSection.Text), IdDovecote = Convert.ToInt32(TX_IdDovecote.Text), FirstName = TX_FName.Text, LastName = TX_LName.Text, Adress = TX_Adress.Text, City = TX_City.Text, Mail = TX_Mail.Text, Telephone_Number = TX_Tel.Text }; using (var ctx = new IDoveEntities()) { ctx.Fancier.Add(fancier); ctx.SaveChanges(); ClearTextbox(); Fanpage.DataGrid.ItemsSource = ctx.Fancier.ToList(); //odświeżanie datagrid } } break; case 2: { using (var ctx = new IDoveEntities()) { var stList = ctx.Fancier.ToList <Fancier>(); Fancier fanciermodyf = stList.Where(f => f.IdFancier == (TX_IdFancier.Text)).FirstOrDefault <Fancier>(); fanciermodyf.FirstName = TX_FName.Text; fanciermodyf.LastName = TX_LName.Text; fanciermodyf.Adress = TX_Adress.Text; fanciermodyf.City = TX_City.Text; fanciermodyf.Mail = TX_Mail.Text; fanciermodyf.Telephone_Number = TX_Tel.Text; fanciermodyf.IdDovecote = Convert.ToInt32(TX_IdDovecote.Text); fanciermodyf.IdSection = Convert.ToInt32(TX_IdSection.Text); ctx.SaveChanges(); ClearTextbox(); TX_IdFancier.IsEnabled = true; Fanpage.DataGrid.ItemsSource = ctx.Fancier.ToList(); } } break; } }
private void DeleteResult_Click(object sender, RoutedEventArgs e) { var selectedItem = DataGrid.SelectedItem; if (selectedItem != null) { int id = (DataGrid.SelectedItem as FlightResult).IdFlightResult; var ctx = new IDoveEntities(); FlightResult result = (from f in ctx.FlightResult where f.IdFlightResult == id select f).SingleOrDefault(); ctx.FlightResult.Remove(result); ctx.SaveChanges(); DataGrid.ItemsSource = ctx.FlightResult.ToList(); } }
public Sec() { Dispatcher.BeginInvoke(DispatcherPriority.Loaded, new Action(() => { var navWindow = Window.GetWindow(this) as NavigationWindow; if (navWindow != null) { navWindow.ShowsNavigationUI = false; } })); InitializeComponent(); var ctx = new IDoveEntities(); DataGridRegion.ItemsSource = ctx.Section.ToList(); }
private void BT_AddSection_Click(object sender, RoutedEventArgs e) { Section section = new IDove.Section() { IdBranch = TX_IdBranch.Text, Name = TX_Name.Text }; using (var ctx = new IDoveEntities()) { ctx.Section.Add(section); ctx.SaveChanges(); ClearTextbox(); } }