Ejemplo n.º 1
0
        public static List <TEMPLATE> Sort()
        {
            List <Task> allTEMPLATE = new List <Task> {
            };

            SqlConnection conn = DB.Connection();

            conn.Open();

            SqlCommand    cmd = new SqlCommand("SELECT * FROM template ORDER BY TEMPLATEdate;", conn);
            SqlDataReader rdr = cmd.ExecuteReader();

            while (rdr.Read())
            {
                int      TEMPLATEId          = rdr.GetInt32(0);
                string   TEMPLATEDescription = rdr.GetString(1);
                TEMPLATE newTEMPLATE         = new TEMPLATE(TEMPLATEDescription, TEMPLATEId);
                allTEMPLATE.Add(newTEMPLATE);
            }

            if (rdr != null)
            {
                rdr.Close();
            }
            if (conn != null)
            {
                conn.Close();
            }

            return(allTEMPLATE);
        }
Ejemplo n.º 2
0
        public static TEMPLATE Find(int id)
        {
            SqlConnection conn = DB.Connection();

            conn.Open();

            SqlCommand   cmd = new SqlCommand("SELECT * FROM template WHERE id = @TEMPLATEId;", conn);
            SqlParameter TEMPLATEIdParameter = new SqlParameter("@TEMPLATEId", id.ToString());

            cmd.Parameters.Add(TEMPLATEIdParameter);
            SqlDataReader rdr = cmd.ExecuteReader();

            int    foundTEMPLATEId          = 0;
            string foundTEMPLATEDescription = null;

            while (rdr.Read())
            {
                foundTEMPLATEId          = rdr.GetInt32(0);
                foundTEMPLATEDescription = rdr.GetString(1);
            }
            TEMPLATE foundTEMPLATE = new TEMPLATE(foundTEMPLATEDescription, foundTEMPLATEId);

            if (rdr != null)
            {
                rdr.Close();
            }
            if (conn != null)
            {
                conn.Close();
            }

            return(foundTEMPLATE);
        }