Hi All,
I’m trying to add a button which the end user can click to add an auto generated payment number (Payment Entry) using max +1 from a range of numbers.
I’ve created the BAQ, added the button and the C# code but I’m stuck at getting the number to enter into the field (it’s trying to enter a string for an Int field).
My C# skills are limited so can anyone can have a look over the below to tell me where I’m going wrong?
Thanks,
Barry
BAQ (AutoGenPayNum)
select (MAX(CheckHed.CheckNum)+1) as [Calculated_CalcCheckNum] from Erp.CheckHed as CheckHed where (CheckHed.CheckNum > 6000000 and CheckHed.CheckNum < 6999999)
C#
extern alias Erp_Contracts_BO_Currency;
extern alias Erp_Contracts_BO_Company;
extern alias Erp_Contracts_BO_Vendor;
extern alias Ice_Contracts_BO_DynamicQuery;
using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Erp.Adapters;
using Erp.UI;
using Ice.BO;
using Ice.Lib;
using Ice.Adapters;
using Ice.Lib.Customization;
using Ice.Lib.ExtendedProps;
using Ice.Lib.Framework;
using Ice.Lib.Searches;
using Ice.UI.FormFunctions;
public class Script
{
DynamicQueryAdapter queryAdapter;
public void InitializeCustomCode()
{
queryAdapter = new DynamicQueryAdapter(PaymentEntryForm);
queryAdapter.BOConnect();
this.epiButtonC1.Click += new System.EventHandler(this.epiButtonC1_Click);
}
public void DestroyCustomCode()
{
queryAdapter.Dispose();
this.epiButtonC1.Click -= new System.EventHandler(this.epiButtonC1_Click);
}
private void epiButtonC1_Click(object sender, System.EventArgs args)
{
DynamicQueryAdapter queryAdapter = new DynamicQueryAdapter(oTrans);
queryAdapter.BOConnect();
QueryExecutionDataSet qeds = queryAdapter.GetQueryExecutionParametersByID("AutoGenPayNum");
queryAdapter.ExecuteByID("AutoGenPayNum",qeds);
EpiDataView edvCheckHed = ((EpiDataView)(this.oTrans.EpiDataViews["CheckHed"]));
System.Data.DataRow edvCheckHedRow = edvCheckHed.CurrentDataRow;
if ((edvCheckHedRow != null))
{
edvCheckHedRow.BeginEdit();
edvCheckHedRow["CheckNum"] = qeds;
edvCheckHedRow.EndEdit();
}
}
}