Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnARMemRemoveUser_Click(object sender, EventArgs e)
        {
            // Reset the results label
            lblARMemResults.Text = "";

            // First make sure the current user is the admin of the selected team
            Team selectedTeam = TeamDAL.GetTeamById(Convert.ToInt64(ddlARMemTeam.SelectedValue));

            if (currentUser.ID != selectedTeam.TeamOwner)
            {
                lblARMemResults.ForeColor = Color.Red;
                lblARMemResults.Text      = "Cannot remove user from a task of a team that you are not the admin of. ";
                return;
            }

            Int64 selectedTaskID = Convert.ToInt64(ddlARMemTask.SelectedValue);
            User  userToRemove   = UserDAL.GetUserByID(Convert.ToInt64(ddlARMemTaskUsers.SelectedValue));

            // Attempt to remove user from this task and signal result within the results label
            if (UserTasksDAL.RemoveUserFromTask(selectedTaskID, userToRemove.ID))
            {
                lblARMemResults.ForeColor = Color.Blue;
                lblARMemResults.Text      = "Successfully removed user from task. ";

                // Remember to refresh all of the drop down lists
                this.RefreshAllDropDownLists();
            }
            else
            {
                lblARMemResults.ForeColor = Color.Red;
                lblARMemResults.Text      = "Unable to remove user from task. ";
            }
        }
Example #2
0
        protected void btnSignIn_Click(object sender, EventArgs e)
        {
            // Clear results tag
            lblResultsSignIn.Text = "";


            // Make sure the email exist in the db first
            ConMan.App_Code.Entities.User user = UserDAL.GetUserByEmail(tbxEmailSignIn.Text);
            if (user != null)
            {
                // Make sure that the password matches up with the User associated
                // with the email
                if (user.Password.Equals(tbxPasswordSignIn.Text))
                {
                    UserTasksDAL.email_notifications_signin(user);
                    FormsAuthentication.RedirectFromLoginPage(user.Email, false);
                }
                else
                {
                    lblResultsSignIn.ForeColor = Color.Red;
                    lblResultsSignIn.Text     += " Incorrect Password. ";
                }
            }
            else
            {
                lblResultsSignIn.ForeColor = Color.Red;
                lblResultsSignIn.Text     += " Email does not exist in ConMan database";
            }
        }
Example #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnARMemAddUser_Click(object sender, EventArgs e)
        {
            // Reset the results label for this view
            lblARMemResults.Text = "";

            // First make sure the current user is the admin of the selected team
            Team selectedTeam = TeamDAL.GetTeamById(Convert.ToInt64(ddlARMemTeam.SelectedValue));
            User newUser      = UserDAL.GetUserByEmail(tbxARMemEmail.Text);

            // Show error messsage and abort
            if (currentUser.ID != selectedTeam.TeamOwner)
            {
                lblARMemResults.ForeColor = Color.Red;
                lblARMemResults.Text      = "Cannot assign user to a task of a team that you are not the admin of. ";
                return;
            }

            // Make sure the specified user exists in the ConMan database
            if (newUser == null)
            {
                lblARMemResults.ForeColor = Color.Red;
                lblARMemResults.Text      = "Cannot add user. User must have account with ConMan. ";
                return;
            }

            // Make sure the specified user is not already assigned to this task
            Int64 selectedTaskID = Convert.ToInt64(ddlARMemTask.SelectedValue);
            Int64 selectedUserID = newUser.ID;

            if (UserTasksDAL.IsTaskAssignedToUser(Convert.ToInt64(ddlARMemTask.SelectedValue), newUser.ID))
            {
                lblARMemResults.ForeColor = Color.Red;
                lblARMemResults.Text      = "Cannot add user. User is already assigned to this task. ";
                return;
            }

            // If we got this far, all data is valid
            Int64 userID = UserTasksDAL.AddUserToTask(Convert.ToInt64(ddlARMemTask.SelectedValue),
                                                      newUser.ID);

            if (userID > 0)
            {
                lblARMemResults.ForeColor = Color.Blue;
                lblARMemResults.Text      = "Successfully assigned user to this task. ";

                // Refresh the drop down lists
                this.RefreshAllDropDownLists();

                // Reset the add user text box
                tbxARMemEmail.Text = "";
            }
            else
            {
                lblARMemResults.ForeColor = Color.Red;
                lblARMemResults.Text      = "Unable to assign user to this task. ";
            }
        }
