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; } }
private bool IsContainInputLabel(string txt) { //isContain = SQLHelper.CheckOverrideName(txt.Trim()); isContain = TagsDAO.CreateTagsDAO().IsExistTag(txt); return(isContain); }