<%
'
'    Filename: relcliinstallconvporte.asp
'    Generated with CodeCharge 2.0.5
'    ASP 2.0.ccp build 01/22/2002
'

'-------------------------------
' relcliinstallconvporte CustomIncludes begin
%>

<!-- #INCLUDE FILE="Common.asp" -->
<!-- #INCLUDE FILE="Menu.asp" -->

<%
' relcliinstallconvporte CustomIncludes end
'-------------------------------

'===============================
' Save Page and File Name available into variables
'-------------------------------
sFileName = "relcliinstallconvporte.asp"
'===============================


'===============================
' relcliinstallconvporte PageSecurity begin
CheckSecurity(1)
' relcliinstallconvporte PageSecurity end
'===============================

'===============================
' relcliinstallconvporte Open Event start
' relcliinstallconvporte Open Event end
'===============================

'===============================
' relcliinstallconvporte OpenAnyPage Event start
' relcliinstallconvporte OpenAnyPage Event end
'===============================

'===============================
' Save the name of the form and type of action into the variables
'-------------------------------
sAction = GetParam("FormAction")
sForm = GetParam("FormName")
'===============================

' relcliinstallconvporte Show begin

'===============================
' Page execution
'-------------------------------
'Initialize error variables
'-------------------------------
srelcliinstallconvporte1Err = ""

'-------------------------------
' Select the FormAction
'-------------------------------
Select Case sForm
  Case "relcliinstallconvporte1"
    relcliinstallconvporte1Action(sAction)
end select
'===============================

'===============================
' HTML Page layout
'-------------------------------
%><html>
<head>
<title>EB Customers 1.09</title>
<meta name="GENERATOR" content="YesSoftware CodeCharge v.2.0.5 build 01/22/2002">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"></head>
<body style="background-color: #FFFFFF; color: #000000">

 <table>
  <tr>
   <td valign="top">
 <% MenuGeneral2_Show %>
   
   </td>
  </tr>
 </table>
 <table>
  <tr>
   <td valign="top">
 <% MenuGeneral_Show %>
   
   </td>
  </tr>
 </table>

 <table>
  <tr>
   
   <td valign="top">
<% RetourInstall1_Show %>
    
   </td>
  </tr>
 </table>
 <table>
  <tr>
   <td valign="top">
<% relcliinstallconvporte_Show %>
    
   </td>
  </tr>
 </table>
 <table>
  <tr>
   <td valign="top">
<% relcliinstallconvporte1_Show %>
    
   </td>
  </tr>
 </table>


</body>
</html>
<%
' relcliinstallconvporte Show end

' relcliinstallconvporte Close Event start
' relcliinstallconvporte Close Event end

'-------------------------------
' Destroy connection object
'-------------------------------
cn.close
Set cn = nothing
'===============================


'********************************************************************************


'===============================
' Display Grid Form
'-------------------------------
Sub relcliinstallconvporte_Show()
'-------------------------------
' Initialize variables  
'-------------------------------
  Dim rs
  Dim sWhere : sWhere = ""
  Dim sOrder : sOrder = ""
  Dim sSQL : sSQL = ""
  Dim sFormTitle: sFormTitle = "Portes propre"
  Dim HasParam : HasParam = false
  Dim bReq : bReq = true
  Dim iSort : iSort = ""
  Dim iSorted : iSorted = ""
  Dim sDirection : sDirection = ""
  Dim form_sorting : form_sorting = ""
  Dim sSortParams : sSortParams = ""
  Dim form_action : form_action = ""
  Dim iRecordsPerPage : iRecordsPerPage = 50
  Dim iCounter : iCounter = 0
  Dim iPage : iPage = 0
  Dim bEof : bEof = False
  Dim sActionFileName : sActionFileName = "relcliinstallconvporte.asp"

  Dim transit_params : transit_params = "idCli=" & ToURL(GetParam("idCli")) & "&idInst=" & ToURL(GetParam("idInst")) & "&idInstConv=" & ToURL(GetParam("idInstConv")) & "&"
  Dim form_params : form_params = "idCli=" & ToURL(GetParam("idCli")) & "&idInst=" & ToURL(GetParam("idInst")) & "&idInstConv=" & ToURL(GetParam("idInstConv")) & "&"

'-------------------------------
' Build ORDER BY statement
'-------------------------------
  sOrder = " order by r.idInstConv Asc"
  iSort = GetParam("Formrelcliinstallconvporte_Sorting")
  iSorted = GetParam("Formrelcliinstallconvporte_Sorted")
  sDirection = ""
  if IsEmpty(iSort) then
    form_sorting = ""
  else
    if iSort = iSorted then 
      form_sorting = ""
      sDirection = " DESC"
      sSortParams = "Formrelcliinstallconvporte_Sorting=" & iSort & "&Formrelcliinstallconvporte_Sorted=" & iSort & "&"
    else
      form_sorting = iSort
      sDirection = " ASC"
      sSortParams = "Formrelcliinstallconvporte_Sorting=" & iSort & "&Formrelcliinstallconvporte_Sorted=" & "&"
    end if
    if iSort = 1 then sOrder = " order by t.Name" & sDirection
    if iSort = 2 then sOrder = " order by r.numB2K" & sDirection
    if iSort = 3 then sOrder = " order by t1.Name" & sDirection
    if iSort = 4 then sOrder = " order by r.ModelePcPorte" & sDirection
    if iSort = 5 then sOrder = " order by r.SNPcPorte" & sDirection
    if iSort = 6 then sOrder = " order by r.emplacementCle" & sDirection
  end if

