コード例 #1
0
        private void updateTagToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (treeViewTag.SelectedNode.Name == "rootNode")
            {
                MessageBox.Show("Root name cannot be revised!");
                return;
            }
            var tagdel = treeViewTag.SelectedNode.Tag as Tag;

            if (tagdel == null)
            {
                return;
            }
            var rettag = _tagController.GetATagById(tagdel.TagId);

            if (rettag == null)
            {
                SysHelper.ShowMessageWarning("Unable to retrive from db!");
                return;
            }
            var input = new TagInputForm(tagdel.Name);

            if (input.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            rettag.Name = input.InputTag;
            _tagController.UpdateTagName(rettag);
            treeViewTag.SelectedNode.Text = input.InputTag;
            treeViewTag.ExpandAll();
        }
コード例 #2
0
        //ok
        private void button1_Click(object sender, EventArgs e)
        {
            _problem.Number = numericUpDown1.Value.ToString();
            if (_problem.ProblemId == 0) //new a problem
            {
                //check if question with same number has existed
                var tmpprob = _problemController.GetAllProblems().FirstOrDefault(r => r.Number == _problem.Number);
                if (tmpprob != null)
                {
                    SysHelper.ShowMessageWarning(string.Format("question with number of {0} has existed!", tmpprob.Number));
                    return;
                }
            }
            _problem.Title       = titleTxtbox.Text;
            _problem.LtUrl       = LtCodeTxtbox.Text;
            _problem.Content     = contentTxtbox.Text;
            _problem.CsdnAddress = CsdnTxtbox.Text;
            if (SysHelper.CollectionNullOrEmpty <UltraGridRow>(this.ultraCombo1.CheckedRows))
            {
                MessageBox.Show("not select any tag! please create a new tag.");
                return;
            }
            if (_problem.Tags != null)
            {
                _problem.Tags.Clear();
            }
            else
            {
                _problem.Tags = new List <Tag>();
            }
            foreach (UltraGridRow row in this.ultraCombo1.CheckedRows)
            {
                //if (!_problem.Tags.Contains(tag))
                int tagid      = (int)(row.ListObject as DataRowView).Row.ItemArray[0];
                Tag retriveTag = _tagController.GetATagById(tagid);
                if (retriveTag != null) //write to log
                {
                    _problem.Tags.Add(retriveTag);
                }
            }

            if (string.IsNullOrEmpty(_problem.Title))
            {
                SysHelper.ShowMessageWarning("Title cannot be empty!");
                return;
            }
            DialogResult = DialogResult.OK;
        }