Пример #1
0
        public override List <LogAdQcodeVO> GetModels(ref LogAdQcodePara mp)
        {
            string where = GetConditionByPara(mp);

            int    pStart = mp.PageIndex.Value * mp.PageSize.Value;
            int    pEnd   = mp.PageSize.Value;
            string cmd    = QUERYPAGE
                            .Replace("@PAGESIZE", pEnd.ToString())
                            .Replace("@PTOP", pStart.ToString())
                            .Replace("@WHERE", where)
                            .Replace("@ORDER", GetOrderByPara(mp));

            CodeCommand command = new CodeCommand();

            command.CommandText = cmd;

            var table = DbProxyFactory.Instance.Proxy.ExecuteTable(command);

            List <LogAdQcodeVO> list = new List <LogAdQcodeVO>();

            for (int i = 0; i < table.Rows.Count; i++)
            {
                list.Add(new LogAdQcodeVO(table.Rows[i]));
            }

            if (!mp.Recount.HasValue)
            {
                mp.Recount = GetRecords(mp);
            }

            return(list);
        }
Пример #2
0
        public override string GetOrderByPara(LogAdQcodePara mp)
        {
            if (!string.IsNullOrEmpty(mp.OrderBy))
            {
                return(string.Format(" order by {0}", mp.OrderBy));
            }

            return("");
        }
Пример #3
0
        public override LogAdQcodeVO GetSingle(LogAdQcodePara mp)
        {
            var list = GetModels(mp);

            if (list.Count == 1)
            {
                return(list[0]);
            }

            return(null);
        }
Пример #4
0
        public override int GetRecords(LogAdQcodePara mp)
        {
            string where = GetConditionByPara(mp);

            CodeCommand command = new CodeCommand();

            command.CommandText = QUERYCOUNT + where;

            var result = DbProxyFactory.Instance.Proxy.ExecuteScalar(command);

            return(int.Parse(result.ToString()));
        }
Пример #5
0
        public override bool Delete(LogAdQcodePara mp)
        {
            string where = GetConditionByPara(mp);

            CodeCommand command = new CodeCommand();

            command.CommandText = DELETE + where;

            int result = DbProxyFactory.Instance.Proxy.ExecuteNonQuery(command);

            if (result >= 1)
            {
                return(true);
            }

            return(false);
        }
Пример #6
0
        private void Bind(int pageIndex = 1)
        {
            LogAdQcodePara cip = new LogAdQcodePara();

            cip.PageIndex = pageIndex - 1;
            cip.PageSize  = 10;
            cip.Time      = int.Parse(DateTime.Now.ToString("yyyyMMdd"));
            cip.OrderBy   = " id desc ";
            if (!string.IsNullOrEmpty(ddlAdPage.SelectedValue))
            {
                cip.AdId = int.Parse(ddlAdPage.SelectedValue);
            }

            var list = LogAdQcodeBLL.Instance.GetModels(ref cip);

            rptTable.DataSource = list;
            rptTable.DataBind();

            apPager.RecordCount = cip.Recount.Value;
        }
Пример #7
0
        public override List <LogAdQcodeVO> GetModels(LogAdQcodePara mp)
        {
            string where = GetConditionByPara(mp);

            CodeCommand command = new CodeCommand();

            string cmd = LOAD
                         .Replace("@WHERE", where)
                         .Replace("@ORDER", GetOrderByPara(mp));

            command.CommandText = cmd;

            var table = DbProxyFactory.Instance.Proxy.ExecuteTable(command);

            List <LogAdQcodeVO> list = new List <LogAdQcodeVO>();

            for (int i = 0; i < table.Rows.Count; i++)
            {
                list.Add(new LogAdQcodeVO(table.Rows[i]));
            }

            return(list);
        }
Пример #8
0
 public override string GetOtherConditionByPara(LogAdQcodePara mp)
 {
     return("");
 }
Пример #9
0
        public override string GetConditionByPara(LogAdQcodePara mp)
        {
            StringBuilder sb = new StringBuilder();

            if (mp.Id.HasValue)
            {
                sb.AppendFormat(" AND [Id]='{0}' ", mp.Id);
            }
            if (mp.AdId.HasValue)
            {
                sb.AppendFormat(" AND [AdId]='{0}' ", mp.AdId);
            }
            if (mp.AdUserId.HasValue)
            {
                sb.AppendFormat(" AND [AdUserId]='{0}' ", mp.AdUserId);
            }
            if (mp.QcodeId.HasValue)
            {
                sb.AppendFormat(" AND [QcodeId]='{0}' ", mp.QcodeId);
            }
            if (!string.IsNullOrEmpty(SqlFilterHelper.CheckPropertyName(mp.Url)))
            {
                sb.AppendFormat(" AND [Url]='{0}' ", mp.Url);
            }
            if (!string.IsNullOrEmpty(SqlFilterHelper.CheckPropertyName(mp.ClientIp)))
            {
                sb.AppendFormat(" AND [ClientIp]='{0}' ", mp.ClientIp);
            }
            if (!string.IsNullOrEmpty(SqlFilterHelper.CheckPropertyName(mp.BrowseType)))
            {
                sb.AppendFormat(" AND [BrowseType]='{0}' ", mp.BrowseType);
            }
            if (mp.CreateDate.HasValue)
            {
                sb.AppendFormat(" AND [CreateDate]='{0}' ", mp.CreateDate);
            }
            if (mp.Time.HasValue)
            {
                sb.AppendFormat(" AND [Time]='{0}' ", mp.Time);
            }
            if (!string.IsNullOrEmpty(SqlFilterHelper.CheckPropertyName(mp.ClientId)))
            {
                sb.AppendFormat(" AND [ClientId]='{0}' ", mp.ClientId);
            }
            if (mp.IsMobile.HasValue)
            {
                sb.AppendFormat(" AND [IsMobile]='{0}' ", mp.IsMobile);
            }
            if (!string.IsNullOrEmpty(SqlFilterHelper.CheckPropertyName(mp.ReferrerUrl)))
            {
                sb.AppendFormat(" AND [ReferrerUrl]='{0}' ", mp.ReferrerUrl);
            }
            if (!string.IsNullOrEmpty(SqlFilterHelper.CheckPropertyName(mp.BrowseName)))
            {
                sb.AppendFormat(" AND [BrowseName]='{0}' ", mp.BrowseName);
            }
            if (!string.IsNullOrEmpty(SqlFilterHelper.CheckPropertyName(mp.BrowseVersion)))
            {
                sb.AppendFormat(" AND [BrowseVersion]='{0}' ", mp.BrowseVersion);
            }
            if (!string.IsNullOrEmpty(SqlFilterHelper.CheckPropertyName(mp.OsName)))
            {
                sb.AppendFormat(" AND [OsName]='{0}' ", mp.OsName);
            }


            sb.Insert(0, " WHERE 1=1 ");

            return(sb.ToString());
        }