예제 #1
0
        public ChooseBOMClient(BOMTool parentForm)
        {
            InitializeComponent();

            bomForm = parentForm;
            ChooseClientComboBox.Items.AddRange(bomForm.db.GetClientNames());
            this.Focus();
        }
예제 #2
0
        public ChooseBOMClient(BOMTool parentForm)
        {
            InitializeComponent();

            bomForm = parentForm;
            ChooseClientComboBox.Items.AddRange(bomForm.db.GetClientNames());
            this.Focus();
        }
예제 #3
0
 public abstract void ChangedCategory(BOMTool bomForm);
예제 #4
0
 public abstract void BuildBOMForm(BOMTool bomForm);
예제 #5
0
 public abstract bool AddImperativeToBOM(string iniName, string busName, string catName, BOMTool bomForm);
예제 #6
0
        public override void BuildBOMForm(BOMTool bomForm)
        {
            XElement client = ClientDataControl.Client.EntityObject as XElement;

            string catName;
            string busName;
            string iniName;

            NewCategory category;
            NewObjective objective;
            NewImperative imperative;

            foreach (XElement bom in client.Element("BOMS").Elements("BOM"))
            {
                catName = bom.Element("CATEGORY").Value.TrimEnd();
                category = bomForm.Categories.Find(delegate(NewCategory cat)
                {
                    return cat.name == catName;
                });
                if (category == null)
                {
                    category = bomForm.AddCategory(catName);
                }

                busName = bom.Element("BUSINESSOBJECTIVE").Value.TrimEnd();
                objective = category.Objectives.Find(delegate(NewObjective bus)
                {
                    return bus.ObjName == busName;
                });
                if (objective == null)
                {
                    objective = category.AddObjective(busName);
                }

                iniName = bom.Element("IMPERATIVE").Value.TrimEnd();
                imperative = objective.Imperatives.Find(delegate(NewImperative ini)
                {
                    return ini.Name == iniName;
                });
                if (imperative == null)
                {
                    imperative = objective.AddImperative(iniName);
                    imperative.Effectiveness = Convert.ToSingle(bom.Element("EFFECTIVENESS").Value);
                    imperative.Criticality = Convert.ToSingle(bom.Element("CRITICALITY").Value);
                    imperative.Differentiation = Convert.ToSingle(bom.Element("DIFFERENTIAL").Value);
                }
            }
        }
예제 #7
0
 public override void ChangedCategory(BOMTool bomForm)
 {
     bomForm.objectiveNames.Items.Clear();
     bomForm.objectiveNames.Text = "<Select Objective>";
     bomForm.imperativeNames.Items.Clear();
     bomForm.imperativeNames.Text = "";
     CATEGORY category;
     if (GetCategory(bomForm.categoryNames.Text.Trim(), out category))
     {
         bomForm.objectiveNames.Items.AddRange((from ent in category.BUSINESSOBJECTIVE
                                        select ent.NAME.TrimEnd()).ToArray());
     }
 }
