Archive

Archive for the ‘VB .Net’ Category

Change component class “UserDefinedType” to display description of UDT

January 19th, 2011 No comments

Open the component class “UserDefinedType”, go to validator, add one more parameter %2 to the UserDefinedTypeValue validator.

image

Open the validator, make sure %2 is there.

image

Then open the property of the validator.

image

Open the Parameters screen

image

Set %=Description in Set Prop/Var/Comp section.

OK all the way back to save the change in Component Class.  Now we have component class “UserDefinedType” ready to show description of user-defined-type as second parameters.

 

To use the component class, just put the field that you want the description display on as second paramenter of component class.  Here is sample,

image

Check to see if form is in “Filter in Place” mode

January 16th, 2011 No comments

Here is the way to check a form’s mode in script.

If Instr(1, ucase(ThisForm.Caption), “(FILTER IN PLACE)”) > 0  Then
ReturnValue = “-1”
Exit Sub
End If

Categories: Development, SQL, VB .Net Tags: ,

Change the sorting in primary collection grid

April 1st, 2010 No comments

The out of box Syteline missed some of the detail carelessly.  For example, the Grid view for RMA is sorted by RMA date ascending.  So it shows the oldest RMA up front and you are seeing those years old closed RMAs.

Syteline Application Case

Change the sorting of Grid view in RMA form, to show the latest RMA up front.

Syteline Technical Component

Form, Primary Collection, Collection Property

Customization Solution

This is pretty easy to change.  Go to Edit mod, in the form collection property, change the Order by to “RmaNum Desc”.  Done.

Syteline RMA

Set default ship via code based on customer type

March 23rd, 2010 1 comment

In Syteline, there are many ways to default field value.  The most simple way is to use the default value property of the field component.  But if you need to set the default value based on some other field value, that simple property value would not cut it.

Syteline Application Case

We want to default ship via code in Customer Ship To form based on customer type.

Syteline Technical Components

Event Handler, Inline Script, SQL Store Procedure.

Customization Solution

Since the customer type is in Customer form, but not in Ship To form, we need to get that in.

1) Create a simple SP: nGetCustType

ALTER PROCEDURE [dbo].[navGetCustType]
(@CustNum [CustNumType],
@CustType [CustTypeType] output)

as

select @CustType = cust_type
from customer
where cust_num = @CustNum and cust_seq = 0

2) Add a new event handler to event:StdObjectNewCompleted, to call the following Inline Script:

Option Explicit On
Option Strict On

Imports System
Imports Microsoft.VisualBasic
Imports Mongoose.IDO.Protocol
Imports Mongoose.Scripting

Namespace SyteLine.GlobalScripts
Public Class EvHandler_StdObjectNewCompleted_5
Inherits GlobalScript

Sub Main()

Dim nRetVal As InvokeResponseData
Dim nRequest As New InvokeRequestData()

nRequest.IDOName = “SP!”
nRequest.MethodName = “nGetCustType”

nRequest.Parameters.Add(ThisForm.PrimaryIDOCollection.GetCurrentObjectProperty(“CustNum”))
nRequest.Parameters.Add(“”)

nRetVal = IDOClient.Invoke(nRequest)

ThisForm.Variables(“vCustType”).Value = nRetVal.Parameters(1).ToString

if ThisForm.Variables(“vCustType”).Value = “AAA” or _
ThisForm.Variables(“vCustType”).Value = “BBB”  then
ThisForm.PrimaryIDOCollection.SetCurrentObjectPropertyPlusModifyRefresh _
(“ShipCode”, “UPRP”)
else
ThisForm.PrimaryIDOCollection.SetCurrentObjectPropertyPlusModifyRefresh _
(“ShipCode”, “UP7A”)
end if
ReturnValue = “0”
End Sub
End Class
End Namespace

Within this script, we call the SP, get the Customer Type, then based on the customer type to set the ShipCode value.

Call Store Procedure within a script

March 3rd, 2010 1 comment

Here is a basic way to call a SQL Store Procedure (SP) within a script, either Form Script or Inline Script.

The sample we use below is calling a SP: GetCustType and return the CustType value to a form variable.

Dim nRetVal As InvokeResponseData
Dim nRequest As New InvokeRequestData()

nRequest.IDOName = “SP!”
nRequest.MethodName = “GetCustType”

