public ProductGroupDetailForm(PostgresDataBaseContext db, ProductGroup group = null)
 {
     InitializeComponent();
     this.db    = db;
     this.group = group;
     if (group != null)
     {
         this.TbName.Text = this.group.Name;
     }
 }
Exemplo n.º 2
0
        private void BtnDelete_Click(object sender, EventArgs e)
        {
            foreach (DataGridViewRow selectedRow in this.dataGridView1.SelectedRows)
            {
                var          selectedId = selectedRow.Cells["Id"].Value;
                ProductGroup selected   = db.ProductGroups.Find(selectedId);
                db.ProductGroups.Remove(selected);
            }

            db.SaveChanges();
        }
        private void BtnOk_Click(object sender, EventArgs e)
        {
            if (this.group == null)
            {
                this.group = new ProductGroup();
                db.ProductGroups.Add(this.group);
            }

            this.group.Name = this.TbName.Text;

            db.SaveChanges();
            this.Close();
        }
Exemplo n.º 4
0
        private void BtnChange_Click(object sender, EventArgs e)
        {
            if (this.dataGridView1.SelectedRows.Count != 1)
            {
                MessageBox.Show("Выберите одну строку");
                return;
            }

            var                    selectedId = this.dataGridView1.SelectedRows[0].Cells["Id"].Value;
            ProductGroup           selected   = db.ProductGroups.Find(selectedId);
            ProductGroupDetailForm add        = new ProductGroupDetailForm(this.db, selected);

            add.Show();
        }