Пример #1
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);
            }
        }
Пример #2
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);
        }
Пример #3
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);
            }
        }