nRequest.Parameters.Add(ThisForm.PrimaryIDOCollection.GetCurrentObjectProperty(“CustNum”))
nRequest.Parameters.Add(“”)

nRetVal = IDOClient.Invoke(nRequest)

ThisForm.Variables(“vCustType”).Value = nRetVal.Parameters(1).ToString

And here is the SP:

PROCEDURE [dbo].[navGetCustType]
(@CustNum [CustNumType],
@CustType [CustTypeType] output)

as

select @CustType = cust_type
from customer
where cust_num = @CustNum and cust_seq = 0

Here is a multiple parameters  sample:

Sub nGetUnitDetails()
Dim nRetVal As InvokeResponseData
Dim nRequest As New InvokeRequestData()

nRequest.IDOName = “SP!”
nRequest.MethodName = “nGetUnitDetails”
nRequest.Parameters.Add(ThisForm.Components(“editUnit”).Text)
nRequest.Parameters.Add(CDate(ThisForm.PrimaryIDOCollection.GetCurrentObjectProperty(“RmahdrRmaDate”)))
nRequest.Parameters.Add(“”)
nRequest.Parameters.Add(“”)
nRequest.Parameters.Add(“”)
nRequest.Parameters.Add(“”)
nRequest.Parameters.Add(“”)
nRequest.Parameters.Add(“”)

nRetVal = IDOClient.Invoke(nRequest)

ThisForm.PrimaryIDOCollection.SetCurrentObjectPropertyPlusModifyRefresh(“Warranty”, nRetVal.Parameters(2).ToString)
ThisForm.PrimaryIDOCollection.SetCurrentObjectPropertyPlusModifyRefresh(“Item”, nRetVal.Parameters(3).ToString)
ThisForm.GenerateEvent(“ItemDataChange”)
ThisForm.PrimaryIDOCollection.SetCurrentObjectPropertyPlusModifyRefresh(“CoNum”, nRetVal.Parameters(4).ToString)
ThisForm.GenerateEvent(“OrderNumLoseFocus”)
ThisForm.PrimaryIDOCollection.SetCurrentObjectPropertyPlusModifyRefresh(“CoLine”, nRetVal.Parameters(5).ToString)
ThisForm.GenerateEvent(“DisplayRMAWarningMsgSp”)
ThisForm.PrimaryIDOCollection.SetCurrentObjectPropertyPlusModifyRefresh(“CoRelease”, nRetVal.Parameters(6).ToString)
ThisForm.GenerateEvent(“CoLineChanged”)
‘New for Parag
‘ThisForm.PrimaryIDOCollection.SetCurrentObjectPropertyPlusModifyRefresh(“UnitCreditConv”, nRetVal.Parameters(7).ToString)
‘ThisForm.GenerateEvent(“RecalcTotals”)

If Not nRetVal.Parameters(3).ToString = “” Then
ThisForm.PrimaryIDOCollection.SetCurrentObjectPropertyPlusModifyRefresh(“QtyToReturnConv”, “1”)
End If

End Sub

Add or remove fields from a pull-down list

February 25th, 2010 No comments

Every combobox in Syteline form has a pull-down list.  For example the item pull-down list may show item# and description.  You may want to add more fields to this pull-down list to show more information for your user.

Business Case:

The current Syteline customer ship-to pull-down list only show the ship-to seq and the customer name, let say you also want to show the city and state for each ship-to, so user can more easily identify the correct ship to customer.

Syteline Technical Component:

Component class, List Source

Solution:

The pull-down list is defined in List Source property.  In this case, the ship-to component is inheriting the property from component class “CustSeq”.  You will need to modify this component class.  Open this component class “CustSeq”

image

Then open the list source property:

image

You can see this list source is pulling from IDO SLCustomers, and the property (fields) it pulls are CustSeq, Name, CreditHold and such.  Insert City and State in front of CreditHold.  Then in the Column to Display, let it to display column 1 to 4.  This way, it will display CustSeq, Name, City and State.

Now the Ship-to customer pull-down will show the City and State, along side the seq and Name

image

Assigning field value in a Syteline Form, based on another field value entered. (1)

February 17th, 2010 No comments

In Syteline form, quite often, you would need to assign some field value, base on another field value entered.

Business case:

Let say in Customer Order, for certain payment terms, you would not allow partial shipment.  So in the CO header form, when user select certain payment term, you want the system automatically uncheck the “Ship Partial” check box.

Syteline Technical Components:

