Exemplo n.º 1
0
        public static List <String> DSMaNL()
        {
            List <string> str         = new List <string>();
            string        QueryString = "Select MaNL From NguyenLieu";

            conn = DataProvider.OpenConnection();
            DataTable dt = DataProvider.LayDataTable(QueryString, conn);

            if (dt.Rows.Count == 0)
            {
                return(null);
            }
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                str.Add(dt.Rows[i]["MaNL"].ToString());
            }
            DataProvider.CloseConnection(conn);
            return(str);
        }
        public static List <StudentDTO> searchStudentNotInClass(string textToSearch, string schoolYear)
        {
            string sCommand = @"select distinct S.*
                                from Student S, Student_Class SC
                                where S.IDStudent in (select IDStudent from Student) and S.IDStudent not in (select IDStudent from Student_Class) and SC.schoolYear ='" + schoolYear + "' and ((S.IDStudent like '%" + textToSearch + "%') or (S.Name like N'%" + textToSearch + "%'))";

            con = DataProvider.OpenConnection();
            DataTable dt = DataProvider.GetDataTable(sCommand, con);

            if (dt.Rows.Count <= 0)
            {
                DataProvider.CloseConnection(con);
                return(null);
            }
            int n = dt.Rows.Count;
            List <StudentDTO> result = new List <StudentDTO>();

            for (int i = 0; i < n; i++)
            {
                StudentDTO student = new StudentDTO();
                student.Id         = dt.Rows[i]["IDStudent"].ToString();
                student.Name       = dt.Rows[i]["Name"].ToString();
                student.Gender     = dt.Rows[i]["Gender"].ToString();
                student.Email      = dt.Rows[i]["Email"].ToString();
                student.Phone      = dt.Rows[i]["Phone"].ToString();
                student.DateofBith = dt.Rows[i]["BirthDay"].ToString();

                if (dt.Rows[i]["isActive"].ToString() == "T")
                {
                    student.Status = "Active";
                }
                else

                {
                    student.Status = "Deactive";
                }
                result.Add(student);
            }
            DataProvider.CloseConnection(con);
            return(result);
        }