protected void ButtonDelete_Click(object sender, EventArgs e)
        {
            if (TextBoxName.Text.Length == 0)
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(),
                                                        "alertMessage",
                                                        "alert('Please enter a name of the Milestone 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);
                        }
                    }
                }

                DropDownListMilestoneSelect.Items.Clear();
                DropDownListMilestoneSelect.DataBind();
                GridViewTaskList.DataBind();
                GridViewAssociatedIssues.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 Milestone.');", true);
            }

            else if (TextBoxExpectedDueDate.Text.Length == 0)
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(),
                                                        "alertMessage",
                                                        "alert('Please enter an Expected Due Date for the Milestone.');", true);
            }

            else if (TextBoxExpectedEffort.Text.Length == 0)
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(),
                                                        "alertMessage",
                                                        "alert('Please enter an Expected Effort for the Milestone.');", 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, " +
                                                           "ExpectedEndDate=@ExpEndDate, ExpectedEffort=@ExpEff," +
                                                           "ActualEndDate=@ActEndDate, ActualEffort=@ActEff, EffortCompleted=@EffCompl " +
                                                           "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("@ExpEndDate", TextBoxExpectedDueDate.Text);
                        cmd.Parameters.AddWithValue("@ExpEff", TextBoxExpectedEffort.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("@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);
                        }
                    }
                }

                DropDownListMilestoneSelect.Items.Clear();
                DropDownListMilestoneSelect.DataBind();
                GridViewTaskList.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 Milestone.');", true);
            }

            else if (TextBoxExpectedDueDate.Text.Length == 0)
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(),
                                                        "alertMessage",
                                                        "alert('Please enter an Expected Due Date for the Milestone.');", true);
            }

            else if (TextBoxExpectedEffort.Text.Length == 0)
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(),
                                                        "alertMessage",
                                                        "alert('Please enter an Expected Effort for the Milestone.');", true);
            }

            else
            {
                using (SqlConnection conn = new SqlConnection(g_sqlConn))
                {
                    Connect(conn);
                    using (SqlCommand cmd = new SqlCommand("insert into tblTasks(UserID,ProjectID,Name,Description,TaskType,ExpectedEndDate,ExpectedEffort)" +
                                                           " values(@UserID, @ProjectID, @Name, @Description,@TaskType, @ExpEnd, @ExpEffort)", conn))
                    {
                        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("@ExpEnd", TextBoxExpectedDueDate.Text);
                        cmd.Parameters.AddWithValue("@ExpEffort", TextBoxExpectedEffort.Text);

                        try
                        {
                            cmd.ExecuteNonQuery();
                        }

                        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);
                    }
                }

                ImageButtonClearActDate.Visible = true;
                ImageButtonClearPred.Visible    = true;
                ImageButtonClearSuc.Visible     = true;

                ImageButtonActualEndDate.Visible = true;
                LabelActualEndDate.Visible       = true;
                TextBoxActualEndDate.Visible     = true;

                LabelActualEffort.Visible   = true;
                TextBoxActualEffort.Visible = true;

                LabelEffortCompleted.Visible   = true;
                TextBoxEffortCompleted.Visible = true;

                ButtonSave.Visible   = true;
                ButtonDelete.Visible = true;
                ButtonGantt.Visible  = true;

                DropDownListMilestoneSelect.Items.Clear();
                DropDownListMilestoneSelect.DataBind();
                GridViewTaskList.DataBind();
                GridViewAssocIssueScrollID.Visible = true;

                LabelPredTask.Visible         = true;
                LabelPredTaskDep.Visible      = true;
                TextBoxPredTask.Visible       = true;
                TextBoxPredDepen.Visible      = true;
                ButtonPredecessorTask.Visible = true;

                LabelSuccTask.Visible       = true;
                LabelSuccDep.Visible        = true;
                TextBoxSuccTask.Visible     = true;
                TextBoxSuccDepen.Visible    = true;
                ButtonSuccessorTask.Visible = true;

                LabelAssocIssue.Visible       = true;
                ButtonAssociateIssues.Visible = true;
            }
        }