<%
OpenConnection1
Set rs=Server.CreateObject("ADODB.Recordset")
Sel="SELECT * FROM Customers WHERE CustomerID=" & CustomerID
If Request.Form("hidSave")="true" then
txtFname=dbReplace(Trim(Request.Form("txtFname")))
txtLname=dbReplace(Trim(Request.Form("txtLname")))
txtCompany=dbReplace(Trim(Request.Form("txtCompany")))
txtBusiness=dbReplace(Trim(Request.Form("txtBusiness")))
nEmployees=Trim(Request.Form("nEmployees"))
txtTitle=dbReplace(Trim(Request.Form("txtTitle")))
txtEmail=dbReplace(Trim(Request.Form("txtEmail")))
txtPhone=dbReplace(Trim(Request.Form("txtPhone")))
txtFax=dbReplace(Trim(Request.Form("txtFax")))
txtURL=dbReplace(Trim(Request.Form("txtURL")))
txtAddress=dbReplace(Trim(Request.Form("txtAddress")))
txtCity=dbReplace(Trim(Request.Form("txtCity")))
txtProvince=dbReplace(Trim(Request.Form("txtProvince")))
nCountry=dbReplace(Trim(Request.Form("selCountry")))
txtPostal=dbReplace(Trim(Request.Form("txtPostal")))
txtSAddress=dbReplace(Trim(Request.Form("txtSAddress")))
txtSCity=dbReplace(Trim(Request.Form("txtSCity")))
txtSProvince=dbReplace(Trim(Request.Form("txtSProvince")))
nSCountry=dbReplace(Trim(Request.Form("selSCountry")))
txtSPostal=dbReplace(Trim(Request.Form("txtSPostal")))
txtComments=dbReplace(Trim(Request.Form("txtComments")))
txtUsername=Trim(Request.Form("txtUsername"))
txtPassword=Trim(Request.Form("txtPassword"))
error=""
error2=""
If txtFname="" then error="...a First Name "
If txtLname="" then error=error & "...a Last Name "
If txtEmail="" then
error=error & "...an Email Address "
Else
If IsValidEmail(txtEmail)=False then error2="The Email Address entered is not valid. Format example: you@somewhere.com "
End If
If nEmployees<>"" then
If IsNumeric(nEmployees)=False then error2=error2 & "The Employees field must be numeric. "
End If
If txtUsername="" then
error=error&"...a User Name "
End If
If txtPassword="" then
error=error&"...a Password "
End If
If error="" And error2="" then
rs.Open Sel,DB,1,3
If rs.EOF then Response.Redirect("Customer_List.asp")
rs("txtFname")=txtFname
rs("txtLname")=txtLname
rs("txtCompany")=txtCompany
rs("txtBusiness")=txtBusiness
If nEmployees<>"" then rs("nEmployees")=nEmployees
rs("txtTitle")=txtTitle
rs("txtEmail")=txtEmail
rs("txtPhone")=txtPhone
rs("txtFax")=txtFax
rs("txtURL")=txtURL
rs("txtAddress")=txtAddress
rs("txtCity")=txtCity
rs("txtProvince")=txtProvince
rs("nCountry")=nCountry
rs("txtPostal")=txtPostal
rs("txtSAddress")=txtSAddress
rs("txtSCity")=txtSCity
rs("txtSProvince")=txtSProvince
rs("txtSPostal")=txtSPostal
rs("nSCountry")=nSCountry
rs("txtComments")=txtComments
rs("txtUsername")=txtUsername
rs("txtPassword")=txtPassword
rs.Update
rs.Close
Response.Redirect("Customer_Details.asp?CID=" & CustomerID)
End If
Else
rs.Open Sel,DB,1,3
If rs.EOF then Response.Redirect("Customer_List.asp")
txtFname=rs("txtFname")
txtLname=rs("txtLname")
txtCompany=rs("txtCompany")
txtBusiness=rs("txtBusiness")
nEmployees=rs("nEmployees")
txtTitle=rs("txtTitle")
txtEmail=rs("txtEmail")
txtPhone=rs("txtPhone")
txtFax=rs("txtFax")
txtURL=rs("txtURL")
txtAddress=rs("txtAddress")
txtCity=rs("txtCity")
txtProvince=rs("txtProvince")
nCountry=rs("nCountry")
txtPostal=rs("txtPostal")
txtSAddress=rs("txtSAddress")
txtSCity=rs("txtSCity")
txtSProvince=rs("txtSProvince")
txtSPostal=rs("txtSPostal")
nSCountry=rs("nSCountry")
If Trim(rs("txtComments"))<>"" then
txtComments=DisPrepText(rs("txtComments"))
End If
txtUsername=rs("txtUserName")
txtPassword=rs("txtPassword")
rs.Close
End If
If error<>"" then%>
Customer details cannot be saved without: <%=error%> |
<%End If
If error2<>"" then%>
| <%=error2%> |
<%End If%>
|