Beispiel #1
0
        public override List <UserCodeInfoVO> GetModels(ref UserCodeInfoPara 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 <UserCodeInfoVO> list = new List <UserCodeInfoVO>();

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

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

            return(list);
        }
Beispiel #2
0
        public override string GetConditionByPara(UserCodeInfoPara mp)
        {
            StringBuilder sb = new StringBuilder();

            if (mp.Id.HasValue)
            {
                sb.AppendFormat(" AND [Id]='{0}' ", mp.Id);
            }
            if (!string.IsNullOrEmpty(SqlFilterHelper.CheckPropertyName(mp.Name)))
            {
                sb.AppendFormat(" AND [Name]='{0}' ", mp.Name);
            }
            if (mp.UserId.HasValue)
            {
                sb.AppendFormat(" AND [UserId]='{0}' ", mp.UserId);
            }
            if (mp.TypeId.HasValue)
            {
                sb.AppendFormat(" AND [TypeId]='{0}' ", mp.TypeId);
            }
            if (!string.IsNullOrEmpty(SqlFilterHelper.CheckPropertyName(mp.CodeContent)))
            {
                sb.AppendFormat(" AND [CodeContent]='{0}' ", mp.CodeContent);
            }
            if (mp.CreateDate.HasValue)
            {
                sb.AppendFormat(" AND [CreateDate]='{0}' ", mp.CreateDate);
            }


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

            return(sb.ToString());
        }
Beispiel #3
0
        public override string GetOrderByPara(UserCodeInfoPara mp)
        {
            if (!string.IsNullOrEmpty(mp.OrderBy))
            {
                return(string.Format(" order by {0}", mp.OrderBy));
            }

            return("");
        }
Beispiel #4
0
        public override UserCodeInfoVO GetSingle(UserCodeInfoPara mp)
        {
            var list = GetModels(mp);

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

            return(null);
        }
Beispiel #5
0
        public override int GetRecords(UserCodeInfoPara 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()));
        }
Beispiel #6
0
        public override bool Delete(UserCodeInfoPara 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);
        }
Beispiel #7
0
        private void Bind(int pageIndex = 1)
        {
            UserCodeInfoPara cip = new UserCodeInfoPara();

            cip.PageIndex = pageIndex - 1;
            cip.PageSize  = 10;
            cip.UserId    = Account.UserId;
            if (!string.IsNullOrEmpty(ddlAdType.SelectedValue))
            {
                cip.TypeId = int.Parse(ddlAdType.SelectedValue);
            }
            cip.OrderBy = " id desc ";

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

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

            apPager.RecordCount = cip.Recount.Value;
        }
Beispiel #8
0
        public override List <UserCodeInfoVO> GetModels(UserCodeInfoPara 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 <UserCodeInfoVO> list = new List <UserCodeInfoVO>();

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

            return(list);
        }
Beispiel #9
0
 public override string GetOtherConditionByPara(UserCodeInfoPara mp)
 {
     return("");
 }