Example #1
0
    protected void taskReport_OnSort(object sender, GridViewSortEventArgs e)
    {
        BCCTaskEffort effort = new BCCTaskEffort();

        effort.TaskAssignedToUserName = CurrentUser;
        effort.TaskStatus = null;
        DateTime startDate = DateTime.Today.Subtract(new TimeSpan(7, 0, 0, 0));
        effort.ReportStartDate = startDate;

        if (DateTime.TryParse(tStartDate.Text, out startDate))
        {
            effort.ReportStartDate = startDate;
        }

        DateTime endDate = DateTime.Today;
        effort.ReportEndDate = endDate;

        if (DateTime.TryParse(tEndDate.Text, out endDate))
        {
            effort.ReportEndDate = endDate;
        }

        DataTable dtTasks = BCCTaskEffort.ReportTaskEfforts(effort);

        if (dtTasks != null)
        {
            DataView dataView = new DataView(dtTasks);
            dataView.Sort = e.SortExpression + " " + ToggleDirection();
            reportView.DataSource = dataView;
            reportView.DataBind();
            reportView.Visible = true;
        }
    }
Example #2
0
    private void FillReport(BCCTaskEffort effort)
    {
        DataTable dtTasks = BCCTaskEffort.ReportTaskEfforts(effort);

        if (dtTasks != null)
        {
            reportView.DataSource = dtTasks;
            reportView.DataBind();
            reportView.Visible = true;
        }
    }
