Exemplo n.º 1
0
 /// <summary>
 /// Deprecated Method for adding a new object to the INITIATIVE EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToINITIATIVE(INITIATIVE iNITIATIVE)
 {
     base.AddObject("INITIATIVE", iNITIATIVE);
 }
Exemplo n.º 2
0
 /// <summary>
 /// Create a new INITIATIVE object.
 /// </summary>
 /// <param name="nAME">Initial value of the NAME property.</param>
 /// <param name="iNITIATIVEID">Initial value of the INITIATIVEID property.</param>
 public static INITIATIVE CreateINITIATIVE(global::System.String nAME, global::System.Int32 iNITIATIVEID)
 {
     INITIATIVE iNITIATIVE = new INITIATIVE();
     iNITIATIVE.NAME = nAME;
     iNITIATIVE.INITIATIVEID = iNITIATIVEID;
     return iNITIATIVE;
 }
Exemplo n.º 3
0
 /// <summary>
 /// Create a new INITIATIVE object.
 /// </summary>
 /// <param name="nAME">Initial value of the NAME property.</param>
 /// <param name="iNITIATIVEID">Initial value of the INITIATIVEID property.</param>
 /// <param name="bUSINESSOBJECTIVE">Initial value of the BUSINESSOBJECTIVE property.</param>
 public static INITIATIVE CreateINITIATIVE(global::System.String nAME, global::System.Int32 iNITIATIVEID, global::System.Int32 bUSINESSOBJECTIVE)
 {
     INITIATIVE iNITIATIVE = new INITIATIVE();
     iNITIATIVE.NAME = nAME;
     iNITIATIVE.INITIATIVEID = iNITIATIVEID;
     iNITIATIVE.BUSINESSOBJECTIVE = bUSINESSOBJECTIVE;
     return iNITIATIVE;
 }
Exemplo n.º 4
0
        private void AddInitiativeToTableButton_Click(object sender, EventArgs e)
        {
            List<int> idList;
            var selectedInitiativeQuery = from ini in mainForm.dbo.INITIATIVE
                                          where ini.NAME == InitiativeComboBox.Text
                                          select ini;

            if (selectedInitiativeQuery.Count() == 0)
            {
                selectedInitiative = new INITIATIVE();
                selectedInitiative.NAME = InitiativeComboBox.Text;
                idList = (from ini in mainForm.dbo.INITIATIVE
                          select ini.INITIATIVEID).ToList();
                selectedInitiative.INITIATIVEID = mainForm.GetUniqueID(idList);
                var selectedBusinessObjectiveQuery = from bus in mainForm.dbo.BUSINESSOBJECTIVE
                                                     where bus.NAME == BusinessObjectiveComboBox.Text
                                                     select bus;

                if (selectedBusinessObjectiveQuery.Count() == 0)
                {
                    selectedBusinessObjective = new BUSINESSOBJECTIVE();
                    selectedBusinessObjective.NAME = BusinessObjectiveComboBox.Text;
                    idList = (from bus in mainForm.dbo.BUSINESSOBJECTIVE
                              select bus.BUSINESSOBJECTIVEID).ToList();
                    selectedBusinessObjective.BUSINESSOBJECTIVEID = mainForm.GetUniqueID(idList);
                    var selectedCategoryQuery = from cat in mainForm.dbo.CATEGORY
                                                where cat.NAME == CategoryComboBox.Text
                                                select cat;

                    if (selectedCategoryQuery.Count() == 0)
                    {
                        selectedCategory = new CATEGORY();
                        selectedCategory.NAME = CategoryComboBox.Text;
                        idList = (from cat in mainForm.dbo.CATEGORY
                                 select cat.CATEGORYID).ToList();
                        selectedCategory.CATEGORYID = mainForm.GetUniqueID(idList);
                        selectedCategory.BUSINESSOBJECTIVE.Add(selectedBusinessObjective);
                        mainForm.dbo.AddToCATEGORY(selectedCategory);
                    }

                    selectedBusinessObjective.CATEGORY = selectedCategory;
                    selectedBusinessObjective.INITIATIVE.Add(selectedInitiative);
                    mainForm.dbo.AddToBUSINESSOBJECTIVE(selectedBusinessObjective);
                }

                selectedInitiative.BUSINESSOBJECTIVE = selectedBusinessObjective;

                mainForm.dbo.AddToINITIATIVE(selectedInitiative);
            }

            BOM newBOM = new BOM();
            idList = (from bom in mainForm.dbo.BOM
                     select bom.BOMID).ToList();
            newBOM.BOMID = mainForm.GetUniqueID(idList);
            newBOM.CLIENT = mainForm.currentClient;
            newBOM.INITIATIVE = selectedInitiative;
            selectedInitiative.BOM.Add(newBOM);

            mainForm.dbo.SaveChanges();

            DataGridViewRow row = (DataGridViewRow)mainForm.BOMTable.Rows[0].Clone();
            row.Cells[0].Value = selectedCategory.NAME;
            row.Cells[1].Value = selectedBusinessObjective.NAME;
            row.Cells[2].Value = selectedInitiative.NAME;
            mainForm.BOMTable.Rows.Add(row);
            this.Close();
        }
Exemplo n.º 5
0
        private void InitiativeComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                var selectedInitiativeQuery = from ini in mainForm.dbo.INITIATIVE
                                              where ini.NAME == InitiativeComboBox.Text
                                              select ini;

                selectedInitiative = selectedInitiativeQuery.Single();
            }

            catch { }
        }
Exemplo n.º 6
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");
                }
            }
        }