protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
 {
     if (!ChangeViewportStateTo(ViewportState.ReadState))
     {
         e.Cancel = true;
     }
     _softwareDm.Select().RowChanged -= SoftwareViewport_RowChanged;
     _softwareDm.Select().RowDeleted -= SoftwareViewport_RowDeleted;
     base.OnClosing(e);
 }
        public override void LoadData()
        {
            dataGridView.AutoGenerateColumns = false;
            DockAreas   = WeifenLuo.WinFormsUI.Docking.DockAreas.Document;
            _softwareDm = SoftwareDataModel.GetInstance();
            _softTypes  = SoftTypesDataModel.GetInstance();
            _softMakers = SoftMakersDataModel.GetInstance();

            // Ожидаем дозагрузки, если это необходимо
            _softwareDm.Select();
            _softTypes.Select();
            _softMakers.Select();

            var ds = DataSetManager.DataSet;

            _vSoftTypes = new BindingSource
            {
                DataMember = "SoftTypes",
                DataSource = ds
            };

            _vSoftMakers = new BindingSource
            {
                DataMember = "SoftMakers",
                DataSource = ds
            };

            _vSoftware = new BindingSource();
            _vSoftware.CurrentItemChanged += v_software_CurrentItemChanged;
            _vSoftware.DataMember          = "Software";
            _vSoftware.DataSource          = ds;
            _vSoftware.Filter              = StaticFilter;
            if (!string.IsNullOrEmpty(StaticFilter) && !string.IsNullOrEmpty(DynamicFilter))
            {
                _vSoftware.Filter += " AND ";
            }
            _vSoftware.Filter += DynamicFilter;

            DataBind();

            _softwareDm.Select().RowChanged += SoftwareViewport_RowChanged;
            _softwareDm.Select().RowDeleted += SoftwareViewport_RowDeleted;

            dataGridView.RowCount = _vSoftware.Count;
            SetViewportCaption();
            ViewportHelper.SetDoubleBuffered(dataGridView);
            _isEditable = true;
        }