public void BusinessValueSetDescriptionTest()
 {
     BusinessValue bv = new BusinessValue("test");
     bv.SetDescription("test1");
     Assert.IsTrue(bv.GetDescription() == "test1");
     bv.SetDescription("test");
 }
Esempio n. 2
0
        public static void AddBusVal(string id, string name, string mapName, string stratID)
        {
            RoadMap map = new RoadMap(mapName);

            StrategyPoint point = map.GetPoint(stratID);

            BusinessValue newBusVal = new BusinessValue(id, mapName);
            point.CreateBusinessValue(id, name, mapName);

            //function to add to database
        }
 public void BusinessValueSetNameTest()
 {
     BusinessValue bv = new BusinessValue("test");
     Assert.IsTrue(bv.SetName("test3"));
     bv.SetName("test");
 }
        public void BusinessValueConstructorTest()
        {
            BusinessValue bv = new BusinessValue("test");

            Assert.IsNotNull(bv);
        }
Esempio n. 5
0
        //Reorder BV to insert a new one in the middle
        public void ReorderBusinessValue(string currname, string desc, bool isFirst)
        {
            BusinessValue current = new BusinessValue(currname, mRoadmapName);
            current.SetDescription(desc);
            int index = (int)Char.GetNumericValue(currname[15]) + 1;
            string nextID = currname.Substring(0,15) + index.ToString();
            string nextdesc = null;

            string selectname = null;
            if (isFirst) selectname = currname;
            else selectname = nextID;

            using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["connstring"].ConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.CommandText = "SELECT Description FROM [dbo].[BusinessValue] WHERE Name=@sname AND RoadmapName=@Rname";
                    cmd.Parameters.AddWithValue("@sname", selectname);
                    cmd.Parameters.AddWithValue("@Rname", mRoadmapName);
                    cmd.Connection = conn;

                    conn.Open();
                    using (SqlDataReader Reader =cmd.ExecuteReader())
                    {
                        if (Reader.HasRows)
                        {
                            Reader.Read();
                            nextdesc = Reader.GetString(0);
                        }
                    }
                    conn.Close();
                }
            }

            BusinessValue next = new BusinessValue(nextID, mRoadmapName);
            next.SetDescription(nextdesc);
            BusinessValue nextdummy = new BusinessValue(currname, mRoadmapName);
            nextdummy.SetDescription(nextdesc);
            if (nextdesc != null)
            {
                nextdummy.SetName(nextID);
                ReorderBusinessValue(nextID, nextdesc, false);
            }
        }
Esempio n. 6
0
        //Reload list of BV's
        public void ReloadBusinessValues()
        {
            mValues = new List<BusinessValue>();

            using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["connstring"].ConnectionString))
            {
                using (SqlCommand cmd1 = new SqlCommand())
                {
                    cmd1.CommandText = "SELECT BusinessValueName FROM [dbo].[SP_BV_Crosswalk] WHERE RoadmapName = @Rname AND StrategyPointName =@Sname";
                    cmd1.Parameters.AddWithValue("@Rname", mRoadmapName);
                    cmd1.Parameters.AddWithValue("@Sname", mName);
                    cmd1.Connection = conn;

                    conn.Open();
                    using (SqlDataReader Reader = cmd1.ExecuteReader())
                    {
                        while (Reader.Read())
                        {
                            string temp = Reader.GetString(0);
                            BusinessValue bv = new BusinessValue(Reader.GetString(0), mRoadmapName);
                            mValues.Add(bv);
                        }
                    }
                }

                foreach (BusinessValue bv in mValues)
                {
                    using (SqlCommand cmd2 = new SqlCommand())
                    {
                        cmd2.CommandText = "SELECT Description FROM [dbo].[BusinessValue] WHERE Name=@BVName AND RoadmapName=@Rname";
                        cmd2.Parameters.AddWithValue("@Rname", mRoadmapName);
                        cmd2.Parameters.AddWithValue("@BVName", bv.GetName());
                        cmd2.Connection = conn;

                        using (SqlDataReader Reader = cmd2.ExecuteReader())
                        {
                            if (Reader.HasRows)
                            {
                                Reader.Read();
                                bv.SetDescription(Reader.GetString(0).ToString());
                                Reader.Close();
                            }
                        }
                    }
                }
                conn.Close();
            }
        }
