Example #1
0
        /// <summary>
        /// 取得維修單列表
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public List <tek_repair> GetRepairList(QueryList query)
        {
            //狀態5的不傳
            string SQL = @"
                with tmp as (
	                select * from (
		                select row_number() over (partition by tek_name,mstatus order by tek_recipient_date desc) as con,* from (
			                select (select top 1 tek_m_status from Mobiletime_Staging where tek_repair_tek_mobiletime = a.tek_name order by id desc) as mstatus,b.tek_m_status,a.* 
			                from Repair_Staging a left outer join Mobiletime_Staging b on a.tek_name = tek_repair_tek_mobiletime
		                ) as x where isnull(mstatus,'') <> '5'
	                ) as y where con = 1
                )
                select top (@PageSize) * 
                from (
                    select *,row_number() over (order by tek_recipient_date desc) as rownumber from tmp  
                ) a
                where rownumber > @PageSize * (@Page - 1)
            ";

            var parameters = new SqlParameter[]
            {
                new SqlParameter("PageSize", query.PageSize),
                new SqlParameter("Page", query.Page),
            };

            try
            {
                return(AdoSupport.GetEntityList <tek_repair>(System.Data.CommandType.Text, SQL, sqlConnectionString, parameters));
            }
            catch (Exception ex)
            {
                throw new DaoException(SQL, "取得維修單列表時發生錯誤", ex);
            }
        }
Example #2
0
        /// <summary>
        /// 取得留言列表
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public List <tek_onsitenote> GetOnSiteNoteList(QueryList query)
        {
            string SQL = @"
                select top (@PageSize) * 
                from (
                    select *,row_number() over (order by id desc) as rownumber from Onsitenote_Staging
                ) a
                where rownumber > @PageSize * (@Page - 1)
            ";

            //看最後一筆,排除 5
            SQL = @"
                with tmp as (
	                select * from (
		                select row_number() over (partition by tek_repair_no,mstatus order by createdon desc) as con,* from (
			                select (select top 1 tek_m_status from Mobiletime_Staging where tek_repair_tek_mobiletime = a.tek_repair_no order by id desc) as mstatus,b.tek_m_status,a.* 
			                from Onsitenote_Staging a left outer join Mobiletime_Staging b on a.tek_repair_no = tek_repair_tek_mobiletime
		                ) as x where isnull(mstatus,'') <> '5'
	                ) as y where con = 1
                )
                select top (@PageSize) * 
                from (
                    select *,row_number() over (order by createdon desc) as rownumber from tmp  
                ) a
                where rownumber > @PageSize * (@Page - 1)
            ";
            //只要有 5 就排除
            SQL = @"
               with tmp as (
                    select a.*,b.tek_m_status,
                    (select count(*) from Mobiletime_Staging c where c.tek_repair_tek_mobiletime = a.tek_repair_no and tek_m_status = '5') as has5,
                    row_number() over (partition by tek_repair_no,tek_m_status order by createdon desc) as con from Onsitenote_Staging a left outer join Mobiletime_Staging b on a.tek_repair_no = tek_repair_tek_mobiletime where isnull(tek_m_status,'') <> '5'
                )
                select top (@PageSize) * 
                from (
                    select *,row_number() over (order by createdon desc) as rownumber from tmp where con = 1 and has5 = 0 
                ) a
                where rownumber > @PageSize * (@Page - 1)
            ";
            var parameters = new SqlParameter[]
            {
                new SqlParameter("PageSize", query.PageSize),
                new SqlParameter("Page", query.Page),
            };

            try
            {
                return(AdoSupport.GetEntityList <tek_onsitenote>(System.Data.CommandType.Text, SQL, sqlConnectionString, parameters));
            }
            catch (Exception ex)
            {
                throw new DaoException(SQL, "取得留言列表時發生錯誤", ex);
            }
        }
Example #3
0
        /// <summary>
        /// CRM留言
        /// </summary>
        /// <param name="tek_repair_no"></param>
        /// <returns></returns>
        public List <tek_onsitenote> GetOnSiteNoteList(string tek_repair_no)
        {
            string SQL = @"
                select * from Onsitenote_Staging where tek_repair_no = @id order by id desc
            ";

            //排除狀態 5
            SQL = @"
                with tmp as (
	                select * from (
		                select row_number() over (partition by tek_repair_no,mstatus order by createdon desc) as con,* from (
			                select (select top 1 tek_m_status from Mobiletime_Staging where tek_repair_tek_mobiletime = a.tek_repair_no order by id desc) as mstatus,b.tek_m_status,a.* 
			                from Onsitenote_Staging a left outer join Mobiletime_Staging b on a.tek_repair_no = tek_repair_tek_mobiletime
		                ) as x where isnull(mstatus,'') <> '5'
	                ) as y where con = 1
                )
                select * from tmp where tek_repair_no = @id order by id desc            
            ";
            //只要有狀態5就排除
            SQL = @"
               with tmp as (
                    select a.*,b.tek_m_status,
                    (select count(*) from Mobiletime_Staging c where c.tek_repair_tek_mobiletime = a.tek_repair_no and tek_m_status = '5') as has5,
                    row_number() over (partition by tek_repair_no,tek_m_status order by createdon desc) as con from Onsitenote_Staging a left outer join Mobiletime_Staging b on a.tek_repair_no = tek_repair_tek_mobiletime where isnull(tek_m_status,'') <> '5'
                )
                select * from tmp where con = 1 and has5 = 0 and tek_repair_no = @id order by id desc   
            ";
            var parameters = new SqlParameter[]
            {
                new SqlParameter("id", tek_repair_no),
            };

            try
            {
                return(AdoSupport.GetEntityList <tek_onsitenote>(System.Data.CommandType.Text, SQL, sqlConnectionString, parameters));
            }
            catch (Exception ex)
            {
                throw new DaoException(SQL, "依維修單號取得留言時發生錯誤", ex);
            }
        }