Esempio n. 1
0
        public int createTNF(TNF tnf) // Insert.
        {
            SqlConnection conn     = null;
            int           toReturn = -1;

            try
            {
                conn = new SqlConnection();
                conn.ConnectionString = ConfigurationManager.ConnectionStrings["DBConnectionString"].ConnectionString;
                conn.Open();
                SqlCommand comm = new SqlCommand();
                comm.Connection  = conn;
                comm.CommandText = "Insert into [TNF] (userID, status, wf_status, wfid, type, applicationDate) OUTPUT INSERTED.tnfid VALUES (@userID, @status, @wf_status, @wfid, @type, @applicationDate)";
                comm.Parameters.AddWithValue("@userID", tnf.getUser().getUserID());
                comm.Parameters.AddWithValue("@status", tnf.getStatus());
                comm.Parameters.AddWithValue("@wf_status", 0);
                comm.Parameters.AddWithValue("@wfid", tnf.getWorkflow().getWorkflowID());
                comm.Parameters.AddWithValue("@type", tnf.getType());
                comm.Parameters.AddWithValue("applicationDate", tnf.getApplicationDate());
                toReturn = (Int32)comm.ExecuteScalar();
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            finally
            {
                conn.Close();
            }
            return(toReturn);
        }
Esempio n. 2
0
        public static Boolean makeRejection(TNF tnf, User approver, Notification noti, string reason)
        {
            //check TNF status
            if (!tnf.getStatus().ToLower().Equals("pending"))
            {
                return(false);
            }

            Workflow   currentWorkflow = tnf.getWorkflow();
            Department currentDept     = deptDAO.getDeptByName(tnf.getUser().getDepartment());
            Course     currentCourse   = tnfDAO.getCourseFromTNF(tnf.getTNFID());
            double     courseCost      = currentCourse.getPrice();

            // if bond exist, reject the bond
            double bondCriteria = currentWorkflow.getBondCriteria();

            if (currentCourse.getPrice() >= bondCriteria)
            {
                Bonds currentBond = bondDAO.getBondByTNFIDandUserID(tnf.getTNFID(), tnf.getUser().getUserID());
                bondDAO.updateBondStatus(currentBond.getBondID(), "rejected");
            }

            //Handle Notification, update status, date and reason
            //If its HR, reject for all HR
            List <User>         allHR             = userDAO.getAllHR();
            List <Notification> allHRNotification = new List <Notification>();

            foreach (User hr in allHR)
            {
                allHRNotification.Add(notificationDAO.getPendingNotificationByTnfIDandUserID(tnf.getTNFID(), hr.getUserID()));
            }
            allHRNotification = allHRNotification.Where(x => x != null).ToList();
            if (allHRNotification.Count < 2)
            {
                notificationDAO.updateNotificationStatus(noti.getNotificationID(), "rejected");
                notificationDAO.updateNotificationApprovedDate(noti.getNotificationID());
                if (reason != null)
                {
                    notificationDAO.updateNotificationRemarks(noti.getNotificationID(), reason);
                }
            }
            else
            {
                foreach (Notification hrNoti in allHRNotification)
                {
                    notificationDAO.updateNotificationStatus(hrNoti.getNotificationID(), "rejected");
                    notificationDAO.updateNotificationApprovedDate(hrNoti.getNotificationID());
                    if (reason != null)
                    {
                        notificationDAO.updateNotificationRemarks(hrNoti.getNotificationID(), reason);
                    }
                }
            }

            //Update TNF status
            tnfDAO.updateTNFStatus(tnf.getTNFID(), "rejected");

            return(true);
        }
Esempio n. 3
0
        protected void btnTNF_Click(object sender, EventArgs e)
        {
            TNFDAO tnfDAO = new TNFDAO();
            TNF    tnf    = tnfDAO.getIndividualTNFByID(GridView2.SelectedRow.Cells[2].Text, int.Parse(GridView2.SelectedRow.Cells[1].Text));

            Workflow_Route.routeForApproval(tnf);
            Response.Redirect("testIndividualRouting.aspx");
        }
Esempio n. 4
0
        public static Boolean routeForApproval(TNF tnf)
        {
            User        currentUser     = null;
            Workflow    currentWorkflow = wfDAO.getCurrentActiveWorkflow();
            List <User> users           = new List <User>();
            string      tnfType         = "";
            Boolean     gotBudget       = false;

            //getting the type if it's individual or group
            if (tnf.getType().Equals("Individual"))
            {
                currentUser = tnf.getUser();
                tnfType     = "Individual";
            }
            else
            {
                users   = tnf.getUsers();
                tnfType = "Group";
            }

            // check if not group then check individual duration, else check each individual in the group
            int probationPeriod = currentWorkflow.getProbationPeriod();

            if (!users.Any())
            {
                if (currentUser.getLengthOfSevice() < probationPeriod)
                {
                    // to do logic for > probationPeriod
                }
            }
            else
            {
                foreach (User user in users)
                {
                    // check duration for each user
                    // to do logic if user’s duration is < probationPeriod
                }
            }

            //To check budget, variable checking is gotBudget
            if (gotBudget)
            {
                if (tnfType.Equals("Individual"))
                {
                    return(routeIndividual(tnf));
                }
                else
                {
                    return(routeGroup(tnf));
                }
            }
            else
            {
                //updateTNFStatus("Rejected.Department no budget");
                //to use tnfDAO to update status
                return(false);
            }
        }
        protected int getTNFid()
        {
            TNFDAO          tnfDAO          = new TNFDAO();
            NotificationDAO notificationDAO = new NotificationDAO();

            int          notificationID      = Convert.ToInt32(Request.QueryString["n"]);
            Notification currentNotification = notificationDAO.getNotificationByID(notificationID);
            TNF          currentTNF          = tnfDAO.getIndividualTNFByID(currentNotification.getUserIDFrom(), currentNotification.getTNFID());

            return(currentTNF.getTNFID());
        }
Esempio n. 6
0
        protected void btnApprover_Click(object sender, EventArgs e)
        {
            TNFDAO          tnfDAO          = new TNFDAO();
            UserDAO         userDAO         = new UserDAO();
            NotificationDAO notificationDAO = new NotificationDAO();

            TNF          tnf                  = tnfDAO.getIndividualTNFByID(GridView1.SelectedRow.Cells[1].Text, int.Parse(GridView1.SelectedRow.Cells[3].Text));
            User         currentUser          = userDAO.getUserByID(GridView1.SelectedRow.Cells[2].Text);
            Notification selectedNotification = notificationDAO.getNotificationByID(int.Parse(GridView1.SelectedRow.Cells[7].Text));

            Workflow_Approve.makeApproval(tnf, currentUser, selectedNotification, "");
            Response.Redirect("testIndividualRouting.aspx");
        }
Esempio n. 7
0
        public static Boolean routeForApproval(TNF tnf)
        {
            User        currentUser     = null;
            Workflow    currentWorkflow = wfDAO.getCurrentActiveWorkflow(tnf.getType());
            List <User> users           = new List <User>();
            string      tnfType         = "";
            Boolean     gotBudget       = false;

            //getting the type if it's individual or group
            if (tnf.getType().Equals("individual"))
            {
                currentUser = tnf.getUser();
                tnfType     = "Individual";
            }
            else
            {
                users   = tnf.getUsers();
                tnfType = "Group";
            }

            //To check budget
            if (tnfType.Equals("Individual"))
            {
                Department currentDept   = deptDAO.getDeptByName(tnf.getUser().getDepartment());
                Course     currentCourse = tnfDAO.getCourseFromTNF(tnf.getTNFID());
                double     courseCost    = currentCourse.getPrice();
                gotBudget = deptDAO.checkDeptBudget(currentDept.getDeptName(), currentCourse.getPrice());
            }
            else
            {
                //check budget for each member of group
            }
            if (gotBudget)
            {
                if (tnfType.Equals("Individual"))
                {
                    return(routeIndividual(tnf));
                }
                else
                {
                    return(routeGroup(tnf));
                }
            }
            else
            {
                tnfDAO.updateTNFStatus(tnf.getTNFID(), "Rejected. Department no budget.");
                return(false);
            }
        }
Esempio n. 8
0
        public List <TNF> getAllTNFByUserID(string userID)
        {
            SqlConnection conn     = new SqlConnection();
            List <TNF>    toReturn = new List <TNF>();

            try
            {
                conn = new SqlConnection();
                string connstr = ConfigurationManager.ConnectionStrings["DBConnectionString"].ToString();
                conn.ConnectionString = connstr;
                conn.Open();
                SqlCommand comm = new SqlCommand();
                comm.Connection  = conn;
                comm.CommandText = "select * from [TNF] where userID=@userID";
                comm.Parameters.AddWithValue("@userID", userID);
                SqlDataReader dr = comm.ExecuteReader();
                while (dr.Read())
                {
                    TNF            t       = new TNF();
                    UserDAO        userDAO = new UserDAO();
                    WorkflowDAO    wfDAO   = new WorkflowDAO();
                    WorkflowSubDAO wfsDAO  = new WorkflowSubDAO();
                    User           user    = userDAO.getUserByID((string)dr["userID"]);
                    t.setUser(user);
                    t.setTNFID((int)dr["tnfid"]);
                    t.setType((string)dr["type"]);
                    t.setStatus((string)(dr["status"]));
                    t.setWFStatus((int)dr["wf_status"]);
                    t.setWorkflow(wfDAO.getWorkflowByID((int)dr["wfid"]));
                    if (!dr.IsDBNull(6))
                    {
                        t.setWorkflowSub(wfsDAO.getWorkflowSubByID((int)dr["wf_sub_id"]));
                    }
                    t.setApplicationDate(dr.GetDateTime(7));

                    toReturn.Add(t);
                }
                dr.Close();
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            finally
            {
                conn.Close();
            }
            return(toReturn);
        }
        protected void cfmRejectBtn_Click(object sender, EventArgs e)
        {
            TNFDAO          tnfDAO          = new TNFDAO();
            UserDAO         userDAO         = new UserDAO();
            NotificationDAO notificationDAO = new NotificationDAO();

            int notificationID = Convert.ToInt32(Request.QueryString["n"]);

            Notification currentNotification = notificationDAO.getNotificationByID(notificationID);
            TNF          currentTNF          = tnfDAO.getIndividualTNFByID(currentNotification.getUserIDFrom(), currentNotification.getTNFID());
            User         approver            = userDAO.getUserByID(currentNotification.getUserIDTo());


            Workflow_Reject.makeRejection(currentTNF, approver, currentNotification, remarksInput.Text);
            Response.Redirect("rejectionConfirmation.aspx");
        }
Esempio n. 10
0
        public static Boolean routeIndividual(TNF tnf)
        {
            User               currentUser        = tnf.getUser();
            UserDAO            userDAO            = new UserDAO();
            Workflow           currentWorkflow    = wfDAO.getCurrentActiveWorkflow();
            int                numOfCriteria      = wfDAO.getNumberOfCriteriaByWorkflow(currentWorkflow.getWorkflowID());
            string             currentStatusOfTNF = tnf.getStatus();
            List <WorkflowSub> workflowSubs       = wfsDAO.getSortedWorflowSubByWorkflow(currentWorkflow.getWorkflowID());
            float              tnfTotalCost       = 0.0F; //to get from tnfDAO and to confirm if gst is included in the fee of consideration

            if (currentStatusOfTNF.Equals("Pending"))
            {
                for (int i = 0; i < numOfCriteria; i++)
                {
                    WorkflowSub             currentWFS = workflowSubs[i];
                    float                   low_limit  = currentWFS.getAmount_low();
                    float                   high_limit = currentWFS.getAmount_high();
                    List <WorkflowApprover> approvers  = wfaDAO.getSortedWorkflowApprovers(currentWorkflow.getWorkflowID(), currentWFS.getWorkflowSubID());
                    if (tnfTotalCost >= low_limit && tnfTotalCost <= high_limit)
                    {
                        WorkflowApprover currentWFApprover = approvers[tnf.getWFStatus()];
                        User             approver          = currentWFApprover.getApprover();
                        //to check if applicant's level is higher than approver's level (need to write another function to check)
                        if (currentUser != approver)
                        {
                            //sendApprovalNotification(tnf, approver);
                            return(true);
                        }
                        else
                        {
                            //do something if applicant is approver
                        }
                    }
                }

                //check bond criteria
                float bondCriteria = currentWorkflow.getBondCriteria();
                if (tnfTotalCost >= bondCriteria)
                {
                    //create new bond object
                    return(true);
                }
            }
            return(false);
        }
Esempio n. 11
0
 public static Boolean routeGroup(TNF tnf)
 {
     /*
      * TNFDAO tnfDAO = new TNFDAO();
      * List<User> users = tnfDAO.getAllUsers(tnf);
      * List<Boolean> statuses = new List<Boolean>();
      * foreach (User user in users) {
      *      statuses.add(routeIndividual(tnf, user);
      * }
      *
      * if (statuses contains false) {
      *      updateTNFStatus("Error in processing");
      *      return false;
      * } else {
      *      return true;
      * }
      */
     return(false);
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["currentUser"] == null)
            {
                Response.Redirect("Login.aspx");
            }
            else
            {
                if (!IsPostBack)
                {
                    User currentUser = (User)Session["currentUser"];

                    TNFDAO              tnfDAO          = new TNFDAO();
                    UserDAO             userDAO         = new UserDAO();
                    int                 tnfID           = Convert.ToInt32(Request.QueryString["tnfid"]);
                    string              applicantUserID = Request.QueryString["applicant"];
                    NotificationDAO     notificationDAO = new NotificationDAO();
                    List <Notification> nList           = notificationDAO.getNotificationsByTnfID(tnfID);

                    TNF     currentTNF = tnfDAO.getIndividualTNFByID(applicantUserID, tnfID);
                    Boolean isApprover = false;

                    for (int i = 0; i < nList.Count(); i++)
                    {
                        Notification n = nList[i];
                        if (n.getUserIDTo().Equals(currentUser.getUserID()))
                        {
                            isApprover = true;
                        }
                    }

                    if (isApprover == false || currentTNF == null)
                    {
                        Response.Redirect("errorPage.aspx");
                    }

                    User applicant = userDAO.getUserByID(applicantUserID);

                    Course   courseApplied   = tnfDAO.getCourseFromTNF(tnfID);
                    Lesson   lessonApplied   = tnfDAO.getLessonFromTNF(tnfID);
                    TNFData  tnfData         = tnfDAO.getIndividualTNFDataByID(tnfID);
                    Workflow currentWorkflow = currentTNF.getWorkflow();
                    int      probationPeriod = currentWorkflow.getProbationPeriod();
                    TimeSpan ts = currentTNF.getApplicationDate().Subtract(applicant.getStartDate());

                    //setting user information
                    nameOfStaffOutput.Text    = applicant.getName();
                    employeeNumberOutput.Text = applicant.getUserID();
                    emailOutput.Text          = applicant.getEmail();
                    designationOutput.Text    = applicant.getJobTitle();
                    departmentOutput.Text     = applicant.getDepartment();

                    //setting course and lesson information
                    courseOutput.Text     = courseApplied.getCourseName();
                    startDate.Text        = lessonApplied.getStartDate().ToString("d MMM yyyy");
                    endDate.Text          = lessonApplied.getEndDate().ToString("d MMM yyyy");
                    startTime.Text        = lessonApplied.getStartTime().ToString();
                    endTime.Text          = lessonApplied.getEndTime().ToString();
                    venueOutput.Text      = lessonApplied.getVenue();
                    instructorOutput.Text = lessonApplied.getInstructor();

                    string internalOrExternal = courseApplied.getInternalOrExternal();
                    if (internalOrExternal.ToLower().Equals("internal"))
                    {
                        inhouse.Checked     = true;
                        external.Checked    = false;
                        lblExternal.Visible = false;
                        externalCourseProviderOutput.Visible = false;
                    }
                    else
                    {
                        inhouse.Checked     = false;
                        external.Checked    = true;
                        lblExternal.Visible = true;
                        externalCourseProviderOutput.Visible = true;
                        externalCourseProviderOutput.Text    = courseApplied.getCourseProvider();
                    }
                    courseFeeOutput.Text = "$" + courseApplied.getPrice();

                    //setting tnf data information
                    string prepareForNewJobRole = tnfData.getPrepareForNewJobRole();
                    if (prepareForNewJobRole.Equals("y"))
                    {
                        objectiveInput1.Checked  = true;
                        objectiveElaborate1.Text = tnfData.getPrepareForNewJobRoleText();
                        completeDateOutput1.Text = tnfData.getPrepareForNewJobRoleCompletionDate().Value.ToString("MM-dd-yyyy");
                    }
                    else
                    {
                        objectiveInput1.Checked  = false;
                        objectiveElaborate1.Text = "-";
                        completeDateOutput1.Text = "-";
                    }

                    string shareKnowledge = tnfData.getShareKnowledge();
                    if (shareKnowledge.Equals("y"))
                    {
                        objectiveInput2.Checked  = true;
                        objectiveElaborate2.Text = tnfData.getShareKnowledgeText();
                        completeDateOutput2.Text = tnfData.getShareKnowledgeCompletionDate().Value.ToString("MM-dd-yyyy");
                    }
                    else
                    {
                        objectiveInput2.Checked  = false;
                        objectiveElaborate2.Text = "-";
                        completeDateOutput2.Text = "-";
                    }

                    string otherObjectives = tnfData.getOtherObjectives();
                    if (otherObjectives.Equals("y"))
                    {
                        objectiveInput3.Checked    = true;
                        objectiveElaborate3.Text   = tnfData.getOtherObjectivesText();
                        completionDateOutput3.Text = tnfData.getOtherObjectivesCompletionDate().Value.ToString("MM-dd-yyyy");
                    }
                    else
                    {
                        objectiveInput3.Checked    = false;
                        objectiveElaborate3.Text   = "-";
                        completionDateOutput3.Text = "-";
                    }
                }
            }
        }
Esempio n. 13
0
        public static Boolean routeIndividual(TNF tnf)
        {
            User     currentUser     = tnf.getUser();
            UserDAO  userDAO         = new UserDAO();
            Workflow currentWorkflow = wfDAO.getCurrentActiveWorkflow("individual");
            //int numOfCriteria = wfDAO.getNumberOfCriteriaByWorkflow(currentWorkflow.getWorkflowID());
            string   currentStatusOfTNF = tnf.getStatus();
            int      probationPeriod    = currentWorkflow.getProbationPeriod();
            TimeSpan ts            = DateTime.Now.Subtract(currentUser.getStartDate());
            Course   currentCourse = tnfDAO.getCourseFromTNF(tnf.getTNFID());

            List <WorkflowSub> workflowSubs;

            if (ts.TotalDays < probationPeriod)
            {
                workflowSubs = wfsDAO.getSortedWorflowSubByWorkflowIDandType(currentWorkflow.getWorkflowID(), "ceo");
            }
            else if (currentCourse.getOverseas().Equals("y"))
            {
                workflowSubs = wfsDAO.getSortedWorflowSubByWorkflowIDandType(currentWorkflow.getWorkflowID(), "ceo");
            }
            else
            {
                workflowSubs = wfsDAO.getSortedWorflowSubByWorkflowIDandType(currentWorkflow.getWorkflowID(), "normal");
            }

            double tnfTotalCost = tnfDAO.getCourseFromTNF(tnf.getTNFID()).getPrice(); //to get from tnfDAO and to confirm if gst is included in the fee of consideration

            if (currentStatusOfTNF.Equals("pending"))
            {
                //check bond criteria
                double bondCriteria = currentWorkflow.getBondCriteria();
                if (tnfTotalCost >= bondCriteria)
                {
                    //create new bond object
                    BondDAO  bondDAO       = new BondDAO();
                    Bonds    newBond       = new Bonds(currentUser.getUserID(), tnf.getTNFID(), "pending");
                    int      bondID        = bondDAO.createBond(newBond);
                    DateTime bondStartDate = currentCourse.getEndDate();
                    bondStartDate = bondStartDate.AddDays(1);
                    bondDAO.updateBondStartDate(bondID, bondStartDate);
                }

                for (int i = 0; i < workflowSubs.Count; i++)
                {
                    if (wfsDAO.getWorkflowSubType(workflowSubs[i].getWorkflowSubID()).Equals("superior"))
                    {
                        i = 0;
                    }
                    WorkflowSub             currentWFS = workflowSubs[i];
                    double                  low_limit  = currentWFS.getAmount_low();
                    double                  high_limit = currentWFS.getAmount_high();
                    List <WorkflowApprover> approvers  = wfaDAO.getSortedWorkflowApprovers(currentWorkflow.getWorkflowID(), currentWFS.getWorkflowSubID());
                    if (tnfTotalCost >= low_limit && tnfTotalCost <= high_limit)
                    {
                        WorkflowApprover currentWFApprover        = approvers[tnf.getWFStatus()];
                        string           currentUser_job_category = currentUser.getJobCategory();
                        WorkflowApprover checkApprover            = wfaDAO.getWorkflowApproverByJobCategory(currentUser_job_category, currentWorkflow.getWorkflowID(), currentWFS.getWorkflowSubID());
                        Boolean          checkIfLevelHigher       = checkJobLevelHigher(currentUser_job_category, currentWFApprover.getJobCategory());
                        //to check if applicant's level is higher than approver's level (need to write another function to check)
                        WorkflowApprover lastWFApprover = wfaDAO.getLastApproverInChain(currentWorkflow.getWorkflowID(), currentWFS.getWorkflowSubID());
                        int levelOfUser = wfaDAO.getLevelByJobCategory(currentUser.getJobCategory(), currentWorkflow.getWorkflowID(), currentWFS.getWorkflowSubID());
                        if (checkApprover.getJobCategory() == null)
                        {
                            if (!checkIfLevelHigher)
                            {
                                tnfDAO.updateTNFWFSub(tnf.getTNFID(), currentWFS.getWorkflowSubID());
                                sendApprovalNotification(tnf, currentWFApprover);
                                return(true);
                            }
                            else
                            {
                                Boolean checkIfLevelHigherThanLastApprover = checkJobLevelHigher(currentUser_job_category, lastWFApprover.getJobCategory());
                                if (!checkIfLevelHigherThanLastApprover)
                                {
                                    for (int j = 0; i < approvers.Count; j++)
                                    {
                                        Boolean checkLevelWithCurrentApprover = checkJobLevelHigher(currentUser_job_category, approvers[j].getJobCategory());
                                        if (checkLevelWithCurrentApprover)
                                        {
                                            continue;
                                        }
                                        else
                                        {
                                            WorkflowApprover nextWFApprover = approvers[j];
                                            tnfDAO.updateTNFWFStatus(tnf.getTNFID(), j);
                                            tnfDAO.updateTNFWFSub(tnf.getTNFID(), currentWFS.getWorkflowSubID());
                                            sendApprovalNotification(tnf, nextWFApprover);
                                            return(true);
                                        }
                                    }
                                }
                                else
                                {
                                    workflowSubs = wfsDAO.getSortedWorflowSubByWorkflowIDandType(currentWorkflow.getWorkflowID(), "superior");
                                }
                            }
                        }
                        else
                        {
                            if (!currentUser.getJobCategory().Equals("ceo"))
                            {
                                if (levelOfUser < lastWFApprover.getLevel())
                                {
                                    WorkflowApprover nextWFApprover = approvers[levelOfUser + 1];
                                    tnfDAO.updateTNFWFSub(tnf.getTNFID(), currentWFS.getWorkflowSubID());
                                    tnfDAO.updateTNFWFStatus(tnf.getTNFID(), levelOfUser + 1);
                                    sendApprovalNotification(tnf, nextWFApprover);
                                    return(true);
                                }
                                else
                                {
                                    //handle last person in chain
                                    workflowSubs = wfsDAO.getSortedWorflowSubByWorkflowIDandType(currentWorkflow.getWorkflowID(), "superior");
                                }
                            }
                            else
                            {
                                //no need handle CEO
                            }
                        }
                    }
                }
            }
            return(false);
        }
Esempio n. 14
0
        protected void submitBtn_Click(object sender, EventArgs e)
        {
            //To do validations here
            if (courseInput.SelectedIndex == 0)
            {
                lblErrorMsgTest.Visible = true;
                lblErrorMsgTest.Text    = "Got error";
            }

            //Assume all fields entered correctly
            //declaration of variables
            WorkflowDAO wfDAO                             = new WorkflowDAO();
            TNFDAO      tnfDAO                            = new TNFDAO();
            User        currentUser                       = (User)Session["currentUser"];
            int         courseID                          = Convert.ToInt32(courseInput.SelectedValue);
            int         lessonID                          = Convert.ToInt32(Request.Form["rbnLessonID"]);
            string      prepareForNewJobRole              = null;
            string      prepareForNewJobRoleText          = null;
            DateTime?   prepareForNewJobRoleCompletedDate = null;
            string      shareKnowledge                    = null;
            string      shareKnowledgeText                = null;
            DateTime?   shareKnowledgeCompletedDate       = null;
            string      otherObjectives                   = null;
            string      otherObjectivesText               = null;
            DateTime?   otherObjectivesCompletedDate      = null;
            DateTime    applicationDate                   = DateTime.Now.Date;


            if (objectiveInput1.Checked)
            {
                prepareForNewJobRole              = "y";
                prepareForNewJobRoleText          = objectiveElaborate1.Text;
                prepareForNewJobRoleCompletedDate = DateTime.ParseExact(completeDateInput1.Text, "MM/dd/yyyy", CultureInfo.InvariantCulture);
            }
            else
            {
                prepareForNewJobRole = "n";
            }
            if (objectiveInput2.Checked)
            {
                shareKnowledge              = "y";
                shareKnowledgeText          = objectiveElaborate2.Text;
                shareKnowledgeCompletedDate = DateTime.ParseExact(completeDateInput2.Text, "MM/dd/yyyy", CultureInfo.InvariantCulture);
            }
            else
            {
                shareKnowledge = "n";
            }
            if (objectiveInput3.Checked)
            {
                otherObjectives              = "y";
                otherObjectivesText          = objectiveElaborate3.Text;
                otherObjectivesCompletedDate = DateTime.ParseExact(completeDateInput3.Text, "MM/dd/yyyy", CultureInfo.InvariantCulture);
            }
            else
            {
                otherObjectives = "n";
            }


            //creation of TNF object
            Workflow currentWF = wfDAO.getCurrentActiveWorkflow("individual");
            TNF      newTNF    = new TNF(currentUser, "individual", "pending", 0, currentWF, applicationDate);
            int      tnfid     = tnfDAO.createTNF(newTNF);

            newTNF.setTNFID(tnfid);
            tnfDAO.createTNF_Data(tnfid, courseID, prepareForNewJobRole, prepareForNewJobRoleText, prepareForNewJobRoleCompletedDate, shareKnowledge, shareKnowledgeText, shareKnowledgeCompletedDate, otherObjectives, otherObjectivesText, otherObjectivesCompletedDate, lessonID);

            //start routing

            Boolean successOrNot = Workflow_Route.routeForApproval(newTNF);

            if (successOrNot)
            {
                //to create lesson info
                Response.Redirect("submitTRF.aspx");
            }
            else
            {
                //do something
            }
        }
Esempio n. 15
0
        public static Boolean makeApproval(TNF tnf, User user, Notification noti, string remarks)
        {
            //check TNF status
            if (!tnf.getStatus().ToLower().Equals("pending"))
            {
                return(false);
            }

            //check budget
            Department currentDept   = deptDAO.getDeptByName(tnf.getUser().getDepartment());
            Course     currentCourse = tnfDAO.getCourseFromTNF(tnf.getTNFID());
            double     courseCost    = currentCourse.getPrice();
            Boolean    gotBudget     = deptDAO.checkDeptBudget(currentDept.getDeptName(), currentCourse.getPrice());
            int        nextWFLevel   = 0;

            if (!gotBudget)
            {
                return(false);
            }

            //check if approver is last in chain
            Boolean          isLastApprover  = false;
            Workflow         currentWorkflow = tnf.getWorkflow();
            WorkflowSub      currentWFS      = tnf.getWorkflowSub();
            WorkflowApprover nextApprover    = new WorkflowApprover();

            WorkflowApprover        lastApprover = wfaDAO.getLastApproverInChain(currentWorkflow.getWorkflowID(), currentWFS.getWorkflowSubID());
            List <WorkflowApprover> approvers    = wfaDAO.getSortedWorkflowApprovers(currentWorkflow.getWorkflowID(), currentWFS.getWorkflowSubID());

            if (user.getJobCategory().Contains(lastApprover.getJobCategory()))
            {
                isLastApprover = true;
            }
            else if (lastApprover.getJobCategory().Equals("superior"))
            {
                User currentTNFUser = tnf.getUser();
                if (currentTNFUser.getSupervisor().Equals(user.getUserID()))
                {
                    isLastApprover = true;
                }
            }
            else
            {
                int levelOfUser = wfaDAO.getLevelByJobCategory(user.getJobCategory(), currentWorkflow.getWorkflowID(), currentWFS.getWorkflowSubID());
                if (levelOfUser == -1)
                {
                    nextApprover = lastApprover;
                    nextWFLevel  = lastApprover.getLevel();
                }
                else
                {
                    nextApprover = approvers[levelOfUser + 1];
                    nextWFLevel  = levelOfUser + 1;
                }
            }

            //If its HR, approve for all HR
            List <User>         allHR             = userDAO.getAllHR();
            List <Notification> allHRNotification = new List <Notification>();

            foreach (User hr in allHR)
            {
                allHRNotification.Add(notificationDAO.getPendingNotificationByTnfIDandUserID(tnf.getTNFID(), hr.getUserID()));
            }
            allHRNotification = allHRNotification.Where(x => x != null).ToList();
            if (allHRNotification.Count < 2)
            {
                if (isLastApprover)
                {
                    notificationDAO.updateNotificationStatus(noti.getNotificationID(), "approved");
                    notificationDAO.updateNotificationApprovedDate(noti.getNotificationID());
                    if (remarks != null)
                    {
                        notificationDAO.updateNotificationRemarks(noti.getNotificationID(), remarks);
                    }
                    tnfDAO.updateTNFStatus(tnf.getTNFID(), "approved");
                    deptDAO.updateDeptBudget(currentDept.getDeptName(), (currentDept.getActualBudget() - currentCourse.getPrice()));
                    double bondCriteria = currentWorkflow.getBondCriteria();
                    if (currentCourse.getPrice() >= bondCriteria)
                    {
                        Bonds currentBond = bondDAO.getBondByTNFIDandUserID(tnf.getTNFID(), tnf.getUser().getUserID());
                        bondDAO.updateBondStatus(currentBond.getBondID(), "approved");
                    }
                }
                else
                {
                    notificationDAO.updateNotificationStatus(noti.getNotificationID(), "approved");
                    notificationDAO.updateNotificationApprovedDate(noti.getNotificationID());
                    if (remarks != null)
                    {
                        notificationDAO.updateNotificationRemarks(noti.getNotificationID(), remarks);
                    }
                    tnfDAO.updateTNFWFStatus(tnf.getTNFID(), nextWFLevel);
                    tnf = tnfDAO.getIndividualTNFByID(tnf.getUser().getUserID(), tnf.getTNFID());
                    Workflow_Route.sendApprovalNotification(tnf, nextApprover);
                }
            }
            else
            {
                if (isLastApprover)
                {
                    foreach (Notification hrNoti in allHRNotification)
                    {
                        notificationDAO.updateNotificationStatus(hrNoti.getNotificationID(), "approved");
                        notificationDAO.updateNotificationApprovedDate(hrNoti.getNotificationID());
                        if (remarks != null)
                        {
                            notificationDAO.updateNotificationRemarks(noti.getNotificationID(), remarks);
                        }
                    }
                    tnfDAO.updateTNFStatus(tnf.getTNFID(), "approved");
                    deptDAO.updateDeptBudget(currentDept.getDeptName(), (currentDept.getActualBudget() - currentCourse.getPrice()));
                    double bondCriteria = currentWorkflow.getBondCriteria();
                    if (currentCourse.getPrice() >= bondCriteria)
                    {
                        Bonds currentBond = bondDAO.getBondByTNFIDandUserID(tnf.getTNFID(), tnf.getUser().getUserID());
                        bondDAO.updateBondStatus(currentBond.getBondID(), "approved");
                    }
                }
                else
                {
                    foreach (Notification hrNoti in allHRNotification)
                    {
                        notificationDAO.updateNotificationStatus(hrNoti.getNotificationID(), "approved");
                        notificationDAO.updateNotificationApprovedDate(hrNoti.getNotificationID());
                        if (remarks != null)
                        {
                            notificationDAO.updateNotificationRemarks(noti.getNotificationID(), remarks);
                        }
                    }
                    tnfDAO.updateTNFWFStatus(tnf.getTNFID(), nextWFLevel);
                    tnf = tnfDAO.getIndividualTNFByID(tnf.getUser().getUserID(), tnf.getTNFID());
                    Workflow_Route.sendApprovalNotification(tnf, nextApprover);
                }
            }
            return(true);
        }
Esempio n. 16
0
        public static void sendApprovalNotification(TNF tnf, WorkflowApprover wfa)
        {
            User            currentUser = tnf.getUser();
            UserDAO         userDAO     = new UserDAO();
            NotificationDAO notiDAO     = new NotificationDAO();
            User            approver    = new User();
            List <User>     hrApprovers = new List <User>();

            if (tnf.getStatus().Equals("pending"))
            {
                int current_wf_status = tnf.getWFStatus();
                int wfaLevel          = wfa.getLevel();
                //if (wfa.getLevel() == current_wf_status)
                //{
                //get out who to send next
                string approverJobCat = wfa.getJobCategory();

                if (approverJobCat.ToLower().Equals("ceo"))
                {
                    approver = userDAO.getCEO();
                }
                else if (approverJobCat.ToLower().Equals("hod"))
                {
                    approver = userDAO.getHODbyDepartment(currentUser.getDepartment());
                }
                else if (approverJobCat.ToLower().Equals("supervisor"))
                {
                    approver = userDAO.getSupervisorbyDepartment(currentUser.getDepartment());
                }
                else if (approverJobCat.ToLower().Equals("hr hod"))
                {
                    approver = userDAO.getHRHOD();
                }
                else if (approverJobCat.ToLower().Equals("hr"))
                {
                    hrApprovers = userDAO.getAllHR();
                }
                else if (approverJobCat.ToLower().Equals("superior"))
                {
                    string supervisorID = userDAO.getSupervisorIDOfUser(currentUser.getUserID());
                    approver = userDAO.getUserByID(supervisorID);
                }

                //insert notification
                if (!hrApprovers.Any())
                {
                    Notification newNotification = new Notification(currentUser.getUserID(), approver.getUserID(), tnf.getTNFID(), "pending");
                    notiDAO.createNotification(newNotification);
                }
                else
                {
                    foreach (User hrUser in hrApprovers)
                    {
                        Notification newNotification = new Notification(currentUser.getUserID(), hrUser.getUserID(), tnf.getTNFID(), "pending");
                        notiDAO.createNotification(newNotification);
                    }
                }

                //}
            }
        }
Esempio n. 17
0
        protected void cfmApproveBtn_Click(object sender, EventArgs e)
        {
            TNFDAO          tnfDAO          = new TNFDAO();
            UserDAO         userDAO         = new UserDAO();
            BondDAO         bondDAO         = new BondDAO();
            NotificationDAO notificationDAO = new NotificationDAO();

            int notificationID = Convert.ToInt32(Request.QueryString["n"]);

            Notification currentNotification = notificationDAO.getNotificationByID(notificationID);
            TNF          currentTNF          = tnfDAO.getIndividualTNFByID(currentNotification.getUserIDFrom(), currentNotification.getTNFID());
            User         applicant           = userDAO.getUserByID(currentNotification.getUserIDFrom());
            User         approver            = userDAO.getUserByID(currentNotification.getUserIDTo());
            Bonds        checkBond           = bondDAO.getBondByTNFIDandUserID(currentTNF.getTNFID(), applicant.getUserID());
            User         currentUser         = (User)Session["currentUser"];

            if (currentUser.getJobCategory().Equals("hr"))
            {
                //to save HR form
                string   probationText          = "n";
                string   isFunding              = "n";
                string   isMSP                  = "n";
                string   duration               = "";
                string   sourceOfFunding        = txtSourceOfFunding.Text;
                DateTime?fundingApplicationDate = null;
                Workflow currentWorkflow        = currentTNF.getWorkflow();
                int      probationPeriod        = currentWorkflow.getProbationPeriod();
                TimeSpan ts = currentTNF.getApplicationDate().Subtract(applicant.getStartDate());

                if (ts.TotalDays < probationPeriod)
                {
                    probationText = "y";
                }
                if (rbnlFunding.SelectedValue.Equals("y"))
                {
                    isFunding = "y";
                }
                if (!txtFundingDate.Text.Equals(""))
                {
                    fundingApplicationDate = DateTime.ParseExact(txtFundingDate.Text, "MM/dd/yyyy", CultureInfo.InvariantCulture);
                }
                if (rbtnMSP.Checked)
                {
                    isMSP    = "y";
                    duration = mspBondDuration.Text;
                    tnfDAO.updateTNFDataHRFields(currentTNF.getTNFID(), probationText, Convert.ToDouble(trainingCost.Text), isFunding, sourceOfFunding, fundingApplicationDate, isMSP, duration);
                }
                else
                {
                    tnfDAO.updateTNFDataHRFields(currentTNF.getTNFID(), probationText, Convert.ToDouble(trainingCost.Text), isFunding, sourceOfFunding, fundingApplicationDate, "n", null);
                }

                if (checkBond != null)
                {
                    //update Bond end date to correspond to number of months entered
                    DateTime endDate = checkBond.getStartDate();
                    endDate = endDate.AddMonths(Convert.ToInt32(mspBondDuration.Text));
                    bondDAO.updateBondEndDate(checkBond.getBondID(), endDate);
                }
            }
            Workflow_Approve.makeApproval(currentTNF, approver, currentNotification, remarksInput.Text);
            Response.Redirect("approvalConfirmation.aspx");
        }
Esempio n. 18
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["currentUser"] == null)
            {
                Response.Redirect("Login.aspx");
            }
            else
            {
                if (!IsPostBack)
                {
                    User currentUser = (User)Session["currentUser"];

                    TNFDAO          tnfDAO          = new TNFDAO();
                    UserDAO         userDAO         = new UserDAO();
                    NotificationDAO notificationDAO = new NotificationDAO();

                    int notificationID = Convert.ToInt32(Request.QueryString["n"]);

                    Notification currentNotification = notificationDAO.getNotificationByID(notificationID);

                    if (currentNotification == null || !currentNotification.getUserIDTo().Equals(currentUser.getUserID()))
                    {
                        Response.Redirect("errorPage.aspx");
                    }

                    TNF  currentTNF = tnfDAO.getIndividualTNFByID(currentNotification.getUserIDFrom(), currentNotification.getTNFID());
                    User applicant  = userDAO.getUserByID(currentNotification.getUserIDFrom());

                    Course   courseApplied   = tnfDAO.getCourseFromTNF(currentNotification.getTNFID());
                    Lesson   lessonApplied   = tnfDAO.getLessonFromTNF(currentNotification.getTNFID());
                    TNFData  tnfData         = tnfDAO.getIndividualTNFDataByID(currentNotification.getTNFID());
                    Workflow currentWorkflow = currentTNF.getWorkflow();
                    int      probationPeriod = currentWorkflow.getProbationPeriod();
                    TimeSpan ts = currentTNF.getApplicationDate().Subtract(applicant.getStartDate());

                    //show warning if overseas, probation, > 10000
                    if (courseApplied.getPrice() > 10000)
                    {
                        warningPanelPrice.Visible = true;
                        lblWarningPrice.Visible   = true;
                        lblWarningPrice.Text      = "This course is over $10,000";
                    }
                    if (courseApplied.getOverseas().ToLower().Equals("y"))
                    {
                        warningPanelOverseas.Visible = true;
                        lblWarningOverseas.Visible   = true;
                        lblWarningOverseas.Text      = "This course is an overseas course";
                    }
                    if (ts.TotalDays < probationPeriod)
                    {
                        warningPanelProbation.Visible = true;
                        lblWarningProbation.Visible   = true;
                        probationDate.Enabled         = true;
                        lblWarningProbation.Text      = "Applicant is under probation";
                    }

                    //setting user information
                    nameOfStaffOutput.Text    = applicant.getName();
                    employeeNumberOutput.Text = applicant.getUserID();
                    emailOutput.Text          = applicant.getEmail();
                    designationOutput.Text    = applicant.getJobTitle();
                    departmentOutput.Text     = applicant.getDepartment();

                    //setting course and lesson information
                    courseOutput.Text     = courseApplied.getCourseName();
                    startDate.Text        = lessonApplied.getStartDate().ToString("d MMM yyyy");
                    endDate.Text          = lessonApplied.getEndDate().ToString("d MMM yyyy");
                    startTime.Text        = lessonApplied.getStartTime().ToString();
                    endTime.Text          = lessonApplied.getEndTime().ToString();
                    venueOutput.Text      = lessonApplied.getVenue();
                    instructorOutput.Text = lessonApplied.getInstructor();

                    string internalOrExternal = courseApplied.getInternalOrExternal();
                    if (internalOrExternal.ToLower().Equals("internal"))
                    {
                        inhouse.Checked     = true;
                        external.Checked    = false;
                        lblExternal.Visible = false;
                        externalCourseProviderOutput.Visible = false;
                    }
                    else
                    {
                        inhouse.Checked     = false;
                        external.Checked    = true;
                        lblExternal.Visible = true;
                        externalCourseProviderOutput.Visible = true;
                        externalCourseProviderOutput.Text    = courseApplied.getCourseProvider();
                    }
                    courseFeeOutput.Text = "$" + courseApplied.getPrice();

                    //setting tnf data information
                    string prepareForNewJobRole = tnfData.getPrepareForNewJobRole();
                    if (prepareForNewJobRole.Equals("y"))
                    {
                        objectiveInput1.Checked  = true;
                        objectiveElaborate1.Text = tnfData.getPrepareForNewJobRoleText();
                        completeDateOutput1.Text = tnfData.getPrepareForNewJobRoleCompletionDate().Value.ToString("MM-dd-yyyy");
                    }
                    else
                    {
                        objectiveInput1.Checked  = false;
                        objectiveElaborate1.Text = "-";
                        completeDateOutput1.Text = "-";
                    }

                    string shareKnowledge = tnfData.getShareKnowledge();
                    if (shareKnowledge.Equals("y"))
                    {
                        objectiveInput2.Checked  = true;
                        objectiveElaborate2.Text = tnfData.getShareKnowledgeText();
                        completeDateOutput2.Text = tnfData.getShareKnowledgeCompletionDate().Value.ToString("MM-dd-yyyy");
                    }
                    else
                    {
                        objectiveInput2.Checked  = false;
                        objectiveElaborate2.Text = "-";
                        completeDateOutput2.Text = "-";
                    }

                    string otherObjectives = tnfData.getOtherObjectives();
                    if (otherObjectives.Equals("y"))
                    {
                        objectiveInput3.Checked    = true;
                        objectiveElaborate3.Text   = tnfData.getOtherObjectivesText();
                        completionDateOutput3.Text = tnfData.getOtherObjectivesCompletionDate().Value.ToString("MM-dd-yyyy");
                    }
                    else
                    {
                        objectiveInput3.Checked    = false;
                        objectiveElaborate3.Text   = "-";
                        completionDateOutput3.Text = "-";
                    }

                    //all HR will view HR approval section
                    if (currentUser.getJobCategory().Equals("hr"))
                    {
                        hrApprovalView.Visible = true;
                        BondDAO    bondDAO     = new BondDAO();
                        DeptDAO    deptDAO     = new DeptDAO();
                        Bonds      checkBond   = bondDAO.getBondByTNFIDandUserID(currentTNF.getTNFID(), applicant.getUserID());
                        Department currentDept = deptDAO.getDeptByName(applicant.getDepartment());
                        lbl_HR.Text = "Is HR";
                        rfv_trainingCost.Enabled    = true;
                        rfv_mspBondDuration.Enabled = true;

                        if (checkBond != null)
                        {
                            rbtnBond.Checked        = true;
                            rbtnMSP.Enabled         = false;
                            rbtnNA.Enabled          = false;
                            mspBondDuration.Text    = string.Empty;
                            mspBondDuration.Enabled = true;
                        }
                        else
                        {
                            rbtnBond.Checked = false;
                            rbtnBond.Enabled = false;
                        }

                        costcentre.Text = currentDept.getCostCentre().ToString();
                        double balance = currentDept.getActualBudget() - courseApplied.getPrice();
                        trainingBudgetBal.Text  = balance.ToString();
                        trainingBudgetDate.Text = DateTime.Now.ToString("MM/dd/yyyy");
                    }
                    else
                    {
                        lbl_HR.Text = "Is not HR";
                        rfv_trainingCost.Enabled    = false;
                        rfv_mspBondDuration.Enabled = false;
                    }
                }
            }
        }