Beispiel #1
0
        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();
            }
        }
Beispiel #2
0
        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;
            }
        }
Beispiel #3
0
        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();
            }
        }
Beispiel #4
0
        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();
            }
        }
Beispiel #5
0
        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();
            }
        }