예제 #8
0
        public override bool AddImperativeToBOM(string iniName, string busName, string catName, BOMTool bomForm)
        {
            IMPERATIVE imperative;
            if (!GetImperative(iniName, out imperative))
            {
                imperative = new IMPERATIVE();
                imperative.NAME = iniName;
                BUSINESSOBJECTIVE objective;
                if (!GetObjective(busName, out objective))
                {
                    objective = new BUSINESSOBJECTIVE();
                    objective.NAME = busName;
                    CATEGORY category;
                    if (!GetCategory(catName, out category))
                    {
                        category = new CATEGORY();
                        category.NAME = catName;
                        if (!AddCategory(category))
                        {
                            MessageBox.Show("Failed to add Category to Database", "Error");
                            return false;
                        }
                    }

                    objective.CATEGORY = category;
                    if (!AddObjective(objective))
                    {
                        MessageBox.Show("Failed to add Objective to Database", "Error");
                        return false;
                    }
                }

                else if (objective.CATEGORY.NAME.TrimEnd() != catName)
                {
                    MessageBox.Show("Objective already exists under category " + objective.CATEGORY.NAME.TrimEnd(), "Error");
                    return false;
                }

                imperative.BUSINESSOBJECTIVE = objective;
                if (!AddImperative(imperative))
                {
                    MessageBox.Show("Failed to add Imperative to Database", "Error");
                    return false;
                }
            }

            else if (imperative.BUSINESSOBJECTIVE.NAME.TrimEnd() != busName)
            {
                MessageBox.Show("Imperative already exists under objective " + imperative.BUSINESSOBJECTIVE.NAME.TrimEnd(), "Error");
                return false;
            }

            BUSINESSOBJECTIVE testObjective;
            if (GetObjective(busName, out testObjective) && testObjective.CATEGORY.NAME.TrimEnd() != catName)
            {
                MessageBox.Show("Objective already exists under category " + testObjective.CATEGORY.NAME.TrimEnd(), "Error");
                return false;
            }

            BOM bom = new BOM();
            bom.IMPERATIVE = imperative;
            if (!AddBOM(bom, ClientDataControl.Client.EntityObject))
            {
                MessageBox.Show("Failed to add Imperative to BOM", "Error");
                return false;
            }
            if (!SaveChanges())
            {
                MessageBox.Show("Failed to save changes to database", "Error");
                return false;
            }

            else
            {
                //Successfully added to database, update GUI
                catName = bom.IMPERATIVE.BUSINESSOBJECTIVE.CATEGORY.NAME.TrimEnd();
                NewCategory category = bomForm.Categories.Find(delegate(NewCategory cat)
                {
                    return cat.name == catName;
                });
                if (category == null)
                {
                    category = bomForm.AddCategory(catName);
                }

                bomForm.CategoryWorkspace.SelectTab(category.name);

                busName = bom.IMPERATIVE.BUSINESSOBJECTIVE.NAME.TrimEnd();
                NewObjective objective = category.Objectives.Find(delegate(NewObjective bus)
                {
                    return bus.ObjName == busName;
                });
                if (objective == null)
                {
                    objective = category.AddObjective(busName);
                }

                iniName = bom.IMPERATIVE.NAME.TrimEnd();
                NewImperative imperativeObj = objective.Imperatives.Find(delegate(NewImperative ini)
                {
                    return ini.Name == iniName;
                });
                if (imperativeObj == null)
                {
                    imperativeObj = objective.AddImperative(iniName);
                }
                else
                {
                    MessageBox.Show("Imperative already exists in BOM", "Error");
                }
            }

            return true;
        }
예제 #9
0
 public DataEntryForm(BOMTool chart)
 {
     mainForm = chart;
     InitializeComponent();
     FillData();
 }
예제 #10
0
 public abstract void ChangedCategory(BOMTool bomForm);
예제 #11
0
 public abstract void BuildBOMForm(BOMTool bomForm);
예제 #12
0
 public abstract bool AddImperativeToBOM(string iniName, string busName, string catName, BOMTool bomForm);
예제 #13
0
 public override void ChangedObjective(BOMTool bomForm)
 {
     bomForm.imperativeNames.Items.Clear();
     bomForm.imperativeNames.Text = "<Select Imperative>";
     XElement objective;
     if (GetObjective(bomForm.objectiveNames.Text.Trim(), out objective))
     {
         bomForm.imperativeNames.Items.AddRange((from ent in objective.Element("IMPERATIVES").Elements("IMPERATIVE")
                                                 select ent.Element("NAME").Value).ToArray());
     }
 }
예제 #14
0
 public override void ChangedCategory(BOMTool bomForm)
 {
     bomForm.objectiveNames.Items.Clear();
     bomForm.objectiveNames.Text = "<Select Objective>";
     bomForm.imperativeNames.Items.Clear();
     bomForm.imperativeNames.Text = "";
     XElement category;
     if (GetCategory(bomForm.categoryNames.Text.Trim(), out category))
     {
         bomForm.objectiveNames.Items.AddRange((from ent in category.Element("BUSINESSOBJECTIVES").Elements("BUSINESSOBJECTIVE")
                                                select ent.Element("NAME").Value).ToArray());
     }
 }
예제 #15
0
 public abstract void ChangedObjective(BOMTool bomForm);
