/// <summary>
    /// Loads all open project of employee into project DDL
    /// </summary>
    private void LoadAllOpenProject()
    {
        try
        {
            string         employeeId           = Session["userID"].ToString();
            ProjectGateway ProjectGatewayObject = new ProjectGateway();
            int            noOfProject          = ProjectGatewayObject.SelectAllOpenProjects(employeeId).Count;
            projectDropDownList.DataSource = ProjectGatewayObject.SelectAllOpenProjects(employeeId);
            //Admin can remove an employee from a project only if he is a member of it

            projectDropDownList.DataTextField  = "Title";
            projectDropDownList.DataValueField = "ID";
            projectDropDownList.DataBind();
            if (noOfProject.Equals(0))
            {
                errorLabel.Text = "Admin is not a member of any project. Admin cant remove any employee";
            }
        }
        catch (SqlException sqlExceptionObject)
        {
            errorLabel.Text = sqlExceptionObject.Message;
        }
        catch (Exception exceptionObject)
        {
            errorLabel.Text = exceptionObject.Message;
        }
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Loads all open project of employee into project DDL
    /// </summary>
    private void LoadAllOpenProject()
    {
        try
        {
            string         employeeId           = Session["userID"].ToString();
            ProjectGateway ProjectGatewayObject = new ProjectGateway();
            projectDropDownList.DataSource     = ProjectGatewayObject.SelectAllOpenProjects();
            projectDropDownList.DataTextField  = "Title";
            projectDropDownList.DataValueField = "ID";
            projectDropDownList.DataBind();

            if (ProjectGatewayObject.SelectAllOpenProjects().Count == 0)
            {
                errorLabel.Text = "Admin is not a member of any project yet. Can't add employee(s) to any project";
            }
        }
        catch (SqlException sqlExceptionObject)
        {
            errorLabel.Text = sqlExceptionObject.Message;
        }
        catch (Exception exceptionObject)
        {
            errorLabel.Text = exceptionObject.Message;
        }
    }
Ejemplo n.º 3
0
 /// <summary>
 /// Fills up projectDropDownList DDL
 /// </summary>
 private void LoadProjectDropDownList()
 {
     try
     {
         ProjectGateway ProjectGatewayObject = new ProjectGateway();
         projectDropDownList.DataSource     = ProjectGatewayObject.SelectAllOpenProjects();
         projectDropDownList.DataTextField  = "Title";
         projectDropDownList.DataValueField = "ID";
         projectDropDownList.DataBind();
         if (ProjectGatewayObject.SelectAllOpenProjects().Count == 0)
         {
             errorLabel.Text = "No project is created yet";
         }
     }
     catch (SqlException sqlExceptionObj)
     {
         errorLabel.Text = sqlExceptionObj.Message;
     }
     catch (Exception exceptionObj)
     {
         errorLabel.Text = exceptionObj.Message;
     }
 }
 /// <summary>
 /// Loads all open project of employee into project DDL
 /// </summary>
 private void LoadAllOpenProject()
 {
     try
     {
         string         employeeId           = Session["userID"].ToString();
         ProjectGateway ProjectGatewayObject = new ProjectGateway();
         projectDropDownList.DataSource     = ProjectGatewayObject.SelectAllOpenProjects(employeeId);
         projectDropDownList.DataTextField  = "title";
         projectDropDownList.DataValueField = "ID";
         projectDropDownList.DataBind();
     }
     catch (SqlException sqlExceptionObject)
     {
         errorLabel.Text = sqlExceptionObject.Message;
     }
     catch (Exception exceptionObject)
     {
         errorLabel.Text = exceptionObject.Message;
     }
 }
    /// <summary>
    /// Checks if admin can remove a employee
    /// </summary>
    /// <returns>true if admin can remove employee else false</returns>
    private bool CheckForEmployeeRemove()
    {
        successLabel.Text = "";

        try
        {
            string         employeeId           = Session["userID"].ToString();
            ProjectGateway ProjectGatewayObject = new ProjectGateway();
            int            numberOfProject      = ProjectGatewayObject.SelectAllOpenProjects(employeeId).Count;
            //Admin can remove an employee from a project only if he is a member of it
            //This counts the number of projects admin have


            EmployeeGateway EmployeeGatewayObject = new EmployeeGateway();
            int             numberOfEmployee      = EmployeeGatewayObject.GetAllEmployeesOfAProject(projectDropDownList.SelectedItem.Value).Count;
            //If there is only one project member then he cant be removed
            //This counts the number of members of the selected project

            UserGateway UserGatewayObjrct = new UserGateway();

            if (projectDropDownList.SelectedIndex.Equals(0))  // Item in index 0 is "-Select-" and not a valid item. So must not use
            {
                errorLabel.Text = "Please select a project";
                return(false);
            }
            else if (numberOfProject == 0)
            {
                errorLabel.Text = "Admin is not a member of any project. Admin cant remove any employee";
                return(false);
            }
            else if (numberOfEmployee == 1)
            {
                errorLabel.Text = "Only Admin is employee of the ptoject. Cant remove!";
                return(false);
            }
            else if (employeeDropDownList.SelectedIndex.Equals(0))  // Item in index 0 is "-Select-" and not a valid item. So must not use
            {
                errorLabel.Text = "Please select an employee to remove";
                return(false);
            }
            else if (UserGatewayObjrct.GetUserType(employeeDropDownList.SelectedItem.Value).ToString() == "True")
            {
                errorLabel.Text = "Admin cant be removed";
                return(false);
            }
            else
            {
                return(true);
            }
        }
        catch (NonUserEmployeeException nonUserEmployeeExceptionObject)
        {
            /*This exception occours when employee is not a user
             * but is a member of a project
             * A non user employee can be removed from the project
             * so true is returned
             * Admin will not be aware of this event as errorLabel.text will be removed when non user employee successfully removed
             * */
            errorLabel.Text = nonUserEmployeeExceptionObject.Message + "Can be removed";
            return(true);
        }
        catch (SqlException sqlExceptionObject)
        {
            errorLabel.Text = sqlExceptionObject.Message;
            return(false);
        }
        catch (Exception exceptionObject)
        {
            errorLabel.Text = exceptionObject.Message;
            return(false);
        }
    }