Exemple #1
0
        /// <summary>
        /// 依照編號取得維修資料
        /// </summary>
        /// <param name="tek_repair_no"></param>
        /// <returns></returns>
        public tek_repair GetRepairById(string tek_name)
        {
            //with tmp as (
            //    select a.*,b.tek_m_status,
            //        (select count(*) from Mobiletime_Staging c where c.tek_repair_tek_mobiletime = a.tek_name and tek_m_status = '5') as has5,
            //        row_number() over(partition by tek_name, tek_m_status order by tek_recipient_date desc) as con from Repair_Staging a left outer join Mobiletime_Staging b on a.tek_name = tek_repair_tek_mobiletime where isnull(tek_m_status,'') <> '5'
            //    )
            //    select top 1 * from tmp where tek_name = @tek_name and con = 1 and has5 = 0

            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 1 * from tmp where tek_name = @tek_name
            ";
            var    parameters = new SqlParameter[]
            {
                new SqlParameter("tek_name", tek_name),
            };

            try
            {
                return(AdoSupport.GetEntity <tek_repair>(System.Data.CommandType.Text, SQL, sqlConnectionString, parameters));
            }
            catch (Exception ex)
            {
                throw new DaoException(SQL, "依照編號取得維修資料時發生錯誤", ex);
            }
        }
Exemple #2
0
        /// <summary>
        /// 取得 user token
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public string GetToken(string user)
        {
            string SQL        = @"
                select * from MToken_Staging where tek_m_user = @user
            ";
            var    parameters = new SqlParameter[]
            {
                new SqlParameter("user", user),
            };

            try
            {
                MToken_Staging obj = AdoSupport.GetEntity <MToken_Staging>(System.Data.CommandType.Text, SQL, sqlConnectionString, parameters);
                if (obj == null)
                {
                    return("");
                }
                else
                {
                    return(obj.tek_m_user_token);
                }
            }
            catch (Exception ex)
            {
                throw new DaoException(SQL, "取得 user token時發生錯誤", ex);
            }
        }
Exemple #3
0
        /// <summary>
        /// CRM留言
        /// </summary>
        /// <param name="tek_repair_no"></param>
        /// <returns></returns>
        public tek_onsitenote GetOnSiteNote(string tek_repair_no)
        {
            string 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 1 * from tmp where tek_repair_no = @id 
            ";
            var    parameters = new SqlParameter[]
            {
                new SqlParameter("id", tek_repair_no),
            };

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