示例#1
0
 public TradeDepartmentDetailForm(PostgresDataBaseContext db, TradeDepartment department = null)
 {
     InitializeComponent();
     this.db         = db;
     this.department = department;
     if (department != null)
     {
         this.TbName.Text = this.department.Name;
     }
 }
示例#2
0
        private void BtnDelete_Click(object sender, EventArgs e)
        {
            foreach (DataGridViewRow selectedRow in this.dataGridView1.SelectedRows)
            {
                var             selectedId = selectedRow.Cells["Id"].Value;
                TradeDepartment selected   = db.TradeDepartments.Find(selectedId);
                db.TradeDepartments.Remove(selected);
            }

            db.SaveChanges();
        }
示例#3
0
        private void BtnOk_Click(object sender, EventArgs e)
        {
            if (this.department == null)
            {
                this.department = new TradeDepartment();
                db.TradeDepartments.Add(this.department);
            }

            this.department.Name = this.TbName.Text;

            db.SaveChanges();
            this.Close();
        }
示例#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;
            TradeDepartment           selected   = db.TradeDepartments.Find(selectedId);
            TradeDepartmentDetailForm add        = new TradeDepartmentDetailForm(this.db, selected);

            add.Show();
        }