Оригинал У меня есть функция условия IF в моем коде, см. Ниже:
//check property and/or i.Prod and then show the popup
void _incident_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) </i>
{
// MessageBox.Show(e.PropertyName); //Check what property name is
/*
if (_incident.ProductID == 182 ||_incident.ProductID ==1959 && _triggerPopup) //If product ID is 183 in incident
{
MessageBox.Show("The GO Classic will soon be end of life, make sure you propose the customer to buy a new device and offer maximum 20% discount to reward his/her loyalty (NOTE: refurbished devices are not included in this offer).");
_triggerPopup = false; //Do not pop up
}*/
}
В настоящее время нам нужно добавить больше ProductID в условие if, например еще 20 ProductID в условие if, код будет выглядетьбеспорядок и неопрятный.
Я думаю, что смогу построить функцию, чтобы немного изменить код;
if (checkProductID(_incident.ProductID)&& _triggerPopup)
{
MessageBox.Show("The GO Classic will soon be end of life, make sure you propose the customer to buy a new device and offer maximum 20% discount to reward his/her loyalty (NOTE: refurbished devices are not included in this offer).");
_triggerPopup = false; //Do not pop up
}
}
protected Boolean checkProductID(int productID)
{
switch (productID)
{
case "182":
return true;
break;
}
}
Мне интересно, это правильный способ сделать это.Я пишу эту функцию checkProductID правильно?другой лучший способ сделать это?спасибо
Ура, Цин