Ejemplo n.º 1
0
 public void BusinessValueSetNameTest()
 {
     BusinessValue bv = new BusinessValue("test");
     Assert.IsTrue(bv.SetName("test3"));
     bv.SetName("test");
 }
Ejemplo n.º 2
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);
            }
        }