Beispiel #1
0
        public List <Course_Assign> LoadCADB(string cnm, string yr, string tnm)
        {
            string query = "";
            List <Course_Assign> CAlst = new List <Course_Assign>();

            if (!String.IsNullOrEmpty(cnm) && !String.IsNullOrEmpty(tnm))
            {
                return(CAlst);
            }
            if (!String.IsNullOrEmpty(cnm) && !String.IsNullOrEmpty(yr))
            {
                return(CAlst);
            }
            if (!String.IsNullOrEmpty(tnm) && !String.IsNullOrEmpty(yr))
            {
                return(CAlst);
            }
            else if (!String.IsNullOrEmpty(cnm))
            {
                query = "SELECT * FROM course_assign WHERE cName='" + cnm + "'";
            }
            else if (!String.IsNullOrEmpty(yr))
            {
                query = "SELECT * FROM course_assign WHERE year='" + yr + "'";
            }
            else if (!String.IsNullOrEmpty(tnm))
            {
                query = "SELECT * FROM course_assign WHERE tName='" + tnm + "'";
            }
            else
            {
                return(CAlst);
            }
            try
            {
                this.OpenConnection();
                MySqlCommand    cmd = new MySqlCommand(query, connection);
                MySqlDataReader dr  = cmd.ExecuteReader();
                while (dr.Read())
                {
                    Course_Assign ca = new Course_Assign();
                    ca.CaId  = dr["caId"].ToString();
                    ca.CName = dr["cName"].ToString();
                    ca.TName = dr["tName"].ToString();
                    ca.Year  = dr["year"].ToString();
                    ca.Sem   = dr["sem"].ToString();
                    CAlst.Add(ca);
                }
                dr.Close();
                return(CAlst);
            }
            catch (Exception e)
            {
                return(CAlst);
            }
            finally
            {
                this.CloseConnection();
            }
        }
Beispiel #2
0
        public List <Course_Assign> getAllCaDB()
        {
            string               query = "SELECT * FROM course_assign";
            Course_Assign        c     = new Course_Assign();
            List <Course_Assign> CAlst = new List <Course_Assign>();

            try
            {
                this.OpenConnection();
                //DataTable table = new DataTable();
                MySqlCommand    cmd = new MySqlCommand(query, connection);
                MySqlDataReader dr  = cmd.ExecuteReader();
                //dr.Fill(table);
                while (dr.Read())
                {
                    Course_Assign ca = new Course_Assign();
                    ca.CaId  = dr["caId"].ToString();
                    ca.CName = dr["cName"].ToString();
                    ca.TName = dr["tName"].ToString();
                    ca.Year  = dr["year"].ToString();
                    ca.Sem   = dr["sem"].ToString();
                    CAlst.Add(ca);
                }
                dr.Close();
                return(CAlst);
            }
            catch (Exception ex)
            {
                c.Error = ex.Message;
                CAlst.Add(c);
                return(CAlst);
            }
            finally
            {
                this.CloseConnection();
            }
        }