c# 下怎么给fastreport注册自定义方法
我想注册一个人民币大小写转换
大写和小写转换的方法到fastreport
网上大都是在delphi的
我想在c#下实现
描述:
我又方法
public string RMBToString(string rr)
{
string str="";
if(rr=="答案")
{
str ="给分";
}
else
{
str ="谢谢";
}
return str
} /// <summary>
/// 打开报表
/// </summary>
public void OpenReport()
{
try
{
report = new TfrxReportClass();
report.LoadReportFromFile(m_ReportTemplate);
report.ClearDatasets();
//report.AddFunction("public void RMBToString(string rr)", "Myfunction", "小写金额转大写的函数");
//report.AddFunction("public string MoneyCn(decimal r)", "Myfunction", "小写金额转大写的函数");
//report.OnUserFunction += new IfrxReportEventDispatcher_OnUserFunctionEventHandler(frxReport1UserFunction); }
catch (Exception ex)
{
m_EMessage = ex.Message;
CloseReport();
throw new Exception(m_EMessage);
}
} //report.AddFunction("public string RMBToString(string rr)", "Myfunction", "小写金额转大写的函数");
//report.OnUserFunction += new IfrxReportEventDispatcher_OnUserFunctionEventHandler(frxReport1UserFunction); 上面是我瞎写的 怎么将RMBToString(string rr)正确注册 啊
report = new TfrxReportClass();
我想注册一个人民币大小写转换
大写和小写转换的方法到fastreport
网上大都是在delphi的
我想在c#下实现
描述:
我又方法
public string RMBToString(string rr)
{
string str="";
if(rr=="答案")
{
str ="给分";
}
else
{
str ="谢谢";
}
return str
} /// <summary>
/// 打开报表
/// </summary>
public void OpenReport()
{
try
{
report = new TfrxReportClass();
report.LoadReportFromFile(m_ReportTemplate);
report.ClearDatasets();
//report.AddFunction("public void RMBToString(string rr)", "Myfunction", "小写金额转大写的函数");
//report.AddFunction("public string MoneyCn(decimal r)", "Myfunction", "小写金额转大写的函数");
//report.OnUserFunction += new IfrxReportEventDispatcher_OnUserFunctionEventHandler(frxReport1UserFunction); }
catch (Exception ex)
{
m_EMessage = ex.Message;
CloseReport();
throw new Exception(m_EMessage);
}
} //report.AddFunction("public string RMBToString(string rr)", "Myfunction", "小写金额转大写的函数");
//report.OnUserFunction += new IfrxReportEventDispatcher_OnUserFunctionEventHandler(frxReport1UserFunction); 上面是我瞎写的 怎么将RMBToString(string rr)正确注册 啊
report = new TfrxReportClass();
Report.AddFunction("function SpellValue(Value: String): String", "User functions", "The value spelled out function");
Report.OnUserFunction += new IfrxReportEventDispatcher_OnUserFunctionEventHandler(OnUserFunction);
/// <summary>
/// On User event handler
/// Provides functionality of adding the user functions to the report
/// NOTE: The current implementation of user functions converts the function's names to the upper case due to Delphi origin of the FR Studio.
/// </summary>private void OnUserFunction(string FunctionName, object Argument, out object ResultValue)
{
System.Array arg = (Array)Argument;
switch(FunctionName)
{
case "SPELLVALUE":
string str = (string)(arg.GetValue(0));
ResultValue = doVerbal( long.Parse(str));
break;
default:
ResultValue = "Undefined user function: " + FunctionName;
break;
}
}
///自定义方法
public string doVerbal(long Value)
{
string result = "";
int idx = 0; while(Value != 0)
{
result = HundredsUnit( (int) Value) + strMultiply[idx] + result;
Value /= 1000;
idx++;
} return result; ;
}只有你一个 把分给你了[/align]