Example #3
0
    protected void lnkViewReport_Click(object sender, EventArgs e)
    {
        BCCTaskEffort effort = new BCCTaskEffort();

        effort.TaskAssignedToUserName = CurrentUser;
        effort.TaskStatus = null;
        DateTime startDate = DateTime.Today.Subtract(new TimeSpan(5, 0, 0, 0));
        effort.ReportStartDate = startDate;

        if (DateTime.TryParse(tStartDate.Text, out startDate))
        {
            effort.ReportStartDate = startDate;
        }

        DateTime endDate = DateTime.Today;
        effort.ReportEndDate = endDate;

        if (DateTime.TryParse(tEndDate.Text, out endDate))
        {
            effort.ReportEndDate = endDate;
        }

        FillReport(effort);
        // Databind charts
        DataBindChart();
    }
    protected void taskEffortView_Sorting(object sender, GridViewSortEventArgs e)
    {
        BCCTaskEffort effort = new BCCTaskEffort();
        effort.ProjectName = projectName;
        effort.ReportStartDate = reportStartDate;
        effort.ReportEndDate = reportEndDate;

        DataTable projectEffort = BCCTaskEffort.ReportProjectEfforts(effort);

        if (projectEffort != null)
        {
            DataView dataView = new DataView(projectEffort);
            dataView.Sort = e.SortExpression + " " + ToggleDirection();
            projectEffortView.DataSource = dataView;
            projectEffortView.DataBind();
        }
    }
    /// <summary>
    /// BindProjectGrid
    /// </summary>
    /// <param name="projectName"></param>
    /// <param name="reportStartDate"></param>
    /// <param name="reportEndDate"></param>
    private void BindProjectGrid(string projectName, DateTime reportStartDate, DateTime reportEndDate)
    {
        BCCTaskEffort effort = new BCCTaskEffort();
        effort.ProjectName = projectName;
        effort.ReportStartDate = reportStartDate;
        effort.ReportEndDate = reportEndDate;

        headerCaption.Text = string.Format("Project Task Report - ({0})", projectName);

        DataTable dtTaskEffort = BCCTaskEffort.ReportProjectEfforts(effort);

        if (dtTaskEffort != null)
        {
            projectEffortView.DataSource = dtTaskEffort;
            projectEffortView.DataBind();
            projectEffortView.Visible = true;
        }
    }
    private void BindTaskEffortGrid(string taskId, string taskName, string projectName)
    {
        Guid taskGuid = new Guid(taskId);

        BCCTaskEffort effort = new BCCTaskEffort();
        effort.TaskID = taskGuid;

        lblTaskEffortCaption.Text = string.Format("Project: {0}, Task: {1}", projectName, taskName);

        // Retrieves all the effort for a specific task.
        DataTable dtTaskEffort = BCCTaskEffort.RetrieveAllTaskEfforts(effort);

        if (dtTaskEffort != null)
        {
            taskEffortView.DataSource = dtTaskEffort;
            taskEffortView.DataBind();
            taskEffortView.Visible = true;
        }
    }
    private void FillTaskEfforts(Guid taskID)
    {
        BCCTaskEffort effort = new BCCTaskEffort();

        effort.TaskID = taskID;

        // Get me all the active tasks.
        DataTable dtTasks = BCCTaskEffort.RetrieveAllTaskEfforts(effort);

        if (dtTasks != null)
        {
            taskEffortView.DataSource = dtTasks;
            taskEffortView.DataBind();
            taskEffortView.Visible = true;
        }
    }
    protected void taskEffortView_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        GridViewRow updatableRow = taskEffortView.Rows[e.RowIndex] as GridViewRow;
        Guid taskGuid = new Guid();

        if (updatableRow != null)
        {
            HiddenField htaskID = updatableRow.FindControl("taskID") as HiddenField;
            HiddenField taskRef = updatableRow.FindControl("taskRef") as HiddenField;

            TextBox tTaskDate = updatableRow.FindControl("tTaskDate") as TextBox;
            DropDownList ddlTaskStatus = updatableRow.FindControl("ddlTaskStatus") as DropDownList;
            TextBox tTaskRemark = updatableRow.FindControl("tTaskRemark") as TextBox;
            TextBox tTaskHours = updatableRow.FindControl("tTaskHours") as TextBox;

            if (htaskID != null)
            {
                taskGuid = new Guid(htaskID.Value);

                BCCTaskEffort effort = new BCCTaskEffort();
                effort.TaskID = taskGuid;
                effort.TaskRef = taskRef.Value;

                effort.TaskAssignedToUserName = HttpContext.Current.User.Identity.Name;

                DateTime today = DateTime.Today;
                DateTime.TryParse(tTaskDate.Text, out today);
                effort.TaskEffortDate = today;

                effort.TaskStatus = ddlTaskStatus.SelectedValue;
                effort.TaskRemark = tTaskRemark.Text;

                double taskEffort = 0;
                Double.TryParse(tTaskHours.Text, out taskEffort);
                effort.TaskEffort = taskEffort;

                BCCTaskEffort.UpdateTaskEffort(effort);
            }
        }

        // Refresh the data
        taskEffortView.EditIndex = -1;
        FillTaskEfforts(taskGuid);
    }
    protected void taskEffortView_Sorting(object sender, GridViewSortEventArgs e)
    {
        Guid taskGuid = new Guid(taskID);
        BCCTaskEffort effort = new BCCTaskEffort();
        effort.TaskID = taskGuid;

        DataTable dtTasks = BCCTaskEffort.RetrieveAllTaskEfforts(effort);

        if (dtTasks != null)
        {
            DataView dataView = new DataView(dtTasks);
            dataView.Sort = e.SortExpression + " " + ToggleDirection();
            taskEffortView.DataSource = dataView;
            taskEffortView.DataBind();
        }
    }
    protected void taskEffortView_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName.Equals("Add"))
        {
            TextBox tNewTaskDate = taskEffortView.FooterRow.FindControl("tNewTaskDate") as TextBox;
            TextBox tNewTaskHours = taskEffortView.FooterRow.FindControl("tNewTaskHours") as TextBox;
            DropDownList ddlNewTaskStatus = taskEffortView.FooterRow.FindControl("ddlNewTaskStatus") as DropDownList;
            TextBox tNewTaskRemark = taskEffortView.FooterRow.FindControl("tNewTaskRemark") as TextBox;

            Guid taskGuid = new Guid();

            if (taskID != null)
            {
                taskGuid = new Guid(taskID);
            }

            if (taskID != null && tNewTaskDate != null && ddlNewTaskStatus != null && tNewTaskHours != null && tNewTaskRemark != null)
            {
                BCCTaskEffort effort = new BCCTaskEffort();

                effort.TaskID = taskGuid;
                effort.TaskAssignedToUserName = HttpContext.Current.User.Identity.Name;

                DateTime today = DateTime.UtcNow.Date;
                DateTime.TryParse(tNewTaskDate.Text, out today);
                effort.TaskEffortDate = today;

                effort.TaskStatus = ddlNewTaskStatus.SelectedValue;
                effort.TaskRemark = tNewTaskRemark.Text;

                double taskEffort = 0;
                Double.TryParse(tNewTaskHours.Text, out taskEffort);
                effort.TaskEffort = taskEffort;

                BCCTaskEffort.CreateTaskEffort(effort);
            }

            FillTaskEfforts(taskGuid);
        }
        else if (e.CommandName.Equals("AddOnEmpty"))
        {
            TextBox tDate = taskEffortView.Controls[0].Controls[0].FindControl("tDate") as TextBox;
            DropDownList ddlTaskStatus2 = taskEffortView.Controls[0].Controls[0].FindControl("ddlTaskStatus2") as DropDownList;
            TextBox tRemark = taskEffortView.Controls[0].Controls[0].FindControl("tRemark") as TextBox;
            TextBox tEffort = taskEffortView.Controls[0].Controls[0].FindControl("tEffort") as TextBox;

            Guid taskGuid = new Guid();

            if (taskID != null)
            {
                taskGuid = new Guid(taskID);
            }

            if (taskID != null && tDate != null && ddlTaskStatus2 != null && tRemark != null && tEffort != null)
            {
                BCCTaskEffort effort = new BCCTaskEffort();

                effort.TaskID = taskGuid;
                effort.TaskAssignedToUserName = HttpContext.Current.User.Identity.Name;

                DateTime today = DateTime.UtcNow.Date;
                DateTime.TryParse(tDate.Text, out today);
                effort.TaskEffortDate = today;

                effort.TaskStatus = ddlTaskStatus2.SelectedValue;
                effort.TaskRemark = tRemark.Text;

                double taskEffort = 0;
                Double.TryParse(tEffort.Text, out taskEffort);
                effort.TaskEffort = taskEffort;

                BCCTaskEffort.CreateTaskEffort(effort);
            }

            FillTaskEfforts(taskGuid);
        }
    }
    protected void taskEffortView_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        GridViewRow deletedRow = taskEffortView.Rows[e.RowIndex] as GridViewRow;
        Guid taskGuid = new Guid();

        if (deletedRow != null)
        {
            HiddenField hGuid = deletedRow.FindControl("taskID") as HiddenField;
            HiddenField taskRef = deletedRow.FindControl("taskRef") as HiddenField;

            taskGuid = new Guid(hGuid.Value);

            BCCTaskEffort taskEffort = new BCCTaskEffort();
            taskEffort.TaskID = taskGuid;
            taskEffort.TaskRef = taskRef.Value;
            // User trying to delete
            taskEffort.TaskAssignedToUserName = HttpContext.Current.User.Identity.Name;

            BCCTaskEffort.RemoveTaskEfforts(taskEffort);
        }

        // Refresh the data
        taskEffortView.EditIndex = -1;
        FillTaskEfforts(taskGuid);
    }
        private void FindTasksAndNotifyUsers()
        {
            // Get all the users - 25 user limit.
            DataTable userTable = BCCTaskDataAccess.RetrieveAllUsers(ApplicationName, 0, USER_LIMIT);
            string mailMessage = string.Empty;
            string mailSubject = string.Empty;

            // foreach user in the user table.
            foreach (DataRow dr in userTable.Rows)
            {
                BCCTaskEffort effort = new BCCTaskEffort();

                effort.TaskAssignedToUserName = dr["userName"] as string;
                effort.TaskStatus = null; // has to be null to get all the tasks.

                DataTable taskTable = null;
                try
                {
                    // Get the list of tasks for each user
                    taskTable = BCCTaskEffort.ReportTaskEfforts(effort);
                }
                catch(Exception exception)
                {
                    System.Diagnostics.Debug.Write(exception.Message, "TaskNotifier");
                }

                // Dont send emails when there are no tasks.
                if (taskTable != null && taskTable.Rows != null && taskTable.Rows.Count > 0)
                {
                    EmailHelper helper = new EmailHelper(EmailConfigSpeedCode);

                    helper.EmailRecipient = dr["email"] as string;
                    WriteToEventLog("Sending email to : " + helper.EmailRecipient);

                    // Form the email message for each task
                    mailMessage = HtmlEmailHelper.FormHTMLContent(taskTable, effort.ReportStartDate, effort.ReportEndDate);
                    mailSubject = "(BCC) - Task Status Report - " + DateTime.UtcNow.Date.ToString("MMM-dd-yyyy");
                    helper.SendMail(mailSubject, mailMessage, false);
                }
                else
                {
                    System.Diagnostics.Debug.Write("No tasks found for " + effort.TaskAssignedToUserName, "TaskNotifier");
                }
            }
        }
