# Print

## OnPrint

The code written in this section specifies the fields which are passed as arguments to the report. The link between reports and modules is made in the module „Formular Generator” (**TFG**).&#x20;

For Reports having no arguments, the below code is not needed.

```csharp
public override void OnPrint()
{
    base.OnPrint();
    
    ShowPrintDialog();
}
```

```csharp
public virtual void ShowPrintDialog()
{
    int nr = this.BusObj.tSet.bel.DefaultViewRows[0].nr;
    short typ = this.BusObj.tSet.bel.DefaultViewRows[0].typ;

    if (BusObj.dSet.HasChanges())
    {
        BusObj.Retrieve(typ, nr);
    }

    this.BusObj.tSet.Args_nr = nr;
    this.BusObj.tSet.Args_typ = typ;
    object document_type = busBelUtils.Instance.GetBelDescription(typ);
    string document_type_string = document_type == null ? string.Empty : document_type.ToString();
    string adr1name1 = this.BusObj.tSet.bel.DefaultViewRows[0].adr1name1;
    string report_name = string.Format("{0} {1} - {2}", document_type_string, nr, adr1name1);    
    string hybrid = HybridExtensions.Get("BEL", typ, nr);

    ModuleManager.Instance.GetReport(this.Module.ModuleId, this.BusObj.dSet.Args, report_name, hybrid, this as xWindowHandlingObject);
    
   this.BusObj.SetDruckStatus();
}
```

{% hint style="info" %}
If no report\_name and/or hybrid values are available, the method can be called replacing the parameters with null values.
{% endhint %}

## OnPrintSpecificReportArgs

The OnPrintSpecificReportArgs method allows to specify dataset retrieval arguments that are specific to one report or dataset. If not set, the standard module args will be used, as before.

```csharp
public override xSqlArgs OnPrintSpecificReportArgs(string dsd_id, string rpt_id)
{
   xSqlArgs args = null;
   dsKalk2.kalk2_kopfRow kalkRow = BusObj.tSet.kalk2_kopf.FirstOrDefault();

   if (dsd_id == "rptKalkulation" && rpt_id == "Kalkulation" && kalkRow != null)
      {
         args = new xSqlArgs();
         args.Add("typ", kalkRow.bab_typ.ToInt(0));
         args.Add("nr", kalkRow.bab_nr.ToInt(0));
      }

   return args;
}
```

