Пример #1
0
        private void toolStripButtonRemove_Click(object sender, EventArgs e)
        {
            TreeNodeConnectionItem tnc = treeView1.SelectedNode as TreeNodeConnectionItem;

            if (tnc != null)
            {
                if (MessageBox.Show(this, "Do you want to remove thid connection?", Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    if (_connectionList != null)
                    {
                        for (int i = 0; i < _connectionList.Count; i++)
                        {
                            if (_connectionList[i].ConnectionGuid == tnc.OwnerItem.ConnectionGuid)
                            {
                                _connectionList.Remove(_connectionList[i]);
                                break;
                            }
                        }
                    }
                    tnc.Remove();
                }
            }
        }
Пример #2
0
 private void toolStripButtonDelete_Click(object sender, EventArgs e)
 {
     if (treeView1.SelectedNode != null)
     {
         TreeNodeConnectionItem tc = treeView1.SelectedNode as TreeNodeConnectionItem;
         if (tc == null)
         {
             tc = treeView1.SelectedNode.Parent as TreeNodeConnectionItem;
         }
         if (tc != null)
         {
             ConnectionItem ci = tc.OwnerItem;
             if (ci != null)
             {
                 if (MessageBox.Show(this, string.Format(System.Globalization.CultureInfo.InvariantCulture, "Do you want to delete connection [{0}]?", ci.ToString()), "Database Connection Manager", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                 {
                     if (System.IO.File.Exists(ci.FullFilePath))
                     {
                         try
                         {
                             System.IO.File.Delete(ci.FullFilePath);
                         }
                         catch (Exception err)
                         {
                             MessageBox.Show(this, err.Message, "Database Connection", MessageBoxButtons.OK, MessageBoxIcon.Error);
                         }
                     }
                     propertyGrid1.SelectedObject = null;
                     tc.Remove();
                     _connectionList.Remove(ci);
                     ConnectionConfig.RemoveConnection(ci.ConnectionObject.ConnectionGuid);
                 }
             }
         }
     }
 }