Esempio n. 1
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);
        }