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 DataGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            targetButton = 3;
            var selectedItem = DataGrid.SelectedItem;

            if (selectedItem != null)
            {
                string IdFancier        = (DataGrid.SelectedItem as Fancier).IdFancier;
                int    IdSection        = (DataGrid.SelectedItem as Fancier).IdSection;
                int    IdDovecote       = (DataGrid.SelectedItem as Fancier).IdDovecote;
                string FirstName        = (DataGrid.SelectedItem as Fancier).FirstName;
                string LastName         = (DataGrid.SelectedItem as Fancier).LastName;
                string Adress           = (DataGrid.SelectedItem as Fancier).Adress;
                string City             = (DataGrid.SelectedItem as Fancier).City;
                string Mail             = (DataGrid.SelectedItem as Fancier).Mail;
                string Telephone_Number = (DataGrid.SelectedItem as Fancier).Telephone_Number;

                fancier = new Fancier(IdFancier, IdSection, IdDovecote, FirstName, LastName, Adress, City, Mail, Telephone_Number);
                FanDetails f = new FanDetails();
                FR_Fancier.Navigate(f);
            }
        }