Example #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnDeleteTeam_Click(object sender, EventArgs e)
        {
            // Make the sure user selected a team
            if (ddlTeamsDelete.SelectedValue.Equals("") || ddlTeamsDelete.Equals("0") || ddlTeamsDelete.SelectedValue == null)
            {
                lblDeleteTeamResults.ForeColor = Color.Red;
                lblDeleteTeamResults.Text      = "You must first select a team to delete. ";
                return;
            }

            // First make sure the current user is the admin of the selected team
            Team team = TeamDAL.GetTeamById(Convert.ToInt64(ddlTeamsDelete.SelectedValue));

            lblDeleteTeamResults.Text = "";

            // If the user is NOT the team admin...
            if (currentUser.ID != team.TeamOwner)
            {
                lblDeleteTeamResults.ForeColor = Color.Red;
                lblDeleteTeamResults.Text      = "Cannot delete a team that you are not the admin of. ";
                return;
            }

            // Attempt to delete all information about the tasks associated with the team
            // to delete (task, task notes, and mappings to assigned users)
            List <Int64> listOfTasksToDelete = TaskDAL.GetAllTeamTasks(team.TeamID);

            foreach (Int64 taskID in listOfTasksToDelete)
            {
                TaskNotesDAL.DeleteAllTaskNotes(taskID);
                UserTasksDAL.DeleteAllTaskUsers(taskID);
                TaskDAL.DeleteTask(taskID);
            }

            // Atttempt to delete the team
            if (TeamDAL.DeleteTeam(team.TeamID) && TeamMemberDAL.RemoveAllMembers(team.TeamID))
            {
                lblDeleteTeamResults.ForeColor = Color.Blue;
                lblDeleteTeamResults.Text      = "Successfully deleted the team.";

                // Remember to update the drop down lists on the page
                ddlTeamsDelete.DataBind();
                ddlTeamsView.DataBind();
                ddlTeamsUpdate.DataBind();
                ddlUpdateRemoveMember.DataBind();
            }
        }
Example #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnDeleteTask_Click(object sender, EventArgs e)
        {
            if (ddlDeleteTeam.SelectedValue.Equals("") || ddlDeleteTeam.SelectedValue.Equals("0") || ddlDeleteTeam.SelectedValue == null ||
                ddlDeleteTask.SelectedValue.Equals("") || ddlDeleteTask.SelectedValue.Equals("0") || ddlDeleteTask.SelectedValue == null)
            {
                lblDeleteTaskResults.ForeColor = Color.Red;
                lblDeleteTaskResults.Text      = "You must first select a team and task to delete a task. ";
                return;
            }

            Task task     = TaskDAL.GetTaskByID(Convert.ToInt64(ddlDeleteTask.SelectedValue));
            Team taskTeam = TeamDAL.GetTeamById(task.TeamID);

            // First ensure that the current user, is the admin of the team that this task
            // is associated with
            if (currentUser.ID != taskTeam.TeamOwner)
            {
                lblDeleteTaskResults.ForeColor = Color.Red;
                lblDeleteTaskResults.Text      = "Cannot delete a task of a team that you are not the admin of.";
                return;
            }

            // Delete the task and all of its notes and all of its mappings to users
            bool wasTaskDeletionSuccessful      = TaskDAL.DeleteTask(task.TaskID);
            bool wasTaskNotesDeletionSuccessful = TaskNotesDAL.DeleteAllTaskNotes(task.TaskID);
            bool wasTaskUsersDeletionSuccessful = UserTasksDAL.DeleteAllTaskUsers(task.TaskID);

            // Signal whether the deletion was successful or not
            if (!wasTaskDeletionSuccessful || !wasTaskNotesDeletionSuccessful || !wasTaskUsersDeletionSuccessful)
            {
                lblDeleteTaskResults.ForeColor = Color.Red;
                lblDeleteTaskResults.Text      = "Error occurred while deleting the task. ";
                return;
            }
            else
            {
                lblDeleteTaskResults.ForeColor = Color.Blue;
                lblDeleteTaskResults.Text      = "Successfully delete the specified task. ";

                // Force all dropdown lists to refresh
                this.RefreshAllDropDownLists();
            }
        }
