protected void ImageButtonClearSuc_Click(object sender, ImageClickEventArgs e) { using (SqlConnection conn = new SqlConnection(g_sqlConn)) { try { Connect(conn); using (SqlCommand cmd = new SqlCommand("UPDATE tblTasks SET SuccessorTask=NULL, SuccessorDependency=NULL WHERE UserID=@UserID AND ProjectID=@ProjID AND TaskID=@TaskID", conn)) { cmd.Parameters.AddWithValue("@UserID", Session["_CurrentUserID"]); cmd.Parameters.AddWithValue("@ProjID", Session["_CurrentProjID"]); cmd.Parameters.AddWithValue("@TaskID", Session["_CurrentTaskID"]); cmd.ExecuteNonQuery(); } } catch (Exception ex) { Response.Write(String.Format("Error while executing query...{0}", ex.ToString())); } finally { Disconnect(conn); } TextBoxSuccDepend.Text = ""; TextBoxSuccessorTask.Text = ""; GridViewTaskList.DataBind(); DropDownListSetPredTask.DataBind(); DropDownListSetSuccTask.DataBind(); } }
/// <summary> /// 删除所有任务 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void ButtonDeleteTask_Click(object sender, EventArgs e) { //string stringSql = "delete from ua_task where cacc_id='017'"; string stringSql = "delete from ua_task "; sqlHelper.ExecuteNonQuery(stringSql); //Response.Write("任务删除成功"); Response.Write("<script languge='javascript'>alert('删除成功'); window.location.href='DeletTask.aspx'</script>"); GridViewTaskList.DataBind(); }
protected void ButtonModalSetPredTask_Click(object sender, EventArgs e) { using (SqlConnection conn = new SqlConnection(g_sqlConn)) { Connect(conn); using (SqlCommand cmd2 = new SqlCommand(String.Format("SELECT TaskID FROM tblTasks WHERE Name='{0}' AND UserID={1} AND ProjectID={2}", TextBoxName.Text, Session["_CurrentUserID"], Session["_CurrentProjID"]), conn)) { SqlDataReader sdr = cmd2.ExecuteReader(); while (sdr.Read()) { Session["_CurrentTaskID"] = sdr[0].ToString(); } sdr.Close(); } using (SqlCommand cmd = new SqlCommand("UPDATE tblTasks SET PredecessorTask=@PredTask, PredecessorDependency=@PredDependency " + "WHERE UserID=@UserID AND ProjectID=@ProjID AND TaskID=@TaskID", conn)) { cmd.Parameters.AddWithValue("@PredTask", this.DropDownListSetPredTask.SelectedValue); cmd.Parameters.AddWithValue("@PredDependency", this.DropDownListPredDependency.SelectedValue); cmd.Parameters.AddWithValue("@UserID", Session["_CurrentUserID"]); cmd.Parameters.AddWithValue("@ProjID", Session["_CurrentProjID"]); cmd.Parameters.AddWithValue("@TaskID", Session["_CurrentTaskID"]); try { cmd.ExecuteNonQuery(); } catch (Exception ex) { Response.Write(String.Format("Error while executing query...{0}", ex.ToString())); } finally { Disconnect(conn); } } } TextBoxPredecessorTask.Text = this.DropDownListSetPredTask.SelectedItem.Text; TextBoxPredDepend.Text = this.DropDownListPredDependency.SelectedItem.Text; this.DropDownListSetPredTask.DataBind(); this.DropDownListSetSuccTask.DataBind(); GridViewTaskList.DataBind(); }
/// <summary> /// 按行删除任务 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void ButtonDeleteTaskOnID_Click(object sender, EventArgs e) { for (int i = 0; i < this.GridViewTaskList.Rows.Count; i++) { CheckBox chk = (CheckBox)GridViewTaskList.Rows[i].FindControl("CheckBoxSelectTask"); if (chk.Checked) { //U8TaskID = this.GridViewTaskList.DataKeyNames[i]; U8TaskID = this.GridViewTaskList.Rows[i].Cells[4].Text; string stringSql = "delete from ua_task where cTaskId= " + U8TaskID; sqlHelper.ExecuteNonQuery(stringSql); } } //Response.Write("任务删除成功"); Response.Write("<script languge='javascript'>alert('删除指定任务成功'); window.location.href='DeletTask.aspx'</script>"); GridViewTaskList.DataBind(); }
protected void ButtonSave_Click(object sender, EventArgs e) { if (TextBoxName.Text.Length == 0 || TextBoxDescription.Text.Length == 0) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Please enter a name and description for the Task.');", true); } else if (TextBoxExpectedStartDate.Text.Length == 0 || TextBoxExpectedDueDate.Text.Length == 0) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Please enter an Expected Start Date and Expected Due Date for the Task.');", true); } else if (TextBoxExpectedEffort.Text.Length == 0) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Please enter an Expected Effort for the Task.');", true); } else if (TextBoxExpectedDuration.Text.Length == 0) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Please enter an Expected Duration for the Task.');", true); } else { using (SqlConnection conn = new SqlConnection(g_sqlConn)) { Connect(conn); using (SqlCommand cmd2 = new SqlCommand(String.Format("SELECT TaskID FROM tblTasks WHERE Name='{0}' AND UserID={1} AND ProjectID={2}", TextBoxName.Text, Session["_CurrentUserID"], Session["_CurrentProjID"]), conn)) { SqlDataReader sdr = cmd2.ExecuteReader(); while (sdr.Read()) { Session["_CurrentTaskID"] = sdr[0].ToString(); } sdr.Close(); } using (SqlCommand cmd = new SqlCommand("UPDATE tblTasks SET Name=@Name, Description=@Description, " + "ExpectedStartDate=@ExpStartDate, ExpectedEndDate=@ExpEndDate, ExpectedEffort=@ExpEff, EffortCompleted=@EffCompl,ExpectedDuration=@ExpDur," + "ActualStartDate=@ActStartDate, ActualEndDate=@ActEndDate, ActualEffort=@ActEff, ActualDuration=@ActDur" + " WHERE UserID=@UserID AND ProjectID=@ProjID AND TaskID=@TaskID", conn)) { cmd.Parameters.AddWithValue("@UserID", Session["_CurrentUserID"]); cmd.Parameters.AddWithValue("@ProjID", Session["_CurrentProjID"]); cmd.Parameters.AddWithValue("@TaskID", Session["_CurrentTaskID"]); cmd.Parameters.AddWithValue("@Name", TextBoxName.Text); cmd.Parameters.AddWithValue("@Description", TextBoxDescription.Text); cmd.Parameters.AddWithValue("@ExpStartDate", TextBoxExpectedStartDate.Text); cmd.Parameters.AddWithValue("@ExpEndDate", TextBoxExpectedDueDate.Text); cmd.Parameters.AddWithValue("@ExpEff", TextBoxExpectedEffort.Text); cmd.Parameters.AddWithValue("@ExpDur", TextBoxExpectedDuration.Text); cmd.Parameters.AddWithValue("@ActStartDate", string.IsNullOrEmpty(TextBoxActualStartDate.Text) ? (object)DBNull.Value : TextBoxActualStartDate.Text); cmd.Parameters.AddWithValue("@ActEndDate", string.IsNullOrEmpty(TextBoxActualEndDate.Text) ? (object)DBNull.Value : TextBoxActualEndDate.Text); cmd.Parameters.AddWithValue("@ActEff", string.IsNullOrEmpty(TextBoxActualEffort.Text) ? (object)DBNull.Value : TextBoxActualEffort.Text); cmd.Parameters.AddWithValue("@ActDur", string.IsNullOrEmpty(TextBoxActualDuration.Text) ? (object)DBNull.Value : TextBoxActualDuration.Text); cmd.Parameters.AddWithValue("@EffCompl", string.IsNullOrEmpty(TextBoxEffortCompleted.Text) ? (object)DBNull.Value : TextBoxEffortCompleted.Text); try { cmd.ExecuteNonQuery(); } catch (Exception ex) { Response.Write(String.Format("Error while executing query...{0}", ex.ToString())); } finally { Disconnect(conn); } } } } this.DropDownListTaskSelect.Items.Clear(); this.DropDownListTaskSelect.DataBind(); GridViewTaskList.DataBind(); }
protected void ButtonDelete_Click(object sender, EventArgs e) { if (TextBoxName.Text.Length == 0) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Please enter the name of the Task to be deleted.');", true); } else { using (SqlConnection conn = new SqlConnection(g_sqlConn)) { Connect(conn); using (SqlCommand cmd2 = new SqlCommand(String.Format("SELECT TaskID FROM tblTasks WHERE Name='{0}' AND UserID={1} AND ProjectID={2}", TextBoxName.Text, Session["_CurrentUserID"], Session["_CurrentProjID"]), conn)) { SqlDataReader sdr = cmd2.ExecuteReader(); while (sdr.Read()) { Session["_CurrentTaskID"] = sdr[0].ToString(); } sdr.Close(); } using (SqlCommand cmd3 = new SqlCommand(String.Format("UPDATE tblIssues SET AssociatedTask = NULL WHERE AssociatedTask={0}", Session["_CurrentTaskID"]), conn)) { try { cmd3.ExecuteNonQuery(); } catch (Exception ex) { Response.Write(String.Format("Error while executing query...{0}", ex.ToString())); } } using (SqlCommand cmd = new SqlCommand(String.Format("delete from tblTasks where UserID={0} and ProjectID={1} AND Name='{2}'", Session["_CurrentUserID"], Session["_CurrentProjID"], TextBoxName.Text), conn)) { try { cmd.ExecuteNonQuery(); } catch (Exception ex) { Response.Write(String.Format("Error while executing query...{0}", ex.ToString())); } finally { Disconnect(conn); } } } } this.DropDownListTaskSelect.Items.Clear(); DropDownListTaskSelect.DataBind(); GridViewTaskList.DataBind(); GridViewAssociatedIssues.DataBind(); }
protected void ButtonNew_Click(object sender, EventArgs e) { if (TextBoxName.Text.Length == 0 || TextBoxDescription.Text.Length == 0) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Please enter a name and description for the Task.');", true); } else if (TextBoxExpectedStartDate.Text.Length == 0 || TextBoxExpectedDueDate.Text.Length == 0) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Please enter an Expected Start Date and Expected Due Date for the Task.');", true); } else if (TextBoxExpectedEffort.Text.Length == 0) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Please enter an Expected Effort for the Task.');", true); } else if (TextBoxExpectedDuration.Text.Length == 0) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Please enter an Expected Duration for the Task.');", true); } else { using (SqlConnection conn = new SqlConnection(g_sqlConn)) { Connect(conn); using (SqlCommand cmd = new SqlCommand("insert into tblTasks(UserID,ProjectID,Name,Description,TaskType,ExpectedStartDate,ExpectedEndDate,ExpectedEffort,ExpectedDuration)" + " values(@UserID, @ProjectID, @Name, @Description,@TaskType , @ExpStart, @ExpEnd, @ExpEffort, @ExpDuration)", conn)) { try { cmd.Parameters.AddWithValue("@UserID", Session["_CurrentUserID"]); cmd.Parameters.AddWithValue("@ProjectID", Session["_CurrentProjID"]); cmd.Parameters.AddWithValue("@Name", TextBoxName.Text); cmd.Parameters.AddWithValue("@Description", TextBoxDescription.Text); cmd.Parameters.AddWithValue("@TaskType", g_TaskType); cmd.Parameters.AddWithValue("@ExpStart", TextBoxExpectedStartDate.Text); cmd.Parameters.AddWithValue("@ExpEnd", TextBoxExpectedDueDate.Text); cmd.Parameters.AddWithValue("@ExpEffort", TextBoxExpectedEffort.Text); cmd.Parameters.AddWithValue("@ExpDuration", TextBoxExpectedDuration.Text); cmd.ExecuteNonQuery(); using (SqlCommand cmd2 = new SqlCommand(String.Format("SELECT TaskID FROM tblTasks WHERE Name='{0}' AND UserID={1} AND ProjectID={2}", TextBoxName.Text, Session["_CurrentUserID"], Session["_CurrentProjID"]), conn)) { SqlDataReader sdr = cmd2.ExecuteReader(); while (sdr.Read()) { Session["_CurrentTaskID"] = sdr[0].ToString(); } sdr.Close(); } } catch (Exception ex) { Response.Write(String.Format("Error while executing query...{0}", ex.ToString())); } finally { Disconnect(conn); } Connect(conn); using (SqlCommand cmd2 = new SqlCommand(String.Format("SELECT TaskID FROM tblTasks WHERE Name='{0}' AND UserID={1} AND ProjectID={2}", TextBoxName.Text, Session["_CurrentUserID"], Session["_CurrentProjID"]), conn)) { SqlDataReader sdr = cmd2.ExecuteReader(); while (sdr.Read()) { Session["_CurrentTaskID"] = sdr[0].ToString(); } sdr.Close(); } Disconnect(conn); } } id_GridviewScroll.Visible = true; LabelActualStartDate.Visible = true; ImageButtonActualStartDate.Visible = true; TextBoxActualStartDate.Visible = true; ImageButtonClearEnd.Visible = true; ImageButtonClearPred.Visible = true; ImageButtonClearResc.Visible = true; ImageButtonClearStart.Visible = true; ImageButtonClearSuc.Visible = true; LabelActualEndDate.Visible = true; ImageButtonActualEndDate.Visible = true; TextBoxActualEndDate.Visible = true; LabelDays.Visible = true; LabelActualDuration.Visible = true; TextBoxActualDuration.Visible = true; LabelActualEffort.Visible = true; TextBoxActualEffort.Visible = true; LabelEffortCompleted.Visible = true; TextBoxEffortCompleted.Visible = true; ButtonSave.Visible = true; ButtonDelete.Visible = true; ButtonGantt.Visible = true; LabelRescource.Visible = true; TextBoxResourceAssigned.Visible = true; ButtonSelectResource.Visible = true; ButtonAddResource.Visible = true; LabelSucc.Visible = true; LabelSuccDep.Visible = true; TextBoxSuccessorTask.Visible = true; TextBoxSuccDepend.Visible = true; ButtonSuccessorTask.Visible = true; LabelPred.Visible = true; LabelPredDep.Visible = true; TextBoxPredecessorTask.Visible = true; TextBoxPredDepend.Visible = true; ButtonPredecessorTask.Visible = true; LabelAssocIssue.Visible = true; ButtonAssociateIssues.Visible = true; this.DropDownListTaskSelect.Items.Clear(); DropDownListTaskSelect.DataBind(); GridViewTaskList.DataBind(); } }