Example #13
0
        /// <summary>
        /// Update
        /// </summary>
        /// <param name="taskEffort"></param>
        public static void UpdateTaskEffort(BCCTaskEffort taskEffort)
        {
            using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["authStore"].ConnectionString))
            {
                SqlCommand command = new SqlCommand("[dbo].[bcc_TaskEfforts_Update]", connection);
                command.CommandType = CommandType.StoredProcedure;

                SqlParameter param = new SqlParameter("@taskID", taskEffort.TaskID);
                command.Parameters.Add(param);

                param = new SqlParameter("@taskRef", taskEffort.TaskRef);
                command.Parameters.Add(param);

                param = new SqlParameter("@taskStatus", taskEffort.TaskStatus);
                command.Parameters.Add(param);

                param = new SqlParameter("@updatedbyUser", taskEffort.TaskAssignedToUserName);
                command.Parameters.Add(param);

                param = new SqlParameter("@taskDate", taskEffort.TaskEffortDate);
                command.Parameters.Add(param);

                param = new SqlParameter("@taskEffort", taskEffort.TaskEffort);
                command.Parameters.Add(param);

                param = new SqlParameter("@taskRemark", taskEffort.TaskRemark);
                command.Parameters.Add(param);

                connection.Open();

                command.ExecuteNonQuery();
            }
        }