'-------------------------------
' HTML column headers
'-------------------------------
%>
     <table style="border: 1px solid #C0C0C0">
      <tr>
       <td style="text-align: Center; background-color: #000000; border: 1px solid #C0C0C0" colspan="6"><a name="relcliinstallconvporte"><font style="font-size: 12pt; color: #FFFFFF; font-weight: bold; font-family: Arial, Tahoma, Verdana, Helvetica"><%=sFormTitle%></font></a></td>
      </tr>
      <tr>
       <td style="background-color: #8CA6CE"><a href="<%=sFileName%>?<%=form_params%>Formrelcliinstallconvporte_Sorting=1&Formrelcliinstallconvporte_Sorted=<%=form_sorting%>&"><font style="color: #000000; font-size: 10pt; font-weight: bold; font-family: Arial, Tahoma, Verdana, Helvetica">idTypeExtraction</font></a></td>
       <td style="background-color: #8CA6CE"><a href="<%=sFileName%>?<%=form_params%>Formrelcliinstallconvporte_Sorting=2&Formrelcliinstallconvporte_Sorted=<%=form_sorting%>&"><font style="color: #000000; font-size: 10pt; font-weight: bold; font-family: Arial, Tahoma, Verdana, Helvetica">numB2K</font></a></td>
       <td style="background-color: #8CA6CE"><a href="<%=sFileName%>?<%=form_params%>Formrelcliinstallconvporte_Sorting=3&Formrelcliinstallconvporte_Sorted=<%=form_sorting%>&"><font style="color: #000000; font-size: 10pt; font-weight: bold; font-family: Arial, Tahoma, Verdana, Helvetica">idTypePcPorte</font></a></td>
       <td style="background-color: #8CA6CE"><a href="<%=sFileName%>?<%=form_params%>Formrelcliinstallconvporte_Sorting=4&Formrelcliinstallconvporte_Sorted=<%=form_sorting%>&"><font style="color: #000000; font-size: 10pt; font-weight: bold; font-family: Arial, Tahoma, Verdana, Helvetica">ModelePcPorte</font></a></td>
       <td style="background-color: #8CA6CE"><a href="<%=sFileName%>?<%=form_params%>Formrelcliinstallconvporte_Sorting=5&Formrelcliinstallconvporte_Sorted=<%=form_sorting%>&"><font style="color: #000000; font-size: 10pt; font-weight: bold; font-family: Arial, Tahoma, Verdana, Helvetica">SNPcPorte</font></a></td>
       <td style="background-color: #8CA6CE"><a href="<%=sFileName%>?<%=form_params%>Formrelcliinstallconvporte_Sorting=6&Formrelcliinstallconvporte_Sorted=<%=form_sorting%>&"><font style="color: #000000; font-size: 10pt; font-weight: bold; font-family: Arial, Tahoma, Verdana, Helvetica">emplacementCle</font></a></td>
      </tr>
<%

'-------------------------------
' Build WHERE statement
'-------------------------------
  pidCli = GetParam("idCli")
  if IsNumeric(pidCli) and not isEmpty(pidCli) then pidCli = ToSQL(pidCli, "Number") else pidCli = Empty
  if not isEmpty(pidCli) then
    HasParam = true
    sWhere = sWhere & "r.idCli=" & pidCli
  else
    bReq = false
  end if
  pidInst = GetParam("idInst")
  if IsNumeric(pidInst) and not isEmpty(pidInst) then pidInst = ToSQL(pidInst, "Number") else pidInst = Empty
  if not isEmpty(pidInst) then
    if not (sWhere = "") then sWhere = sWhere & " and "
    HasParam = true
    sWhere = sWhere & "r.idInst=" & pidInst
  else
    bReq = false
  end if
  pidInstConv = GetParam("idInstConv")
  if IsNumeric(pidInstConv) and not isEmpty(pidInstConv) then pidInstConv = ToSQL(pidInstConv, "Number") else pidInstConv = Empty
  if not isEmpty(pidInstConv) then
    if not (sWhere = "") then sWhere = sWhere & " and "
    HasParam = true
    sWhere = sWhere & "r.idInstConv=" & pidInstConv
  else
    bReq = false
  end if


  if HasParam then
    sWhere = " AND (" & sWhere & ")"
  end if

'-------------------------------
' Build base SQL statement
'-------------------------------
  sSQL = "select r.ModelePcPorte as r_ModelePcPorte, " & _
    "r.SNPcPorte as r_SNPcPorte, " & _
    "r.emplacementCle as r_emplacementCle, " & _
    "r.id as r_id, " & _
    "r.idCli as r_idCli, " & _
    "r.idInst as r_idInst, " & _
    "r.idInstConv as r_idInstConv, " & _
    "r.idTypeExtraction as r_idTypeExtraction, " & _
    "r.idTypePcPorte as r_idTypePcPorte, " & _
    "r.numB2K as r_numB2K, " & _
    "t.id as t_id, " & _
    "t.Name as t_Name, " & _
    "t1.id as t1_id, " & _
    "t1.Name as t1_Name " & _
    " from relcliinstallconvporte r, typeextraction t, typepcporte t1" & _
    " where t.id=r.idTypeExtraction and t1.id=r.idTypePcPorte  "