Example #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnAddNoteButton_Click(object sender, EventArgs e)
        {
            // First make sure a team and task where selected
            if (ddlAddNoteTeam.SelectedValue.Equals("") || ddlAddNoteTeam.SelectedValue.Equals("0") || ddlAddNoteTeam.SelectedValue == null ||
                ddlAddNoteTask.SelectedValue.Equals("") || ddlAddNoteTask.SelectedValue.Equals("0") || ddlAddNoteTask.SelectedValue == null)
            {
                lblAddNoteResults.ForeColor = Color.Red;
                lblAddNoteResults.Text      = "You must first select a team and task to add a note. ";
                return;
            }

            Int64 selectedTaskID = Convert.ToInt64(ddlAddNoteTask.SelectedValue);

            // Maker sure user is assigned to the task before they can add a note
            if (UserTasksDAL.IsTaskAssignedToUser(selectedTaskID, currentUser.ID) == false)
            {
                lblAddNoteResults.ForeColor = Color.Red;
                lblAddNoteResults.Text      = "Cannot add note to task that you are not assigned to. ";
                return;
            }

            // Attempt to create note
            if (TaskNotesDAL.AddNotesToTask(selectedTaskID, currentUser.ID, tbxAddNoteNote.Text, DateTime.Now))
            {
                lblAddNoteResults.ForeColor = Color.Blue;
                lblAddNoteResults.Text      = "Successfully added notes to selected task. ";
                tbxAddNoteNote.Text         = "";
                NotesDataList.DataBind();
                //this.RefreshAllDropDownLists();
                NotesDataList.Visible = true;
            }
            else
            {
                lblAddNoteResults.ForeColor = Color.Red;
                lblAddNoteResults.Text      = "Unable to add notes to selected task. ";
            }
        }
Example #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnARMemRemoveUser_Click(object sender, EventArgs e)
        {
            // Reset the results label for this view
            lblARMemResults.Text = "";

            // Make sure a team and task is selected
            if (ddlARMemTeam.SelectedValue.Equals("") || ddlARMemTeam.SelectedValue.Equals("0") || ddlARMemTeam.SelectedValue == null ||
                ddlARMemTask.SelectedValue.Equals("") || ddlARMemTask.SelectedValue.Equals("0") || ddlARMemTask.SelectedValue == null)
            {
                lblARMemResults.ForeColor = Color.Red;
                lblARMemResults.Text      = "You must select a team and task before attempting to unassign a user from the task.";
                return;
            }

            // First make sure the current user is the admin of the selected team
            Team selectedTeam = TeamDAL.GetTeamById(Convert.ToInt64(ddlARMemTeam.SelectedValue));
            User userToRemove = UserDAL.GetUserByEmail(tbxARMemEmail.Text);

            // Show error messsage and abort
            if (currentUser.ID != selectedTeam.TeamOwner)
            {
                lblARMemResults.ForeColor = Color.Red;
                lblARMemResults.Text      = "Cannot remove user from a task of a team that you are not the admin of. ";
                return;
            }

            // Make sure the specified user exists in the ConMan database
            if (userToRemove == null)
            {
                lblARMemResults.ForeColor = Color.Red;
                lblARMemResults.Text      = "Cannot remove user. User must have account with ConMan. ";
                return;
            }

            // Make sure the specified user is not already assigned to this task
            Int64 selectedTaskID = Convert.ToInt64(ddlARMemTask.SelectedValue);
            Int64 selectedUserID = userToRemove.ID;

            if (UserTasksDAL.IsTaskAssignedToUser(Convert.ToInt64(ddlARMemTask.SelectedValue), userToRemove.ID) == false)
            {
                lblARMemResults.ForeColor = Color.Red;
                lblARMemResults.Text      = "Cannot remove user. User is not assigned to this task. ";
                return;
            }

            // No attempt to remove the user
            if (UserTasksDAL.RemoveUserFromTask(selectedTaskID, selectedUserID))
            {
                lblARMemResults.ForeColor = Color.Blue;
                lblARMemResults.Text      = "Successfully removed user from this task. ";

                // Refresh the drop down lists
                this.RefreshAllDropDownLists();

                // Reset the add user text box
                tbxARMemEmail.Text = "";
            }
            else
            {
                lblARMemResults.ForeColor = Color.Red;
                lblARMemResults.Text      = "Unable to remove user from this task. ";
            }
        }