我的应用程序中有一份 rdlc
报告,我想使用一个表达式来显示波斯日期,但问题是我找不到任何表达式,有没有办法在我的rdlc
文件报告中显示波斯日期?
问问题
868 次
3 回答
3
在 rdlc 报告的报告菜单中选择报告属性,然后转到“代码”选项卡并开始编写自定义方法,用于在 VB 中将格鲁吉亚日期转换为波斯 (Jalali) 日历。(请记住,在自定义代码中,您只能在 VB 中编写代码!)然后在您的报告中添加一个文本框并编写如下表达式: =Code.GetPersianDate(Fields!Date.Value)
其中 Date 是数据集中的一列,显然 GetPersianDate 是方法的名称。
感谢 http://ilood.com/?i=ObwcXTETQTY=
它真的很有帮助。
于 2015-12-26T17:42:12.467 回答
2
在报告属性/代码选项卡中复制此代码
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()
注意:您之前的表达式应该在括号内。
于 2017-02-22T08:56:43.343 回答
1
对于小时,分钟和秒,您可以在以前的答案中添加一些行
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
于 2019-05-09T06:06:28.580 回答