November 10, 2009 at 6:55 am
I have the following script inside of a 2008 ssis script component written in C#. I'm using it to set an output variable's value but I'm noticing that the variable isn't being displayed in the dataview.
The call is as follows (ServiceYearAndQuarter is a string (6)):
Row.ServiceYearAndQuarter = CalculatePXCodeYearAndQuarter(Row.ADMDT, int.Parse(Row.PR5DT));
the method is:
private string CalculatePXCodeYearAndQuarter(string strAdmitDate, int intNumberOfDaysToProcedure)
{
int intMonth;
int intYear;
string strPXCodeYearAndQuarter;
intMonth = int.Parse(strAdmitDate.Substring(4));
intYear = int.Parse(strAdmitDate.Substring(0,4));
intMonth += (int)(intNumberOfDaysToProcedure / 30);
// Handle when adding intNumberOfDaysToProcedure causes a change in year.
if (intMonth < 1)
{
intYear -= 1;
intMonth += 12;
}
else if (intMonth > 12)
{
intYear += 1;
intMonth -= 12;
}
switch (intMonth)
{
case 1:
strPXCodeYearAndQuarter = intYear.ToString() + "01";
break;
case 2:
strPXCodeYearAndQuarter = intYear.ToString() + "01";
break;
case 3:
strPXCodeYearAndQuarter = intYear.ToString() + "01";
break;
case 4:
strPXCodeYearAndQuarter = intYear.ToString() + "02";
break;
case 5:
strPXCodeYearAndQuarter = intYear.ToString() + "02";
break;
case 6:
strPXCodeYearAndQuarter = intYear.ToString() + "02";
break;
case 7:
strPXCodeYearAndQuarter = intYear.ToString() + "03";
break;
case 8:
strPXCodeYearAndQuarter = intYear.ToString() + "03";
break;
case 9:
strPXCodeYearAndQuarter = intYear.ToString() + "03";
break;
case 10:
strPXCodeYearAndQuarter = intYear.ToString() + "04";
break;
case 11:
strPXCodeYearAndQuarter = intYear.ToString() + "04";
break;
case 12:
strPXCodeYearAndQuarter = intYear.ToString() + "04";
break;
default:
MessageBox.Show("Error in CalculatePXCodeYearAndQuarter Switch:" + intMonth.ToString() + " Date: " + strAdmitDate + " Days: " + intNumberOfDaysToProcedure.ToString());
strPXCodeYearAndQuarter = "error";
break;
}
return strPXCodeYearAndQuarter;
}
November 11, 2009 at 10:17 am
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply