Using enumeration in your code is a quick way to make your code
more readable.
Declare a new type
private enum _medTypes { newMed, changeMed, stopMed };
//newMed =0, changedMed = 1, stopMed =2
Declare a variable of your new type
private _medTypes _medType;
Converting an int to your new type
_medType = (_medTypes)int.Parse(Request.QueryString["medType"]);
Testing your new type
if (_medType == _medTypes.newMed || _medType == _medTypes.changeMed)
switch(_medType)
{
case _medTypes.newMed:
msgSpan.InnerHtml = @"Meds written since ED Reg date default as new. " +
"To exclude a medication from appearing on the discharge note the user needs to uncheck the new box.";
medsGridView.Columns[0].Visible = true;
break;
case _medTypes.changeMed:
msgSpan.InnerHtml = @"Medication changes must be made in LMR.";
medsGridView.Columns[1].Visible = true;
break;
case _medTypes.stopMed:
msgSpan.InnerHtml = @"Meds discontinued since the ED Reg date are displayed below.";
medsGridView.Columns[2].Visible = true;
break;
default:
break;
}
No comments:
Post a Comment