本文介绍了将文本框值传递给Crystal Report的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有其他方法来简化这个?
is there any other way to simplify this?
private void btnPrint_Click(object sender, EventArgs e)
{
ReportDocument objRpt = new ReportDocument();
objRpt.Load(@"c:\users\c&c\documents\visual studio 2012\Projects\textbox to crystal\textbox to crystal\rptPrint.rpt");
ParameterFieldDefinitions crParameterFieldDefinitions;
ParameterFieldDefinition crParameterFieldDefinition;
ParameterValues crParameterValues = new ParameterValues();
ParameterDiscreteValue crParameterDiscreteValue = new ParameterDiscreteValue();
crParameterDiscreteValue.Value = txtName.Text;
crParameterFieldDefinitions = objRpt.DataDefinition.ParameterFields;
crParameterFieldDefinition = crParameterFieldDefinitions["Name"];
crParameterValues = crParameterFieldDefinition.CurrentValues;
crParameterValues.Clear();
crParameterValues.Add(crParameterDiscreteValue);
crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);
ParameterFieldDefinitions crParameterFieldDefinitions1;
ParameterFieldDefinition crParameterFieldDefinition1;
ParameterValues crParameterValues1 = new ParameterValues();
ParameterDiscreteValue crParameterDiscreteValue1 = new ParameterDiscreteValue();
crParameterDiscreteValue1.Value = txtAddress.Text;
crParameterFieldDefinitions1 = objRpt.DataDefinition.ParameterFields;
crParameterFieldDefinition1 = crParameterFieldDefinitions1["Address"];
crParameterValues1 = crParameterFieldDefinition1.CurrentValues;
crParameterValues1.Clear();
crParameterValues1.Add(crParameterDiscreteValue1);
crParameterFieldDefinition1.ApplyCurrentValues(crParameterValues1);
ParameterFieldDefinitions crParameterFieldDefinitions2;
ParameterFieldDefinition crParameterFieldDefinition2;
ParameterValues crParameterValues2 = new ParameterValues();
ParameterDiscreteValue crParameterDiscreteValue2 = new ParameterDiscreteValue();
crParameterDiscreteValue2.Value = txtMobile.Text;
crParameterFieldDefinitions2 = objRpt.DataDefinition.ParameterFields;
crParameterFieldDefinition2 = crParameterFieldDefinitions2["Mobile"];
crParameterValues2 = crParameterFieldDefinition2.CurrentValues;
crParameterValues2.Clear();
crParameterValues2.Add(crParameterDiscreteValue2);
crParameterFieldDefinition2.ApplyCurrentValues(crParameterValues2);
ParameterFieldDefinitions crParameterFieldDefinitions3;
ParameterFieldDefinition crParameterFieldDefinition3;
ParameterValues crParameterValues3 = new ParameterValues();
ParameterDiscreteValue crParameterDiscreteValue3 = new ParameterDiscreteValue();
crParameterDiscreteValue3.Value = txtDepartment.Text;
crParameterFieldDefinitions3 = objRpt.DataDefinition.ParameterFields;
crParameterFieldDefinition3 = crParameterFieldDefinitions3["Department"];
crParameterValues3 = crParameterFieldDefinition3.CurrentValues;
crParameterValues3.Clear();
crParameterValues3.Add(crParameterDiscreteValue2);
crParameterFieldDefinition3.ApplyCurrentValues(crParameterValues3);
crystalReportViewer1.ReportSource = objRpt;
crystalReportViewer1.Refresh();
}
i我将多个文本框值传递给水晶
谢谢
i am passing multiple textbox values to crystal
Thanks
推荐答案
这篇关于将文本框值传递给Crystal Report的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!