/// <summary>
        /// Retrieves list of UserBranch objects from SqlCommand, after database query
        /// number of rows retrieved and returned depends upon the rows field value
        /// </summary>
        /// <param name="cmd">The command object to use for query</param>
        /// <param name="rows">Number of rows to process</param>
        /// <returns>A list of UserBranch objects</returns>
        private UserBranchList GetList(SqlCommand cmd, long rows)
        {
            // Select multiple records
            SqlDataReader reader;
            long          result = SelectRecords(cmd, out reader);

            //UserBranch list
            UserBranchList list = new UserBranchList();

            using ( reader )
            {
                // Read rows until end of result or number of rows specified is reached
                while (reader.Read() && rows-- != 0)
                {
                    UserBranch userBranchObject = new UserBranch();
                    FillObject(userBranchObject, reader);

                    list.Add(userBranchObject);
                }

                // Close the reader in order to receive output parameters
                // Output parameters are not available until reader is closed.
                reader.Close();
            }

            return(list);
        }
        /// <summary>
        /// Retrieves all UserBranch objects by PageRequest
        /// </summary>
        /// <returns>A list of UserBranch objects</returns>
        public UserBranchList GetPaged(PagedRequest request)
        {
            using (SqlCommand cmd = GetSPCommand(GETPAGEDUSERBRANCH))
            {
                AddParameter(cmd, pInt32Out("TotalRows"));
                AddParameter(cmd, pInt32("PageIndex", request.PageIndex));
                AddParameter(cmd, pInt32("RowPerPage", request.RowPerPage));
                AddParameter(cmd, pNVarChar("WhereClause", 4000, request.WhereClause));
                AddParameter(cmd, pNVarChar("SortColumn", 128, request.SortColumn));
                AddParameter(cmd, pNVarChar("SortOrder", 4, request.SortOrder));

                UserBranchList _UserBranchList = GetList(cmd, ALL_AVAILABLE_RECORDS);
                request.TotalRows = Convert.ToInt32(GetOutParameter(cmd, "TotalRows"));
                return(_UserBranchList);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Retrieve list of UserBranch.
        /// </summary>
        /// <param name="fillChild"></param>
        /// <returns>List of UserBranch</returns>
        public UserBranchList GetAll(bool fillChild)
        {
            UserBranchList userBranchList = new UserBranchList();

            using (UserBranchDataAccess data = new UserBranchDataAccess(ClientContext))
            {
                userBranchList = data.GetAll();
            }
            if (fillChild)
            {
                foreach (UserBranch userBranchObject in userBranchList)
                {
                    FillUserBranchWithChilds(userBranchObject, fillChild);
                }
            }
            return(userBranchList);
        }