예제 #1
0
        public bool UpdateLop(lop l)
        {
            String query = "update lop set tenlop =N'" + l.tenlop + "' , makhoa ='" + l.makhoa + "' where malop = '" + l.malop + "'";

            try {
                SqlCommand cmd = new SqlCommand(query, getConnection());
                cmd.ExecuteNonQuery();
                return(true);
            } catch (Exception e) {
                return(false);
            }
        }
예제 #2
0
        public bool deleteLop(lop l)
        {
            String query = "delete lop where malop = '" + l.malop + "'";

            try {
                SqlCommand cmd = new SqlCommand(query, getConnection());
                cmd.ExecuteNonQuery();
                return(true);
            } catch (Exception e) {
                return(false);
            }
        }
예제 #3
0
        public bool insertLop(lop lop)
        {
            String query = "Insert into lop values  ('" + lop.malop + "' , N'" + lop.tenlop + "' , '" + lop.makhoa + "');";

            try {
                SqlCommand cmd = new SqlCommand(query, getConnection());
                cmd.ExecuteNonQuery();
                return(true);
            } catch (Exception e) {
                return(false);
            }
        }
예제 #4
0
        public List <lop> searchListLop(String search)
        {
            List <lop> list = new List <lop>();
            String     query;

            query = "Select * from lop where makhoa = '" + search + "' or lop.malop = '" + search + "' or lop.tenlop = '" + search + "'";

            try {
                SqlCommand    cmd    = new SqlCommand(query, getConnection());
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    lop l = new lop();
                    l.lopIDataReader(reader);
                    list.Add(l);
                }
                reader.Close();
            } catch (Exception e) {
            }
            return(list);
        }
예제 #5
0
        public List <lop> getListLop()
        {
            List <lop> list = new List <lop>();
            String     query;

            query = "Select * from lop ";

            try
            {
                SqlCommand    cmd    = new SqlCommand(query, getConnection());
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    lop l = new lop();
                    l.lopIDataReader(reader);
                    list.Add(l);
                }
                reader.Close();
            }
            catch (Exception e)
            {
            }
            return(list);
        }