'-------------------------------

'-------------------------------
' relcliinstallconvporte Open Event start
' relcliinstallconvporte Open Event end
'-------------------------------

'-------------------------------
' Assemble full SQL statement
'-------------------------------
  sSQL = sSQL & sWhere & sOrder
'-------------------------------

'-------------------------------
' Process the link to the record page
'-------------------------------
form_action = sActionFileName
'-------------------------------

'-------------------------------
' Process if form has all required parameter
'-------------------------------
  if not bReq then
%>
     <tr>
      <td colspan="6" style="background-color: #DDE4F0"><font style="color: #000000; font-size: 10pt; font-family: Arial, Tahoma, Verdana, Helvetica">No records</font></td>
     </tr>
    </table>
<%
    exit sub
  end if
'-------------------------------


'-------------------------------
' Open the recordset
'-------------------------------
  openrs rs, sSQL
'-------------------------------

'-------------------------------
' Process empty recordset
'-------------------------------
  if rs.eof then
%>
     <tr>
      <td colspan="6" style="background-color: #DDE4F0"><font style="color: #000000; font-size: 10pt; font-family: Arial, Tahoma, Verdana, Helvetica">No records</font></td>
     </tr>
<%
  end if
'-------------------------------

'-------------------------------
'Initialize page counter and records per page
'-------------------------------
  iRecordsPerPage = 50
  iCounter = 0

'-------------------------------
' Process page scroller
'-------------------------------
  iPage = GetParam("Formrelcliinstallconvporte_Page")
  if IsEmpty(iPage) then iPage = 1 else iPage = CLng(iPage)
  while not rs.eof and iCounter < (iPage-1)*iRecordsPerPage
    rs.movenext
		iCounter = iCounter + 1
  wend
  iCounter = 0
'-------------------------------

'-------------------------------
' Display grid based on recordset
'-------------------------------
  while not rs.EOF  and iCounter < iRecordsPerPage
'-------------------------------
' Create field variables based on database fields
'-------------------------------
    fldemplacementCle = GetValue(rs, "r_emplacementCle")
    fldid = GetValue(rs, "r_id")
    fldidCli = GetValue(rs, "r_idCli")
    fldidInst = GetValue(rs, "r_idInst")
    fldidInstConv = GetValue(rs, "r_idInstConv")
    fldidTypeExtraction_URLLink = "relcliinstallconvporte.asp"
    fldidTypeExtraction_id = GetValue(rs, "r_id")
    fldidTypeExtraction = GetValue(rs, "t_Name")
    fldidTypePcPorte = GetValue(rs, "t1_Name")
    fldModelePcPorte = GetValue(rs, "r_ModelePcPorte")
    fldnumB2K = GetValue(rs, "r_numB2K")
    fldSNPcPorte = GetValue(rs, "r_SNPcPorte")
'-------------------------------
' relcliinstallconvporte Show begin
'-------------------------------

'-------------------------------
' relcliinstallconvporte Show Event start
' relcliinstallconvporte Show Event end
'-------------------------------

'-------------------------------
' Process the HTML controls
'-------------------------------
%>
      <tr>
       <td style="background-color: #DDE4F0"><font style="color: #000000; font-size: 10pt; font-family: Arial, Tahoma, Verdana, Helvetica"><a href="<%=fldidTypeExtraction_URLLink%>?id=<%=fldidTypeExtraction_id%>&<%=transit_params%>"><font style="color: #000000; font-size: 10pt; font-family: Arial, Tahoma, Verdana, Helvetica"><%=fldidTypeExtraction%></font></a>&nbsp;</font></td>
       <td style="background-color: #DDE4F0"><font style="color: #000000; font-size: 10pt; font-family: Arial, Tahoma, Verdana, Helvetica"><%=ToHTML(fldnumB2K)%>&nbsp;</font></td>
       <td style="background-color: #DDE4F0"><font style="color: #000000; font-size: 10pt; font-family: Arial, Tahoma, Verdana, Helvetica"><%=ToHTML(fldidTypePcPorte)%>&nbsp;</font></td>
       <td style="background-color: #DDE4F0"><font style="color: #000000; font-size: 10pt; font-family: Arial, Tahoma, Verdana, Helvetica"><%=ToHTML(fldModelePcPorte)%>&nbsp;</font></td>
       <td style="background-color: #DDE4F0"><font style="color: #000000; font-size: 10pt; font-family: Arial, Tahoma, Verdana, Helvetica"><%=ToHTML(fldSNPcPorte)%>&nbsp;</font></td>
       <td style="background-color: #DDE4F0"><font style="color: #000000; font-size: 10pt; font-family: Arial, Tahoma, Verdana, Helvetica"><%=ToHTML(fldemplacementCle)%>&nbsp;</font></td>
      </tr><%

'-------------------------------
' relcliinstallconvporte Show end
'-------------------------------

'-------------------------------
' Move to the next record and increase record counter
'-------------------------------
    rs.MoveNext
    iCounter = iCounter + 1
  wend
