コード例 #1
0
ファイル: EZ Sun Model.cs プロジェクト: emmazee/Sun-Model
        /// <summary>
        /// Launches the add attribute form.
        /// </summary>
        /// <param name="dimensionName">Name of the dimension.</param>
        /// <param name="parentName">Name of the parent.</param>
        private void LaunchAddAttribute(string dimensionName, string parentName)
        {
            string          businessProcess = this.tabControlArea.SelectedTab.Text;
            BusinessProcess b = this.cmodel.GetBusinessProcess(businessProcess);

            using (AddAttribute am = new AddAttribute(b, dimensionName, parentName))
            {
                Point location = new Point((this.Left + (this.Width / 2)) - am.Width / 2, (this.Top + (this.Height / 2)) - am.Height / 2);
                am.StartPosition = FormStartPosition.Manual;
                am.Location      = location;
                var result = am.ShowDialog();
                if (result == DialogResult.OK)
                {
                    Level l = new Level();

                    if (am.IsSharedNode.Checked)
                    {
                        Level sh = b.GetSharedNodeLevelByUID(am.SharedNodeName.SelectedValue.ToString());
                        if (am.ConvergedKey.Checked)
                        {
                            l.ConvergedKey = sh.Key;
                        }
                        else if (am.CDAKey.Checked)
                        {
                            l.CDAKey = sh.Key;
                        }
                        else
                        {
                            l.Key = sh.Key;
                        }
                    }
                    else
                    {
                        l.Name                 = am.AttributeName.Text;
                        l.Type                 = (LevelType)Enum.Parse(typeof(LevelType), am.AttributeType.Text);
                        l.OptionalLevel        = am.OptionalLevel.Checked;
                        l.OptionalRelationship = am.OptionalBranch.Checked;
                        l.MultipleRelationship = am.ManyToMany.Checked;
                        l.Recursive            = am.Recursive.Checked;
                    }
                    Dimension d = b.GetDimension(am.Dimension.Text);
                    if (am.Parent.Text.ToString() == "n/a" && am.Parent.SelectedValue == null)
                    {
                        d.Level = l;
                    }
                    else
                    {
                        Level parent = d.GetLevelByUID(am.Parent.SelectedValue.ToString());
                        if (parent.Level1 == null)
                        {
                            parent.Level1 = new List <Level>();;
                        }
                        parent.Level1.Add(l);
                    }

                    this.Draw();
                    tabControlArea.SelectTab(businessProcess);
                }
            }
        }