Exemplo n.º 1
0
        private void Delete_Click(object sender, RoutedEventArgs e)
        {
            Class_point_gr gr;

            if (data_grid1.SelectedItem != null || data_grid2.SelectedItem != null)
            {
                using (bd_table db = new bd_table())
                {
                    if (data_grid1.SelectedItem != null)
                    {
                        gr = data_grid1.SelectedItem as Class_point_gr;
                    }
                    else
                    {
                        gr = data_grid2.SelectedItem as Class_point_gr;
                    }

                    var item = db.table.ToList().Where(u => u.Id == gr.Id).First();
                    if (item != null)
                    {
                        db.table.Remove(item);
                        db.SaveChanges();
                    }

                    Window_Activated(sender, e);
                }
            }
        }
Exemplo n.º 2
0
        private void Window_Activated(object sender, EventArgs e)
        {
            using (var db = new bd_table())
            {
                list_gr1 = new List <Class_point_gr>();
                list_gr2 = new List <Class_point_gr>();

                foreach (Class_table str in db.table.ToList())
                {
                    if (str.index == "Тspkoп")
                    {
                        list_gr1.Add(new Class_point_gr()
                        {
                            Id = str.Id, Name = str.Name, xy = str.xy
                        });
                    }
                    else
                    {
                        list_gr2.Add(new Class_point_gr()
                        {
                            Id = str.Id, Name = str.Name, xy = str.xy
                        });
                    }
                }
                data_grid1.ItemsSource = list_gr1;
                data_grid2.ItemsSource = list_gr2;
            }
        }
 private void Save_Click(object sender, RoutedEventArgs e)
 {
     if (Name_box.Text == "" || type_gr.Text == "")
     {
         MessageBox.Show("Перевірте поля, деякі поля є пустими.");
     }
     else
     {
         using (bd_table db = new bd_table())
         {
             if (gr_table != null)
             {
                 gr_table.xy = String.Empty;
                 Add_data(Convert.ToInt32(numericUpDown.Value));
                 db.table.Update(gr_table);
             }
             else
             {
                 gr_table = new Class_table();
                 Add_data(Convert.ToInt32(numericUpDown.Value));
                 db.table.Add(gr_table);
             }
             db.SaveChanges();
         }
         window.Activate();
         this.Close();
     }
 }
Exemplo n.º 4
0
 public App()
 {
     using (var db = new bd_table())
     {
         db.Database.Migrate();
     }
 }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            if (Class_Model.Buffer != null)
            {
                var id = Convert.ToInt32(Class_Model.Buffer);
                using (bd_table db = new bd_table())
                {
                    gr_table = db.table.FirstOrDefault(c => c.Id == id);
                }
            }

            if (gr_table != null)
            {
                this.Title          = "Редагування даних графіка";
                count_txtbox        = gr_table.xy.Split(';').Length - 1;
                numericUpDown.Value = count_txtbox;
                Name_box.Text       = gr_table.Name;
                type_gr.Text        = gr_table.index;
                Edit_data(gr_table.xy);
            }
        }