'-------------------------------

 
'-------------------------------
' Process the bottom on the Grid. The insert link and record navigator.
'-------------------------------
%>
    <tr>
     <td colspan="6" style="background-color: #8CA6CE"><font style="color: #000000; font-size: 10pt; font-weight: bold; font-family: Arial, Tahoma, Verdana, Helvetica"><a href="<%= form_action %>?<%= transit_params %>"><font style="color: #000000; font-size: 10pt; font-weight: bold; font-family: Arial, Tahoma, Verdana, Helvetica">Insert</font></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<%

'-------------------------------
' relcliinstallconvporte Navigation begin
'-------------------------------
  bEof = rs.eof
  if not(rs.EOF and iPage=1) then
    if iPage = 1 then
%>
        <font style="color: #000000; font-size: 10pt; font-weight: bold; font-family: Arial, Tahoma, Verdana, Helvetica">Previous</font>
<%
    else
%>
        <a href="<%=sFileName%>?<%=form_params%><%=sSortParams%>Formrelcliinstallconvporte_Page=<%=iPage - 1%>#relcliinstallconvporte"><font style="color: #000000; font-size: 10pt; font-weight: bold; font-family: Arial, Tahoma, Verdana, Helvetica">Previous</font></a>
<%
    end if
    response.write "&nbsp;[&nbsp;" & iPage & "&nbsp;]&nbsp;"
    
    if bEof then
%>
        <font style="color: #000000; font-size: 10pt; font-weight: bold; font-family: Arial, Tahoma, Verdana, Helvetica">Next</font>
<%
    else
%>
        <a href="<%=sFileName%>?<%=form_params%><%=sSortParams%>Formrelcliinstallconvporte_Page=<%=iPage + 1%>#relcliinstallconvporte"><font style="color: #000000; font-size: 10pt; font-weight: bold; font-family: Arial, Tahoma, Verdana, Helvetica">Next</font></a>
<%
    end if
  end if
'-------------------------------
' relcliinstallconvporte Navigation end
'-------------------------------
  
'-------------------------------
' Finish form processing
'-------------------------------  
  set rs = nothing

  %>
      </font></td></tr>
    </table>
  <%

'-------------------------------
' relcliinstallconvporte Close Event start
' relcliinstallconvporte Close Event end
'-------------------------------
end sub
'===============================
'===============================
' Action of the Record Form
'-------------------------------
Sub relcliinstallconvporte1Action(sAction)
'-------------------------------
' Initialize variables  
'-------------------------------
  Dim bExecSQL: bExecSQL = true
  Dim sActionFileName : sActionFileName = ""
  Dim sParams : sParams = "?"
  Dim sWhere : sWhere = "" 
  Dim bErr : bErr = False
  Dim pPKid : pPKid = ""
  Dim fldidTypeExtraction : fldidTypeExtraction = ""
  Dim fldnumB2K : fldnumB2K = ""
  Dim fldidTypePcPorte : fldidTypePcPorte = ""
  Dim fldModelePcPorte : fldModelePcPorte = ""
  Dim fldSNPcPorte : fldSNPcPorte = ""
  Dim fldemplacementCle : fldemplacementCle = ""
'-------------------------------

'-------------------------------
' relcliinstallconvporte1 Action begin
'-------------------------------
  sActionFileName = "relcliinstallconvporte.asp"
  sParams = sParams & "idCli=" & ToURL(GetParam("Trn_idCli")) & "&"
  sParams = sParams & "idInst=" & ToURL(GetParam("Trn_idInst")) & "&"
  sParams = sParams & "idInstConv=" & ToURL(GetParam("Trn_idInstConv"))

'-------------------------------
' CANCEL action
'-------------------------------
  if sAction = "cancel" then

'-------------------------------
' relcliinstallconvporte1 BeforeCancel Event start
' relcliinstallconvporte1 BeforeCancel Event end
'-------------------------------
    cn.Close
    Set cn = Nothing
    response.redirect sActionFileName & sParams
  end if
'-------------------------------

'-------------------------------
' Build WHERE statement
'-------------------------------
  if sAction = "update" or sAction = "delete" then
    pPKid = GetParam("PK_id")
    if IsEmpty(pPKid) then exit sub
    sWhere = "id=" & ToSQL(pPKid, "Number")
  end if
'-------------------------------


'-------------------------------
' Load all form fields into variables
'-------------------------------
  fldidCli = GetParam("Rqd_idCli")
  fldidInst = GetParam("Rqd_idInst")
  fldidInstConv = GetParam("Rqd_idInstConv")
  fldidTypeExtraction = GetParam("idTypeExtraction")
  fldnumB2K = GetParam("numB2K")
  fldidTypePcPorte = GetParam("idTypePcPorte")
  fldModelePcPorte = GetParam("ModelePcPorte")
  fldSNPcPorte = GetParam("SNPcPorte")
  fldemplacementCle = GetParam("emplacementCle")

'-------------------------------
' Validate fields
'-------------------------------
  if sAction = "insert" or sAction = "update" then
    if IsEmpty(fldidTypeExtraction) then
      srelcliinstallconvporte1Err = srelcliinstallconvporte1Err & "The value in field idTypeExtraction is required.<br>"
    end if
    if IsEmpty(fldidTypePcPorte) then
      srelcliinstallconvporte1Err = srelcliinstallconvporte1Err & "The value in field idTypePcPorte is required.<br>"
    end if
    if not isNumeric(fldidTypeExtraction) then
      srelcliinstallconvporte1Err = srelcliinstallconvporte1Err & "The value in field idTypeExtraction is incorrect.<br>"
    end if
    if not isNumeric(fldidTypePcPorte) then
      srelcliinstallconvporte1Err = srelcliinstallconvporte1Err & "The value in field idTypePcPorte is incorrect.<br>"
    end if
