PageRenderTime 40ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/CT/m004a0201.asp

http://github.com/boss2009/ASP-site
ASP | 258 lines | 250 code | 8 blank | 0 comment | 17 complexity | 34e18983dc301413a4c4e78165d90fea MD5 | raw file
  1. <%@language="JAVASCRIPT"%>
  2. <!--#include file="../inc/ASPUtility.inc" -->
  3. <!--#include file="../inc/ASPCheckLogin.inc" -->
  4. <!--#include file="../Connections/cnnASP02.asp" -->
  5. <%
  6. var MM_editAction = Request.ServerVariables("URL");
  7. if (Request.QueryString) {
  8. MM_editAction += "?" + Request.QueryString;
  9. }
  10. if (String(Request.Form("MM_Insert"))=="true") {
  11. var Address_type = ((String(Request.Form("AddressType")) == "Home")?"H":"W");
  12. var insAddress_type = ((String(Request.Form("AddressType")) == "Home")?"6":"11");
  13. var rsNewAddress = Server.CreateObject("ADODB.Recordset");
  14. rsNewAddress.ActiveConnection = MM_cnnASP02_STRING;
  15. rsNewAddress.Source="{call dbo.cp_Contact_Address("+Request.Form("intContact_id")+",0,'"+Address_type+"','"+String(Request.Form("StreetAddress")).replace(/'/g, "''")+"','"+String(Request.Form("City")).replace(/'/g, "''") + "',"+ Request.Form("Province") + ",'"+ Request.Form("PostalCode") + "',"+ Request.Form("PrimaryPhoneType") + ",'"+ Request.Form("PrimaryPhoneAreaCode") + "','"+ Request.Form("PrimaryPhoneNumber") + "','"+ Request.Form("PrimaryPhoneExtension") + "',"+ Request.Form("SecondaryPhoneType") + ",'"+ Request.Form("SecondaryPhoneAreaCode")+ "','"+Request.Form("SecondaryPhoneNumber")+"','"+Request.Form("SecondaryPhoneExtension")+"',0,'','','','"+ Request.Form("EMail") + "','"+ String(Request.Form("Notes")).replace(/'/g, "''") + "',"+ insAddress_type + ",0,'A',0)}";
  16. rsNewAddress.CursorType = 0;
  17. rsNewAddress.CursorLocation = 2;
  18. rsNewAddress.LockType = 3;
  19. rsNewAddress.Open();
  20. Response.Redirect("InsertSuccessful.html");
  21. }
  22. var rsProvince = Server.CreateObject("ADODB.Recordset");
  23. rsProvince.ActiveConnection = MM_cnnASP02_STRING;
  24. rsProvince.Source = "{call dbo.cp_Prov_State}";
  25. rsProvince.CursorType = 0;
  26. rsProvince.CursorLocation = 2;
  27. rsProvince.LockType = 3;
  28. rsProvince.Open();
  29. var rsPhoneType = Server.CreateObject("ADODB.Recordset");
  30. rsPhoneType.ActiveConnection = MM_cnnASP02_STRING;
  31. rsPhoneType.Source = "{call dbo.cp_Phone_Type}";
  32. rsPhoneType.CursorType = 0;
  33. rsPhoneType.CursorLocation = 2;
  34. rsPhoneType.LockType = 3;
  35. rsPhoneType.Open();
  36. var rsAreaCode = Server.CreateObject("ADODB.Recordset");
  37. rsAreaCode.ActiveConnection = MM_cnnASP02_STRING;
  38. rsAreaCode.Source = "{call dbo.cp_area_code(0,'',0,2,'Q',0)}";
  39. rsAreaCode.CursorType = 0;
  40. rsAreaCode.CursorLocation = 2;
  41. rsAreaCode.LockType = 3;
  42. rsAreaCode.Open();
  43. %>
  44. <html>
  45. <head>
  46. <title>New <%=((Request.QueryString("AddressType")=="Home")?"Home":"Work")%> Address</title>
  47. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  48. <link rel="stylesheet" href="../css/MyStyle.css" type="text/css">
  49. <script language="Javascript" src="../js/MyFunctions.js"></script>
  50. <script for="document" event="onkeyup()" language="JavaScript">
  51. if (window.event.ctrlKey) {
  52. switch (window.event.keyCode) {
  53. case 83 :
  54. //alert("S");
  55. Save();
  56. break;
  57. case 76 :
  58. //alert("L");
  59. self.close();
  60. break;
  61. }
  62. }
  63. </script>
  64. <script language="Javascript">
  65. function Save(){
  66. if (!CheckTextArea(document.frm0201.Notes, 50)){
  67. alert("Text area cannot exceed 50 characters.");
  68. return ;
  69. }
  70. if (!CheckPostalCode(document.frm0201.PostalCode.value)){
  71. alert("Invalid Postal Code.");
  72. document.frm0201.PostalCode.focus();
  73. return ;
  74. }
  75. if (!CheckEmail(document.frm0201.EMail.value)){
  76. alert("Invalid Email.");
  77. document.frm0201.EMail.focus();
  78. return ;
  79. }
  80. var tempPC = document.frm0201.PostalCode.value;
  81. tempPC = tempPC.toUpperCase();
  82. document.frm0201.PostalCode.value = tempPC;
  83. document.frm0201.submit();
  84. }
  85. function CopyFields(){
  86. document.frm0201.MM_Insert.value="false";
  87. document.frm0201.MM_CopyFields.value="true";
  88. document.frm0201.submit();
  89. }
  90. function Init(){
  91. <%
  92. var rsContactAddress = Server.CreateObject("ADODB.Recordset");
  93. rsContactAddress.ActiveConnection = MM_cnnASP02_STRING;
  94. rsContactAddress.Source = "{call dbo.cp_contact_address("+Request.QueryString("intContact_id")+",0,'','','',0,'',0,'','','',0,'','','',0,'','','','','',0,0,'Q',0)}"
  95. rsContactAddress.CursorType = 0;
  96. rsContactAddress.CursorLocation = 2;
  97. rsContactAddress.LockType = 3;
  98. rsContactAddress.Open();
  99. if (rsContactAddress.EOF) {
  100. %>
  101. document.frm0201.Copy.disabled = true;
  102. <%
  103. }
  104. if (String(Request.Form("MM_CopyFields"))=="true") {
  105. if (!rsContactAddress.EOF) {
  106. var rsAddress = Server.CreateObject("ADODB.Recordset");
  107. rsAddress.ActiveConnection = MM_cnnASP02_STRING;
  108. rsAddress.Source = "{call dbo.cp_Contact_Address(0," + rsContactAddress.Fields.Item("intaddr_id").Value + ",'','','',0,'',0,'','','',0,'','','',0,'','','','','',0,1,'Q',0)}";
  109. rsAddress.CursorType = 0;
  110. rsAddress.CursorLocation = 2;
  111. rsAddress.LockType = 3;
  112. rsAddress.Open();
  113. %>
  114. document.frm0201.StreetAddress.value="<%=(rsAddress.Fields.Item("chvAddress").Value)%>";
  115. document.frm0201.City.value="<%=(rsAddress.Fields.Item("chvCity").Value)%>";
  116. document.frm0201.Province.value="<%=rsAddress.Fields.Item("intprvst_id").Value%>";
  117. document.frm0201.PostalCode.value="<%=(rsAddress.Fields.Item("chvPostal_zip").Value)%>";
  118. document.frm0201.PrimaryPhoneType.value="<%=rsAddress.Fields.Item("intPhone_Type_1").Value%>";
  119. document.frm0201.PrimaryPhoneAreaCode.value="<%=rsAddress.Fields.Item("chvPhone1_Arcd").Value%>";
  120. document.frm0201.PrimaryPhoneNumber.value="<%=(rsAddress.Fields.Item("chvPhone1_Num").Value)%>";
  121. document.frm0201.PrimaryPhoneExtension.value="<%=(rsAddress.Fields.Item("chvPhone1_Ext").Value)%>";
  122. document.frm0201.SecondaryPhoneType.value="<%=rsAddress.Fields.Item("intPhone_Type_2").Value%>";
  123. document.frm0201.SecondaryPhoneAreaCode.value="<%=rsAddress.Fields.Item("chvPhone2_Arcd").Value%>";
  124. document.frm0201.SecondaryPhoneNumber.value="<%=(rsAddress.Fields.Item("chvPhone2_Num").Value)%>";
  125. document.frm0201.SecondaryPhoneExtension.value="<%=(rsAddress.Fields.Item("chvPhone2_Ext").Value)%>";
  126. document.frm0201.EMail.value="<%=(rsAddress.Fields.Item("chvEmail").Value)%>";
  127. document.frm0201.Notes.value="<%=(rsAddress.Fields.Item("chvNote").Value)%>";
  128. <%
  129. }
  130. }
  131. %>
  132. document.frm0201.StreetAddress.focus();
  133. }
  134. </script>
  135. </head>
  136. <body onLoad="Init();">
  137. <form ACTION="<%=MM_editAction%>" METHOD="POST" name="frm0201">
  138. <h5>New <%=((String(Request.QueryString("AddressType"))=="Home")?"Home":"Work")%> Address</h5>
  139. <hr>
  140. <table cellpadding="1" cellspacing="1">
  141. <tr>
  142. <td nowrap valign="top">Street Address:</td>
  143. <td nowrap valign="top"><textarea name="StreetAddress" cols="30" rows="3" tabindex="1" accesskey="F"></textarea></td>
  144. </tr>
  145. <tr>
  146. <td nowrap>City:</td>
  147. <td nowrap><input type="text" name="City" maxlength="50" tabindex="2"></td>
  148. </tr>
  149. <tr>
  150. <td nowrap>Province:</td>
  151. <td nowrap><select name="Province" tabindex="3">
  152. <%
  153. while (!rsProvince.EOF) {
  154. %>
  155. <option value="<%=(rsProvince.Fields.Item("intprvst_id").Value)%>" <%=((rsProvince.Fields.Item("intprvst_id").Value=="1")?" SELECTED":"")%>><%=(rsProvince.Fields.Item("chrprvst_abbv").Value)%></option>
  156. <%
  157. rsProvince.MoveNext();
  158. }
  159. %>
  160. </select></td>
  161. </tr>
  162. <tr>
  163. <td nowrap>Postal Code:</td>
  164. <td nowrap><input type="text" name="PostalCode" tabindex="4" size="10" maxlength="7" onChange="FormatPostalCode(this);"></td>
  165. </tr>
  166. <tr>
  167. <td nowrap>Primary Phone:</td>
  168. <td nowrap>
  169. <select name="PrimaryPhoneType" tabindex="5">
  170. <%
  171. while (!rsPhoneType.EOF) {
  172. %>
  173. <option value="<%=(rsPhoneType.Fields.Item("intPhone_type_id").Value)%>" <%=((rsPhoneType.Fields.Item("intPhone_type_id").Value=="2")?"SELECTED":"")%>><%=(rsPhoneType.Fields.Item("chvName").Value)%></option>
  174. <%
  175. rsPhoneType.MoveNext();
  176. }
  177. rsPhoneType.MoveFirst();
  178. %>
  179. </select>
  180. <select name="PrimaryPhoneAreaCode" tabindex="6">
  181. <%
  182. while (!rsAreaCode.EOF) {
  183. %>
  184. <option value="<%=rsAreaCode.Fields.Item("chvAC_num").Value%>"><%=rsAreaCode.Fields.Item("chvAC_num").Value%>
  185. <%
  186. rsAreaCode.MoveNext();
  187. }
  188. rsAreaCode.MoveFirst();
  189. %>
  190. </select>
  191. <input type="text" name="PrimaryPhoneNumber" size="9" tabindex="7" onKeypress="AllowNumericOnly();" maxlength="8" onChange="FormatPhoneNumberOnly(this)">
  192. Ext <input type="text" name="PrimaryPhoneExtension" size="4" tabindex="8" onKeypress="AllowNumericOnly();" maxlength="4">
  193. </td>
  194. </tr>
  195. <tr>
  196. <td nowrap>Secondary Phone:</td>
  197. <td nowrap>
  198. <select name="SecondaryPhoneType" tabindex="9">
  199. <%
  200. while (!rsPhoneType.EOF) {
  201. %>
  202. <option value="<%=(rsPhoneType.Fields.Item("intPhone_type_id").Value)%>" <%=((rsPhoneType.Fields.Item("intPhone_type_id").Value=="2")?"SELECTED":"")%>><%=(rsPhoneType.Fields.Item("chvName").Value)%></option>
  203. <%
  204. rsPhoneType.MoveNext();
  205. }
  206. %>
  207. </select>
  208. <select name="SecondaryPhoneAreaCode" tabindex="10">
  209. <%
  210. while (!rsAreaCode.EOF) {
  211. %>
  212. <option value="<%=rsAreaCode.Fields.Item("chvAC_num").Value%>"><%=rsAreaCode.Fields.Item("chvAC_num").Value%>
  213. <%
  214. rsAreaCode.MoveNext();
  215. }
  216. %>
  217. </select>
  218. <input type="text" name="SecondaryPhoneNumber" size="9" tabindex="11" onKeypress="AllowNumericOnly();" maxlength="8" onChange="FormatPhoneNumberOnly(this)">
  219. Ext <input type="text" name="SecondaryPhoneExtension" size="4" tabindex="12" onKeypress="AllowNumericOnly();" maxlength="4">
  220. </td>
  221. </tr>
  222. <tr>
  223. <td nowrap>E-Mail:</td>
  224. <td nowrap><input type="text" name="EMail" tabindex="13"></td>
  225. </tr>
  226. <tr>
  227. <td nowrap valign="top">Notes:</td>
  228. <td nowrap valign="top"><textarea name="Notes" cols="50" rows="5" tabindex="14" accesskey="L"></textarea></td>
  229. </tr>
  230. </table>
  231. <hr>
  232. <table cellpadding="1" cellspacing="1">
  233. <tr>
  234. <td><input type="button" value="Save" tabindex="15" onClick="Save();" class="btnstyle"></td>
  235. <td><input type="button" name="Copy" value="Copy From <%=((String(Request.QueryString("AddressType"))=="Home")?"Work":"Home")%>" tabindex="16" onClick="CopyFields();" class="btnstyle"></td>
  236. <td><input type="button" value="Close" tabindex="17" onClick="self.close();" class="btnstyle"></td>
  237. </tr>
  238. </table>
  239. <input type="hidden" name="intContact_id" value="<%=Request.QueryString("intContact_id")%>">
  240. <input type="hidden" name="MM_Insert" value="true">
  241. <input type="hidden" name="MM_CopyFields" value="false">
  242. <input type="hidden" name="AddressType" value="<%=Request.QueryString("AddressType")%>">
  243. </form>
  244. </body>
  245. </html>
  246. <%
  247. rsProvince.Close();
  248. rsPhoneType.Close();
  249. rsAreaCode.Close();
  250. %>