public void SetEndDateTest() { Project proj = new Project("test3", "test proj3", "test2"); DateTime enddate = new DateTime(2012, 10, 5); Assert.IsTrue(proj.SetEndDate(enddate)); }
public void GetStartDateTest() { Project proj = new Project("test3", "test proj3", "test2"); DateTime startdate = new DateTime(2012, 10, 5); Assert.IsTrue(proj.GetStartDate()==startdate); }
public static void AddProject(string id, string name, string mapName, string stratID, string valID) { RoadMap map = new RoadMap(mapName); StrategyPoint point = map.GetPoint(stratID); BusinessValue val = point.GetBusinessValue(valID); Project newProj = new Project(id, name, valID, mapName); val.CreateNewProject(newProj); //val.addProject(newProj); }
public void SetNameTest() { Project proj = new Project("test", "test proj", "test2"); Assert.Inconclusive("Will throw primary key error if ran"); }
public void SetDescriptionTest() { Project proj = new Project("test2", "test proj", "test2"); Assert.IsTrue(proj.SetDescription("weee")); }
public void SetBusinessValueTest() { Project proj = new Project("test3", "test proj3", "test2"); Assert.IsTrue(proj.SetBusinessValue("test2")); }
public void GetNameTest() { Project proj = new Project("test2", "test proj", "test2"); Assert.IsTrue(proj.GetName()=="test2"); }
public void GetDescriptionTest() { Project proj = new Project("test3", "test proj3", "test2"); proj.InsertDB(); Assert.IsTrue(proj.GetDescription()=="test proj3"); }
public void ConstructorTest() { Project proj = new Project("test", "test proj", "test2"); Assert.IsNotNull(proj); }
//Gets all projects for a roadmap public List<Project> GetAllProjects() { List<Project> projects = new List<Project>(); using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["connstring"].ConnectionString)) { using (SqlCommand cmd = new SqlCommand()) { cmd.CommandText = "SELECT Name, Description, BusinessValueName, RoadmapName FROM [dbo].[Project] WHERE RoadmapName = @Rname ORDER BY NAME ASC"; cmd.Parameters.AddWithValue("@Rname", mName); cmd.Connection = conn; conn.Open(); using (SqlDataReader Reader = cmd.ExecuteReader()) { while (Reader.Read()) { Project temp = new Project(Reader.GetString(0), Reader.GetString(1), Reader.GetString(2), Reader.GetString(3)); projects.Add(temp); } Reader.Close(); } conn.Close(); } } return projects; }
public bool DeleteDependant(Project dependant) { bool flag; using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["connstring"].ConnectionString)) { using (SqlCommand cmd = new SqlCommand()) { cmd.CommandText = "DELETE [dbo].[Dependents] WHERE RoadmapName = @Rname AND ProjectName = @Pname AND DependantName = @name"; cmd.Parameters.AddWithValue("@Rname", mRoadmapName); cmd.Parameters.AddWithValue("@Pname", mName); cmd.Parameters.AddWithValue("@name", dependant.GetName()); cmd.Connection = conn; conn.Open(); flag = cmd.ExecuteNonQuery() != 0; conn.Close(); } } mDependencies.Remove(dependant.GetName()); return flag; }
//Create/delete dependents in list and DB public bool CreateDependant(Project dependant) { bool flag; using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["connstring"].ConnectionString)) { using (SqlCommand cmd = new SqlCommand()) { cmd.CommandText = "INSERT INTO [dbo].[Dependents] (ProjectName, DependantName, Description, RoadmapName) VALUES (@Pname,@name,@descrip,@Rname)"; cmd.Parameters.AddWithValue("@Pname", mName); cmd.Parameters.AddWithValue("@name", dependant.GetName()); cmd.Parameters.AddWithValue("@descrip", dependant.GetDescription()); cmd.Parameters.AddWithValue("@Rname", mRoadmapName); cmd.Connection = conn; conn.Open(); flag = cmd.ExecuteNonQuery() != 0; conn.Close(); } } mDependencies.Add(dependant.GetName()); return flag; }
public bool CreateNewProject( Project proj) { try { bool flag; string name = proj.GetBusinessValue(); int i = 8; while (i < 100) { if (Char.IsNumber(name[i])) i++; else break; } int j = i+6; while (j < 100) { if (Char.IsNumber(proj.GetName()[j])) j++; else break; } string orderstring = proj.GetName().Substring(j + 7, (proj.GetName().Length) - (j + 7)); int order = Convert.ToInt32(proj.GetName().Substring(j+7, (proj.GetName().Length) - (j+7))); using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["connstring"].ConnectionString)) { using (SqlCommand cmd = new SqlCommand()) { cmd.CommandText = "INSERT INTO [dbo].[Project] (Name, Description, BusinessValueName, RoadmapName, Sort) VALUES (@PName, @pDescrip, @BVName, @RName, @sort)"; cmd.Parameters.AddWithValue("@PName", proj.GetName()); cmd.Parameters.AddWithValue("@PDescrip", proj.GetDescription()); cmd.Parameters.AddWithValue("@BVName", proj.GetBusinessValue()); cmd.Parameters.AddWithValue("@Rname", mRoadmapName); cmd.Parameters.AddWithValue("@sort", order); cmd.Connection = conn; conn.Open(); flag = cmd.ExecuteNonQuery()!=0; conn.Close(); } } mProjects.Add(proj); return flag; } catch (Exception ex) { return false; } }
//Add a project to the project list public void AddProject(Project proj) { //Add it to the list mProjects.Add(proj); //Set the BV Name proj.SetBusinessValue(mName); }
//Reorders projects based on deleting currname public void ReorderProject(string currname, string desc, bool isFirst) { Project current = new Project(currname, desc, mName, mRoadmapName); //Grab the # of the project to be deleted int index = (int)Char.GetNumericValue(currname[23]) + 1; string nextID = currname.Substring(0, 23) + index.ToString(); string nextdesc = null; string selectname = null; if (isFirst) selectname = currname; else selectname = nextID; //Select the description of the project to be moved using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["connstring"].ConnectionString)) { using (SqlCommand cmd = new SqlCommand()) { cmd.CommandText = "SELECT Description FROM [dbo].[Project] WHERE Name=@PName AND RoadmapName=@Rname AND BusinessValueName=@BVName"; cmd.Parameters.AddWithValue("@PName", selectname); cmd.Parameters.AddWithValue("@Rname", mRoadmapName); cmd.Parameters.AddWithValue("@BVName", mName); cmd.Connection = conn; conn.Open(); using (SqlDataReader Reader = cmd.ExecuteReader()) { if (Reader.HasRows) { Reader.Read(); nextdesc = Reader.GetString(0); Reader.Close(); } } conn.Close(); } } //Change the name of the project to reorder Project next = new Project(nextID,desc, mName, mRoadmapName); Project nextdummy = new Project(currname, nextdesc,mName,mRoadmapName); if (nextdesc != null) { nextdummy.SetName(nextID); ReorderProject(nextID, nextdesc, false); } }