'-------------------------------
' relcliinstallconvporte1 Check Event start
' relcliinstallconvporte1 Check Event end
'-------------------------------
    If len(srelcliinstallconvporte1Err) > 0 then
      exit sub
    end if
  end if
'-------------------------------


'-------------------------------
' Create SQL statement
'-------------------------------
  select case sAction
    case "insert"
'-------------------------------
' relcliinstallconvporte1 Insert Event start
' relcliinstallconvporte1 Insert Event end
'-------------------------------
      sSQL = "insert into relcliinstallconvporte (" & _
          "idCli," & _
          "idInst," & _
          "idInstConv," & _
          "idTypeExtraction," & _
          "numB2K," & _
          "idTypePcPorte," & _
          "ModelePcPorte," & _
          "SNPcPorte," & _
          "emplacementCle)" & _
          " values (" & _
          ToSQL(fldidCli, "Number") & "," & _
          ToSQL(fldidInst, "Number") & "," & _
          ToSQL(fldidInstConv, "Number") & "," & _
          ToSQL(fldidTypeExtraction, "Number") & "," & _
          ToSQL(fldnumB2K, "Text") & "," & _
          ToSQL(fldidTypePcPorte, "Number") & "," & _
          ToSQL(fldModelePcPorte, "Text") & "," & _
          ToSQL(fldSNPcPorte, "Text") & "," & _
          ToSQL(fldemplacementCle, "Text") & _
          ")"
    case "update"
'-------------------------------
' relcliinstallconvporte1 Update Event start
' relcliinstallconvporte1 Update Event end
'-------------------------------
      sSQL = "update relcliinstallconvporte set " & _
        "idTypeExtraction=" & ToSQL(fldidTypeExtraction, "Number") & _
        ",numB2K=" & ToSQL(fldnumB2K, "Text") & _
        ",idTypePcPorte=" & ToSQL(fldidTypePcPorte, "Number") & _
        ",ModelePcPorte=" & ToSQL(fldModelePcPorte, "Text") & _
        ",SNPcPorte=" & ToSQL(fldSNPcPorte, "Text") & _
        ",emplacementCle=" & ToSQL(fldemplacementCle, "Text")
      sSQL = sSQL & " where " & sWhere
  end select
'-------------------------------
'-------------------------------
' relcliinstallconvporte1 BeforeExecute Event start
' relcliinstallconvporte1 BeforeExecute Event end
'-------------------------------

'-------------------------------
' Execute SQL statement
'-------------------------------
if len(srelcliinstallconvporte1Err) > 0 then Exit Sub
  on error resume next
  if bExecSQL then 
    cn.execute sSQL
  end if
  srelcliinstallconvporte1Err = ProcessError
  on error goto 0
  if len(srelcliinstallconvporte1Err) > 0 then Exit Sub
  cn.Close
  Set cn = Nothing
  response.redirect sActionFileName & sParams
'-------------------------------
' relcliinstallconvporte1 Action end
'-------------------------------
end sub
'===============================

'===============================
' Display Record Form
'-------------------------------
Sub relcliinstallconvporte1_Show()
'-------------------------------
' relcliinstallconvporte1 Show begin
'-------------------------------
  sWhere = ""
  Dim sFormTitle: sFormTitle = "Insert / Modify"
  bPK = true

%>
   
   <table style="border: 1px solid #C0C0C0">
   <form method="POST" action="<%= sFileName %>" name="relcliinstallconvporte1">
   <tr><td style="text-align: Center; background-color: #000000; border: 1px solid #C0C0C0" colspan="2"><font style="font-size: 12pt; color: #FFFFFF; font-weight: bold; font-family: Arial, Tahoma, Verdana, Helvetica"><%=sFormTitle%></font></td></tr>
   <% if not (srelcliinstallconvporte1Err = "") then %>
		<tr><td style="background-color: #DDE4F0" colspan="2"><font style="color: #000000; font-size: 10pt; font-family: Arial, Tahoma, Verdana, Helvetica"><%= srelcliinstallconvporte1Err %></font></td></tr>
	 <% end if %>
<% 

'-------------------------------
' Load primary key and form parameters
'-------------------------------
  if srelcliinstallconvporte1Err = "" then
    fldid = GetParam("id")
    fldidCli = GetParam("idCli")
    fldidInst = GetParam("idInst")
    fldidInstConv = GetParam("idInstConv")
    Trn_idCli = GetParam("idCli")
    Trn_idInst = GetParam("idInst")
    Trn_idInstConv = GetParam("idInstConv")
    Rqd_idCli = GetParam("idCli")
    Rqd_idInst = GetParam("idInst")
    Rqd_idInstConv = GetParam("idInstConv")
    pid = GetParam("id")
  else
    fldid = GetParam("id")
    fldidTypeExtraction = GetParam("idTypeExtraction")
    fldnumB2K = GetParam("numB2K")
    fldidTypePcPorte = GetParam("idTypePcPorte")
    fldModelePcPorte = GetParam("ModelePcPorte")
    fldSNPcPorte = GetParam("SNPcPorte")
    fldemplacementCle = GetParam("emplacementCle")
    Rqd_idCli = GetParam("Rqd_idCli")
    Rqd_idInst = GetParam("Rqd_idInst")
    Rqd_idInstConv = GetParam("Rqd_idInstConv")
    fldidCli = GetParam("Trn_idCli")
    Trn_idCli = GetParam("Trn_idCli")
    Trn_idInst = GetParam("Trn_idInst")
    Trn_idInstConv = GetParam("Trn_idInstConv")
    pid = GetParam("PK_id")
  end if
  
