Results 1 to 14 of 14

Thread: Tornado - Dropdown during Add Record

  1. #1
    Join Date
    Dec 2002
    Location
    Albany, NY
    Posts
    115

    Tornado - Dropdown during Add Record

    I'm still unable to successfully implement a dropdown field in Add record mode. This seems to occur when using multiple "new tornado.z" modules.
    Using a single module works fine.

    I've included some code using "NWIND"
    as an example.

    <%@ Page Language="vb" %>
    <script runat="server">

    Sub Page_Load(Source as Object, E as EventArgs)


    Dim Emp As String = "Nancy,Andrew,Janet,Margret,Steven,Micheal,Robert, Laura,Anne"
    Dim ID As String
    Dim GD As New Tornado.Getdata()
    Dim M1 As New Tornado.Z()
    With M1
    .dbQP = "U=6| M=ty=SBox!SboxMacro=({{1,2,3,4,5,6,7,8,9}}~{{" & Emp & "}})"
    .dbTextHolder = "Title=Select an Employee"
    .ASPdbNET()
    End With
    Response.Write("<Center>" & GD.Get_Sbox(6) & "</center>")
    ID = GD.Get_SelectBoxSelection(6)

    Dim EmpArr As String() = Split(Emp, ",")
    Dim M2 As New Tornado.Z()
    With M2
    .dbQP = "U=7| M=Grid| D=NWIND| ni=b5,add| gdf=0,1,2,3,7|Bm=orders;0| Q=Select * FROM Employees where EmployeeID = " & ID

    .dbEditUpdateFlds = "fi=lastname|ty=SelectBox|tex=empIDx"
    .dbCommonTables = "i=empIDx|sql=SELECT LastName FROM Employees"

    .ASPdbNET()
    End With

    End Sub
    </script>

    Last edited by paul mancuso; 01-15-2004 at 02:03 PM.

  2. #2
    Join Date
    Oct 2002
    Posts
    933
    Look at M2 -> you are Adding and not Updating. Change dbEditUpdateFlds to dbEditAddFlds and it'll go.

    One thing to remember, commontable is common to ALL modules and should be loaded in the beginning. Since M1 is Sbox and not related in this example, it is OK. In a regular multi-modules app, load it first.


    FK

  3. #3
    Join Date
    Dec 2002
    Location
    Albany, NY
    Posts
    115
    Thanks Frank, I recognize the mistake and corrected it, it does work. However, if you use a third module it seems to fall apart. The other issue is this:

    I have modified the code to reflect the problem. Please note the .dbCommonTables sql = parameter. I have included a sql WHERE clause which, in my actual application, would select only those dropdown criteria per the actual selection of GD.Get_SelectBoxSelection(6). What's happening here is that GD.Get_SelectBoxSelection(6) is defaulting to the first selection after a call to .dbEditAddFlds. Doing this the application can not select the correct dropdown criteria.

    How do I pass selection, GD.Get_SelectBoxSelection(6), to .dbCommonTables and have that result not default during a .dbEditAddflds or .dbEditUpdateFlds?

    Paul


    <%@ Page Language="vb" %>
    <script runat="server">

    Sub Page_Load(Source as Object, E as EventArgs)


    Dim Emp As String = " Nancy,Andrew,Janet,Margret,Steven,Micheal,Robert,L
    aura,Anne"
    Dim ID As String
    Dim GD As New Tornado.Getdata()
    Dim M1 As New Tornado.Z()
    With M1
    .dbQP = "U=6| M=ty=SBox!SboxMacro=({{1,2,3,4,5,6,7,8,9}}~{{" & Emp & "}})"
    .dbTextHolder = "Title=Select an Employee"
    .ASPdbNET()
    End With
    Response.Write("<Center>" & GD.Get_Sbox(6) & "</center>")
    ID = GD.Get_SelectBoxSelection(6)

    Dim EmpArr As String() = Split(Emp, ",")
    Dim M2 As New Tornado.Z()
    With M2
    .dbQP = "U=7| M=Grid| D=NWIND| ni=b5,add| gdf=0,1,2,3,7|Bm=orders;0| Q=Select * FROM Employees where EmployeeID = " & ID

    .dbEditUpdateFlds = "fi=lastname|ty=SelectBox|tex=empIDx"
    .dbCommonTables = "i=empIDx|sql=SELECT LastName FROM Employees where EmployeeID = " & ID

    .ASPdbNET()
    End With

    End Sub
    </script>

  4. #4
    Join Date
    Oct 2002
    Posts
    933
    this code is still wrong as before (mixing add and update). Fix that and indcate what is to be expected at which dropdown.

    FK

  5. #5
    Join Date
    Dec 2002
    Location
    Albany, NY
    Posts
    115
    I know the code is wrong but I don't have the time to create or debug this example code. I do need an answer though.

    How do I pass selection, GD.Get_SelectBoxSelection(6), to .dbCommonTables and have that result not default during a .dbEditAddflds or .dbEditUpdateFlds?

    Everytime I press the "Add" button the dropdown, in my application defaults to the initial GD.Get_SelectBoxSelection().
    Maybe I'm asking too much of Tornado?

  6. #6
    Join Date
    Oct 2002
    Posts
    933
    do not understand your question....
    GD.Get_SelectBoxSelection(6) retrieves a single value. how do you pass that?

    >>..I don't have the time to create or debug this example code

    You need to make time to define the problem clearly before it can be solved. If you do not have time then nobody can help ou.

    FK

  7. #7
    Join Date
    Dec 2002
    Location
    Albany, NY
    Posts
    115
    Frank,

    Here's my actual code:

    <%@ Page Language="vb" %>
    <script runat="server">

    Sub Page_Load(Source as Object, E as EventArgs)


    Dim GD as New Tornado.Getdata()
    Dim mpo as string = "Kingston/Ulster,MHSTCC,N/STCC,NOCTS,NYCTCC,PDCTC"
    Dim mpoArr() as string = split(MPO, ",")
    Dim mpoID as string
    Dim z1 as New Tornado.Z()

    with z1
    .dbQP="u=70|skin=20|M=ty=SBox!SboxMacro=({{1,2,3,4 ,5,6}}~{{" & MPO & "}})"
    .dbSkin = 20
    .dbTextHolder = "(;|)Title=New York Metropolitan Transportation Council<br>eS-TIP Information System<br><br> Select an MPO Name"
    .aspDBNet()
    end with

    response.write("<center>" & GD.Get_Sbox(70)&"</center>")
    mpoID = GD.Get_SelectBoxSelection(70)

    Dim x1 as New Tornado.z()
    with x1
    Dim qp as string = ""
    qp = "u=75|m=grid|skin=20|d=eSTIP|ni=b5,add,update|gdf= 1,2,3| "
    qp = qp & "Bm=mpoProject;0"
    .dbQP = qp


    Dim IsMpoID as string = ""
    Dim IsMpoName as string = ""

    select case mpoID
    case "1"
    IsMpoID = "1"
    IsMpoName = "Kingston/Ulster"
    case "2"
    IsMpoID = "2"
    IsMpoName = "MHSTCC"
    case "3"
    IsMpoID = "3"
    IsMpoName = "N/STCC"
    case "4"
    IsMpoID = "4"
    IsMpoName = "NOCTS"
    case "5"
    IsMpoID = "5"
    IsMpoName = "NYCTCC"
    case "6"
    IsMpoID = "6"
    IsMpoName = "PDCTC"
    end select


    Dim pSql as String = ""
    pSql = "SELECT Phase.PinID, Phase.RecActivity, Phase.Phase, Phase.Amount, Phase.NFA_Amt,"
    pSql = pSql & "Phase.FFY, Phase.Obligated, Phase.FedApproval, Phase.Fund,"
    pSql = pSql & "STIP.Pin, STIP.CountyName, STIP.AreaType, STIP.Descript, STIP.Region,"
    pSql = pSql & "mpoProject.mpoPin, mpoProject.mpoName, mpoProject.Location, mpoProject.Distance,"
    pSql = pSql & "mpoProject.WorkType,"
    pSql = pSql & "mpoProject.Safety, mpoProject.FunctionClass, mpoProject.OnStateSystem,"
    pSql = pSql & "mpoProject.MilePostBegin,"
    pSql = pSql & "mpoProject.MilePostEnd, mpoProject.Let_Date, mpoProject.IsActive, mpoProject.Safety,"
    pSql = pSql & "mpoProject.ObligateDate,"
    pSql = pSql & "mpoProject.ProjManager, mpoProject.Map_Number, mpoProject.FundType,"
    pSql = pSql & "mpoProject.mpoAgency, mpoProject.Phase, mpoProject.Let_Date, mpoProject.CreatedDate,"
    pSql = pSql & "mpoProject.CreatedBy, mpoProject.Cost, mpoProject.MatchCost FROM STIP "
    pSql = pSql & "INNER JOIN mpoProject ON STIP.Pin = mpoProject.mpoPIN "
    pSql = pSql & "INNER JOIN Phase ON mpoProject.mpoPin = Phase.PinID where mpoNameCode = " & MpoID
    .dbSQL = pSql

    Dim caTbls as string = ""
    caTbls = "index=mpoNamex|sql=SELECT mpoName FROM mpoNames;"
    caTbls = caTbls & "index=mpoPinx|sql=SELECT Pin FROM Stip;"
    caTbls = caTbls & "index=IsActivex|sql=SELECT IsActive FROM MpoProject;"
    caTbls = caTbls & "index=WorkTypex|sql=SELECT WorkType FROM mpoWorkTypes where TypeName = " & IsMpoID
    .dbCommonTables=caTbls

    Dim eaFlds as string = ""
    eaFlds = "field=mpoPin|type=text size=8|tex=mpoPinx,"
    eaFlds = eaFlds & "field=IsActive|type=Radio|val=tf,"
    eaFlds = eaFlds & "field=WorkType|type=SelectBox|tex=WorkTypex,"
    eaFlds = eaFlds & "field=mpoName|type=ROAdd|Def = " & IsMpoName
    .dbEditAddFlds=eaFlds




    .aspDBNet()
    end with

    End Sub
    </script>


    I'm passing a variable to .dbCommonTables from the mpoID = GD.Get_SelectBoxSelection(70) statement.
    The dropdown produced by the .dbEditAddFlds should contain the appropriate selections. It doesn't rather it constantly defaults to the initial GD.Get_SelectBoxSelection(70)selection.

    I know it difficult to understand everyones code and I appreciate your trying to help.....

  8. #8
    Join Date
    Oct 2002
    Posts
    933
    the code is not good to debug. how about this...

    describe the NWIND process like ->

    1. User drop to allow selection of emplyee ID

    2. Use employeeID to create a commonlist for drop down in add

    3...

    4...

    I'll modify the sample NWIND code to reflect that.

    Looks like you select a value and then use it to query a new drop down...
    let me see about that.


    I think I undestand the problem ... I'll take a look at that


    FK

  9. #9
    Join Date
    Oct 2002
    Posts
    933
    The dbCommonTable can only be executes ONCE and that is why a second modificationis rejected...

    I'll see about a solution to this and see whether there is another way to do that rather than make the dbCommonTable dynamic.


    FK

  10. #10
    Join Date
    Dec 2002
    Location
    Albany, NY
    Posts
    115
    OK,

    1. Initial screen is a selection from mpo string.

    2. Upon "Add" button being pressed the add record screen appears with the criteria listed in .dbEditAddFlds.

    3. I need .dbCommonTables to produce a dropdown of selections based on users selection from GD.Get_SelectBoxSelection(7).

    4. Look at the .dbCommonTables index - WorkTypesx. The sql = SELECT WorkType FROM mpoWorkTypes WHERE TypeName = & IsMpoID

    This is the area of code I can not get to work. When the Add Record screen is called it appears that the WHERE clause is ignored.

    Does this help?

  11. #11
    Join Date
    Oct 2002
    Posts
    933
    I add code to detect a change in the dbCommonTable property and if there is a change then I re-process the Commontables. That would make it dynamic and seems to work. I'll make more test before I make a patch release.

    FK

  12. #12
    Join Date
    Oct 2002
    Posts
    933
    As I looked into this application, it is very interesting indeed. It is actually not simple at all. The following is an analysis and a solution ->

    1. Module #1 changes the SQL when selected and it actually creates a NEW module #2.

    2. When you click on Module #2 (navigation or Editing), it is a PostBack operation with Module #1 as an inactive module.

    3. To make things worse, The SQL and dropdowns are both modified according to the M1 selection.

    4. Besides the DropDowns, we also perform a LookUp in the Grid and also perform a ReadOnly ADD with a LookUp in the Edit Form's EmployeeID. This is not trival at all.

    5. I decided not to auto detect the SQL change to force a NEW and instead leave it to the users because there might be other conditions that requires a NEW like identical SQL for a different DSN.

    6. Would really like to see somebody do this using the VS stuff and see how far they can go !!!

    Solution ->

    * Make the dbCommonTable dynamic by detecting the change in the property.

    * When M1 is clicked, force M2 to be a "New" entry.

    * When M2 is clicked, display the inactive M1 and treat M2 as active and PostBack.

    All these we can do it in 26 lines of code as below. Contact support to get this patch DLL for testing.

    Dim Emp As String = "Nancy,Andrew,Janet,Margret,Steven,Micheal,Robert, Laura,Anne"
    Dim ID, Box6, Condition As String
    Dim GD As New Tornado.Getdata()
    Dim LastUnit As String = GD.Get_Unit
    Dim M1 As New Tornado.Z()
    '... Create SBox
    With M1
    .dbQP = "U=6| M=ty=SBox!SboxMacro=({{1,2,3,4,5,6,7,8,9}}~{{" & Emp & "}})"
    .dbTextHolder = "Title=Select an Employee"
    .ASPdbNET()
    End With
    '... if Sbox is clicked then save the screen for inactive display
    Condition = "" '... PostBack
    If LastUnit = "6" Or Session("Box6") = "" Then
    Session("Box6") = "<Center>" & GD.Get_Sbox(6) & "</center>"
    Session("ID") = GD.Get_SelectBoxSelection(6)
    Condition = "New=True" 'New Entry - SQL changed
    End If
    '... display active or inactive Sbox
    Response.Write(Session("Box6"))
    Dim EmpArr As String() = Split(Emp, ",")
    Dim M2 As New Tornado.Z()
    With M2
    '... build SQL and drop list according to selected value
    .dbQP = "U=7| M=Grid| ps=5| D=NWIND| ni=b5,add| gdf=0,1,2,3,7|Bm=orders;0| Q=Select * FROM Orders where EmployeeID = " & Session("ID")
    .dbEditAddFlds = "fi=EmployeeID|Ty=ROADD|Def=" & Session("ID") & ", fi=CustomerID|ty=SelectBox|val=cusID"
    .dbCommonTables = "i=cusID|sql=SELECT CustomerID FROM Orders where EmployeeID = " & Session("ID") & "; ind=empID,empName| sql=SELECT employeeid, lastname FROM Employees"
    .dbLookUpFlds = "fi=employeeid|key=empID|Look=empName"
    .ASPdbNET(Condition)
    End With

  13. #13
    Join Date
    Dec 2002
    Location
    Albany, NY
    Posts
    115
    Frank,

    Success!!!!!!!!!! Your Tornado modifications were right on target, you hit the bullseye. Not only that but through your excellent demonstration program I was able to make the required modification to my code in minutes. My project is now "back on schedule".

    Not only is Tornado the superior product but the support that Frank and company provide extends way beyond what is expected. Where else would a product be modified, tested and rolled out for production in less then a day? I have been involved in programming for 18 years and have never experienced such excellent support. And that is why the Tornado product is the best WEB development environment we have.

    Take a bow Frank, Tornado has just evolved, again..... Paul Mancuso

  14. #14
    Join Date
    Oct 2002
    Posts
    933
    Paul,

    Thanks for the kind remarks. I guess our job is to make it work. Inputs like yours force us to improve the product hence makes it stronger every day.


    Frank

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •