Exemplo n.º 1
0
        private void btnRemoveData_Click(object sender, EventArgs e)
        {
            pp_dbEntities db = new pp_dbEntities();

            if (lblData.Text == "Жанр")
            {
                int    id          = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells[0].Value.ToString());
                genres delete_item = db.genres.Find(id);
                db.genres.Remove(delete_item);
                db.SaveChanges();
            }
            else if (lblData.Text == "Страна")
            {
                int     id          = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells[0].Value.ToString());
                country delete_item = db.country.Find(id);
                db.country.Remove(delete_item);
                db.SaveChanges();
            }
            else
            {
                int       id          = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells[0].Value.ToString());
                agerating delete_item = db.agerating.Find(id);
                db.agerating.Remove(delete_item);
                db.SaveChanges();
            }
            zapis();
        }
Exemplo n.º 2
0
        private void btnAddData_Click(object sender, EventArgs e)
        {
            pp_dbEntities db = new pp_dbEntities();

            if (txtboxData.Text != "")
            {
                if (lblData.Text == "Жанр")
                {
                    genres gr = new genres
                    {
                        name = txtboxData.Text
                    };
                    db.genres.Add(gr);
                    db.SaveChanges();
                    this.Close();
                }
                else if (lblData.Text == "Страна")
                {
                    country cr = new country
                    {
                        name = txtboxData.Text
                    };
                    db.country.Add(cr);
                    db.SaveChanges();
                    this.Close();
                }
                else
                {
                    agerating ar = new agerating
                    {
                        name = txtboxData.Text
                    };
                    db.agerating.Add(ar);
                    db.SaveChanges();
                    this.Close();
                }
            }
            else
            {
                MessageBox.Show("Поле пустое");
            }
        }