'-------------------------------
' Load all form fields

'-------------------------------

'-------------------------------
' Build WHERE statement

  if IsEmpty(pid) then bPK = False
  
  sWhere = sWhere & "id=" & ToSQL(pid, "Number")
  PK_id = pid
'-------------------------------
'-------------------------------
' relcliinstallconvporte1 Open Event start
' relcliinstallconvporte1 Open Event end
'-------------------------------

'-------------------------------
' Build SQL statement and open recordset
'-------------------------------
  sSQL = "select * from relcliinstallconvporte where " & sWhere
  openrs rs, sSQL
  bIsUpdateMode = (bPK and not(sAction = "insert" and sForm = "relcliinstallconvporte1") and not rs.eof)
'-------------------------------

'-------------------------------
' Load all fields into variables from recordset or input parameters
'-------------------------------
  if bIsUpdateMode then
    fldid = GetValue(rs, "id")
    fldidCli = GetValue(rs, "idCli")
    fldidInst = GetValue(rs, "idInst")
    fldidInstConv = GetValue(rs, "idInstConv")

'-------------------------------
' Load data from recordset when form displayed first time
'-------------------------------
    if srelcliinstallconvporte1Err = "" then
      fldidTypeExtraction = GetValue(rs, "idTypeExtraction")
      fldnumB2K = GetValue(rs, "numB2K")
      fldidTypePcPorte = GetValue(rs, "idTypePcPorte")
      fldModelePcPorte = GetValue(rs, "ModelePcPorte")
      fldSNPcPorte = GetValue(rs, "SNPcPorte")
      fldemplacementCle = GetValue(rs, "emplacementCle")
    end if
'-------------------------------
' relcliinstallconvporte1 ShowEdit Event start
' relcliinstallconvporte1 ShowEdit Event end
'-------------------------------
  else
    if srelcliinstallconvporte1Err = "" then
      fldid = ToHTML(GetParam("id"))
      fldidCli = ToHTML(GetParam("idCli"))
      fldidInst = ToHTML(GetParam("idInst"))
      fldidInstConv = ToHTML(GetParam("idInstConv"))
    end if
'-------------------------------
' relcliinstallconvporte1 ShowInsert Event start
' relcliinstallconvporte1 ShowInsert Event end
'-------------------------------
  end if

'-------------------------------
' Set lookup fields
'-------------------------------
  fldidCli = DLookUp("eb_clients", "FriendName", "id=" & ToSQL(fldidCli, "Number"))
  fldidInst = DLookUp("relcliinstall", "Description", "id=" & ToSQL(fldidInst, "Number"))
  fldidInstConv = DLookUp("relcliinstallconv", "numB2K", "id=" & ToSQL(fldidInstConv, "Number"))
'-------------------------------
' relcliinstallconvporte1 Show Event start
' relcliinstallconvporte1 Show Event end
'-------------------------------

'-------------------------------
' Show form fields
'-------------------------------
    %>
      <tr>
       <td style="background-color: #8CA6CE">
         <font style="; color: #000000; font-size: 10pt; font-family: Arial, Tahoma, Verdana, Helvetica">idCli</font>
       </td>
       <td style="background-color: #DDE4F0">
         <font style="color: #000000; font-size: 10pt; font-family: Arial, Tahoma, Verdana, Helvetica"><%=ToHTML(fldidCli)%></font>&nbsp;</td>
     </tr>
      <tr>
       <td style="background-color: #8CA6CE">
         <font style="; color: #000000; font-size: 10pt; font-family: Arial, Tahoma, Verdana, Helvetica">idInst</font>
       </td>
       <td style="background-color: #DDE4F0">
         <font style="color: #000000; font-size: 10pt; font-family: Arial, Tahoma, Verdana, Helvetica"><%=ToHTML(fldidInst)%></font>&nbsp;</td>
     </tr>
      <tr>
       <td style="background-color: #8CA6CE">
         <font style="; color: #000000; font-size: 10pt; font-family: Arial, Tahoma, Verdana, Helvetica">idInstConv</font>
       </td>
       <td style="background-color: #DDE4F0">
         <font style="color: #000000; font-size: 10pt; font-family: Arial, Tahoma, Verdana, Helvetica"><%=ToHTML(fldidInstConv)%></font>&nbsp;</td>
     </tr>
      <tr>
       <td style="background-color: #8CA6CE">
         <font style="; color: #000000; font-size: 10pt; font-family: Arial, Tahoma, Verdana, Helvetica">idTypeExtraction</font>
       </td>
       <td style="background-color: #DDE4F0">
         <font style="color: #000000; font-size: 10pt; font-family: Arial, Tahoma, Verdana, Helvetica"><select name="idTypeExtraction">