예제 #16
0
 public DataEntryForm(BOMTool chart)
 {
     mainForm = chart;
     InitializeComponent();
     FillData();
 }
예제 #17
0
 public abstract void ChangedObjective(BOMTool bomForm);
예제 #18
0
 public NewCategory(BOMTool owner, int id, string name)
 {
     this.owner = owner;
     this.ID = id;
     this.name = name;
 }
예제 #19
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="info"></param>
        public BOMChartDynamically(BOMTool info)
        {
            mainForm = info;
            MaxCount = Count();

            //ClientDataControl.Client = mainForm.CompanyName;

            for (int i = 0; i < MaxCount; i++)
            {
                circle[i] = new OvalShape();
                labelInfo[i] = new Label();
                objectivesCheckBox[i] = new CheckBox();
                categoryLabel[i] = new Label();
                labelHide[i] = false;
                newDiff[i] = new float();
                newCrit[i] = new float();
                newEff[i] = new int();
                catArray[i] = new int();
                objArray[i] = new int();
                iniArray[i] = new int();

                count[i] = new int();
                clickArray[i] = new int();
                for (int j = 0; j < 100; j++)
                {
                    difArray[i, j] = new float();
                    effArray[i, j] = new float();
                    criArray[i, j] = new float();
                    locX[i, j] = new int();
                    locY[i, j] = new int();
                    //access[i, j] = new string("", j);
                }
            }

            panelChart.Parent = this;
            panelList.Parent = this;
            btnClose.Parent = this;
            btnReset.Parent = this;
            btnUndo.Parent = this;
            btnSave.Parent = this;
            btnUpdate.Parent = this;
            infoPanel.Parent = this;

            infoGridView.Parent = infoPanel;
            infoLabel.Parent = infoPanel;

            ShapeContainer canvas = new ShapeContainer();
            canvas.Parent = panelChart;

            lineX.Parent = canvas;
            lineY.Parent = canvas;
            diffLabel.Parent = panelChart;
            origin.Parent = panelChart;
            endX.Parent = panelChart;
            endY.Parent = panelChart;
            endXLine.Parent = canvas;
            endYLine.Parent = canvas;

            panelChart.Width = 550;
            panelChart.Height = 550;

            panelList.Width = 200;
            panelList.Height = 400;

            infoPanel.Width = 770;
            infoPanel.Height = 140;
            infoPanel.AutoScroll = true;

            infoLabel.Width = 770;
            infoLabel.Height = 20;
            infoLabel.Font = new Font("Arial", 12);
            infoLabel.Text = "View Bubble: ";

            infoGridView.Width = 770;
            infoGridView.Height = 100;
            infoGridView.AllowUserToAddRows = false;
            infoGridView.AllowUserToDeleteRows = false;
            infoGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;

            DataGridViewCellStyle columnHeaderStyle = new DataGridViewCellStyle();
            columnHeaderStyle.BackColor = Color.Aqua;
            columnHeaderStyle.Font = new Font("Verdana", 12, FontStyle.Bold);
            columnHeaderStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            infoGridView.ColumnHeadersDefaultCellStyle = columnHeaderStyle;

            DataGridViewCellStyle rowStyle = new DataGridViewCellStyle();
            rowStyle.Font = new Font("Verdana", 12);
            rowStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            infoGridView.RowsDefaultCellStyle = rowStyle;

            infoGridView.ColumnCount = 4;
            infoGridView.Columns[0].Name = "Imperative";
            infoGridView.Columns[1].Name = "Differentiation";
            infoGridView.Columns[2].Name = "Criticality";
            infoGridView.Columns[3].Name = "Effectiveness";

            infoGridView.RowHeadersVisible = false;
            infoGridView.AutoSize = true;

            panelList.AutoScroll = true;

            diffLabel.AutoSize = true;
            diffLabel.Text = "Differentiation";
            diffLabel.Font = new Font("Arial", 14, FontStyle.Bold);
            diffLabel.BringToFront();

            origin.AutoSize = true;
            origin.Text = "0";
            origin.Font = new Font("Arial", 12);

            endX.AutoSize = true;
            endX.Text = "10";
            endX.Font = new Font("Arial", 12);

            endY.AutoSize = true;
            endY.Text = "10";
            endY.Font = new Font("Arial", 12);

            //criticLabel.AutoSize = true;
            //criticLabel.Text = "Criticality";
            //criticLabel.Font = new Font("Arial", 14, FontStyle.Bold);
            //diffLabel.Font.Size = 14;
            //diffLabel.Font.Name = "Arial";
            //diffLabel.Font.Bold = true;

            diffLabel.Location = new Point(panelChart.Width / 2 - diffLabel.Width / 2, panelChart.Height - diffLabel.Height - 5);

            Size btnSize = new Size(200, 35);
            Size btnSmallSize = new Size(95, 35);

            btnClose.Size = btnSize;
            btnReset.Size = btnSmallSize;
            btnUndo.Size = btnSmallSize;
            btnSave.Size = btnSize;
            btnUpdate.Size = btnSize;

            btnClose.Text = "Close";
            btnReset.Text = "Reset";
            btnUndo.Text = "Undo";
            btnSave.Text = "Save Image";
            btnUpdate.Text = "Update";

            btnClose.TextAlign = ContentAlignment.MiddleCenter;

            lineX.X1 = 30;
            lineX.X2 = panelChart.Width - 20;
            lineX.Y1 = panelChart.Height - 30;
            lineX.Y2 = panelChart.Height - 30;
            lineX.Enabled = false;

            lineY.X1 = 30;
            lineY.X2 = 30;
            lineY.Y1 = 20;
            lineY.Y2 = panelChart.Height - 30;
            lineY.Enabled = false;

            endXLine.X1 = lineX.X2;
            endXLine.X2 = lineX.X2;
            endXLine.Y1 = lineX.Y1;
            endXLine.Y2 = lineX.Y1 + 5;

            endYLine.X1 = lineY.X1 - 5;
            endYLine.X2 = lineY.X1;
            endYLine.Y1 = lineY.Y1;
            endYLine.Y2 = lineY.Y1;

            origin.Location = new Point(lineX.X1 - origin.Size.Width, lineX.Y1);
            endX.Location = new Point(endXLine.X2 - endX.Size.Width / 2, endXLine.Y2);
            endY.Location = new Point(endYLine.X1 - endY.Size.Width, endYLine.Y1);

            origin.BringToFront();
            endX.BringToFront();
            endY.BringToFront();

            this.SizeChanged += new EventHandler(BOMChartDynamically_SizeChanged);
            SizeChanged += new EventHandler(panelChart_SizeChanged);
            SizeChanged += new EventHandler(panelList_SizeChanged);
            SizeChanged += new EventHandler(infoPanel_SizeChanged);

            panelChart.BackColor = Color.White;
            panelList.BackColor = Color.LightGray;
            infoPanel.BackColor = Color.DimGray;

            panelChart.Location = new Point(5, 5);
            panelList.Location = new Point(570, 5);
            infoPanel.Location = new Point(5, 560);
            infoLabel.Location = new Point(0, 0);
            infoGridView.Location = new Point(0, 20);

            btnUndo.Location = new Point(570, panelList.Height + 10);
            btnReset.Location = new Point(570 + btnUndo.Width, panelList.Height + 10);
            btnUpdate.Location = new Point(570, btnUndo.Location.Y + 38);
            btnSave.Location = new Point(570, btnUpdate.Location.Y + 38);
            btnClose.Location = new Point(570, btnSave.Location.Y + 38);

            btnUndo.Click += new EventHandler(btnUndo_Click);
            btnReset.Click += new EventHandler(btnReset_Click);
            btnSave.Click += new EventHandler(btnSave_Click);
            btnClose.Click += new EventHandler(btnClose_Click);
            btnUpdate.Click += new EventHandler(btnUpdate_Click);

            //picBox.Parent = panelChart;

            //panelChart.Paint += new PaintEventHandler(OnPaintBackground);
            //picBox.BringToFront();

            int rowCount = 0;
            objCount = 0;

            int cirCount = 0;
            int objectivesCount = 0;
            mouseDown = false;

            for (int i = 0; i < circleCount; i++)
            {
                if (labelInfo[i] != null)
                {
                    labelInfo[i].ResetText();
                    labelInfo[i] = new Label();
                }
            }

            for (int i = 0; i < circleCount; i++)
            {
                if (circle[i] != null)
                {
                    circle[i].Hide();
                    circle[i] = new OvalShape();
                }
            }

            circleCount = 0;
            labelCount = 0;

            int x = 5;
            int y = 5;

            if (mainForm == null)
            {
                this.Hide();
            }

            int valOfCount = 0;

            for (int i = 0; i < mainForm.Categories.Count; i++)
            {
                rowCount++;
                categoryLabel[i].Parent = panelList;
                categoryLabel[i].Text = mainForm.Categories[i].name;
                categoryLabel[i].AutoSize = true;
                categoryLabel[i].Font = new Font("Arial", 12, FontStyle.Bold);
                categoryLabel[i].BackColor = Color.Orange;
                y += i * 24;
                categoryLabel[i].Location = new Point(x, y);
                for (int j = 0; j < mainForm.Categories[i].Objectives.Count; j++)
                {
                    rowCount++;
                    objectivesCheckBox[objCount].Parent = panelList;
                    //System.Diagnostics.Trace.WriteLine(mainForm.Categories[i].Objectives[j].Name);
                    objectivesCheckBox[objCount].Text = mainForm.Categories[i].Objectives[j].ObjName;
                    objectivesCheckBox[objCount].Name = objectivesCheckBox[j].Text;
                    y += 24;
                    objectivesCheckBox[objCount].Location = new Point((x + 10), y);
                    objectivesCheckBox[objCount].Font = new Font("Arial", 12);
                    objectivesCheckBox[objCount].AutoSize = true;
                    objectivesCheckBox[objCount].BackColor = mainForm.Categories[i].Objectives[j].BackColor;
                    if (valOfCount > 0 && objectivesCheckBox[objCount - valOfCount].BackColor ==  objectivesCheckBox[objCount].BackColor)
                        objectivesCheckBox[objCount].BackColor = Color.FromArgb(random.Next(225), random.Next(225), random.Next(225), random.Next(225));
                    objectivesCheckBox[objCount].Checked = true;
                    objectivesCheckBox[objCount].CheckedChanged += new EventHandler(checkBox_CheckedChanged);
                    valOfCount++;
                    //if (objectivesCheckBox[objectivesCount].Checked)
                    //{
                        for (int k = 0; k < mainForm.Categories[i].Objectives[j].Imperatives.Count; k++)
                        {
                            name = mainForm.Categories[i].Objectives[j].Imperatives[k].Name;
                            criticality = mainForm.Categories[i].Objectives[j].Imperatives[k].Criticality;
                            differentiation = mainForm.Categories[i].Objectives[j].Imperatives[k].Differentiation;
                            effectiveness = mainForm.Categories[i].Objectives[j].Imperatives[k].Effectiveness;

                            catArray[cirCount] = i;
                            objArray[cirCount] = j;
                            iniArray[cirCount] = k;

                            float effective = effectiveness * 20;
                            int effectivenessBig = (int)(effective);
                            newEff[cirCount] = effectivenessBig;
                            effArray[cirCount, 0] = effectiveness;

                            float critical = criticality * ((lineY.Y2 - lineY.Y1) / 10);
                            int newCriticality = (int)(critical);
                            newCrit[cirCount] = criticality;
                            criArray[cirCount, 0] = criticality;

                            float different = differentiation * ((lineX.X2 - lineX.X1) / 10);
                            int newDifferentiation = (int)(different);
                            newDiff[cirCount] = differentiation;
                            difArray[cirCount, 0] = differentiation;

                            System.Diagnostics.Trace.WriteLine("Diff: " + newDifferentiation.ToString() + "  Critic: " + newCriticality.ToString());

                            circle[cirCount].Parent = canvas;

                            circle[cirCount].FillStyle = FillStyle.Solid;
                            circle[cirCount].FillColor = objectivesCheckBox[objectivesCount].BackColor;

                            circle[cirCount].Name = (i + 1).ToString() + "." + (j + 1).ToString() + "." + (k + 1).ToString() + " " + name;

                            circle[cirCount].AccessibleName = "Differentiation: " + differentiation.ToString() + ",  Criticality: " + criticality.ToString()
                                + ",  Effectiveness: " + effectiveness.ToString();

                            //circle[cirCount].AccessibleDescription = circle[cirCount].Name + "\n" + circle[cirCount].AccessibleName;

                            circle[cirCount].Visible = true;
                            circle[cirCount].Location = new System.Drawing.Point((30 + (int)(newDifferentiation) - (int)effectivenessBig / 2), (lineX.Y1 - (int)(newCriticality) - (int)(effectivenessBig / 2)));
                            circle[cirCount].Size = new System.Drawing.Size(effectivenessBig, effectivenessBig);

                            locX[cirCount, 0] = circle[cirCount].Left;
                            locY[cirCount, 0] = circle[cirCount].Top;
                            count[cirCount] = 0;
                            access1[cirCount, 0] = circle[cirCount].Name;
                            access2[cirCount, 0] = circle[cirCount].AccessibleName;

                            System.Diagnostics.Trace.WriteLine("X: " + circle[cirCount].Location.X.ToString() + "  Y: " + circle[cirCount].Location.Y.ToString());

                            circle[cirCount].MouseClick += new MouseEventHandler(circle_MouseClick);
                            circle[cirCount].MouseDown += new MouseEventHandler(circle_MouseDown);
                            circle[cirCount].MouseMove += new MouseEventHandler(circle_MouseMove);
                            circle[cirCount].MouseUp += new MouseEventHandler(circle_MouseUp);

                            rowCount++;
                            circleCount++;
                            cirCount++;
                            imperativesCount++;

                        }
                    //}*/
                    objectivesCount++;
                    objCount++;
                }
                y += 10;
            }
            panelChart.Paint += new PaintEventHandler(picBox_Paint);

            Bitmap bmp = new Bitmap(panelChart.Width, panelChart.Height);
            //new Bitmap(this.panelChart.Width,this.panelChart.Height);
            panelChart.DrawToBitmap(bmp, new Rectangle(5, 5, bmp.Width, bmp.Height));
            //System.Diagnostics.Trace.WriteLine("path: " + Application.StartupPath.ToString());
            bmp.Save(ClientDataControl.Client.FilePath + "/BubbleChart.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
            bmp.Save(Directory.GetCurrentDirectory() + @"/Charts/" + "BubbleChart.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);

            InitializeComponent();

            //this.panelChart.Paint += new PaintEventHandler(picBox_Paint);
            //GenerateText();
        }
예제 #20
0
        public override void BuildBOMForm(BOMTool bomForm)
        {
            CLIENT client = ClientDataControl.Client.EntityObject as CLIENT;

            string catName;
            string busName;
            string iniName;

            NewCategory category;
            NewObjective objective;
            NewImperative imperative;

            foreach (BOM bom in client.BOM)
            {
                catName = bom.IMPERATIVE.BUSINESSOBJECTIVE.CATEGORY.NAME.TrimEnd();
                category = bomForm.Categories.Find(delegate(NewCategory cat)
                {
                    return cat.name == catName;
                });
                if (category == null)
                {
                    category = bomForm.AddCategory(catName);
                }

                bomForm.CategoryWorkspace.SelectTab(category.name);

                busName = bom.IMPERATIVE.BUSINESSOBJECTIVE.NAME.TrimEnd();
                objective = category.Objectives.Find(delegate(NewObjective bus)
                {
                    return bus.ObjName == busName;
                });
                if (objective == null)
                {
                    objective = category.AddObjective(busName);
                }

                iniName = bom.IMPERATIVE.NAME.TrimEnd();
                imperative = objective.Imperatives.Find(delegate(NewImperative ini)
                {
                    return ini.Name == iniName;
                });
                if (imperative == null)
                {
                    imperative = objective.AddImperative(iniName);
                    imperative.Effectiveness = bom.EFFECTIVENESS.HasValue ? bom.EFFECTIVENESS.Value : 0;
                    imperative.Criticality = bom.CRITICALITY.HasValue ? bom.CRITICALITY.Value : 0;
                    imperative.Differentiation = bom.DIFFERENTIAL.HasValue ? bom.DIFFERENTIAL.Value : 0;
                }
            }
        }
예제 #21
0
 public NewCategory(BOMTool owner, int id, string name)
 {
     this.owner = owner;
     this.ID    = id;
     this.name  = name;
 }
예제 #22
0
 public override void ChangedObjective(BOMTool bomForm)
 {
     bomForm.imperativeNames.Items.Clear();
     bomForm.imperativeNames.Text = "<Select Imperative>";
     BUSINESSOBJECTIVE objective;
     if (GetObjective(bomForm.objectiveNames.Text.Trim(), out objective))
     {
         bomForm.imperativeNames.Items.AddRange((from ent in objective.IMPERATIVE
                                         select ent.NAME.TrimEnd()).ToArray());
     }
 }
예제 #23
0
        public override bool AddImperativeToBOM(string iniName, string busName, string catName, BOMTool bomForm)
        {
            XElement categoryXML;
            if (!GetCategory(catName, out categoryXML))
            {
                categoryXML = new XElement("CATEGORY");
                categoryXML.Add(new XElement("NAME", catName));
                if (!AddCategory(categoryXML))
                {
                    MessageBox.Show("Failed to add Category to File", "Error");
                    return false;
                }
            }

            XElement objectiveXML;
            if (!GetObjective(busName, out objectiveXML))
            {
                objectiveXML = new XElement("BUSINESSOBJECTIVE");
                objectiveXML.Add(new XElement("NAME", busName));
                if (!AddObjective(objectiveXML, categoryXML))
                {
                    MessageBox.Show("Failed to add Objective to File", "Error");
                    return false;
                }
            }

            else if (objectiveXML.Parent.Parent.Element("NAME").Value != catName)
            {
                MessageBox.Show("Objective already exists under category " + objectiveXML.Parent.Parent.Element("NAME").Value, "Error");
                return false;
            }

            XElement imperativeXML;
            if (!GetImperative(iniName, out imperativeXML))
            {
                imperativeXML = new XElement("IMPERATIVE");
                imperativeXML.Add(new XElement("NAME", iniName));
                if (!AddImperative(imperativeXML, objectiveXML, categoryXML))
                {
                    MessageBox.Show("Failed to add Imperative to File", "Error");
                    return false;
                }
            }

            else if (imperativeXML.Parent.Parent.Element("NAME").Value != busName)
            {
                MessageBox.Show("Imperative already exists under objective " + imperativeXML.Parent.Parent.Element("NAME").Value, "Error");
                return false;
            }

            XElement bom = new XElement("BOM");
            bom.Add(new XElement("IMPERATIVE", imperativeXML.Element("NAME").Value));
            bom.Add(new XElement("BUSINESSOBJECTIVE", objectiveXML.Element("NAME").Value));
            bom.Add(new XElement("CATEGORY", categoryXML.Element("NAME").Value));

            if (!AddBOM(bom, ClientDataControl.Client.EntityObject))
            {
                MessageBox.Show("Failed to add Imperative to BOM", "Error");
                return false;
            }

            if (!SaveChanges())
            {
                MessageBox.Show("Failed to save changes to File", "Error");
                return false;
            }

            else
            {
                //Successfully added to database, update GUI
                NewCategory category = bomForm.Categories.Find(delegate(NewCategory cat)
                {
                    return cat.name == catName;
                });
                if (category == null)
                {
                    category = bomForm.AddCategory(catName);
                }

                NewObjective objective = category.Objectives.Find(delegate(NewObjective bus)
                {
                    return bus.ObjName == busName;
                });
                if (objective == null)
                {
                    objective = category.AddObjective(busName);
                }

                NewImperative imperativeObj = objective.Imperatives.Find(delegate(NewImperative ini)
                {
                    return ini.Name == iniName;
                });
                if (imperativeObj == null)
                {
                    imperativeObj = objective.AddImperative(iniName);
                }
                else
                {
                    MessageBox.Show("Imperative already exists in BOM", "Error");
                }
            }

            return true;
        }