Ejemplo n.º 1
0
        public List <IdentityWarehouse> GetByPage(IdentityWarehouse filter, int currentPage, int pageSize)
        {
            //Common syntax
            var sqlCmd = @"Warehouse_GetByPage";
            List <IdentityWarehouse> listData = null;

            //For paging
            int offset = (currentPage - 1) * pageSize;

            //For parameters
            var parameters = new Dictionary <string, object>
            {
                { "@ProductCode", filter.ProductCode },
                { "@Keyword", filter.Keyword },
                { "@IsStockOut", filter.IsStockOut },
                { "@IsStockTakeQTY", filter.IsStockTakeQTY },
                { "@Offset", offset },
                { "@PageSize", pageSize },
            };

            try
            {
                using (var conn = new SqlConnection(_connectionString))
                {
                    using (var reader = MsSqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, sqlCmd, parameters))
                    {
                        listData = ParsingListWarehouseFromReader(reader);

                        if (listData.Count > 0)
                        {
                            if (reader.NextResult())
                            {
                                while (reader.Read())
                                {
                                    var productInfo = RpsProduct.ExtractProductData(reader);
                                    foreach (var item in listData)
                                    {
                                        if (productInfo.Id == item.ProductId)
                                        {
                                            item.ProductInfo = productInfo;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                var strError = "Failed to execute Warehouse_GetByPage. Error: " + ex.Message;
                throw new CustomSQLException(strError);
            }

            return(listData);
        }
Ejemplo n.º 2
0
        public List <IdentityWarehouseActivity> GetHistoryByPage(IdentityWarehouseActivity filter, int currentPage, int pageSize)
        {
            //Common syntax
            var sqlCmd = @"Warehouse_Activity_GetByPage";
            List <IdentityWarehouseActivity> listData = null;

            //For paging
            int offset = (currentPage - 1) * pageSize;

            //For parameters
            var parameters = new Dictionary <string, object>
            {
                { "@ProductId", filter.ProductId },
                { "@StaffId", filter.StaffId },
                { "@Keyword", filter.Keyword },
                { "@ActivityType", filter.ActivityType },
                { "@DeviceId", filter.DeviceId },
                { "@FromDate", filter.FromDate },
                { "@ToDate", filter.ToDate },
                { "@Offset", offset },
                { "@PageSize", pageSize }
            };

            try
            {
                using (var conn = new SqlConnection(_connectionString))
                {
                    using (var reader = MsSqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, sqlCmd, parameters))
                    {
                        listData = new List <IdentityWarehouseActivity>();
                        while (reader.Read())
                        {
                            var item = ExtractWarehouseActivityData(reader);
                            listData.Add(item);
                        }

                        if (listData.Count > 0)
                        {
                            if (reader.NextResult())
                            {
                                while (reader.Read())
                                {
                                    var productInfo = RpsProduct.ExtractProductData(reader);
                                    foreach (var item in listData)
                                    {
                                        if (productInfo.Id == item.ProductId)
                                        {
                                            item.ProductInfo = productInfo;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                var strError = "Failed to execute Warehouse_Activity_GetByPage. Error: " + ex.Message;
                throw new CustomSQLException(strError);
            }

            return(listData);
        }