예제 #1
0
        public IEnumerable <AreaListView> Query(AreaQueryConditon condition)
        {
            var           result   = new List <AreaListView>();
            string        sql      = "SELECT [Id],[Name],[Remark] FROM [dbo].[T_SellArea]";
            StringBuilder strWhere = new StringBuilder();

            using (var dbOperator = new DbOperator(Provider, ConnectionString)) {
                if (!string.IsNullOrWhiteSpace(condition.Name))
                {
                    strWhere.Append(" WHERE [Name]=@Name");
                    dbOperator.AddParameter("Name", condition.Name);
                }
                if (strWhere.Length > 0)
                {
                    sql += strWhere;
                }
                using (var reader = dbOperator.ExecuteReader(sql)) {
                    while (reader.Read())
                    {
                        var view = new AreaListView();
                        view.Id     = reader.GetGuid(0);
                        view.Name   = reader.GetString(1);
                        view.Remark = reader.IsDBNull(2) ? string.Empty : reader.GetString(2);
                        result.Add(view);
                    }
                }
            }
            return(result);
        }
예제 #2
0
        private AreaQueryConditon getCondition()
        {
            var condition = new AreaQueryConditon()
            {
                Name = this.txtAreaName.Text
            };

            return(condition);
        }
예제 #3
0
        private void initData()
        {
            AreaQueryConditon condition = new AreaQueryConditon();

            this.dropArea.DataSource     = AreaService.Query(condition);
            this.dropArea.DataTextField  = "Name";
            this.dropArea.DataValueField = "Name";
            this.dropArea.DataBind();
        }
예제 #4
0
        public IEnumerable <AreaListView> Query(AreaQueryConditon condition, Pagination pagination)
        {
            var result       = new List <AreaListView>();
            var fields       = "[Id],[Name],[Remark]";
            var catelog      = "[dbo].[T_SellArea]";
            var orderbyFiled = "[Id]";

            var where = new StringBuilder();
            using (var dbOperator = new DbOperator(Provider, ConnectionString))
            {
                if (!string.IsNullOrWhiteSpace(condition.Name))
                {
                    where.AppendFormat("Name = '{0}'", condition.Name.Trim());
                }
                dbOperator.AddParameter("@iField", fields);
                dbOperator.AddParameter("@iCatelog", catelog);
                dbOperator.AddParameter("@iCondition", where.ToString());
                dbOperator.AddParameter("@iOrderBy", orderbyFiled);
                dbOperator.AddParameter("@iPagesize", pagination.PageSize);
                dbOperator.AddParameter("@iPageIndex", pagination.PageIndex);
                dbOperator.AddParameter("@iGetCount", pagination.GetRowCount);
                var totalCount = dbOperator.AddParameter("@oTotalCount");
                totalCount.DbType    = System.Data.DbType.Int32;
                totalCount.Direction = System.Data.ParameterDirection.Output;
                using (var reader = dbOperator.ExecuteReader("dbo.P_Pagination", System.Data.CommandType.StoredProcedure))
                {
                    while (reader.Read())
                    {
                        result.Add(new AreaListView()
                        {
                            Id     = reader.GetGuid(0),
                            Name   = reader.GetString(1),
                            Remark = reader.IsDBNull(2) ? string.Empty : reader.GetString(2)
                        });
                    }
                }
                if (pagination.GetRowCount)
                {
                    pagination.RowCount = (int)totalCount.Value;
                }
            }
            return(result);
        }
예제 #5
0
        /// <summary>
        /// 查询销售区域列表(分页)
        /// </summary>
        /// <param name="condition">区域查询条件</param>
        /// <returns>销售区域列表</returns>
        public static IEnumerable <AreaListView> Query(AreaQueryConditon condition, Pagination pagination)
        {
            var repository = Factory.CreateAreaRepository();

            return(repository.Query(condition, pagination));
        }