How can I show a message from the server?

I am not a Java developer, but my company buys a product for processing my java-based accounting materials. Now I am faced with a problem because they want to prevent repeated invoices in the system, and the software allows the user to do this. I called support, and they suggested that I create a suppressed field on the client side, copy the message that I want to show in this field, and read this field when the user tab is in the next field. it is many steps and completely ineffective. Below my code is based on what they suggested. Currently, I have shown that the message about the presence of the invoice twice .

server side

CSServer.log (Step)
  if ((CSEvent.getTarget().getName() == "InvoiceNumber") && (CSEvent.getAction() == "Tabout" ) && (Step == 0)) 
    {
      if (!cnn) 
      {
        CSServer.log ("GPCONNECT Lookup::CSForm_OnValidateLookup Connection to the database failed");
      } 
      else 
      {
        Sql  = "SELECT COUNT (*) as Result FROM [DYNAMICS].[dbo].[AP_Invoice_Table] WHERE [VendorID] = '" + CSForm.getField("VendorID").getValue() + "' and [DocumentNumber] = '" + CSForm.getField("InvoiceNumber").getValue()+"'";
        resultInvSet = cnn.executeSQL(Sql);
        var x =null;
        x = resultInvSet.getValue("Result");
      }
      if (x > 0) 
      {
        CSForm.getField("msg").setValue("Invoice number already exist, please check your entry!");
        return false;
      } 
      else
      {
        CSForm.getField("msg").setValue("");
      }
    }

client side

function InvoiceAmount_OnFocus()
{
  var m =CSForm.getField('msg').getValue();
  if (m != "")
  {
    $("#InvoiceNumber").focus();
    CSClient.alert(m);
    CSForm.getField("InvoiceNumber").setFillColor("FF0000");
  }
  else
  {
  CSForm.getField("InvoiceNumber").setFillColor("FFFFFF");
  }
  return true;
}

-, , ?

Update: SOAP HTTP- .

+4
2

-, AJAX, javascript .

( .aspx):

        function doSomething(id) {
            $.ajax({
                type: "POST",
                url: "Do_Something.aspx/DoSomething?id=" + id,
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (response) {
                    alert(response);
                }
            });

Do_Something.aspx.cs:

    [WebMethod]
    public static string DoSomething(string id)
    {
        var docs = SqlHelper.SelectAllByInvoiceId(id);
        if (docs.Count > 0)
        {
            return "exists";
        }
        return "does not exist";
    }
+2
+1

All Articles