Beispiel #1
0
        /// <summary>
        /// 更新标签
        /// </summary>
        /// <param name="updatemodel"></param>
        /// <returns></returns>
        public string UpdateTag(TagModel updatemodel)
        {
            if (updatemodel.TagID <= 0)
            {
                return("ID为空");
            }

            var tagdal = new TagDal();
            var model  = tagdal.GetFirst(x => x.TagID == updatemodel.TagID);

            if (model == null)
            {
                return("数据不存在");
            }

            model.TagName = updatemodel.TagName;
            model.TagDesc = updatemodel.TagDesc;
            model.TagLink = updatemodel.TagLink;

            if (tagdal.Exist(x => x.TagName == model.TagName && x.TagID != model.TagID))
            {
                return("存在同名标签");
            }

            return(tagdal.Update(model) > 0 ? SUCCESS : "添加失败");
        }
Beispiel #2
0
        //删除tag及其memo
        private void tsMenuItemTadRemove_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("您确定要删除吗?", "警告", MessageBoxButtons.OKCancel) == DialogResult.OK)
            {
                TabPage page = tabControlMain.SelectedTab;
                if (TagDal.RemoveTagAndMemo(page.Tag.ToString()))
                {
                    foreach (ToolStripItem item in tsdropBtnTags.DropDownItems)
                    {
                        if (item.Tag.Equals(page.Tag))
                        {
                            tsdropBtnTags.DropDownItems.Remove(item);

                            break;
                        }
                    }
                    SavePendingMemo.Remove(page.Tag.ToString());
                    tabControlMain.TabPages.Remove(page);
                }
                else
                {
                    MessageBox.Show("删除失败");
                }
            }
        }
Beispiel #3
0
        public string DeleteTag(string id)
        {
            var tagdal = new TagDal();
            var model  = tagdal.GetFirst(x => x.UID == id);

            if (model == null)
            {
                return("数据不存在");
            }
            return(tagdal.Delete(model) > 0 ? SUCCESS : "删除失败");
        }
Beispiel #4
0
        private void InitLoadTagMenuStrip()
        {
            List <Tag> tags = TagDal.GetMyTags(Session.currUser.id);

            tsdropBtnTags.DropDownItems.Clear();
            if (tags != null)
            {
                foreach (Tag tag in tags)
                {
                    NewTagMenu(tag.id, tag.tag);
                }
            }
        }
Beispiel #5
0
        public string DeleteTag(int id)
        {
            if (id <= 0)
            {
                return("ID为空");
            }
            var tagdal = new TagDal();
            var model  = tagdal.GetFirst(x => x.TagID == id);

            if (model == null)
            {
                return("数据不存在");
            }
            return(tagdal.Delete(model) > 0 ? SUCCESS : "删除失败");
        }
Beispiel #6
0
        /// <summary>
        /// 获取标签
        /// </summary>
        /// <param name="tagtype"></param>
        /// <param name="skip"></param>
        /// <param name="take"></param>
        /// <returns></returns>
        public List <TagModel> GetList(List <string> ids = null, int skip = 0, int take = 1000)
        {
            var             tagdal = new TagDal();
            List <TagModel> list   = null;

            tagdal.PrepareIQueryable((query) =>
            {
                if (ValidateHelper.IsPlumpList(ids))
                {
                    query = query.Where(x => ids.Contains(x.UID));
                }
                list = query.OrderByDescending(x => x.CreateTime).Skip(skip).Take(take).ToList();
                return(true);
            });
            return(list);
        }
Beispiel #7
0
        /// <summary>
        /// 添加标签
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public string AddTag(TagModel model)
        {
            string err = CheckModel(model);

            if (ValidateHelper.IsPlumpString(err))
            {
                return(err);
            }
            var tagdal = new TagDal();

            if (tagdal.Exist(x => x.TagName == model.TagName))
            {
                return("存在同名标签");
            }

            return(tagdal.Add(model) > 0 ? SUCCESS : "添加失败");
        }
Beispiel #8
0
        /// <summary>
        /// 获取标签
        /// </summary>
        /// <param name="tagtype"></param>
        /// <param name="skip"></param>
        /// <param name="take"></param>
        /// <returns></returns>
        public List <TagModel> GetList(List <int> ids = null, int skip = 0, int take = 1000)
        {
            ids = ConvertHelper.NotNullList(ids).Where(x => x > 0).ToList();
            var key = Com.GetCacheKey("TagBll.GetList:", string.Join(",", ids), skip.ToString(), take.ToString());

            return(Cache(key, () =>
            {
                var tagdal = new TagDal();
                List <TagModel> list = null;
                tagdal.PrepareIQueryable((query) =>
                {
                    if (ValidateHelper.IsPlumpList(ids))
                    {
                        query = query.Where(x => ids.Contains(x.TagID));
                    }
                    list = query.OrderByDescending(x => x.TagID).Skip(skip).Take(take).ToList();
                    return true;
                });
                return list;
            }));
        }
Beispiel #9
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrWhiteSpace(txtTagName.Text))
            {
                if (operation == FormOperations.add)
                {
                    if (!TagDal.IsExistTag(Session.currUser.id, txtTagName.Text.Trim()))
                    {
                        currTag         = new Tag();
                        currTag.id      = StringUtil.getGuidN();
                        currTag.tag     = txtTagName.Text.Trim();
                        currTag.userid  = Session.currUser.id;
                        currTag.addtime = DateTime.Now;

                        memo          = new Memo();
                        memo.tagid    = currTag.id;
                        memo.content  = "";
                        memo.lasttime = DateTime.Now;
                        if (TagDal.AddTagAndMemo(currTag, memo))
                        {
                            this.DialogResult = DialogResult.OK;
                            this.Close();
                        }
                        else
                        {
                            ShowHint("保存失败");
                        }
                    }
                    else
                    {
                        ShowHint("已存在相同名称的备忘录,请输入另外的名称");
                        txtTagName.Focus();
                    }
                }
                else
                {
                    currTag = TagDal.Get(tagId);
                    if (currTag != null)
                    {
                        currTag.tag = txtTagName.Text.Trim();
                        if (TagDal.Modify(currTag))
                        {
                            this.DialogResult = DialogResult.OK;
                            this.Close();
                        }
                        else
                        {
                            ShowHint("保存失败");
                        }
                    }
                    else
                    {
                        MessageBox.Show("数据异常,保存失败");
                        this.Close();
                    }
                }
            }
            else
            {
                ShowHint("请输入名称");
                txtTagName.Focus();
            }
        }
Beispiel #10
0
        /// <summary>
        /// 通过id获取标签
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public TagModel GetTagByID(string id)
        {
            var tagdal = new TagDal();

            return(tagdal.GetFirst(x => x.UID == id));
        }