예제 #1
0
        public override string _builtSQL(params List <DTO.TuKhoaDTO>[] arrListTuKhoa)
        {
            if (isEmpty(arrListTuKhoa))
            {
                return(String.Format("select * from {0} where  INSTR(@dk, {1}) > 0", _tableName, _fileds[1]));
            }
            StringBuilder sql1 = new StringBuilder("select MaPhuong from DULIEU where");
            int           flag = 0;

            if (!isEmpty(arrListTuKhoa[0]))
            {
                TuKhoaDAO._builtSQL(arrListTuKhoa[0], ref sql1, "MaDichVu", ref flag);
            }
            if (!isEmpty(arrListTuKhoa[1]))
            {
                TuKhoaDAO._builtSQL(arrListTuKhoa[1], ref sql1, "MaTinhThanh", ref flag);
            }
            if (!isEmpty(arrListTuKhoa[2]))
            {
                TuKhoaDAO._builtSQL(arrListTuKhoa[2], ref sql1, "MaPhuong", ref flag);
            }
            string sql2 = String.Format("select * from {0} where  INSTR(@dk, {1}) > 0 And MaPhuong in ({2})", _tableName, _fileds[1], sql1);

            return(sql2);
        }
예제 #2
0
        /// <summary>
        /// Tìm kiếm trên tất cả các dịch vụ
        /// </summary>
        /// <param name="_strChuoiDieuKien"></param>
        /// <returns></returns>
        public List <DuLieuDTO> timKiem(string _strChuoiDieuKien)
        {
            List <DuLieuDTO> lst = new List <DuLieuDTO>();

            try
            {
                openConnect();

                //B1. Tìm trong table TUKHOADICHVU

                List <TuKhoaDTO> lstTKDV = _tkDV.getListTuKhoa(ref _strChuoiDieuKien);

                //B2. Tìm trong table TUKHOATINHTHANH
                List <TuKhoaDTO> lstTKTT = _tkTT.getListTuKhoa(ref _strChuoiDieuKien, lstTKDV);

                //B3. Tìm trong table TUKHOAQUANHUYEN
                List <TuKhoaDTO> lstTKQH = _tkQH.getListTuKhoa(ref _strChuoiDieuKien, lstTKDV, lstTKTT);

                //B4. Tìm trong table TUKHOAPHUONG
                List <TuKhoaDTO> lstTKP = _tkP.getListTuKhoa(ref _strChuoiDieuKien, lstTKDV, lstTKTT, lstTKQH);

                //B5. Tìm trong table TUKHOADUONG
                List <TuKhoaDTO> lstTKD = _tkD.getListTuKhoa(ref _strChuoiDieuKien, lstTKDV, lstTKTT, lstTKQH, lstTKP);

                //B6. Tìm trong table TUKHOADIADIEM
                List <TuKhoaDTO> lstTKTDD = _tkTDD.getListTuKhoa(ref _strChuoiDieuKien, lstTKDV, lstTKTT, lstTKQH, lstTKP, lstTKD);


                if (TuKhoaDAO.isEmpty(lstTKD, lstTKDV, lstTKP, lstTKQH, lstTKTDD, lstTKTT))
                {
                    return(lst);
                }
                StringBuilder _sql = new StringBuilder("select DISTINCT * from DULIEU Where ");
                int           flag = 0;
                TuKhoaDAO._builtSQL(lstTKDV, ref _sql, "MaDichVu", ref flag);
                TuKhoaDAO._builtSQL(lstTKTT, ref _sql, "MaTinhThanh", ref flag);
                TuKhoaDAO._builtSQL(lstTKTDD, ref _sql, "MaTenDiaDiem", ref flag);
                TuKhoaDAO._builtSQL(lstTKP, ref _sql, "MaPhuong", ref flag);
                TuKhoaDAO._builtSQL(lstTKQH, ref _sql, "MaQuanHuyen", ref flag);
                TuKhoaDAO._builtSQL(lstTKD, ref _sql, "MaDuong", ref flag);
                _sqlSearch = _sql.ToString();
                lst        = _dlDAO.getListDuLieu(_sql.ToString(), 0, Comm.PageSize);
                // Hủy
                lstTKD = lstTKP = lstTKQH = lstTKTDD = lstTKTT = null;
                // Lưu lại result count
                _resultCount = Convert.ToInt32(_dbmanager.ExecuteScalar(System.Data.CommandType.Text, _sqlSearch.Replace("*", " count(*) ").ToString()));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                closeConnect();
            }
            return(lst);
        }