#region
//参数字段方法
public ParameterFields GetParameterFields()
{
ParameterFields fields = new ParameterFields();
//单位、部门、人员、日期范围参数
fields.Add(this.CreateParameterField("@Guid", proid.Text.Trim()));
//fields.Add(this.CreateParameterField("@barcode", dataGridView1.Rows[]));
fields.Add(this.CreateParameterField("@等级", comboBox2.Text));
//返回
return fields;
}
private ParameterField CreateParameterField(string FieldName, object FieldValue)
{
ParameterField field = new ParameterField();
ParameterDiscreteValue pvalue = new ParameterDiscreteValue();
pvalue.Value = FieldValue;
field.Name = FieldName;
field.CurrentValues.Add(pvalue);
//返回参数字段
return field;
}
//水晶报表登陆代码
//private void LogonToReport(string server, string database, string ID, string password, CachedCrystalReport1 Report)
//{
// TableLogOnInfo logonInfo = new TableLogOnInfo();
// foreach (Table table in Report.Database.Tables)
// {
// logonInfo = table.LogOnInfo;
// logonInfo.ConnectionInfo.ServerName = server;
// logonInfo.ConnectionInfo.DatabaseName = database;
// logonInfo.ConnectionInfo.UserID = ID;
// logonInfo.ConnectionInfo.Password = password;
// table.ApplyLogOnInfo(logonInfo);
// }
//}
#endregion
以上代码从网络各处搜罗来的,方便自己使用