示例#1
0
 private void categoryAddButton_Click(object sender, EventArgs e)
 {
     Category category = new Category(this, categoryNames.Text);
     categories.Add(category);
     categoryCount++;
     category.Click += new EventHandler(category_Click);
 }
示例#2
0
        public BusinessObjective(Category owner, string name)
        {
            this.owner = owner;
            this.name = name;
            baseObjectiveWidth = owner.Width;
            owner.Controls.Add(this);
            this.Height = baseObjectiveHeight;
            this.Width = Parent.Width;
            this.BackColor = Color.Aquamarine;
            this.Location = FindLocation();

            MakeLabel();
            // objective.Name = name;
               owner.UpdateHeight();
            //owner.Controls.Add(this);
            //this.Location = FindLocation();
        }
示例#3
0
 private void category_Click(object sender, EventArgs e)
 {
     Category cat = (Category)sender;
     lastFocused = cat;
     Console.WriteLine("clicked on category:" + cat.Name);
 }
示例#4
0
 /// <summary>
 /// Create a new Category object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 public static Category CreateCategory(global::System.Int32 id)
 {
     Category category = new Category();
     category.Id = id;
     return category;
 }
示例#5
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Category EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToCategory(Category category)
 {
     base.AddObject("Category", category);
 }
 public BusinessObjective(Category owner, string name)
 {
     this.owner = owner;
     this.name = name;
 }
示例#7
0
        private void initiativeAddButton_Click(object sender, EventArgs e)
        {
            string catName;
            string busName;
            string iniName = initiativeNames.Text.Trim();
            INITIATIVE initiative;
            if (!db.GetInitiative(iniName, out initiative))
            {
                initiative = new INITIATIVE();
                initiative.NAME = iniName;
                BUSINESSOBJECTIVE objective;
                busName = objectiveNames.Text.Trim();
                if(!db.GetObjective(busName, out objective))
                {
                    objective = new BUSINESSOBJECTIVE();
                    objective.NAME = objectiveNames.Text.Trim();
                    CATEGORY category;
                    catName = categoryNames.Text.Trim();
                    if(!db.GetCategory(catName, out category))
                    {
                        category = new CATEGORY();
                        category.NAME = catName;
                        if(!db.AddCategory(category))
                        {
                            MessageBox.Show("Failed to add Category to Database", "Error");
                            return;
                        }
                    }

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

                initiative.BUSINESSOBJECTIVE = objective;
                if (!db.AddInitiative(initiative))
                {
                    MessageBox.Show("Failed to add Initiative to Database", "Error");
                    return;
                }
            }

            BOM bom = new BOM();
            bom.INITIATIVE = initiative;
            if (!db.AddBOM(bom, client))
            {
                MessageBox.Show("Failed to add Initiative to BOM", "Error");
                return;
            }
            if (!db.SaveChanges())
            {
                MessageBox.Show("Failed to save changes to database", "Error");
                return;
            }

            else
            {
                //Successfully added to database, update GUI
                catName = bom.INITIATIVE.BUSINESSOBJECTIVE.CATEGORY.NAME.TrimEnd();
                Category category = categories.Find(delegate(Category cat)
                {
                    return cat.Name == catName;
                });
                if (category == null)
                {
                    category = new Category(this, catName);
                    categories.Add(category);
                    categoryCount++;
                    category.Click += new EventHandler(category_Click);
                }

                busName = bom.INITIATIVE.BUSINESSOBJECTIVE.NAME.TrimEnd();
                BusinessObjective objective = category.Objectives.Find(delegate(BusinessObjective bus)
                {
                    return bus.Name == busName;
                });
                if (objective == null)
                {
                    objective = category.AddObjective(busName);
                }

                iniName = bom.INITIATIVE.NAME.TrimEnd();
                Initiative initiativeObj = objective.Initiatives.Find(delegate(Initiative ini)
                                                                   {
                                                                       return ini.Name == iniName;
                                                                   });
                if (initiativeObj == null)
                {
                    initiativeObj = objective.AddInitiative(iniName);
                }
                else
                {
                    MessageBox.Show("Initiative already exists in BOM", "Error");
                }
            }
        }