/// <summary> /// Handles the updation and saving of tests... /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Button1_Click(object sender, System.EventArgs e) { Test test = new Test( ); // Determine if we are updating or adding a test to the database... if (dbConnection.RetrieveTest(EditTestInternalID.Text) == null) { if (EditTestTestPriorityListBox.SelectedItem == null) { PriorityRequiredError.Text = "You must enter a priority."; return; } // here we are adding a new test... test.Name = EditTestTestName.Text; test.Description = EditTestTestDescription.Text; test.Priority = EditTestTestPriorityListBox.SelectedItem.Text.Replace("P", ""); test.OwnerID = dbConnection.GetUserIDFromName(EditTestOwnerList.SelectedItem.Text); test.ExecutionPath = EditTestExecutionPath.Text; test.ExecutionBinary = EditTestExecutionName.Text; test.ExecutionArgs = EditTestExecutionArgs.Text; test.OperatingSystem = EditTestOS.SelectedValue; test.OSVersion = EditTestOSVersion.SelectedItem.Text; test.RunFrequency = new RunFrequency(DateTime.Now, new TimeSpan(System.Convert.ToInt32(RunFreqMonths.Text) * 30 + System.Convert.ToInt32(RunFreqDays.Text), System.Convert.ToInt32(RunFreqHours.Text), System.Convert.ToInt32(RunFreqMinutes.Text), 0, 0), System.Convert.ToInt32(EditTestRunNumberOfTimes.Text), EditTestInfinite.Checked).GetFrequencyString( ); // Get the are to which the test should belong... test.AreaID = AreaHolder.Text; dbConnection.AddTest(test); // Refresh the listing of information... ShowSelectedAreaInformation(TestTreeView.GetNodeFromIndex(TestTreeView.SelectedNodeIndex)); // Repopulate the tree view... PopulateTreeview( ); this.ExpandTreeNodes( ); this.SetSelectedNode( ); } else { // Set the currently edited test ID... test = dbConnection.RetrieveTest(EditTestInternalID.Text); // here we are updating an existing test... if (EditTestTestPriorityListBox.SelectedItem == null) { PriorityRequiredError.Text = "You must enter a priority."; return; } test.Name = EditTestTestName.Text; test.Description = EditTestTestDescription.Text; test.Priority = EditTestTestPriorityListBox.SelectedItem.Text.Replace("P", ""); test.OwnerID = dbConnection.GetUserIDFromName(EditTestOwnerList.SelectedItem.Text); test.ExecutionPath = EditTestExecutionPath.Text; test.ExecutionBinary = EditTestExecutionName.Text; test.ExecutionArgs = EditTestExecutionArgs.Text; test.OperatingSystem = EditTestOS.SelectedValue; test.OSVersion = EditTestOSVersion.SelectedItem.Text; test.RunFrequency = new RunFrequency(DateTime.Now, new TimeSpan(System.Convert.ToInt32(RunFreqMonths.Text) * 30 + System.Convert.ToInt32(RunFreqDays.Text), System.Convert.ToInt32(RunFreqHours.Text), System.Convert.ToInt32(RunFreqMinutes.Text), 0, 0), System.Convert.ToInt32(EditTestRunNumberOfTimes.Text), EditTestInfinite.Checked).GetFrequencyString( ); // Update the information for the test... dbConnection.UpdateTest(test.ID, test); // Refresh the listing of information... if (TestTreeView.GetNodeFromIndex(TestTreeView.SelectedNodeIndex).Type == "Area") { ShowSelectedAreaInformation(TestTreeView.GetNodeFromIndex(TestTreeView.SelectedNodeIndex)); } // Repopulate the tree view... PopulateTreeview( ); this.ExpandTreeNodes( ); this.SetSelectedNode( ); } }