//1st Overload of GetPriceRangeForProperty public static PriceRange GetPriceRangeForProperty(long aPropertyID) { PortugalVillasContext _db = new PortugalVillasContext(); long propertyid = aPropertyID; var thePricingMax = _db.PropertyPricingSeasonalInstances .Where(x => x.PropertyID == propertyid) .Select(x => x.Price).Max(); var thePricingMin = _db.PropertyPricingSeasonalInstances .Where(x => x.PropertyID == propertyid) .Select(x => x.Price).Min(); PriceRange thePriceRange = new PriceRange() { //it is weekly pricing MinPrice = (thePricingMin), MaxPrice = (thePricingMax), PropertyID = propertyid }; return(thePriceRange); }
public void Test_DiffToLowerShadow() { var priceRange1 = new PriceRange { Low = 0, Open = 1, Close = 2 }; var priceRange2 = new PriceRange { Low = 0, Open = 2, Close = 1 }; var priceRange3 = new PriceRange { Low = 1, Open = 1, Close = 2 }; var priceRange4 = new PriceRange { Low = 1, Open = 2, Close = 1 }; Assert.Equal(1, priceRange1.DiffToLowerShadow); Assert.Equal(1, priceRange2.DiffToLowerShadow); Assert.Equal(0, priceRange3.DiffToLowerShadow); Assert.Equal(0, priceRange4.DiffToLowerShadow); }
public PutItemResponse(PriceRange priceRange, Item item) { IdPriceRange = priceRange.Id; IdItem = item.Id; Name = item.Name; }
protected void rptrPriceRange_ItemDataBound(object sender, DataListItemEventArgs e) { if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item) { PriceRange priceRange = e.Item.DataItem as PriceRange; HyperLink hlPriceRange = e.Item.FindControl("hlPriceRange") as HyperLink; hlPriceRange.Text = getPriceRangeString(priceRange.From, priceRange.To).Replace("000<", "тыс<"); string fromQuery = string.Empty; if (priceRange.From.HasValue) { fromQuery = priceRange.From.Value.ToString(new CultureInfo("en-US")); } string toQuery = string.Empty; if (priceRange.To.HasValue) { toQuery = priceRange.To.Value.ToString(new CultureInfo("en-US")); } string url = CommonHelper.ModifyQueryString(CommonHelper.GetThisPageURL(true), QueryStringProperty + "=" + fromQuery + "-" + toQuery, null); url = excludeQueryStringParams(url); hlPriceRange.NavigateUrl = url; } }
public bool UpdatePriceRange(string priceRangeReference, PriceRange priceRange) { Check.If(priceRangeReference).IsNotNullOrEmpty(); Check.If(priceRange).IsNotNull(); return _priceRangeRepository.UpdatePriceRange(priceRangeReference, priceRange); }
private PriceRange GetRandomPriceRange() { var ran = new Random(); var value = Enum.GetValues(typeof(PriceRange)); PriceRange randomPriceRange = (PriceRange)value.GetValue(ran.Next(0, value.Length)); return(randomPriceRange); }
/// <summary> /// Get cars in provided price range. /// </summary> /// <param name="range">The price range where price of the car should land.</param> /// <returns>A enumerable of cars in provided price range or empty enumerable.</returns> public IEnumerable <Car> GetCarsInPriceRange(PriceRange range) { var query = document.Elements() .Where(x => Convert.ToDouble(x.Element("price").Value) >= range.MinPrice) .Where(x => Convert.ToDouble(x.Element("price").Value) <= range.MaxPrice); return(Read(query).ToArray()); }
private void CandleTypesSelectionChanged(object sender, SelectionChangedEventArgs e) { var type = CandleType.GetSelectedValue <CandleTypes>().Value; TimeFrame.SetVisibility(type == CandleTypes.TimeFrame); PriceRange.SetVisibility(type == CandleTypes.Range); VolumeCtrl.SetVisibility(type == CandleTypes.Tick || type == CandleTypes.Volume); }
// // GET: /Trade/ public ActionResult List(ItemType category, ItemSort sort, SexType sex, PriceRange range, int age) { ViewBag.ItemType = category; ViewBag.ItemSort = sort; ViewBag.SexType = sex; ViewBag.Age = age; ViewBag.PriceRange = range; return(View("~/Views/Trade/Index.cshtml", GetGoods(0, 20, category, sort, range, sex, age).Data)); }
public InventoryItem(Resource resource, ActionType actionType, PriceRange priceRange, float max, float ideal, float amount = 0) { Resource = resource; Action = actionType; PriceRange = priceRange; Max = max; Ideal = ideal; Amount = amount; }
public OfferRecord(int round, PriceRange priceRange, PriceAmountPair offer, bool offerAccepted) { Round = round; Max = priceRange.Max; Min = priceRange.Min; Amount = offer.Amount; Price = offer.Price; Success = offerAccepted; }
public bool CreatePriceRange(PriceRange priceRange) { if (priceRange.PriceRangeReference.IsNullOrEmpty()) return false; _propertyMatrixContext.PriceRanges.Add(priceRange); return _propertyMatrixContext.SaveChanges() > 0; }
public void AddResource(Resource resource, InventoryItem.ActionType action, float max, float ideal, float amount = 0) { float priceMin = (float)Math.Floor(resource.BasePrice); float priceMax = (float)Math.Ceiling(resource.BasePrice + resource.BasePrice * 0.75f); PriceRange priceRange = new PriceRange(priceMin, priceMax); InventoryItem row = new InventoryItem(resource, action, priceRange, max, ideal, amount); Inventory.Add(resource.Type, row); }
private void AddResource(Resource resource) { float maxResource = Population; //maybe max amount of inventory is dictated by storehouses float idealResource = RequiredResourceAmount(); float min = (float)Math.Round(ResourceUtil.GetResourceByType(resource.Type).BasePrice / 2); float max = (float)Math.Round(ResourceUtil.GetResourceByType(resource.Type).BasePrice * 2); PriceRange priceRange = new PriceRange(min, max); Inventory.Add(resource.Type, new InventoryItem(resource, InventoryItem.ActionType.buy, priceRange, maxResource, idealResource)); }
public FilerPopupPage(ProductList productList, List <Category> selectedCategories, PriceRange maxPriceRange, PriceRange selectedPriceRange) { BackgroundColor = Color.FromHex("#CC000000"); this.maxPriceRange = maxPriceRange; this.selectedpriceRange = selectedPriceRange; this.selectedCategories = selectedCategories; this.productList = productList; InitializeComponent(); Load(); }
public IHttpActionResult GetPriceRange(int id) { PriceRange priceRange = db.PriceRanges.Find(id); if (priceRange == null) { return(NotFound()); } return(Ok(priceRange)); }
///////////////////////////// //// INSTANCE METHODS ///////////////////////////// //this intialised the pricerange fr the property public void CreatePriceRange() { PortugalVillasContext _db = new PortugalVillasContext(); var checkForPricings = _db.PropertyPricingSeasonalInstances .Where(x => x.PropertyID == PropertyID) .ToList(); if (checkForPricings.Count > 1) { this.PriceRange = GetPriceRangeForProperty(this.PropertyID); } }
public string Create(PriceRange priceRange) { Check.If(priceRange).IsNotNull(); if (priceRange.PriceRangeReference.IsNullOrEmpty()) { return null; } var result = _priceRangeRepository.CreatePriceRange(priceRange.CreateReference(_referenceGenerator)); return result ? priceRange.PriceRangeReference : null; }
private bool ProductIsInRange(Product product, PriceRange priceRange) { switch (priceRange) { case PriceRange.Under100: return product.Price < 100M; case PriceRange.From100To500: return product.Price >= 100M && product.Price <= 500M; case PriceRange.Above500: return product.Price > 500M; default: return true; } }
public AskerActor(string tickerSymbol, ITradeEventSubscriptionManager subscriptionManager, IActorRef tradeGateway, PriceRange targetRange, ITradeOrderIdGenerator tradeOrderIdGenerator, ITimestamper timestampGenerator) { _tickerSymbol = tickerSymbol; _subscriptionManager = subscriptionManager; _tradeGateway = tradeGateway; _targetRange = targetRange; _tradeOrderIdGenerator = tradeOrderIdGenerator; _timestampGenerator = timestampGenerator; _traderId = $"{_tickerSymbol}-{_tradeOrderIdGenerator.NextId()}"; Self.Tell(DoSubscribe.Instance); Subscribing(); }
/// <summary> /// Obtains the current control values and returns a SearchCriteria object. /// Note: does not validate the controls; perform validation before calling. /// </summary> /// <returns></returns> private SearchCriteria GetSearchCriteria() { DoubleRange priceRange = PriceRange.GetValues(); double minReviewCount = Convert.ToDouble(txtMinNumberOfReviews.Text); return(new SearchCriteria(txtSearch.Text, Convert.ToDouble(txtNumberOfResults.Text), priceRange, ScoreDistribution.Distribution, minReviewCount, (bool)chkMatchAll.IsChecked, Constants.USE_STRICT_PRIME_ELIGIBILITY)); }
public IHttpActionResult DeletePriceRange(int id) { PriceRange priceRange = db.PriceRanges.Find(id); if (priceRange == null) { return(NotFound()); } db.PriceRanges.Remove(priceRange); db.SaveChanges(); return(Ok(priceRange)); }
public static CandleStickShape GetCandleStickShape(PriceRange priceRange) { if (priceRange.OpenCloseDiff >= _LargeBody) { return(GetLongBodyCandleStickShape(priceRange)); } if (priceRange.OpenCloseDiff <= _TinyBody) { return(GetTinyBodyCandleStickShape(priceRange)); } return(GetShortBodyCandleStickShape(priceRange)); }
static int Main(string[] args) { var config = File.ReadAllText("app.conf"); var conf = ConfigurationFactory.ParseString(config).BoostrapApplication(new AppBootstrapConfig(false, true)); var actorSystem = ActorSystem.Create("AkkaTrader", conf); var tradeRouter = actorSystem.ActorOf( Props.Empty.WithRouter(new ClusterRouterGroup( new ConsistentHashingGroup(new[] { "/user/orderbooks" }, TradeEventConsistentHashMapping.TradeEventMapping), new ClusterRouterGroupSettings(10000, new [] { "/user/orderbooks" }, true, useRole: "trade-processor"))), "tradesRouter"); Cluster.Cluster.Get(actorSystem).RegisterOnMemberUp(() => { var sharding = ClusterSharding.Get(actorSystem); var shardRegionProxy = sharding.StartProxy("orderBook", "trade-processor", new StockShardMsgRouter()); foreach (var stock in AvailableTickerSymbols.Symbols) { var max = (decimal)ThreadLocalRandom.Current.Next(20, 45); var min = (decimal)ThreadLocalRandom.Current.Next(10, 15); var range = new PriceRange(min, 0.0m, max); // start bidders foreach (var i in Enumerable.Repeat(1, ThreadLocalRandom.Current.Next(1, 6))) { actorSystem.ActorOf(Props.Create(() => new BidderActor(stock, range, shardRegionProxy))); } // start askers foreach (var i in Enumerable.Repeat(1, ThreadLocalRandom.Current.Next(1, 6))) { actorSystem.ActorOf(Props.Create(() => new AskerActor(stock, range, shardRegionProxy))); } } }); // start Petabridge.Cmd (for external monitoring / supervision) var pbm = PetabridgeCmd.Get(actorSystem); pbm.RegisterCommandPalette(ClusterCommands.Instance); pbm.RegisterCommandPalette(ClusterShardingCommands.Instance); pbm.RegisterCommandPalette(RemoteCommands.Instance); pbm.Start(); actorSystem.WhenTerminated.Wait(); return(0); }
public static List<ItemPricing> FindPricingsInRange(PriceRange range, List<Quality> qualitiesAllowed, List<ItemSlotPlain> slotsAllowed, bool? craftable = true, bool? halloween = null, bool? botkiller = null) { DealsFilters deals = new DealsFilters() { Qualities = qualitiesAllowed, Slots = slotsAllowed, Craftable = craftable, Halloween = halloween, Botkiller = botkiller, }; return FindPricingsInRange(range, deals); }
public static PriceRange FromPriceRangeDTOToPriceRange(PriceRangeDTO priceRangeDTO) { if (priceRangeDTO == null) { return(null); } var priceRange = new PriceRange { Id = priceRangeDTO.Id, PriceRangeValue = priceRangeDTO.PriceRangeValue }; return(priceRange); }
public static PriceRangeDTO FromPriceRangeToPriceRangeDTO(PriceRange priceRange) { if (priceRange == null) { return(null); } var priceRangeDTO = new PriceRangeDTO { Id = priceRange.Id, PriceRangeValue = priceRange.PriceRangeValue }; return(priceRangeDTO); }
public Village(String name, float population, Resource resource) { Name = name; Population = population; Resource = resource; VillageType = GetVillageType(Resource.Type); float price = (float)Math.Round(Resource.BasePrice / 2); PriceRange priceRange = new PriceRange(price, price); InventoryItem inventory = new InventoryItem(Resource, InventoryItem.ActionType.sell, priceRange, 20, 5, 5); Inventory.Add(Resource.Type, inventory); }
/// <summary> /// Renders the results view. /// </summary> /// <returns>The view.</returns> public ActionResult Results(string suburbId, string minPrice, string maxPrice) { var Id = suburbId.GetDecimalValueOrDefault(); var minimumPrice = minPrice.GetDecimalValueOrDefault(); var maximumPrice = maxPrice.GetDecimalValueOrDefault(); var suburb = new Suburb { Id = (int)Id }; var priceRange = new PriceRange(minimumPrice, maximumPrice); var model = propertyProcessor.FindMatchingPropertiesBy(suburb, priceRange); return(View(model)); }
public void ValuesShouldBeRetrievedCorrectly() { // Arrange decimal originalMinimum = 50; decimal originalMaximum = 200; var range = new PriceRange(originalMinimum, originalMaximum); // Act var expectedMinimum = range.Minimum; var expectedMaximum = range.Maximum; // Assert expectedMinimum.Should().Be(originalMinimum); expectedMaximum.Should().Be(originalMaximum); }
public bool Equals(PriceRange <T> other) { if (other == null) { return(false); } if (!Min.Equals(other.Min)) { return(false); } if (!Max.Equals(other.Max)) { return(false); } return(true); }
static int Main(string[] args) { var config = File.ReadAllText("app.conf"); var conf = ConfigurationFactory.ParseString(config) .WithFallback(OpsConfig.GetOpsConfig()) .WithFallback(ClusterSharding.DefaultConfig()) .WithFallback(DistributedPubSub.DefaultConfig()); var actorSystem = ActorSystem.Create("AkkaTrader", conf.BootstrapFromDocker()); Cluster.Cluster.Get(actorSystem).RegisterOnMemberUp(() => { var sharding = ClusterSharding.Get(actorSystem); var shardRegionProxy = sharding.StartProxy("orderBook", "trade-processor", new StockShardMsgRouter()); foreach (var stock in AvailableTickerSymbols.Symbols) { var max = (decimal)ThreadLocalRandom.Current.Next(20, 45); var min = (decimal)ThreadLocalRandom.Current.Next(10, 15); var range = new PriceRange(min, 0.0m, max); // start bidders foreach (var i in Enumerable.Repeat(1, ThreadLocalRandom.Current.Next(1, 2))) { actorSystem.ActorOf(Props.Create(() => new BidderActor(stock, range, shardRegionProxy))); } // start askers foreach (var i in Enumerable.Repeat(1, ThreadLocalRandom.Current.Next(1, 2))) { actorSystem.ActorOf(Props.Create(() => new AskerActor(stock, range, shardRegionProxy))); } } }); // start Petabridge.Cmd (for external monitoring / supervision) var pbm = PetabridgeCmd.Get(actorSystem); pbm.RegisterCommandPalette(ClusterCommands.Instance); pbm.RegisterCommandPalette(ClusterShardingCommands.Instance); pbm.RegisterCommandPalette(RemoteCommands.Instance); pbm.Start(); actorSystem.WhenTerminated.Wait(); return(0); }
public void Test_UpwardTrend() { var priceRange1 = new PriceRange { Open = 6, Close = 13 }; var priceRange2 = new PriceRange { Open = 13, Close = 6 }; Assert.True(priceRange1.UpwardTrend); Assert.False(priceRange2.UpwardTrend); }
public new void AddResource(Resource resource, InventoryItem.ActionType action, float max, float ideal, float amount = 0) { AddSelfToMarket(resource); float priceMin = (float)Math.Round(resource.BasePrice - resource.BasePrice * 0.5); float priceMax = (float)Math.Round(resource.BasePrice + resource.BasePrice * 0.5); PriceRange priceRange = new PriceRange(priceMin, priceMax); InventoryItem row = new InventoryItem(resource, action, priceRange, max, ideal, amount); if (action == InventoryItem.ActionType.sell) { CommodityProduced = resource; } Inventory.Add(resource.Type, row); }
public ActionResult List(Brand brand = Brand.All, PriceRange priceRange = PriceRange.Any) { var products = new ProductRepository().Products; if (brand != Brand.All) products = products.Where(product => product.Brand == brand); if (priceRange != PriceRange.Any) products = products.Where(product => ProductIsInRange(product, priceRange)); return View(new ProductsListViewModel { Brand = brand, PriceRange = priceRange, Products = products.ToList() }); }
//filters bootcamps when user searches on home page public List<Bootcamp> FilterBootcamps(SearchParams searchParams) { //get all the bootcamps var allBootcamps = _bootcampRepo.GetAllBootcamps(); //create empty list of bootcamps to which the ones which //pass the filter test will be added var filteredBootcamps = new List<Bootcamp>(); //get the price range based on user selection PriceRange priceRange = new PriceRange(); if (searchParams.SelectedPriceRange.HasValue) { priceRange = GetPriceRange(searchParams.SelectedPriceRange.Value); } //loop through each bootcamp and check each user selection against it foreach (FutureCodr.Models.Bootcamp bootcamp in allBootcamps) { //first get all of the bootcamp's location and technology IDs //to compare to the user's selection List<int> bootcampLocationIds = _bootcampLocationsRepo .GetAllBootcampLocationsByBootcampId(bootcamp.BootcampID) .Select(m => m.LocationID).ToList(); List<int> bootcampTechnologyIds = _bootcampTechnologyRepo .GetAllBootcampTechnologiesByBootcampId(bootcamp.BootcampID) .Select(m => m.TechnologyID).ToList(); //then check each bootcamp against price, location and technology if ((!searchParams.SelectedPriceRange.HasValue || ((bootcamp.Price >= priceRange.Min) && (bootcamp.Price <= priceRange.Max))) && (!searchParams.SelectedLocationId.HasValue || !bootcampLocationIds.Contains(searchParams.SelectedLocationId)) && (!searchParams.SelectedTechnologyId.HasValue || !bootcampTechnologyIds.Contains(searchParams.SelectedTechnologyId)) { filteredBootcamps.Add(bootcamp); } } //convert all of the bootcamps that passed the filter into the //correct format and return the list var filteredAndConvertedBootcampList = new List<FutureCodr.UI.Models.Home.Bootcamp>(); foreach (FutureCodr.Models.Bootcamp bootcamp in list2) { filteredAndConvertedBootcampList.Add(ConvertBootcampFormat(bootcamp)); } return filteredAndConvertedBootcampList; }
public string CreateQuote(Search search) { Check.If(search).IsNotNull(); //find a price range var priceRange = _priceRangeRepository.FindMatchingPriceRange(search); //create a zero quote if (priceRange.IsNull()) priceRange = new PriceRange(); //save the search var result = _quoteRepository.CreateSearch( search.CreateReference(_referenceGenerator).CreateQuote(_referenceGenerator, priceRange)); //return the quote reference return result ? search.GetQuoteReference(): null; }
public void RunCommand(CommandHandler sender, List<string> args) { if (args.Count < 2) { VersatileIO.Error("Syntax: " + Syntax); return; } Price min, max; if (!Price.TryParse(args[0], out min)) { VersatileIO.Error("Invalid price: " + args[0]); return; } if (!Price.TryParse(args[1], out max)) { VersatileIO.Error("Invalid price: " + args[1]); } PriceRange range = new PriceRange(min, max); DealsFilters filters = new DealsFilters(); for (int i = 2; i < args.Count; i++) { filters.HandleArg(args[i]); } VersatileIO.Debug("Searching pricings..."); List<ItemPricing> res = GetInRange(range, filters); foreach (ItemPricing p in res) { VersatileIO.WriteComplex(" " + p.Quality.GetColorCode() + p.ToUnpricedString() + "&7 for " + p.GetPriceString()); } VersatileIO.Info("{0} pricings matching filters [{1}].", res.Count, filters.ToString()); }
public ItemPricing(List<Item> items, Quality quality, string currency, double price, double priceHigh, string priceIndex = "0", bool craftable = true, bool tradable = true, bool australium = false) { Items = items; Quality = quality; Craftable = craftable; Tradable = tradable; Australium = australium; // hyphen in middle if (!priceIndex.StartsWith("-") && priceIndex.Contains("-")) { string[] pair = priceIndex.Split('-'); PriceIndex = int.Parse(pair[0]); ChemistrySetQuality = (Quality)int.Parse(pair[1]); } else { PriceIndex = int.Parse(priceIndex); } if (items.Contains(Price.RefinedMetal) && quality == Quality.Unique) { Pricing = new PriceRange(Price.OneRef); } else { Pricing = new PriceRange(new Price(price, currency)); if (priceHigh != 0) { Pricing = Pricing.SetHigh(new Price(priceHigh, currency)); } } }
public void RunCommand(CommandHandler sender, List<string> args) { string steamid = Settings.Instance.HomeSteamID64; bool noWeapons = false; foreach (string s in args) { if (s.EqualsIgnoreCase("/noweapons")) { noWeapons = true; } else if (!s.StartsWith("/")) { steamid = s; } } string name = "#" + steamid; if (steamid == Settings.Instance.HomeSteamID64) { name = "'" + Settings.Instance.SteamPersonaName + "'"; } Backpack bp = GetBackpack(steamid); if (bp == null) { VersatileIO.Error("Could not retrieve backpack."); return; } VersatileIO.Info("Backpack contents of user {0} ({1} slots):", name, bp.SlotCount); PriceRange netWorth = new PriceRange(Price.Zero); Price totalPure = Price.Zero; foreach (ItemInstance item in bp.GetAllItems()) { if (!item.Tradable) { if (!item.Item.IsCheapWeapon() || !noWeapons) { VersatileIO.WriteLine(" " + item + ": Not Tradable", ConsoleColor.DarkGray); } continue; } var checkedPrice = PriceChecker.GetPriceFlagged(item); PriceRange? price = checkedPrice.Result; string priceString = "&cUNKNOWN"; if (price != null) { priceString = "&f" + price.Value; netWorth += price.Value; } #region formatting if (item.Item.IsCheapWeapon() && item.Quality == Quality.Unique && noWeapons) { continue; } if (checkedPrice.Contains("market")) { priceString += " &8[M]"; } string qualityMarker = item.Quality.GetColorCode(); if (item.Item.IsCheapWeapon() && item.Quality == Quality.Unique) { qualityMarker = "&7"; if (price != null) { priceString = qualityMarker + price.Value; } } if (item.Item.IsCurrency()) { qualityMarker = "&f"; priceString = qualityMarker + item.Item.GetCurrencyPrice(); totalPure += item.Item.GetCurrencyPrice(); } #endregion formatting string prefix = " "; if (item.IsNewToBackpack) { prefix += "&a[New] "; } VersatileIO.WriteComplex(prefix + qualityMarker + item + "&7: " + priceString); } VersatileIO.Info("Net worth: " + netWorth); VersatileIO.Info("Total pure: " + totalPure); }
public static List<ItemPricing> FindPricingsInRange(PriceRange range, DealsFilters filters) { List<ItemPricing> results = new List<ItemPricing>(); VersatileIO.Info("Finding valid items in price range..."); foreach (ItemPricing p in DataManager.PriceData.Prices) // get ALL the datas! { if (!range.Contains(p.Pricing)) { continue; } if (!filters.MatchesPricing(p)) { continue; } results.Add(p); } return results; }
public static List<ItemPricing> GetInRange(PriceRange range, DealsFilters filters) { return DataManager.PriceData.Prices.FindAll((p) => filters.MatchesPricing(p) && range.Contains(p.Pricing)); }
public PricedViewModel(ItemPriceInfo info, PriceRange range) { Info = info; Price = range; }
public bool UpdatePriceRange(string priceRangeReference, PriceRange priceRange) { var existingPriceRange = _propertyMatrixContext.PriceRanges.Active() .FirstOrDefault(p => p.PriceRangeReference == priceRangeReference); if (existingPriceRange.IsNull()) return false; var isDirty = _mapper.Map(priceRange, existingPriceRange); return !isDirty || _propertyMatrixContext.SaveChanges() > 0; }
/// <summary> /// �۸�Χ ��ӣ�ɾ������ /// </summary> /// <param name="priceRange"></param> /// <returns></returns> public bool PriceRangeCreateDeleteUpdate(PriceRange priceRange, UserAction ua) { bool result = false; string commandText = string.Empty; switch (ua) { case UserAction.Create: commandText = "INSERT INTO PriceRange (PriceRangeID, PriceRangeName, PriceRangeVisible) VALUES (" + priceRange.ID + ", '" + priceRange.Name + "'," + priceRange.IsVisible + ") "; break; case UserAction.Delete: commandText = "DELETE FROM PriceRange where PriceRangeID=" + priceRange.ID.ToString(); break; case UserAction.Update: commandText = "UPDATE PriceRange SET PriceRangeID = " + priceRange.ID + ", PriceRangeName = '" + priceRange.Name + "', PriceRangeVisible = " + priceRange.IsVisible + " where PriceRangeID ="+priceRange.ID ; break; } using (SqlConnection conn = new SqlConnection(DataHelper2.SqlConnectionString)) { using (SqlCommand comm = new SqlCommand()) { comm.CommandText = commandText; comm.Connection = conn; conn.Open(); try { comm.ExecuteNonQuery(); result = true; } catch (Exception ex) { throw new Exception(ex.Message); } } } return result; }
//�۸�Χ���б�����幦�ܻ�û����ӵ�����ʦ�������������У�������Ʒ�С��ȴ���������� /// <summary> /// ��ü۸�Χ�б� /// </summary> /// <param name="count"></param> /// <returns></returns> public List<PriceRange> GetPriceRanges(int count) { List<PriceRange> list = new List<PriceRange>(); string commText = string.Empty; switch (count) { case 0: commText = "SELECT PriceRange.* FROM PriceRange ORDER BY PriceRangeID DESC"; break; default: commText = "select top " + count.ToString() + " * FROM PriceRange ORDER BY PriceRangeID DESC"; break; } using (SqlConnection conn = new SqlConnection(DataHelper2.SqlConnectionString)) { { using (SqlCommand comm = new SqlCommand()) { comm.Connection = conn; comm.CommandText = commText; conn.Open(); using (SqlDataReader reader = comm.ExecuteReader()) { while (reader.Read()) { PriceRange price = new PriceRange(); price.ID = int.Parse(reader["PriceRangeID"].ToString()); price.IsVisible = bool.Parse(reader["PriceRangeVisible"].ToString()); price.Name = reader["PriceRangeName"].ToString(); list.Add(price); } } } } } return list; }
public PriceChangedEventArgs(PriceRange old, PriceRange _new) { OldPrice = old; NewPrice = _new; }
public Price(PriceRange value) { Value = value; Name = "Price"; }