예제 #1
0
        private void AddCompose()
        {
            FormCompose frm = new FormCompose(null);

            if (frm.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            ComposingRuleItem item = frm.RuleItem;

            if (item == null)
            {
                return;
            }

            foreach (ComposingRuleItem i in Program.ServiceMgt.Config.Composing.Fields)
            {
                if (item.Table == i.Table &&
                    item.FieldName == i.FieldName)
                {
                    MessageBox.Show(this, "Field " + i.ToString() + " is already in the list.", "Warning",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }

            Program.ServiceMgt.Config.Composing.Fields.Add(item);
            RefreshComposeList();
        }
예제 #2
0
        private void EditCompose()
        {
            if (this.listViewCompose.SelectedItems.Count < 1)
            {
                return;
            }

            ComposingRuleItem f = this.listViewCompose.SelectedItems[0].Tag as ComposingRuleItem;

            if (f == null)
            {
                return;
            }

            ComposingRuleItem tmpf = f.Clone();
            FormCompose       frm  = new FormCompose(tmpf);

            if (frm.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            foreach (ComposingRuleItem i in Program.ServiceMgt.Config.Composing.Fields)
            {
                if (i.Table == f.Table &&
                    i.FieldName == f.FieldName)
                {
                    continue;
                }

                if (tmpf.Table == i.Table &&
                    tmpf.FieldName == i.FieldName)
                {
                    MessageBox.Show(this, "Field " + i.ToString() + " is already in the list.", "Warning",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }

            int index = Program.ServiceMgt.Config.Composing.Fields.IndexOf(f);

            Program.ServiceMgt.Config.Composing.Fields.Insert(index, tmpf);
            Program.ServiceMgt.Config.Composing.Fields.Remove(f);

            RefreshComposeList();
        }