I need to calculate the NetAmount and IVA automatically from the TotalAmount, all works fine but the big problem is when the user for error digit a character in the field TotalAmount and when this happen shows an error and the program closes automatically without terminate all the process. We need that in the field TotalAmount also admit string character or find the way to accept any character.
if (field.Name == "InvoiceTotalAmount")
{
Field total = (Field)field.ParentDocument.Fields["InvoiceTotalAmount"]; //Field Total
string totaltemp;
double totaltemp1;
totaltemp = total.Value;
totaltemp1 = System.Convert.ToDouble(totaltemp);
bool isNumeric = double.TryParse("1234567890", out totaltemp1);
if (isNumeric == true)
//if (total.Value != "" )
{
Field iva = (Field)field.ParentDocument.Fields["InvoiceVatAmount"]; // IVA
Field neto = (Field)field.ParentDocument.Fields["InvoiceNetAmount"]; // Netamount
double var1;
double var11;
string var4;
var4 = total.Value;
double var5 = System.Convert.ToDouble(var4);
var1 = 0.0087;
var11 = 0.0013;
var1 = (var5 * var1);
var11 = (var5 * var11);
string var3 = var1.ToString("C");
string var12 = var11.ToString("C");
neto.Value = var3;
iva.Value = var12;
neto.State = DataState.Ok;
iva.State = DataState.Ok;
}
else
{
return false;
}
}
return false;