I have a database with some prices in it. For example I have milk = 1€. I want the price not to be modify for more or less than 10%. So in this case you can set the price only between 0.90 or 1.10. It's easy to do that, however, when the price is modified, the user can modify it again right after. (if he sets it to 0.9, then he can set it between 0.81 and 0.99 and so on...)So I want to affect in a variable the price for example each day at 9 a.m, so in one day it can't change for more or less than 10%.
DataClassesDataContext db = new DataClassesDataContext();
List<ARTICLE> article = db.ARTICLE.ToList();
for (int i = 0; i < article.Count; i++)
{
switch (article[i].Name)
{
case "Milk":
if (decimal.Parse(Milk.Text, CultureInfo.InvariantCulture) <=
(article[i].Price/ 10) * 11 && decimal.Parse(Milk.Text,
CultureInfo.InvariantCulture) >= (article[i].Price/ 10) * 9)
{
if (decimal.Parse(Milk.Text, CultureInfo.InvariantCulture) != article[i].Price)
{
article[i].Price= decimal.Parse(Milk.Text, CultureInfo.InvariantCulture);
}
}
break;
case "Other thing":
//... etc
}
}