Example #14
0
        /// <summary>
        /// Retrieve All Tasks whatever the case may be.
        /// </summary>
        /// <param name="task">BCC Task</param>
        /// <returns>DataTable</returns>
        public static DataTable RetrieveAllTaskEfforts(BCCTaskEffort taskEffort)
        {
            DataTable dt = null;

            using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["authStore"].ConnectionString))
            {
                SqlCommand command = new SqlCommand("[dbo].[bcc_TaskEfforts_Efforts]", connection);
                command.CommandType = CommandType.StoredProcedure;

                SqlParameter param = new SqlParameter("@taskID", taskEffort.TaskID);
                command.Parameters.Add(param);

                connection.Open();

                SqlDataReader reader = command.ExecuteReader();

                dt = new DataTable();
                dt.Load(reader);

                reader.Close();
            }

            return dt;
        }
Example #15
0
        /// <summary>
        /// Task Effort Report
        /// </summary>
        /// <param name="effort"></param>
        public static DataTable ReportTaskEfforts(BCCTaskEffort effort)
        {
            DataTable dt = null;

            using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["authStore"].ConnectionString))
            {
                SqlCommand command = new SqlCommand("[dbo].[bcc_TaskEfforts_TaskEffortReport]", connection);
                command.CommandType = CommandType.StoredProcedure;

                SqlParameter param = new SqlParameter("@assignedToUser", effort.TaskAssignedToUserName);
                command.Parameters.Add(param);

                param = new SqlParameter("@reportStartDate", effort.ReportStartDate);
                command.Parameters.Add(param);

                param = new SqlParameter("@reportEndDate", effort.ReportEndDate);
                command.Parameters.Add(param);

                if (effort.TaskStatus != null)
                {
                    param = new SqlParameter("@taskStatus", effort.TaskStatus);
                    command.Parameters.Add(param);
                }
                else
                {
                    param = new SqlParameter("@taskStatus", DBNull.Value);
                    command.Parameters.Add(param);
                }

                connection.Open();

                SqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection);

                dt = new DataTable();
                dt.Load(reader);

                reader.Close();
            }

            return dt;
        }
Example #16
0
        /// <summary>
        /// Task Effort Report
        /// </summary>
        /// <param name="effort"></param>
        public static DataTable ReportProjectEfforts(BCCTaskEffort effort)
        {
            DataTable dt = null;

            using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["authStore"].ConnectionString))
            {
                SqlCommand command = new SqlCommand("[dbo].[bcc_TaskEfforts_ProjectTaskEffort]", connection);
                command.CommandType = CommandType.StoredProcedure;

                SqlParameter param = new SqlParameter("@projectName", effort.ProjectName);
                command.Parameters.Add(param);

                param = new SqlParameter("@reportStartDate", effort.ReportStartDate);
                command.Parameters.Add(param);

                param = new SqlParameter("@reportEndDate", effort.ReportEndDate);
                command.Parameters.Add(param);

                connection.Open();

                SqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection);

                dt = new DataTable();
                dt.Load(reader);

                reader.Close();
            }

            return dt;
        }