如何在 Visual Studio 2010 的 rdlc 报告中显示波斯语日期?

How to show persian date in rdlc report in Visual Studio 2010?

我的应用程序中有一个 rdlc 报告,我想使用一个表达式来显示波斯语日期,但问题是我找不到任何表达式,有没有办法显示波斯语日期在我的 rdlc 文件中的报告中?

在 rdlc 报告的“报告”菜单中选择“报告属性”,然后转到 "Code" 选项卡并开始编写一个自定义方法,用于在 VB 中将格鲁吉亚日期转换为波斯(贾拉利)日历。 (请记住,在自定义代码中,您只能在 VB 中编写代码!)之后,在您的报告中添加一个文本框并编写如下表达式:=Code.GetPersianDate(Fields!Date.Value)

哪个日期是数据集中的一列,显然 GetPersianDate 是方法的名称。

感谢http://ilood.com/?i=ObwcXTETQTY=
真的很有帮助。

在报告 properties/Code 选项卡中复制此代码

Public Function   GetPersianDate(dtGeorgian as DateTime) as string
    dim  strPersianDate  as string
    dim  strYear as string
    dim strMonth as string
    dim strDay as string
    dim objPersiancal as System.Globalization.PersianCalendar
    objPersiancal = new System.Globalization.PersianCalendar()
    if(dtGeorgian =Nothing) then
    return string.empty
    end if

    strYear = objPersiancal.GetYear(dtGeorgian).ToString()
    strMonth = objPersiancal.GetMonth(dtGeorgian).ToString()
    strDay = objPersiancal.GetDayOfMonth(dtGeorgian).ToString()
    if (strDay.Length < 2) then strDay = "0" + strDay
    if (strMonth.Length < 2)  then strMonth = "0" + strMonth
    strPersianDate = strYear + "/" + strMonth + "/" + strDay
    return strPersianDate
End Function

现在在您想要的任何文本框上单击鼠标右键并选择表达式,然后在该表达式前面添加此代码。 =Code.GetPersianDate()

注意:您之前的表达式应该在括号内。

时、分、秒 您可以在以前的答案中添加一些行

    Public Function   GetPersianDateAndTime(dtGeorgian as DateTime) as string

    dim  strPersianDate  as string
    dim strPersianTime as string
    dim  strYear as string
    dim strMonth as string
    dim strDay as string
    dim strHour as string
    dim strMinute as string
    dim strSeconds as string

    dim objPersiancal as System.Globalization.PersianCalendar
    objPersiancal = new System.Globalization.PersianCalendar()

    if(dtGeorgian =Nothing) then

    return string.empty

    end if

    strYear = objPersiancal.GetYear(dtGeorgian).ToString()
    strMonth = objPersiancal.GetMonth(dtGeorgian).ToString()
    strDay = objPersiancal.GetDayOfMonth(dtGeorgian).ToString()
     strHour = objPersiancal.GetHour(dtGeorgian).ToString()
     strMinute  = objPersiancal.GetMinute(dtGeorgian).ToString()
     strSeconds = objPersiancal.GetDayOfMonth(dtGeorgian).ToString()
    if (strDay.Length< 2) then strDay = "0" + strDay
    if (strMonth.Length< 2)  then strMonth = "0" + strMonth
    strPersianDate = strYear + "/" + strMonth + "/" + strDay
    strPersianTime = strHour + ":" + strMinute + ":" + strSeconds

    return strPersianDate+"_"+strPersianTime


    End Function