コード例 #1
0
ファイル: SaveFavouriteClasses.cs プロジェクト: erdincay/db4o
        internal void AddFolderToDatabase(FavouriteFolder favFolder)
        {
            try
            {
                container = Db4oClient.RecentConn;
                if (m_lstFavfolder != null)
                {
                    FavouriteList favList = FetchAllFavouritesForAConnection();
                   
                    if (favList == null)
                    {
                        favList = new FavouriteList(m_connParam);
                        List<FavouriteFolder> lstFavfolder = new List<FavouriteFolder>();
                        favList.m_TimeOfCreation = Sharpen.Runtime.CurrentTimeMillis();   
                        lstFavfolder.Add(favFolder);
                        container.Store(favList);
                        container.Commit();
                        return;
                    }
                    container.Activate(favList, 5);
                    List<FavouriteFolder> lstFavFolder = favList.lstFavFolder;
                   
                    bool check = false;
                    FavouriteFolder temp = null;
                    foreach (FavouriteFolder str in lstFavFolder)
                    {
                        if (str != null)
                        {
                            if (str.FolderName.Equals(favFolder.FolderName))
                            {
                                temp = str;
                                check = true;
                                break;
                            }
                        }
                    }
                    if (check == false)
                    {

                        lstFavFolder.Add(favFolder);
                    }
                    else
                    {
                        lstFavFolder.Remove(temp);
                        lstFavFolder.Add(favFolder);
                        container.Delete(temp);
                    }


                    favList.lstFavFolder = lstFavFolder;
                    container.Ext().Store(favList, 5);
                    container.Commit();


                }
            }
            catch (Exception oEx)
            {
                LoggingHelper.HandleException(oEx);  
            }
        }
コード例 #2
0
ファイル: dbInteraction.cs プロジェクト: erdincay/db4o
		public static void RenameFolderInDatabase(ConnParams conn, FavouriteFolder oldFav, FavouriteFolder newFav)
		{
			FavouriteList lstFav = new FavouriteList(conn);
			lstFav.RenameFolderInDatabase(oldFav, newFav);  
		}
コード例 #3
0
ファイル: SaveFavouriteClasses.cs プロジェクト: erdincay/db4o
        internal void RenameFolderInDatabase(FavouriteFolder oldFavFolder, FavouriteFolder newFavFolder)
        {
            try
            {
                container = Db4oClient.RecentConn;
                FavouriteList favList = FetchAllFavouritesForAConnection();


                List<FavouriteFolder> lstFavFolder = favList.lstFavFolder;
                bool check = false;
                FavouriteFolder temp = null;
                foreach (FavouriteFolder str in lstFavFolder)
                {
                    if (str != null)
                    {
                        if (str.FolderName.Equals(oldFavFolder.FolderName))
                        {
                            temp = str;
                            check = true;
                            break;
                        }
                    }
                }
                if (check == true)
                {
                    lstFavFolder.Remove(temp);
                    container.Delete(temp);
                    temp.FolderName = newFavFolder.FolderName;
                    lstFavFolder.Add(temp);
                    favList.lstFavFolder = lstFavFolder;
                    container.Ext().Store(favList, 5);
                    container.Commit();
                }
            }
            catch (Exception oEx)
            {
                LoggingHelper.HandleException(oEx);
            }

        }
コード例 #4
0
ファイル: dbInteraction.cs プロジェクト: erdincay/db4o
		public static void UpdateFavourite(ConnParams conn, FavouriteFolder FavFolder)
		{
			FavouriteList lstFav = new FavouriteList(conn);
			lstFav.RemoveFolderfromDatabase(FavFolder);  
		}
コード例 #5
0
ファイル: dbInteraction.cs プロジェクト: erdincay/db4o
		public static void SaveFavourite(ConnParams conn, FavouriteFolder FavFolder)
		{
			FavouriteList lstFav = new FavouriteList(conn);
			lstFav.AddFolderToDatabase(FavFolder);
		}
コード例 #6
0
ファイル: dbTreeView.cs プロジェクト: erdincay/db4o
		protected override void OnAfterLabelEdit(NodeLabelEditEventArgs e)
		{
			try
			{
				base.OnAfterLabelEdit(e);
				if (!string.IsNullOrEmpty(e.Label))
				{
					bool checkSameNode = false;
					for (int i = 0; i < Nodes.Count; i++)
					{
						TreeNode tNode = Nodes[i];
						if (tNode.Text == e.Label)
						{
							checkSameNode = true;
							break;
						}
					}
					if (checkSameNode == false)
					{
						e.Node.Text = e.Label;
					}
					else
					{
						MessageBox.Show("The Foldername already exist, Please use some other name.",
						                Helper.GetResourceString(Constants.PRODUCT_CAPTION), MessageBoxButtons.OK, MessageBoxIcon.Error);
						e.CancelEdit = true;
					}
				}
				else if (e.Label == string.Empty)
				{
					MessageBox.Show("The Foldername cannot be empty.", Helper.GetResourceString(Constants.PRODUCT_CAPTION),
					                MessageBoxButtons.OK, MessageBoxIcon.Error);
					e.CancelEdit = true;
				}
				if (e.Node.Text != folderName)
				{
					FavouriteFolder oldfav = new FavouriteFolder(null, folderName);
					FavouriteFolder newFav = new FavouriteFolder(null, e.Node.Text);
					dbInteraction.RenameFolderInDatabase(dbInteraction.GetCurrentRecentConnection().ConnParam, oldfav, newFav);
				}
				else
				{
					FavouriteFolder newFav = new FavouriteFolder(null, e.Node.Text);
					dbInteraction.SaveFavourite(dbInteraction.GetCurrentRecentConnection().ConnParam, newFav);
				}
			}
			catch (Exception oEx)
			{
				LoggingHelper.ShowMessage(oEx);
			}
		}
コード例 #7
0
ファイル: dbTreeView.cs プロジェクト: erdincay/db4o
		protected override void OnKeyDown(KeyEventArgs e)
		{
			try
			{
				if (e.KeyCode == Keys.Delete)
				{
					FavouriteFolder Fav = null;
					if (SelectedNode.Tag != null && SelectedNode.Tag.ToString() == "Fav Folder")
					{
						Fav = new FavouriteFolder(null, SelectedNode.Text);
						dbInteraction.UpdateFavourite(dbInteraction.GetCurrentRecentConnection().ConnParam, Fav);
						Nodes.Remove(SelectedNode);
					}
					else if (SelectedNode.Parent != null && SelectedNode.Parent.Tag != null &&
					         SelectedNode.Parent.Tag.ToString() == "Fav Folder")
					{
						TreeNode tNode = SelectedNode;
						TreeNode parentNode = SelectedNode.Parent;


						if (parentNode.Nodes.Count > 0)
						{
							List<string> lststr = new List<string>();
							foreach (TreeNode tempNode in parentNode.Nodes)
							{
								lststr.Add(tempNode.Text);
							}
							Fav = new FavouriteFolder(lststr, tNode.Parent.Text);
						}
						dbInteraction.SaveFavourite(dbInteraction.GetCurrentRecentConnection().ConnParam, Fav);
						SelectedNode.Remove();
					}
				}
			}
			catch (Exception oEx)
			{
				LoggingHelper.ShowMessage(oEx);
			}
		}
コード例 #8
0
ファイル: dbTreeView.cs プロジェクト: erdincay/db4o
		protected override void OnDragDrop(DragEventArgs e)
		{
			try
			{
				base.OnDragDrop(e);
				e.Effect = DragDropEffects.Move;
				Point pos = PointToClient(new Point(e.X, e.Y));
				TreeNode parentTreeNode = GetNodeAt(pos);
				if (parentTreeNode != null)
				{
					TreeNode dragNode = new TreeNode(Helper.FindRootNode(SelectedNode));
					dragNode.Tag = dragNode.Text;
					dragNode.Name = dragNode.Text;
					dragNode.ImageIndex =
						dragNode.SelectedImageIndex = 1;
					if (dragNode.Tag != null && dragNode.Tag.ToString() != "Fav Folder")
					{
						//dragNode.Tag = this.SelectedNode.Text;
						AddDummyChildNode(dragNode);

						bool checkSameNode = false;
						for (int i = 0; i < parentTreeNode.Nodes.Count; i++)
						{
							TreeNode tNode = parentTreeNode.Nodes[i];
							if (tNode.Text == dragNode.Text)
							{
								checkSameNode = true;
								break;
							}
						}
						if (checkSameNode == false && parentTreeNode.Tag != null && parentTreeNode.Tag.ToString() == "Fav Folder")
						{
							parentTreeNode.Nodes.Add(dragNode);
							FavouriteFolder Fav = new FavouriteFolder(null, parentTreeNode.Text);
							Fav.FolderName = parentTreeNode.Text;
							if (parentTreeNode.Nodes.Count > 0)
							{
								List<string> lststr = new List<string>();
								foreach (TreeNode tnode in parentTreeNode.Nodes)
								{
									lststr.Add(tnode.Text);
								}
								Fav.ListClass = lststr;
							}

							dbInteraction.SaveFavourite(dbInteraction.GetCurrentRecentConnection().ConnParam, Fav);
						}
					}
				}
			}
			catch (Exception oEx)
			{
				LoggingHelper.ShowMessage(oEx);
			}
		}