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;
        }
Exemplo n.º 3
0
        private void txbTypeTag_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                {
                    if (this.txbTypeTag.Text == "")
                    {
                        return;
                    }
                    if (this.listViewNoiDung.SelectedItems.Count <= 0)
                    {
                        return;
                    }

                    List <Tag> get    = TagControllers.getAllTag();
                    Tag        gettag = new Tag();
                    gettag.TenTag = this.txbTypeTag.Text;
                    TagControllers.addTag(gettag);

                    Tag tagforadd = TagControllers.getoneTag(this.txbTypeTag.Text);
                    int selectt   = this.listViewNoiDung.SelectedItems[0].Index;
                    //int i2 = this.listViewNoiDung.SelectedItems[1].Index;
                    int  chose    = idList[selectt]++;
                    Note getchose = NoteControllers.getNote(chose);
                    getchose.Tags.Add(tagforadd);

                    Note temp = new Note();
                    temp.SoThuTu  = getchose.SoThuTu;
                    temp.TieuDe   = getchose.TieuDe;
                    temp.NoiDung  = getchose.NoiDung;
                    temp.ThongTin = getchose.ThongTin;
                    temp.Rac      = getchose.Rac;
                    temp.PintoTop = getchose.PintoTop;
                    foreach (Tag fina in getchose.Tags)
                    {
                        temp.Tags.Add(fina);
                    }

                    NoteControllers.deleteNote(getchose);
                    NoteControllers.addNote(getchose);

                    string show = "";
                    foreach (Tag forshow in getchose.Tags)
                    {
                        show = show + forshow.TenTag + " ";
                    }
                    this.rtbShowTag.Text = show;
                    this.rtbred.Text     = show;

                    this.txbTypeTag.Text = "";
                }
            }
        }