protected string storeProject(int hasImage) { string projectId = ""; DateTime entryTime = DateTime.Now; connect.Open(); SqlCommand cmd = connect.CreateCommand(); string description = txtDescription.Text.Replace("'", "''"); description = description.Replace("\n", "<br />"); description = description.Replace("\r", " "); string project_name = txtTitle.Text.Replace("'", "''"); project_name = project_name.Replace("'", "''"); project_name = project_name.Replace("\n", ""); project_name = project_name.Replace("\r", " "); //Get the current user's ID: cmd.CommandText = "select userId from Users where loginId = '" + loginId + "' "; string userId = cmd.ExecuteScalar().ToString(); cmd.CommandText = "insert into Projects (project_name, project_description, project_createdBy, project_createdDate, project_isTerminated, project_isDeleted, project_startedDate, project_hasImage) values " + "('" + project_name + "', '" + description + "', '" + userId + "', '" + entryTime + "', 0, 0, '" + calStartDate.SelectedDate + "', '" + hasImage + "') "; cmd.ExecuteScalar(); cmd.CommandText = "select [projectId] from(SELECT rowNum = ROW_NUMBER() OVER(ORDER BY projectId ASC), * FROM [Projects] " + "where project_createdBy = '" + userId + "' and project_name like '" + project_name + "' and project_createdDate = '" + Layouts.getOriginalTimeFormat(entryTime.ToString()) + "' " + " and project_startedDate = '" + Layouts.getOriginalTimeFormat(calStartDate.SelectedDate.ToString()) + "' " + " and project_hasImage = '" + hasImage + "' and project_isDeleted = '0' and project_isTerminated = '0' " + " ) as t where rowNum = '1'"; projectId = cmd.ExecuteScalar().ToString(); connect.Close(); return(projectId); }
protected void rebindValues() { if (grdProjects.Rows.Count > 0) { //Hide the header called "User ID": grdProjects.HeaderRow.Cells[3].Visible = false; //Hide IDs column and content which are located in column index 3: for (int i = 0; i < grdProjects.Rows.Count; i++) { grdProjects.Rows[i].Cells[3].Visible = false; } } connect.Open(); try { SqlCommand cmd = connect.CreateCommand(); string project_name = "", createdBy = "", createdOn = "", creatorId = ""; for (int row = 0; row < grdProjects.Rows.Count; row++) { //Set links to review a user: project_name = grdProjects.Rows[row].Cells[0].Text; createdBy = grdProjects.Rows[row].Cells[1].Text; createdOn = grdProjects.Rows[row].Cells[2].Text; creatorId = grdProjects.Rows[row].Cells[3].Text; //Get the Project ID: cmd.CommandText = "select [projectId] from [Projects] where project_name like '" + project_name + "' and " + "project_createdDate = '" + Layouts.getOriginalTimeFormat(createdOn) + "' and project_createdBy = '" + creatorId + "' "; string id = cmd.ExecuteScalar().ToString(); //string linkToReviewUser = "******" + id; HyperLink projectLink = new HyperLink(); HyperLink userLink = new HyperLink(); HyperLink dateLink = new HyperLink(); projectLink.Text = project_name + " "; userLink.Text = createdBy + " "; dateLink.Text = Layouts.getTimeFormat(createdOn) + " "; projectLink.NavigateUrl = "ViewProject.aspx?id=" + id; userLink.NavigateUrl = "Profile.aspx?id=" + creatorId; dateLink.NavigateUrl = "ViewProject.aspx?id=" + id; grdProjects.Rows[row].Cells[0].Controls.Add(projectLink); grdProjects.Rows[row].Cells[1].Controls.Add(userLink); grdProjects.Rows[row].Cells[2].Controls.Add(dateLink); } } catch (Exception e) { Console.WriteLine("Error: " + e.ToString()); } connect.Close(); }
protected string storeSprintTask(int hasImage) { string sprintTaskId = ""; DateTime createdDate = DateTime.Now; string sprintTaskUId = txtUniqueSprintTaskID.Text.Replace(" ", ""); sprintTaskUId = txtUniqueSprintTaskID.Text.Replace("'", "''"); string userStoryUId = txtUniqueUserStoryID.Text.Replace(" ", ""); userStoryUId = txtUniqueUserStoryID.Text.Replace("'", "''"); string taskDescription = txtTaskDescription.Text.Replace("'", "''"); string dateIntroduced = calDateIntroduced.SelectedDate.ToString(); string dateConsidered = calDateConsidered.SelectedDate.ToString(); string currentStatus = drpCurrentStatus.SelectedValue; connect.Open(); SqlCommand cmd = connect.CreateCommand(); //Get the current user's ID: cmd.CommandText = "select userId from Users where loginId = '" + loginId + "' "; string createdBy = cmd.ExecuteScalar().ToString(); //Mark to original Sprint Task as deleted: cmd.CommandText = "update SprintTasks set sprintTask_currentStatus = 'Revised', sprintTask_editedBy = '" + createdBy + "', " + "sprintTask_editedDate = '" + createdDate + "', sprintTask_isDeleted = '1' " + "where sprintTaskId = '" + g_sprintTaskId + "' "; cmd.ExecuteScalar(); //Store the new user story in the database: cmd.CommandText = "insert into SprintTasks (userStoryId, sprintTask_createdBy, sprintTask_createdDate, sprintTask_uniqueId, sprintTask_taskDescription, sprintTask_dateIntroduced, " + "sprintTask_dateConsideredForImplementation, sprintTask_hasImage, sprintTask_currentStatus, sprintTask_previousVersion) values " + "('" + g_userStoryId + "', '" + createdBy + "', '" + createdDate + "', '" + sprintTaskUId + "', '" + taskDescription + "', '" + dateIntroduced + "', '" + dateConsidered + "', " + " '" + hasImage + "', '" + currentStatus + "', '" + g_sprintTaskId + "') "; cmd.ExecuteScalar(); //Get the ID of the newly stored Sprint task from the database: cmd.CommandText = "select [sprintTaskId] from(SELECT rowNum = ROW_NUMBER() OVER(ORDER BY sprintTaskId ASC), * FROM [SprintTasks] " + "where userStoryId = '" + g_userStoryId + "' and sprintTask_createdBy = '" + createdBy + "' and sprintTask_createdDate = '" + Layouts.getOriginalTimeFormat(createdDate.ToString()) + "' " + " and sprintTask_uniqueId like '" + sprintTaskUId + "' " + " and sprintTask_dateIntroduced = '" + Layouts.getOriginalTimeFormat(dateIntroduced.ToString()) + "' " + " and sprintTask_dateConsideredForImplementation = '" + Layouts.getOriginalTimeFormat(dateConsidered.ToString()) + "' " + " and sprintTask_hasImage = '" + hasImage + "' and sprintTask_currentStatus like '" + currentStatus + "' " + " and sprintTask_isDeleted = '0' " + " ) as t where rowNum = '1'"; sprintTaskId = cmd.ExecuteScalar().ToString(); connect.Close(); return(sprintTaskId); }
protected string storeTestCase(int hasImage) { string new_testCaseId = ""; DateTime createdDate = DateTime.Now; string testCaseUId = txtUniqueTestCaseID.Text.Replace(" ", ""); testCaseUId = testCaseUId.Replace("'", "''"); string sprintTaskUId = txtUniqueSprintTaskID.Text.Replace(" ", ""); sprintTaskUId = sprintTaskUId.Replace("'", "''"); string userStoryUId = txtUniqueUserStoryID.Text.Replace(" ", ""); userStoryUId = userStoryUId.Replace("'", "''"); string testScenario = txtTestCaseScenario.Text.Replace("'", "''"); string expectedOutput = txtExpectedOutput.Text.Replace("'", "''"); string currentStatus = drpCurrentStatus.SelectedValue; connect.Open(); SqlCommand cmd = connect.CreateCommand(); //Get the current user's ID: cmd.CommandText = "select userId from Users where loginId = '" + loginId + "' "; string createdBy = cmd.ExecuteScalar().ToString(); //Mark to original Test Case as deleted: cmd.CommandText = "update TestCases set testCase_currentStatus = 'Revised', testCase_editedBy = '" + createdBy + "', " + "testCase_editedDate = '" + createdDate + "', testCase_isDeleted = '1' " + "where testCaseId = '" + g_testCaseId + "' "; cmd.ExecuteScalar(); //Store the new user story in the database: cmd.CommandText = "insert into TestCases (sprintTaskId, testCase_createdBy, testCase_createdDate, testCase_uniqueId, testCase_testCaseScenario, testCase_expectedOutput, " + "testCase_hasImage, testCase_currentStatus, testCase_previousVersion) values " + "('" + g_sprintTaskId + "', '" + createdBy + "', '" + createdDate + "', '" + testCaseUId + "', '" + testScenario + "', '" + expectedOutput + "', " + " '" + hasImage + "', '" + currentStatus + "', '" + g_sprintTaskId + "') "; cmd.ExecuteScalar(); //Get the ID of the newly stored test case from the database: cmd.CommandText = "select testCaseId from(SELECT rowNum = ROW_NUMBER() OVER(ORDER BY testCaseId ASC), * FROM TestCases " + "where sprintTaskId = '" + g_sprintTaskId + "' and testCase_createdBy = '" + createdBy + "' and testCase_createdDate = '" + Layouts.getOriginalTimeFormat(createdDate.ToString()) + "' " + " and testCase_uniqueId like '" + testCaseUId + "' " + " and testCase_hasImage = '" + hasImage + "' and testCase_currentStatus like '" + currentStatus + "' " + " and testCase_isDeleted = '0' " + " ) as t where rowNum = '1'"; new_testCaseId = cmd.ExecuteScalar().ToString(); //Store the parameters: foreach (var p in drpInputParametersList.Items) { cmd.CommandText = "insert into Parameters (testCaseId, parameter_name) values ('" + new_testCaseId + "', '" + p.ToString().Replace("'", "''") + "')"; cmd.ExecuteScalar(); } connect.Close(); return(new_testCaseId); }
protected string storeUserStory(int hasImage) { string newUserStoryId = ""; DateTime entryTime = DateTime.Now; SqlCommand cmd = connect.CreateCommand(); connect.Open(); string newUniqueId = txtUniqueUserStoryID.Text.Replace(" ", ""); newUniqueId = txtUniqueUserStoryID.Text.Replace("'", "''"); string asARole = ""; int counter = 0; foreach (ListItem listItem in drpAsRole.Items) { if (listItem.Selected) { counter++; var val = listItem.Value; var txt = listItem.Text; if (counter == 1) { asARole += val.ToString(); } else { asARole = asARole + ", " + val.ToString(); } } } string iWant = txtIWantTo.Text.Replace("'", "''"); string soThat = txtSoThat.Text.Replace("'", "''"); string currentStatus = drpCurrentStatus.SelectedValue; string dateIntroduced = calDateIntroduced.SelectedDate.ToString(); string dateConsidered = calDateConsidered.SelectedDate.ToString(); //Get the current user's ID: cmd.CommandText = "select userId from Users where loginId = '" + loginId + "' "; string userId = cmd.ExecuteScalar().ToString(); //Mark to original User Story as deleted: cmd.CommandText = "update UserStories set userStory_currentStatus = 'Revised', userStory_editedBy = '" + userId + "', " + "userStory_editedDate = '" + entryTime + "', userStory_isDeleted = '1' " + "where userStoryId = '" + userStoryId + "' "; cmd.ExecuteScalar(); //Add a new user story with another unique ID according to the format x.x: cmd.CommandText = "insert into UserStories (projectId, userStory_createdBy, userStory_createdDate, userStory_uniqueId, userStory_asARole, userStory_iWantTo, " + "userStory_soThat, userStory_dateIntroduced, userStory_dateConsideredForImplementation," + " userStory_hasImage, userStory_currentStatus, userStory_previousVersion) values " + "('" + g_projectId + "', '" + userId + "', '" + entryTime + "', '" + newUniqueId + "', '" + asARole + "', '" + iWant + "', '" + soThat + "', '" + dateIntroduced + "'," + " '" + dateConsidered + "', '" + hasImage + "', '" + currentStatus + "', '" + userStoryId + "') "; cmd.ExecuteScalar(); //Get the ID of the newly stored User Story from the database: cmd.CommandText = "select [userStoryId] from(SELECT rowNum = ROW_NUMBER() OVER(ORDER BY userStoryId ASC), * FROM [UserStories] " + "where projectId = '" + g_projectId + "' and userStory_createdBy = '" + userId + "' and userStory_createdDate = '" + Layouts.getOriginalTimeFormat(entryTime.ToString()) + "' " + " and userStory_asARole like '" + asARole + "' and userStory_iWantTo like '" + iWant + "' and userStory_soThat like '" + soThat + "' " + " and userStory_dateIntroduced = '" + Layouts.getOriginalTimeFormat(dateIntroduced.ToString()) + "' " + " and userStory_dateConsideredForImplementation = '" + Layouts.getOriginalTimeFormat(dateConsidered.ToString()) + "' " + " and userStory_hasImage = '" + hasImage + "' and userStory_currentStatus like '" + currentStatus + "' " + " and userStory_isDeleted = '0' " + " ) as t where rowNum = '1'"; newUserStoryId = cmd.ExecuteScalar().ToString(); cmd.ExecuteScalar(); connect.Close(); return(newUserStoryId); }