protected void environmentView_RowUpdating(object sender, GridViewUpdateEventArgs e) { GridViewRow updatableRow = environmentView.Rows[e.RowIndex] as GridViewRow; if (updatableRow != null) { TextBox tEnvName = updatableRow.FindControl("tEnvName") as TextBox; TextBox tEnvDesc = updatableRow.FindControl("tEnvDesc") as TextBox; TextBox tMachineName = updatableRow.FindControl("tMachineName") as TextBox; TextBox tDatabaseName = updatableRow.FindControl("tDatabaseName") as TextBox; HiddenField hGuid = updatableRow.FindControl("envID") as HiddenField; BCCTaskEnvironment env = new BCCTaskEnvironment(); Guid envGUID = new Guid(hGuid.Value); env.EnvID = envGUID; env.EnvName = tEnvName.Text; env.EnvDesc = tEnvDesc.Text; env.MachineName = tMachineName.Text; env.DatabaseName = tDatabaseName.Text; BCCTaskEnvironment.UpdateTaskEnvironment(env); } // Refresh the data environmentView.EditIndex = -1; FillEnvironments(); }
protected void environmentView_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Add") { TextBox tNewEnvName = environmentView.FooterRow.FindControl("tNewEnvName") as TextBox; TextBox tNewEnvDesc = environmentView.FooterRow.FindControl("tNewEnvDesc") as TextBox; TextBox tNewMachineName = environmentView.FooterRow.FindControl("tNewMachineName") as TextBox; TextBox tNewDatabaseName = environmentView.FooterRow.FindControl("tNewDatabaseName") as TextBox; if (tNewEnvName != null && tNewEnvDesc != null) { BCCTaskEnvironment env = new BCCTaskEnvironment(); env.EnvName = tNewEnvName.Text; env.EnvDesc = tNewEnvDesc.Text; env.MachineName = tNewMachineName.Text.Trim(); env.DatabaseName = tNewDatabaseName.Text.Trim(); BCCTaskEnvironment.AddTaskEnvironment(env); } FillEnvironments(); } else if (e.CommandName == "AddOnEmpty") { TextBox tNewEnvName = environmentView.Controls[0].Controls[0].FindControl("tNewEnvName") as TextBox; TextBox tNewEnvDesc = environmentView.Controls[0].Controls[0].FindControl("tNewEnvDesc") as TextBox; TextBox tNewMachineName = environmentView.Controls[0].Controls[0].FindControl("tNewMachineName") as TextBox; TextBox tNewDatabaseName = environmentView.Controls[0].Controls[0].FindControl("tNewDatabaseName") as TextBox; if (tNewEnvName != null && tNewEnvDesc != null) { BCCTaskEnvironment env = new BCCTaskEnvironment(); env.EnvName = tNewEnvName.Text.Trim(); env.EnvDesc = tNewEnvDesc.Text.Trim(); env.MachineName = tNewMachineName.Text.Trim(); env.DatabaseName = tNewDatabaseName.Text.Trim(); BCCTaskEnvironment.AddTaskEnvironment(env); } FillEnvironments(); } }
protected void environmentView_RowUDeleting(object sender, GridViewDeleteEventArgs e) { GridViewRow deletedRow = environmentView.Rows[e.RowIndex] as GridViewRow; if (deletedRow != null) { Label lblEnvName = deletedRow.FindControl("lblEnvName") as Label; Label lblEnvDesc = deletedRow.FindControl("lblEnvDesc") as Label; HiddenField hGuid = deletedRow.FindControl("envID") as HiddenField; BCCTaskEnvironment env = new BCCTaskEnvironment(); Guid envGUID = new Guid(hGuid.Value); env.EnvID = envGUID; env.EnvName = lblEnvName.Text; env.EnvDesc = lblEnvDesc.Text; env.EnvVisible = 0; // Inactive BCCTaskEnvironment.EnvironmentActivation(env); } // Refresh the data environmentView.EditIndex = -1; FillEnvironments(); FillArchivedEnvironments(); }
protected void archivedEnvironments_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Activate") { GridViewRow clickedRow = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer); HiddenField hGuid = clickedRow.FindControl("envID") as HiddenField; if (hGuid != null) { BCCTaskEnvironment env = new BCCTaskEnvironment(); Guid envGuid = new Guid(hGuid.Value); env.EnvID = envGuid; env.EnvVisible = 1; BCCTaskEnvironment.EnvironmentActivation(env); FillEnvironments(); FillArchivedEnvironments(); } } }
private void FillEnvironments() { BCCTaskEnvironment env = new BCCTaskEnvironment(); env.EnvVisible = 1; DataTable dtEnv = BCCTaskEnvironment.RetrieveEnvironments(env); if (dtEnv != null) { environmentView.DataSource = dtEnv; environmentView.DataBind(); environmentView.Visible = true; } FillProjects(); }
private void FillArchivedEnvironments() { BCCTaskEnvironment env = new BCCTaskEnvironment(); env.EnvVisible = 0; DataTable dtEnv = BCCTaskEnvironment.RetrieveEnvironments(env); if (dtEnv != null) { archivedEnvironments.DataSource = dtEnv; archivedEnvironments.DataBind(); archivedEnvironments.Visible = true; } FillArchivedProjects(); }
/// <summary> /// Update Task Environment /// </summary> /// <param name="taskProject"></param> /// <returns>Data table</returns> public static DataTable UpdateTaskEnvironment(BCCTaskEnvironment taskEnv) { DataTable dt = null; using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["authStore"].ConnectionString)) { SqlCommand command = new SqlCommand("[dbo].[bcc_TaskList_UpdateEnv]", connection); command.CommandType = CommandType.StoredProcedure; SqlParameter param = new SqlParameter("@envID", taskEnv.EnvID); command.Parameters.Add(param); param = new SqlParameter("@envName", taskEnv.EnvName.Trim()); command.Parameters.Add(param); param = new SqlParameter("@envDescription", taskEnv.EnvDesc.Trim()); command.Parameters.Add(param); param = new SqlParameter("@machineName", taskEnv.MachineName.Trim()); command.Parameters.Add(param); param = new SqlParameter("@databaseName", taskEnv.DatabaseName.Trim()); command.Parameters.Add(param); param = new SqlParameter("@showFlag", taskEnv.EnvVisible); command.Parameters.Add(param); connection.Open(); SqlDataReader reader = command.ExecuteReader(); dt = new DataTable(); dt.Load(reader); } return dt; }
/// <summary> /// Retrieve Task Environment /// </summary> /// <param name="taskProject"></param> /// <returns>Data table</returns> public static DataTable RetrieveEnvironments(BCCTaskEnvironment taskEnv) { DataTable dt = null; using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["authStore"].ConnectionString)) { SqlCommand command = new SqlCommand("[dbo].[bcc_TaskList_Environments]", connection); command.CommandType = CommandType.StoredProcedure; SqlParameter param = new SqlParameter("@showFlag", taskEnv.EnvVisible); command.Parameters.Add(param); connection.Open(); SqlDataReader reader = command.ExecuteReader(); dt = new DataTable(); dt.Load(reader); } return dt; }