Exemplo n.º 1
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (tagSelectCtrl.SelectedItem != null)
            {
                ITagData    tag  = tagSelectCtrl.SelectedItem;
                TagEditForm form = new TagEditForm();
                form.TagEditControl.SetDataSource(tag);
                form.StartPosition = FormStartPosition.CenterParent;

                if (form.ShowDialog(this) == DialogResult.OK)
                {
                    form.TagEditControl.GetDataSource(tag);

                    if (!IsTagNameUnique(tag))
                    {
                        MessageBox.Show(this, "Tag name must be unique and not empty.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        SetTagData();
                    }
                    else
                    {
                        m_adapter.UpdateTag(tag);
                        SetTagData();

                        if (m_editTags.Contains(tag))
                        {
                            m_editTags.Remove(tag);
                        }

                        m_editTags.Add(tag);
                    }

                    tagSelectCtrl.SetSelectedItem(tag);
                }
            }
        }
Exemplo n.º 2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            TagEditForm form = new TagEditForm {
                StartPosition = FormStartPosition.CenterParent
            };

            if (form.ShowDialog(this) == DialogResult.OK)
            {
                TagDataSource ds = new TagDataSource();
                form.TagEditControl.GetDataSource(ds);
                if (!this.IsTagNameUnique(ds))
                {
                    MessageBox.Show(this, "Tag name must be unique and not empty.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                }
                else
                {
                    this.m_adapter.InsertTag(ds);
                    this.Init(this.m_adapter);
                    IEnumerable <ITagDataSource> source = from item in this.m_adapter.GetTags()
                                                          where item.Name == ds.Name
                                                          select item;
                    if (source.Count <ITagDataSource>() > 0)
                    {
                        if (this.m_addTags.Contains(source.First <ITagDataSource>()))
                        {
                            this.m_addTags.Remove(source.First <ITagDataSource>());
                        }
                        this.m_addTags.Add(source.First <ITagDataSource>());
                    }
                }
            }
        }
Exemplo n.º 3
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            TagEditForm form = new TagEditForm();

            form.StartPosition = FormStartPosition.CenterParent;

            if (form.ShowDialog(this) == DialogResult.OK)
            {
                TagData tag = new TagData();
                form.TagEditControl.GetDataSource(tag);

                if (!IsTagNameUnique(tag))
                {
                    MessageBox.Show(this, "Tag name must be unique and not empty.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    m_adapter.InsertTag(tag);
                    SetTagData();

                    IEnumerable <ITagData> check = m_adapter.GetTags().Where(x => x.Name == tag.Name);

                    if (check.Any())
                    {
                        if (m_addTags.Contains(check.First()))
                        {
                            m_addTags.Remove(check.First());
                        }

                        m_addTags.Add(check.First());
                        tagSelectCtrl.SetSelectedItem(check.First());
                    }
                }
            }
        }
Exemplo n.º 4
0
 private void btnEdit_Click(object sender, EventArgs e)
 {
     if (this.dgvTags.SelectedRows.Count > 0)
     {
         ITagDataSource dataBoundItem = this.dgvTags.SelectedRows[0].DataBoundItem as ITagDataSource;
         if (dataBoundItem != null)
         {
             TagEditForm form = new TagEditForm();
             form.TagEditControl.SetDataSource(dataBoundItem);
             form.StartPosition = FormStartPosition.CenterParent;
             if (form.ShowDialog(this) == DialogResult.OK)
             {
                 if (!this.IsTagNameUnique(dataBoundItem))
                 {
                     MessageBox.Show(this, "Tag name must be unique and not empty.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                 }
                 else
                 {
                     form.TagEditControl.GetDataSource(dataBoundItem);
                     this.m_adapter.UpdateTag(dataBoundItem);
                     this.Init(this.m_adapter);
                     if (this.m_editTags.Contains(dataBoundItem))
                     {
                         this.m_editTags.Remove(dataBoundItem);
                     }
                     this.m_editTags.Add(dataBoundItem);
                 }
             }
         }
     }
 }