Inline Script, Event Handler

Solution

In Syteline 7 & 8, there is quite a few differ ways to accomplish this.  The first one we are going to discuss here is to use Inline Script.

1)      In Customer Order Form, for form component: TermCodeEdit, add a data change event: TermChange.  And the event handler will call an Inline Script

2)      The Inline Script:

Option Explicit On

Option Strict On

Imports System

Imports Microsoft.VisualBasic

Imports Mongoose.IDO.Protocol

Imports Mongoose.Scripting

Namespace SyteLine.GlobalScripts

Public Class EvHandler_TermChange_0

Inherits GlobalScript

Sub Main()

if ThisForm.PrimaryIDOCollection.GetCurrentObjectProperty(“TermsCode”) = “128” then

ThisForm.PrimaryIDOCollection.SetCurrentObjectPropertyPlusModifyRefresh _

(“ShipPartial”, “0”)

end if

ReturnValue = “0”

End Sub

End Class

End Namespace

This script will assign the ShipPartial to 0, when user select TermsCode = 128.

Dynamic change color on a row of grid, based on some cell value

January 21st, 2010 2 comments

This is considered by some people as Holy Grail of Syteline Form Personalization.

Here is what we want to do.  In “Time Phased Inventory” form, we want to change the color to yellow for those rows that is PO.

First, we need to create a new form script method, called SetPOColor()

Sub SetPOColor()
Dim i as Integer
Dim j as Integer
Dim sReference As String
Dim sRef3 As String
Dim sRef4 As String
Dim oSupDem As IWSIDOCollection

oSupDem = ThisForm.PrimaryIDOCollection.GetSubCollection(“SLSupDems”, -1)
j = oSupDem.GetNumEntries

‘    MsgBox(“j = ” + CStr(j))

For i = 1 To j

sReference = ThisForm.Components(“SLSupDemsGrid”).GetGridValueByColumnName(i, “SLSupDemsReferenceSubGridCol”)

sRef3 = Mid(sReference, 1, 3)
sRef4 = Mid(sReference, 1, 4)
If sRef3 = “PO ” Or sRef4 = “XPO ” Then
ThisForm.Components(“SLSupDemsGrid”).SetGridRowColColor(i, 0, “255,255,0”, “”)
End If
Next i
ThisForm.Components(“SLSupDemsGrid”).ForceRepaint
End Sub

Secondly, we create a new event handler for event “StdObjectSelectCurrentCompleted”, to call the above form script method SetPOColor().

Done.  Now here we are:

Events For Non-Query Forms

January 3rd, 2010 2 comments

For Syteline programmer, when doing the form personalization, it is important to understand the various event sequence for Syteline Forms, so you can know where to put your customized logic in. The following list outlines the sequences of events during form execution for non-query forms.

1. Form initialization

StdFormPredisplay is always the first event to fire. At this point, the components are all created, and the caches, if any, exist and are initialized, but have not yet been loaded with data.

Depending on the initial command, the events generated vary:

Refresh (after the refresh is performed):

StdFormLoadBoundValues

StdFormLoadDerivedValues

StdObjectRefreshCompleted

New (after the new is performed)

StdFormLoadBoundValues

StdFormLoadDerivedValues

StdObjectNewCompleted

Filter (by query):

StdFormLoadBoundValues

StdFormLoadDerivedValues

Meanwhile, the filter form is launched; nothing further occurs until the user finishes with the filter form.

FilterInPlace

The form enter filter-in-place mode; the normal events are generated once the user cancels or executes the filter-in-place.

Default (initialize with auto-insert new if new is enabled)

StdFormLoadBoundValues

StdFormLoadDerivedValues

StdObjectNewCompleted (only if new is enabled and the auto-insert new took place)

Event custom (as defined by the developer)

2. New, including auto-insert new

StdObjectNew

StdFormGetBoundValues

StdFormPerformValidations

StdFormValidationsCompleted

(at this point, the new object is actually inserted into the cache, and becomes the current object)

StdFormLoadBoundValues

StdFormLoadDerivedValues

StdObjectNewCompleted

3. Delete

Due to navigating away from unmodified auto-insert row

StdFormLoadBoundValues

StdFormLoadDerivedValues

StdObjectDeleteCompleted

Marking existing record deleted

StdObjectDelete

StdFormGetBoundValues

StdObjectDeleteCompleted

Deleting new record

StdObjectDelete

