示例#1
0
        public static bool RemoveTagAndMemo(string tagId)
        {
            IDbTransaction tran = getTransaction();

            try
            {
                if (Remove(tagId, tran))
                {
                    if (MemoDal.Remove(tagId, tran))
                    {
                        tran.Commit();
                        return(true);
                    }
                    else
                    {
                        tran.Rollback();
                        return(false);
                    }
                }
                else
                {
                    tran.Rollback();
                    return(false);
                }
            }
            catch (Exception)
            {
                tran.Rollback();
                return(false);
            }
            finally
            {
                tran.Dispose();
            }
        }
示例#2
0
        //添加标签选项卡
        private void NewTagPage(string key, string text, Memo memo = null)
        {
            lblWelcome.Hide();
            for (int i = 0; i < tabControlMain.TabPages.Count; i++)
            {
                if (tabControlMain.TabPages[i].Tag.Equals(key))
                {
                    tabControlMain.SelectTab(i);
                    return;
                }
            }
            if (memo == null)
            {
                memo = MemoDal.Get(key);
            }
            TabPage page = new TabPage();

            page.Text = text;
            page.Tag  = key;
            RichTextBox txtBox = new RichTextBox();

            txtBox.Parent       = page;
            txtBox.Width        = page.Width;
            txtBox.Height       = page.Height;
            txtBox.Text         = EncryptUtil.DecryptDes(memo.content);
            txtBox.Anchor       = AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom | AnchorStyles.Left;
            txtBox.KeyDown     += new KeyEventHandler(RickTextBox_KeyDown);
            txtBox.TextChanged += new EventHandler(RTxtBoxTextChanged);
            tabControlMain.TabPages.Add(page);
            tabControlMain.SelectTab(page);
        }
示例#3
0
        public static bool AddTagAndMemo(Tag tag, Memo memo)
        {
            IDbTransaction tran = getTransaction();

            try
            {
                if (Add(tag, tran))
                {
                    if (MemoDal.Add(memo, tran))
                    {
                        tran.Commit();
                        return(true);
                    }
                    else
                    {
                        tran.Rollback();
                        return(false);
                    }
                }
                else
                {
                    tran.Rollback();
                    return(false);
                }
            }
            catch (Exception) {
                tran.Rollback();
                return(false);
            }
            finally
            {
                tran.Dispose();
            }
        }
示例#4
0
        private void SaveMemo(TabPage page = null)
        {
            if (page == null)
            {
                page = tabControlMain.SelectedTab;
            }

            if (page != null)
            {
                RichTextBox rtxtbox = page.Controls[0] as RichTextBox;
                Memo        memo    = new Memo();
                memo.tagid    = page.Tag.ToString();
                memo.lasttime = DateTime.Now;
                memo.content  = EncryptUtil.EncryptDes(rtxtbox.Text.Trim());
                MemoDal.Modify(memo);
                //从待保存memo列表中移除已保存memo
                SavePendingMemo.Remove(page.Tag.ToString());
            }
            else
            {
                MessageBox.Show("请先新建或者选择一个备忘录", "提示");
            }
        }