Esempio n. 7
0
        //CONSTRUCTOR
        public StrategyPoint(string id,string desc, string rname)
        {
            mName = id;
            mDescription = desc;
            mRoadmapName = rname;

            //Get the StrategyPoints
            using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["connstring"].ConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.CommandText = "SELECT BusinessValueName FROM [dbo].[SP_BV_Crosswalk] WHERE RoadmapName =@Rname AND StrategyPointName =@Sname";
                    cmd.Parameters.AddWithValue("@Rname", mRoadmapName);
                    cmd.Parameters.AddWithValue("@Sname", mName);
                    cmd.Connection = conn;

                    conn.Open();
                    using (SqlDataReader Reader = cmd.ExecuteReader())
                    {
                        while (Reader.Read())
                        {
                            string temp = Reader.GetString(0);
                            BusinessValue bv = new BusinessValue(Reader.GetString(0), mRoadmapName);
                            mValues.Add(bv);
                        }
                    }

                }

                using (SqlCommand cmd3 = new SqlCommand())
                {
                    cmd3.CommandText = "SELECT color FROM [dbo].[StrategyPoint] WHERE RoadmapName =@Rname AND Name = @sName";
                    cmd3.Parameters.AddWithValue("@Rname", mRoadmapName);
                    cmd3.Parameters.AddWithValue("@Sname", mName);
                    cmd3.Connection = conn;

                    try
                    {
                        using (SqlDataReader Reader = cmd3.ExecuteReader())
                        {
                            Reader.Read();

                            mColor = Reader.GetString(0);
                        }
                    }
                    catch
                    {
                        mColor = "#000000";
                    }
                }

                foreach (BusinessValue bv in mValues)
               {
                   using (SqlCommand cmd2 = new SqlCommand())
                   {
                       cmd2.CommandText = "SELECT Description FROM [dbo].[BusinessValue] WHERE Name=@BVName AND RoadmapName=@Rname";
                       cmd2.Parameters.AddWithValue("@Rname", mRoadmapName);
                       cmd2.Parameters.AddWithValue("@BVName", bv.GetName());
                       cmd2.Connection = conn;

                       //conn.Open();
                        using (SqlDataReader Reader = cmd2.ExecuteReader())
                        {
                            if (Reader.HasRows)
                            {
                               Reader.Read();
                               bv.SetDescription(Reader.GetString(0).ToString());
                            }
                        }
                   }
               }
                conn.Close();

            }
        }
Esempio n. 8
0
        public bool CreateBusinessValue(string name, string desc, string rname)
        {
            try
            {
                bool flag;
                //Add to both the BV table, and the BV/SP ownership table
                int i = 8;
                while (i<100)
                {
                    if (Char.IsNumber(name[i])) i++;
                    else break;
                }
                string orderstring = name.Substring(i + 6, (name.Length) - (i + 6));
                int order = Convert.ToInt32(name.Substring(i+6, (name.Length) - (i+6)));

                using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["connstring"].ConnectionString))
                {
                    using (SqlCommand cmd1 = new SqlCommand())
                    {
                        cmd1.CommandText = "INSERT INTO [dbo].[BusinessValue] (Name, Description, RoadmapName, Sort) VALUES (@BVName, @desc,@Rname, @sort)";
                        cmd1.Parameters.AddWithValue("@BVName", name);
                        cmd1.Parameters.AddWithValue("@desc", desc);
                        cmd1.Parameters.AddWithValue("@Rname", mRoadmapName);
                        cmd1.Parameters.AddWithValue("@sort", order);
                        cmd1.Connection = conn;

                        conn.Open();
                        flag = cmd1.ExecuteNonQuery() != 0;
                        conn.Close();
                    }
                    using (SqlCommand cmd2 = new SqlCommand())
                    {
                        cmd2.CommandText = "INSERT INTO [dbo].[SP_BV_Crosswalk] (StrategyPointName, BusinessValueName, RoadmapName) VALUES (@Sname,@BVName,@Rname)";
                        cmd2.Parameters.AddWithValue("@BVName", name);
                        cmd2.Parameters.AddWithValue("@Sname", mName);
                        cmd2.Parameters.AddWithValue("@Rname", mRoadmapName);
                        cmd2.Connection = conn;

                        conn.Open();
                        flag = cmd2.ExecuteNonQuery() != 0;
                        conn.Close();
                    }
                }
                BusinessValue bis = new BusinessValue(name, rname);
                bis.SetDescription(desc);
                mValues.Add(bis);
                return flag;
            }
            catch (Exception ex)
            {
                return false;
            }
        }