Exemplo n.º 1
0
        private void btnDelFor_Click(object sender, EventArgs e)
        {
            if (this.listViewNoiDung.SelectedItems.Count <= 0)
            {
                return;
            }
            int i = this.listViewNoiDung.SelectedItems[0].Index;
            //int j = this.listViewNoiDung.SelectedItems[1].Index;
            int  stt     = idList[i];
            Note getnote = NoteControllers.getNote(stt);

            NoteControllers.deleteNote(getnote);
            showRac();

            List <Tag> listtag = TagControllers.getAllTag();

            foreach (Tag gettag in listtag)
            {
                if (gettag.Notes.Count() <= 0)
                {
                    TagControllers.deleteTag(gettag);
                }
            }

            this.rtbTypeNoiDung.Clear();
            this.rtbShowTag.Clear();
            this.rtbred.Clear();
            this.lbInfo.Text = "";
        }
Exemplo n.º 2
0
        private void btnDeleteTag_Click(object sender, EventArgs e)
        {
            if (txbTypeTag.Text == "")
            {
                return;
            }
            if (this.listViewNoiDung.SelectedItems.Count <= 0)
            {
                return;
            }
            int i = this.listViewNoiDung.SelectedItems[0].Index;
            //int j = this.listViewNoiDung.SelectedItems[1].Index;
            int  stt    = idList[i]++;
            Note source = NoteControllers.getNote(stt);

            foreach (Tag tag in source.Tags)
            {
                if (tag.TenTag == this.txbTypeTag.Text)
                {
                    source.Tags.Remove(tag);

                    Note get = new Note();
                    get.SoThuTu  = source.SoThuTu;
                    get.TieuDe   = source.TieuDe;
                    get.NoiDung  = source.NoiDung;
                    get.ThongTin = source.ThongTin;
                    get.Rac      = source.Rac;
                    get.PintoTop = source.PintoTop;
                    foreach (Tag getsource in source.Tags)
                    {
                        get.Tags.Add(getsource);
                    }

                    NoteControllers.deleteNote(source);
                    NoteControllers.addNote(get);

                    string showtag = "";
                    foreach (Tag gettag in get.Tags)
                    {
                        showtag = showtag + gettag.TenTag + " ";
                    }
                    this.rtbShowTag.Text = showtag;
                    this.rtbred.Text     = showtag;

                    this.txbTypeTag.Text = "";

                    List <Tag> sourcetag = TagControllers.getAllTag();
                    foreach (Tag take in sourcetag)
                    {
                        if (take.Notes.Count() <= 0)
                        {
                            TagControllers.deleteTag(take);
                        }
                    }

                    return;
                }
            }
            return;
        }