Please visit support.cavallo.com

Start a conversation

Signature Pad Report Scripting

Overview

SalesPad Signature Pad is a module that allows users to capture signatures for Sales Documents. These signatures are stored within the database and can be called onto a Printed Report with a script. In this document, you will learn how to modify the provided script to make it work within your system. For more information about Printed Reports or Report Designer, see the Reports documentation. For more information about Report Manager, see the Report Manager video. For more information about Signature Pad, see the Signature Pad documentation.

Preparing the Report

Before applying the script, you will need to add a picture box to the report. Open the report in Report Designer, and then click on the Picture Box option in the Standard Controls area.

Create a picture box on the report and note the object name, as it will be used in the script. You can view this by selecting the picture box on the document, then looking at the report explorer to see what the object is called.

You will also need to click the green arrow in the top right of the picture box object. This will open up a small list of properties to edit. Set the image sizing here to Stretch Image.

Applying the Script

This is the script that will allow you to bring a signature onto a report:

{code:C#}

private void ReportFooter_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e) {

    string SalesDocNum = ((System.Data.DataSet)this.rptOrder.DataSource).Tables["SalesDocument"].Rows[0]["Sales_Doc_Num"].ToString();
    string SalesDocType = ((System.Data.DataSet)this.rptOrder.DataSource).Tables["SalesDocument"].Rows[0]["Sales_Doc_Type"].ToString();

    SalesPad.Bus.SalesDocumentSignature sign = new SalesPad.Bus.SalesDocumentSignature();
    SearchClause sc = new SearchClause(SalesPad.Bus.SalesDocumentSignature._Sales_Doc_Num, "=", SalesDocNum);
    sc.And(SalesPad.Bus.SalesDocumentSignature._Sales_Doc_Type, "=", SalesDocType);

    if(sign.Load(sc))
    {
        pictureBox1.Image = Genframe4.Utils.ResizeImageFromByteArray(sign.val_Signature_Image, pictureBox1.Size.Height, pictureBox1.Size.Width);
    }
    else
    {
        SalesDocNum = ((System.Data.DataSet)this.rptOrder.DataSource).Tables["SalesDocument"].Rows[0]["Prev_Sales_Doc_Num"].ToString();
        SalesDocType = ((System.Data.DataSet)this.rptOrder.DataSource).Tables["SalesDocument"].Rows[0]["Prev_Sales_Doc_Type"].ToString();

        sign = new SalesPad.Bus.SalesDocumentSignature();
        sc = new SearchClause(SalesPad.Bus.SalesDocumentSignature._Sales_Doc_Num, "=", SalesDocNum);
        sc.And(SalesPad.Bus.SalesDocumentSignature._Sales_Doc_Type, "=", SalesDocType);

        if(sign.Load(sc))
        {
            pictureBox1.Image = Genframe4.Utils.ResizeImageFromByteArray(sign.val_Signature_Image, pictureBox1.Size.Height, pictureBox1.Size.Width);
        }
    }
}

{code}

Copy this code into your system by clicking the Scripts button in report designer. You will want to ensure that the highlighted names match the corresponding names in your system. The report name can be found in the tab at the top of the report. Report names change based on which kind of report you are using. Replace rptOrder1 in the script with your Report Name.

You will also want to ensure that the pictureBox object in the script matches the picture box we created earlier. Once both of these fields have been adjusted for your system, use the dropdown menu at the top left of the scripting area to select your order name, then select BeforePrint in the dropdown menu on the top right.

This process will bind the script to the report, ensuring that the script will run correctly.

Choose files or drag and drop files
Was this article helpful?
Yes
No
  1. SalesPad Support

  2. Posted
  3. Updated

Comments