Exemple #1
0
        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            GameArray ga         = new GameArray();
            var       thisobject = listBox1.SelectedItem as GameArray;

            textBox1.Text = thisobject.Seed;
            nameBox.Text  = thisobject.Name;
        }
Exemple #2
0
 //D
 public void DeleteFromDb(GameArray o)
 {
     using (Context context = new Context())
     {
         var objecttoRemove = context.GameArrays.Find(o);
         context.GameArrays.Remove(objecttoRemove);
         context.SaveChanges();
     }
 }
Exemple #3
0
        //TODO:

        //C
        public void AddToDB(GameArray o)
        {
            using (Context context = new Context())
            {
                var objecttoAdd = o as GameArray;
                context.GameArrays.Add(o);
                context.SaveChanges();
            }
        }
Exemple #4
0
        void Populate()
        {
            listBox1.ResetText();
            GameArray ga = new GameArray();

            using (Context conn = new Context())
            {
                listBox1.DataSource    = conn.GameArrays.ToList();
                listBox1.DisplayMember = "Name";
            }
        }
Exemple #5
0
        private void Delete_Click(object sender, System.EventArgs e)
        {
            GameArray ga       = new GameArray();
            var       deleteme = listBox1.SelectedItem as GameArray;


            try
            {
                ga.DeleteFromDb(deleteme);
            }
            catch { MessageBox.Show("Error Removing"); }
            Populate();
        }
Exemple #6
0
 private void saveButton_Click(object sender, EventArgs e)
 {
     try
     {
         SeedString = textBox1.Text;
         GameArray ga = new GameArray {
             Name = nameBox.Text.ToString(), Seed = SeedString
         };
         ga.AddToDB(ga);
     }
     catch
     {
         MessageBox.Show("Error Saving");
     }
     Populate();
 }
Exemple #7
0
        //R



        //U
        public void UpdateDb(GameArray o)
        {
            using (Context context = new Context())
            {
            }
        }