Beispiel #1
0
        private void btn_Add_Click(object sender, EventArgs e)
        {
            //TipsForm tf = new TipsForm();
            #region MyRegion
            //int labelCount = this.panel_Tags.Controls.Count;
            //int lines = labelCount / 4;
            //int left = labelCount % 4;
            //int X = (left * WIDTH) + (left + 1) * MARGIN;
            //int Y = lines * HEIGHT + (lines + 1) * MARGIN;
            //LabelWithCheck label = new LabelWithCheck();
            ////if (string.IsNullOrEmpty(txt_Tag.Text))
            ////{
            ////    MessageBox.Show("请填写标签名称!");
            ////    return;
            ////}
            ////label.LabelText = this.txt_Tag.Text;
            //label.Location = new Point(X,Y);
            //panel_Tags.Controls.Add(label);
            #endregion

            if (!string.IsNullOrEmpty(txt_Tag.Text)&&!IsContainInputLabel(txt_Tag.Text))
            {
                //Model.Tags.Tag tag = TagsDAO.CreateTagsDAO().GetTagByName(txt_Tag.Text.Trim());
                Model.Tags.Tag tag = new Model.Tags.Tag();
                tag.TagId = Guid.NewGuid();
                tag.TagContent = txt_Tag.Text;
                Guid gid=(Guid)TagsDAO.CreateTagsDAO().Save(tag);
                if (gid == Guid.Empty)
                {
                    MessageBoxEx.Show("未知错误",Constant.KM_TYPE_ERROR);
                    return;
                }

                new MainForm(false).AddLabelToLocation(this.panel_Tags, 4, txt_Tag.Text,tag.TagId,false,true);
                this.txt_Tag.Text = string.Empty;
                //SQLHelper.InsertTag(txt_Tag.Text);
            }
            else
            {
                MessageBoxEx.Show(string.Format("请输入标签或\r\n确保标签唯一!", txt_Tag.Text),"注意",MessageBoxButtons.OK);
                txt_Tag.Text = string.Empty;
                return;
            }
        }
Beispiel #2
0
        private void btn_Add_Click(object sender, EventArgs e)
        {
            //TipsForm tf = new TipsForm();
            #region MyRegion
            //int labelCount = this.panel_Tags.Controls.Count;
            //int lines = labelCount / 4;
            //int left = labelCount % 4;
            //int X = (left * WIDTH) + (left + 1) * MARGIN;
            //int Y = lines * HEIGHT + (lines + 1) * MARGIN;
            //LabelWithCheck label = new LabelWithCheck();
            ////if (string.IsNullOrEmpty(txt_Tag.Text))
            ////{
            ////    MessageBox.Show("请填写标签名称!");
            ////    return;
            ////}
            ////label.LabelText = this.txt_Tag.Text;
            //label.Location = new Point(X,Y);
            //panel_Tags.Controls.Add(label);
            #endregion

            if (!string.IsNullOrEmpty(txt_Tag.Text) && !IsContainInputLabel(txt_Tag.Text))
            {
                //Model.Tags.Tag tag = TagsDAO.CreateTagsDAO().GetTagByName(txt_Tag.Text.Trim());
                Model.Tags.Tag tag = new Model.Tags.Tag();
                tag.TagId      = Guid.NewGuid();
                tag.TagContent = txt_Tag.Text;
                Guid gid = (Guid)TagsDAO.CreateTagsDAO().Save(tag);
                if (gid == Guid.Empty)
                {
                    MessageBoxEx.Show("未知错误", Constant.KM_TYPE_ERROR);
                    return;
                }

                new MainForm(false).AddLabelToLocation(this.panel_Tags, 4, txt_Tag.Text, tag.TagId, false, true);
                this.txt_Tag.Text = string.Empty;
            }
            else
            {
                MessageBoxEx.Show(string.Format("请输入标签或\r\n确保标签唯一!", txt_Tag.Text), "注意", MessageBoxButtons.OK);
                txt_Tag.Text = string.Empty;
                return;
            }
        }
Beispiel #3
0
 public object Save(Tag tag)
 {
     Guid id = Guid.Empty;
     using (ISession session = sessionFactory.OpenSession())
     {
         ITransaction trans = session.BeginTransaction();
         try
         {
             //tag = session.CreateCriteria(typeof(Tag)).Add(Restrictions.Eq("TagContent", text.Trim())).List<Tag>();
             id=(Guid)session.Save(tag);//数据没有进数据库,没有Commit
             trans.Commit();
         }
         catch (Exception)
         {
             trans.Rollback();
             throw;
         }
     }
     return id;
 }