<%
      openrs rsidTypeExtraction, "select id, Name from typeextraction order by 2"
      while not rsidTypeExtraction.EOF
        if cstr(GetValue(rsidTypeExtraction, 0)) = cstr(fldidTypeExtraction) then
          response.write "<option selected value=""" & GetValue(rsidTypeExtraction, 0) & """>" & GetValue(rsidTypeExtraction, 1) & "</option>"
        else
          response.write "<option value=""" & GetValue(rsidTypeExtraction, 0) & """>" & GetValue(rsidTypeExtraction, 1) & "</option>"
        end if
        rsidTypeExtraction.MoveNext
      wend
      set rsidTypeExtraction = nothing
    
%></select></font></td>
     </tr>
      <tr>
       <td style="background-color: #8CA6CE">
         <font style="; color: #000000; font-size: 10pt; font-family: Arial, Tahoma, Verdana, Helvetica">numB2K</font>
       </td>
       <td style="background-color: #DDE4F0">
         <font style="color: #000000; font-size: 10pt; font-family: Arial, Tahoma, Verdana, Helvetica"><input type="text" name="numB2K" maxlength="10" value="<%= ToHTML(fldnumB2K) %>" size="10" ></font></td>
     </tr>
      <tr>
       <td style="background-color: #8CA6CE">
         <font style="; color: #000000; font-size: 10pt; font-family: Arial, Tahoma, Verdana, Helvetica">idTypePcPorte</font>
       </td>
       <td style="background-color: #DDE4F0">
         <font style="color: #000000; font-size: 10pt; font-family: Arial, Tahoma, Verdana, Helvetica"><select name="idTypePcPorte">
<%
      openrs rsidTypePcPorte, "select id, Name from typepcporte order by 2"
      while not rsidTypePcPorte.EOF
        if cstr(GetValue(rsidTypePcPorte, 0)) = cstr(fldidTypePcPorte) then
          response.write "<option selected value=""" & GetValue(rsidTypePcPorte, 0) & """>" & GetValue(rsidTypePcPorte, 1) & "</option>"
        else
          response.write "<option value=""" & GetValue(rsidTypePcPorte, 0) & """>" & GetValue(rsidTypePcPorte, 1) & "</option>"
        end if
        rsidTypePcPorte.MoveNext
      wend
      set rsidTypePcPorte = nothing
    
%></select></font></td>
     </tr>
      <tr>
       <td style="background-color: #8CA6CE">
         <font style="; color: #000000; font-size: 10pt; font-family: Arial, Tahoma, Verdana, Helvetica">ModelePcPorte</font>
       </td>
       <td style="background-color: #DDE4F0">
         <font style="color: #000000; font-size: 10pt; font-family: Arial, Tahoma, Verdana, Helvetica"><input type="text" name="ModelePcPorte" maxlength="50" value="<%= ToHTML(fldModelePcPorte) %>" size="50" ></font></td>
     </tr>
      <tr>
       <td style="background-color: #8CA6CE">
         <font style="; color: #000000; font-size: 10pt; font-family: Arial, Tahoma, Verdana, Helvetica">SNPcPorte</font>
       </td>
       <td style="background-color: #DDE4F0">
         <font style="color: #000000; font-size: 10pt; font-family: Arial, Tahoma, Verdana, Helvetica"><input type="text" name="SNPcPorte" maxlength="50" value="<%= ToHTML(fldSNPcPorte) %>" size="50" ></font></td>
     </tr>
      <tr>
       <td style="background-color: #8CA6CE">
         <font style="; color: #000000; font-size: 10pt; font-family: Arial, Tahoma, Verdana, Helvetica">emplacementCle</font>
       </td>
       <td style="background-color: #DDE4F0">
         <font style="color: #000000; font-size: 10pt; font-family: Arial, Tahoma, Verdana, Helvetica"><input type="text" name="emplacementCle" maxlength="255" value="<%= ToHTML(fldemplacementCle) %>" size="50" ></font></td>
     </tr>
    <tr><td colspan="2" align="right"><% if not bIsUpdateMode then %>
   <input type="hidden" value="insert" name="FormAction">
   <input type="submit" value="Insert" onclick="document.relcliinstallconvporte1.FormAction.value = 'insert';">
<% end if %>
<% if bIsUpdateMode then %>
  <input type="hidden" value="update" name="FormAction"/>
  <input type="submit" value="Update" onclick="document.relcliinstallconvporte1.FormAction.value = 'update';">
<% end if %>
  <input type="submit" value="Cancel" onclick="document.relcliinstallconvporte1.FormAction.value = 'cancel';">
  <input type="hidden" name="FormName" value="relcliinstallconvporte1">
  
  <input type="hidden" name="Trn_idCli" value="<%= Trn_idCli %>">
  <input type="hidden" name="Trn_idInst" value="<%= Trn_idInst %>">
  <input type="hidden" name="Trn_idInstConv" value="<%= Trn_idInstConv %>">
  <input type="hidden" name="Rqd_idCli" value="<%= Rqd_idCli %>";>
  <input type="hidden" name="Rqd_idInst" value="<%= Rqd_idInst %>";>
  <input type="hidden" name="Rqd_idInstConv" value="<%= Rqd_idInstConv %>";>
  <input type="hidden" name="PK_id" value="<%= pid %>">  
  <input type="hidden" name="id" value="<%= ToHTML(fldid)%>">
  </td></tr>
  </form>
  </table>
<%


'-------------------------------
' relcliinstallconvporte1 Close Event start
' relcliinstallconvporte1 Close Event end
'-------------------------------

Set rs = Nothing

'-------------------------------
' relcliinstallconvporte1 Show end
'-------------------------------
End Sub
'===============================


'===============================
' Display Grid Form
'-------------------------------
Sub RetourInstall1_Show()
'-------------------------------
' Initialize variables  
'-------------------------------
  Dim rs
  Dim sWhere : sWhere = ""
  Dim sOrder : sOrder = ""
  Dim sSQL : sSQL = ""
  Dim sFormTitle: sFormTitle = ""
  Dim HasParam : HasParam = false
  Dim iRecordsPerPage : iRecordsPerPage = 20
  Dim iCounter : iCounter = 0

  Dim transit_params : transit_params = ""
  Dim form_params : form_params = "idCli=" & ToURL(GetParam("idCli")) & "&idInst=" & ToURL(GetParam("idInst")) & "&"

'-------------------------------
' HTML column headers
'-------------------------------
%>
     <table style="border: 1px solid #C0C0C0">
      <tr>
       <td style="background-color: #8CA6CE"><font style="color: #000000; font-size: 10pt; font-weight: bold; font-family: Arial, Tahoma, Verdana, Helvetica">Installation</td>
      </tr>
<%

'-------------------------------
' Build WHERE statement
'-------------------------------
  pidCli = GetParam("idCli")
  if IsNumeric(pidCli) and not isEmpty(pidCli) then pidCli = ToSQL(pidCli, "Number") else pidCli = Empty
  if not isEmpty(pidCli) then
    HasParam = true
    sWhere = sWhere & "r.idCli=" & pidCli
  end if
  pidInst = GetParam("idInst")
  if IsNumeric(pidInst) and not isEmpty(pidInst) then pidInst = ToSQL(pidInst, "Number") else pidInst = Empty
  if not isEmpty(pidInst) then
    if not (sWhere = "") then sWhere = sWhere & " and "
    HasParam = true
    sWhere = sWhere & "r.id=" & pidInst
  end if


  if HasParam then
    sWhere = " AND (" & sWhere & ")"
  end if

'-------------------------------
' Build base SQL statement
'-------------------------------
  sSQL = "select r.id as r_id, " & _
    "r.idCli as r_idCli, " & _
    "r1.id as r1_id, " & _
    "r1.Description as r1_Description " & _
    " from relcliinstall r, relcliinstall r1" & _
    " where r1.id=r.id  "
'-------------------------------

'-------------------------------
' RetourInstall1 Open Event start
' RetourInstall1 Open Event end
'-------------------------------

'-------------------------------
' Assemble full SQL statement
'-------------------------------
  sSQL = sSQL & sWhere & sOrder
'-------------------------------


'-------------------------------
' Open the recordset
'-------------------------------
  openrs rs, sSQL
'-------------------------------

'-------------------------------
' Process empty recordset
'-------------------------------
  if rs.eof then
%>
     <tr>
      <td colspan="1" style="background-color: #DDE4F0"><font style="color: #000000; font-size: 10pt; font-family: Arial, Tahoma, Verdana, Helvetica">No records</font></td>
     </tr>
<%
  end if
'-------------------------------

'-------------------------------
'Initialize page counter and records per page
'-------------------------------
  iRecordsPerPage = 20
  iCounter = 0

'-------------------------------
' Display grid based on recordset
'-------------------------------
  while not rs.EOF  and iCounter < iRecordsPerPage
'-------------------------------
' Create field variables based on database fields
'-------------------------------
    fldid_URLLink = "relcliinstallconv.asp"
    fldid_idInst = GetValue(rs, "r_id")
    fldid_idCli = GetValue(rs, "r_idCli")
    fldid = GetValue(rs, "r1_Description")
'-------------------------------
' RetourInstall1 Show begin
'-------------------------------

'-------------------------------
' RetourInstall1 Show Event start
' RetourInstall1 Show Event end
'-------------------------------

'-------------------------------
' Process the HTML controls
'-------------------------------
%>
      <tr>
       <td style="background-color: #DDE4F0"><font style="color: #000000; font-size: 10pt; font-family: Arial, Tahoma, Verdana, Helvetica"><a href="<%=fldid_URLLink%>?idInst=<%=fldid_idInst%>&idCli=<%=fldid_idCli%>&<%=transit_params%>"><font style="color: #000000; font-size: 10pt; font-family: Arial, Tahoma, Verdana, Helvetica"><%=fldid%></font></a>&nbsp;</font></td>
      </tr><%

'-------------------------------
' RetourInstall1 Show end
'-------------------------------

'-------------------------------
' Move to the next record and increase record counter
'-------------------------------
    rs.MoveNext
    iCounter = iCounter + 1
  wend
'-------------------------------

 
  
'-------------------------------
' Finish form processing
'-------------------------------  
  set rs = nothing

  %>
    </table>
  <%

'-------------------------------
' RetourInstall1 Close Event start
' RetourInstall1 Close Event end
'-------------------------------
end sub
'===============================
%>