Skip to main content

Limit Control on Form

Before coming to the code part, open the project properties by right-clicking on the project and add the following DLLs to the system.

%SystemPath%\Common\eBAPI.dll
%SystemPath%\Common\eBAIntegrationAPI.dll

Right-click on the form and click 'View Server Code'. Add the following references to the form.

using eBAPI;
using eBAPI.Connection;
using eBAIntegrationAPI;
using System.Data;
using System.Collections.Generic;

Add the following function to the Code Side.

DataTable IntegrationQuery(string connection,string query,Dictionary```<```string,string```>``` parameters)
{
eBAConnection con = CreateServerConnection();
Con. open();
eBAIntegrationQuery qry= new eBAIntegrationQuery(Connection, Query);
foreach(KeyValuePair```<```string,string```>``` data in parameters)
{
qry. Parameters.Add(data. Key, data. Value);
}
DataTable dt = qry. Execute(con);
return dt;
}
Double-click the OnLoadData method of the form and fill it out as follows. In this way, we have assigned your remaining balance to the Price Control Object. If your query will take parameters, fill in the new Dictionary```<```string,string```>``` {} field as the parameter name and value such as . new Dictionary```<```string,string```>``` { {"Param1", "Value1"}, {"Param2", "Value2"}, {"Param3", "Value3"}}.
public void OnLoadData()
{
DataTable dt = IntegrationQuery("ConnectionName","QueryName",new Dictionary```<```string,string```>``` {});
if (dt != null && dt. Rows != null && dt. Rows.Count ```>``` 0 & dt. Rows[0]. ItemArray.Length ```>``` 0)
{
PriceControl.Text = dt. Rows[0]. ItemArray[0]. ToString();
}
}

Double-click the OnLoadData method of the form and fill it out as follows. In this way, we have assigned your remaining balance to the Price Control Object. If your query will take parameters
Fill in the Dictionary<string,string> {} field as the parameter name and value such as . new Dictionary<string,string> { {"Param1", "Value1"}, {"Param2", "Value2"}, {"Param3", "Value3"}}.

public void OnLoadData()
{
DataTable dt = IntegrationQuery("ConnectionName","QueryName",new Dictionary```<```string,string```>``` {});
if (dt != null && dt. Rows != null && dt. Rows.Count ```>``` 0 & dt. Rows[0]. ItemArray.Length ```>``` 0)
{
PriceControl.Text = dt. Rows[0]. ItemArray[0]. ToString();
}
}

Right-click on the form and click 'View Validation Code' in the drop-down menu. Fill in the OnValidateDocument method on the Code screen that opens as follows. In this way, limit control will be provided and the remaining limit message will be given as a warning.

public override void OnValidateDocument(string view, bool canEdit, Hashtable parameters, ValidationSummary summary)
{
EstimatePrice is the name of the object. Do not use it in the form of EstimatePrice.Text.
if(Convert.ToDouble(EstimatePrice) ```>``` Convert.ToDouble(PriceCheck))
{
summary. AddMessage("The remaining limit for this month is "+PriceControl.ToString()+" TL. ");
}
}