StdFormGetBoundValues

StdFormLoadBoundValues

StdFormLoadDerivedValues

StdObjectDeleteCompleted

4. Navigation (substitute “Previous”, “First”, or “Last” for Next for those cases):

StdObjectNext

StdFormGetBoundValues

StdFormPerformValidations

StdFormValidationsCompleted

StdFormLoadBoundValues

StdObjectNextCompleted

5. Refresh

StdObjectRefresh

StdFormGetBoundValues

StdFormLoadBoundValues

StdObjectRefreshCompleted

6. RefreshCurrent

StdObjectRefreshCurrent

StdFormGetBoundValues

StdFormLoadBoundValues

StdFormLoadDerivedValues

StdObjectRefreshCurrentCompleted

7. Filter by query

StdFormFilter

variety of events from query form

StdFormCalledFormReturned

(Query form)StdFormClose

If query form returns Ok

StdObjectRefresh

StdFormGetBoundValues

StdFormLoadBoundValues

StdFormLoadDerivedValues

StdObjectRefreshCompleted

8. Filter in place

Ending with Execute:

StdFormFilterInPlaceBegin

StdFormGetBoundValues

StdFormFilterInPlaceExecute

StdFormGetBoundValues

StdFormLoadBoundValues

StdFormLoadDerivedValues

StdObjectRefreshCompleted

Ending with Cancel:

StdFormFilterInPlaceBegin

StdFormGetBoundValues

StdFormFilterInPlaceCancel

StdFormGetBoundValues

StdFormLoadBoundValues

StdFormLoadDerivedValues

9. Form close

StdFormClose

10. Focus change from one component to another, whether by keyboard or mouse:

If there is a lose focus event specified for the component losing focus, and if the previously current component’s data is modified, then the following occurs for the previously current component:

If the component has the validate immediately attribute:

Move the value to the data source if variable- or standard-object bound, but without refreshing dependents of data source.

Run validators; if this succeeds, then the component modified flag is turned off.

Notify dependents of component to refresh themselves.

Place the value to the data source again (for variable- or standard-object-bound components), this time refreshing dependents of data source.

If there was no validation error, and data changed event specified, generate the data changed event.

If there is a gain focus event specified for the component receiving the focus, the gain focus event is generated.

11. Data modification to a component:

If the modification is “immediate” (selection from a drop-down, selection change in a list box, or clicking a check box or radio button):

Component is marked modified.

If the component is standard-object-bound, then the current object is marked modified.

If the component has the validate immediately attribute:

Move the value to the data source if variable- or standard-object-bound, but without refreshing dependents of data source.

Run validators; if this succeeds, then the component modified flag if turned off.

Notify dependents of component to refresh themselves.

Place the value to the data source again (for variable- or standard-object-bound components), this time refreshing dependents of data source.

If there was no validation error, and data changed event specified, generate the data changed event.

Otherwise: no events are generated, but the following flags are adjusted:

Component is marked modified.

If the component is standard-object-bound, then the current object is marked modified.

Categories: Development, VB .Net Tags: , ,

Line Break in VBScript

November 16th, 2009 No comments

When doing the VBScript programming, it often need to have a VBScript constant containing a line-break character. 

Of course this is right out:

CONST blah = "hello 
there"

…It’s just bad syntax.  The closing string quote has to be on the same line as the opening one.

The normally you would try this:

CONST blah = "hello " & vbCRLF & " there"

..But the ampersand (concatenation operator) automatically makes it an expression to the VBScript compiler, and therefore it assumes "not constant." This is of course despite the fact that both parts are known at the time of compilation (which is the main criterion for a constant — value is known at compile time).  Anyway, the ampersand is right out.

Now in JScript/Javascript/ECMAScript, you can do this:

var blah = "hello \r\n there"

…The \r\n switches define the line-break character, they go inside the string, and they are only interpreted when it’s read. 

Unfortunately, there’s no similar switch in VBScript.  While HTML does honor ASCII codes like 
 or 
, and web browsers honor hexadecimal codes in URLs, VBScript does neither.  So these also don’t work:

CONST blah ="hello 

 there"
CONST blah = "hello %0A%0D there"
CONST blah = "hello 0x0A0x0D there"

SO, if you need a line-break in a VBScript constant, just use a variable instead:

DIM blah
blah = "hello " & vbCRLF & " there"
Categories: Development, VB .Net Tags: