Example #1
0
        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();
        }
Example #2
0
        public Pig()
        {
            InitializeComponent();
            var ctx = new IDoveEntities();

            DataGrid.ItemsSource = ctx.Pigeon.ToList();
        }
Example #3
0
        public FlgR()
        {
            InitializeComponent();
            var ctx = new IDoveEntities();

            DataGrid.ItemsSource = ctx.FlightResult.ToList();
        }
Example #4
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();
            }
        }
Example #5
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();
            }
        }
Example #6
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;
            }
        }
Example #7
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();
            }
        }
Example #8
0
        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();
        }
Example #9
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();
            }
        }