Example #1
0
 private void pbBuildingAdd_Click(object sender, EventArgs e)
 {
     using (var frm = new BuildingAddEditForm(new Building()))
     {
         frm.Theme = this.Theme;
         frm.Style = this.Style;
         if (frm.ShowDialog() == DialogResult.OK)
         {
             var client = (Client)clientBindingSource.Current;
             client.Buildings.Add(frm.BuildingInfo);
             buildingBindingSource.Add(frm.BuildingInfo);
             //buildingsGrid.Refresh();
         }
     }
 }
Example #2
0
        private void buildingsGrid_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            //var bld = (Building)buildingsGrid.SelectedRows[0].DataBoundItem;
            var bld = (Building)buildingBindingSource.Current;
            //var bld_edit = (Building)db.Entry(bld).CurrentValues.ToObject();
            var bld_edit = new Building {
                Address = bld.Address, DeliveryDistanse = bld.DeliveryDistanse
            };

            switch (e.ColumnIndex)
            {
            //building edit
            case 2:
                using (var frm = new BuildingAddEditForm(bld_edit))
                {
                    frm.Style = this.Style;
                    frm.Theme = this.Theme;
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        frm.Theme            = this.Theme;
                        frm.Style            = this.Style;
                        bld.Address          = bld_edit.Address;
                        bld.DeliveryDistanse = bld_edit.DeliveryDistanse;
                        buildingsGrid.Refresh();
                    }
                }
                break;

            //building delete
            case 3:
                db.Buildings.Remove(bld);
                buildingBindingSource.Remove(bld);
                buildingsGrid.Refresh();
                UpdateWalls();
                break;

            default:
                break;
            }
        }