Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2004
    Posts
    5

    Unanswered: Desk Order System: Add record field at the right model id

    I have a very complicated (for me) logic to think of at this time.

    This system is production system (my new project, started a week ago). One of the module is desk order system. The logic is

    desk_order: desk_order_id
    desk_order_details: desk_order_detail_id, model_id, desk_order_id
    model: model_id, desk_order_id

    Pseudocode
    Code:
    select * from model
    if not eof then
      do while not eof
        select * from desk_order_details where model_id = strModelID (above)
        if not eof then
          do while not eof
            display desk order details record
            next
          loop
        end if
      next
      loop
    end if
    Actually, I have no problem if I were to either to display all records in group like above and seperate data entry page but the complicated area is combining both in one page. [view my attachment]

    When I click Add Item, the empty field should appear in that model_id, not all, which is my current problem at this time.

    My code is below (Sorry, if it's too long):

    Code:
    <%
    set rs_model = Server.CreateObject("ADODB.recordset")
    sql = "SELECT * FROM model"
    sql = sql & " WHERE desk_order_id = " & session("sDeskOrderID") & " " 
    rs_model.CursorLocation = 3				
    rs_model.Open sql, conn
    
    if not rs_model.eof then
      Do While not rs_model.eof
        strModelID = rs_model("model_id")
        strModelGName = rs_model("model_g_name")
        strModelCode = rs_model("model_code")
        %>
        <form name=myform action="deskorder_add_3.asp" method=post>
        <tr>
          <td colspan=11><br>Model general name: <%=strModelGName%> 
          [ <a href="" class=content>Edit</a> 
          | <a href="" class=content>Delete</a> 
          | <a href="deskorder_add_3_form.asp?passModelID=<%=strModelID%>&passAddItem=Y" class=content>Add item</a> ]
         </td>
        </tr>
        <tr><td colspan=11>Model code: <%=strModelCode%></td></tr>
        <%
        set rs_desk_order_d = Server.CreateObject("ADODB.recordset")
        sql = "SELECT * FROM desk_order_details"
        sql = sql & " WHERE desk_order_id = " & session("sDeskOrderID") & " "
        sql = sql & " AND model_id = " & strModelID & " "
        rs_desk_order_d.CursorLocation = 3
        rs_desk_order_d.Open sql, conn
    
        if not rs_desk_order_d.eof then
          DO while not rs_desk_order_d.eof
            %>
            <tr valign=top>
              <td><%=rs_desk_order_d("model_size")%></td>
              <td><%=rs_desk_order_d("model_size_d")%></td>
              <td><%=rs_desk_order_d("deduction")%></td>
              <td><%=rs_desk_order_d("clr")%></td>
              <td align=right><%=rs_desk_order_d("qty")%></td>
              <td align=right><%=formatnumber(rs_desk_order_d("customer_price"),2)%></td>
              <%
              if rs_desk_order_d("qty") > 0 then
                strCPrice = rs_desk_order_d("customer_price") * rs_desk_order_d("qty")
              else												
                strCPrice = 0
              end if				
              %>
              <td align=right><%=formatnumber(strCPrice,2)%></td>
              <td align=right><%=formatnumber(rs_desk_order_d("factory_price"),2)%></td>
              <%
              if rs_desk_order_d("qty") > 0 then
                strFPrice = rs_desk_order_d("factory_price") * rs_desk_order_d("qty")
              else
                strFPrice = 0
              end if
              %>
              <td align=right><%=formatnumber(strFPrice,2)%></td>
              <td><%=rs_desk_order_d("price_factor")%></td>
              <td>[ <a href="" class=content>Edit</a> | <a href="" class=content>X</a> ]</td>
            </tr>
            <%
            strTQty = strTQty + rs_desk_order_d("qty")
            strTCPrice = cdbl(strTCPrice) + cdbl(strCPrice)
            strTFPrice = cdbl(strTFPrice) + cdbl(strFPrice)
            'if there is at least one record already exist in that model id.
            modelIDtmp = request.querystring("passModelID")
            strPassAddItem = request.querystring("passAddItem")
            if strPassAddItem = "Y" and strmodelID = modelIDtmp then
              %>
              <tr valign=top>
                <td>
                  <input type=text name=model_size_fr>
                  <input type=hidden name=model_id_fr value="<%=strModelID%>">
                </td>
                <td><input type=text name=model_size_d_fr></td>
                <td><input type=text name=deduction_fr size=1></td>
                <td><input type=text name=clr_fr size=2></td>
                <td><input type=text name=qty_fr size=2></td>
                <td><input type=text name=customer_price_fr size=4></td>
                <td>&nbsp;</td>
                <td><input type=text name=factory_price_fr size=4></td>
                <td>&nbsp;</td>
                <td><input type=text name=price_factor_fr size=3></td>
                <td><input type=submit value="Save1"></td>
              </tr>
              <%
            end if
          rs_desk_order_d.movenext
          LOOP
        end if
        'for the first empty record to be added.
        strPassAddItem = request.querystring("passAddItem")
        if strPassAddItem = "Y" then		
          %>
          <tr valign=top>
            <td>
             <input type=text name=model_size_fr>
             <input type=hidden name=model_id_fr value="<%=strModelID%>">
            </td>
            <td><input type=text name=model_size_d_fr></td>
            <td><input type=text name=deduction_fr size=1></td>
            <td><input type=text name=clr_fr size=2></td>
            <td><input type=text name=qty_fr size=2></td>
            <td><input type=text name=customer_price_fr size=4></td>
            <td>&nbsp;</td>
            <td><input type=text name=factory_price_fr size=4></td>
            <td>&nbsp;</td>
            <td><input type=text name=price_factor_fr size=3></td>
            <td><input type=submit value="Save2"></td>
          </tr>
          <%
        end if
      rs_model.movenext
      LOOP
    end if
    %>
    Attached Thumbnails Attached Thumbnails print_screen.bmp  

  2. #2
    Join Date
    Jan 2004
    Posts
    5
    It's ok guys. I managed to solve it already. Hurray

Posting Permissions

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