Пример #1
0
        private void ModifyItem()
        {
            if (_transportList.Count == 0)
            {
                MessageBox.Show("Your list is empty!");
                return;
            }
            var frm = new AddNewTransportForm();

            frm.Transport = (ITransport)iTransportBindingSource.Current;
            if (frm.ShowDialog() == DialogResult.OK)
            {
                var transport = frm.Transport;
                var index     = _transportList.IndexOf((ITransport)iTransportBindingSource.Current);
                if (_afterSearchChanges == false)
                {
                    iTransportBindingSource.RemoveAt(index);
                    iTransportBindingSource.Insert(index, transport);
                }
                else
                {
                    var afterIndex = _searchedTransportList.IndexOf((ITransport)iTransportBindingSource.Current);
                    iTransportBindingSource.RemoveAt(afterIndex);
                    iTransportBindingSource.Insert(afterIndex, transport);
                    _transportList.RemoveAt(index);
                    _transportList.Insert(index, transport);
                }
                FormNameChanging(_projectSavedChanges);
                _projectSavedChanges = false;
            }
        }
Пример #2
0
        private void AddNewItem()
        {
            var frm = new AddNewTransportForm();

            if (frm.ShowDialog() == DialogResult.OK)
            {
                var transport = frm.Transport;
                iTransportBindingSource.Add(transport);
                _projectSavedChanges = false;
                FormNameChanging(_projectSavedChanges);
            }
        }