|
3. |
Add code to handle btnNavigation1_Click. Remember that the generated code is independent of connection properties. The ones used during the design may not be the
same as the ones used in production. That is why you have to specify the new connection properties in your code.
Note that if you do not specify connection properties (no constructor in your navigation class), the ones used during the
design will be used in your code.
Example:
using HFLI ;
. . .
private void button1_Click(object sender, System.EventArgs e)
{
// Note that here the generated class hasthe name Nav1 in the HFLI namespace
// The following classes are embedded in thge Nav1class
// ConnectionProperties
// ConnectionType
// EmulationType
// Table
// TableField
try
{
Nav1.ConnectionProperties cnxProps = newNav1.ConnectionProperties() ;
cnxProps.ConnectionType =Nav1.ConnectionType.Http ;
cnxProps.EmulationType =Nav1.EmulationType.Emulation5250 ;
cnxProps.Password ="";
cnxProps.UserName ="tn";
cnxProps.UriBuilder = newUriBuilder("http","192.168.1.123", 80);
Nav1 nav = new Nav1 (cnxProps) ;
HFLI.Nav1Result res = nav.Navigate ("MONTREAL","QUE","VANCOUVER","BC","1000");
if (res.CapturedExceptionMessage.Length>0)
MessageBox.Show (res.CapturedExceptionMessage,"Navigation Failed",
MessageBoxButtons.OK,MessageBoxIcon.Hand) ;
else
MessageBox.Show (res.Total_Charges.ToString(),"Navigation Result",
MessageBoxButtons.OK,MessageBoxIcon.Information) ;
}
catch (Exception ex)
{
MessageBox.Show (ex.Message,"Navigation Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
}
}
|