home *** CD-ROM | disk | FTP | other *** search
/ 203.33.198.31 / ftp-203.33.198.31.7z / 203.33.198.31 / addDealers.jsp < prev    next >
Encoding:
Text File  |  2008-12-29  |  7.0 KB  |  263 lines

  1. <%@page import="com.pp.*"%>
  2. <%@page import="java.util.Date,java.io.*"%>
  3. <%@page import="java.util.*"%>
  4. <jsp:useBean id="database" class="com.gil.baanservice.Database" >
  5. </jsp:useBean>
  6. <%
  7.     String comp="";
  8.     String lUser = "";
  9.     try{
  10.         lUser = (String)session.getValue("username");
  11.         }catch(Throwable e){}
  12.     if (lUser == null) lUser = "GITL";
  13.         try{
  14.      comp  =(String)session.getValue("company");
  15.     }catch(Throwable e){}
  16.     if (comp == null) comp = "309";
  17.  
  18.     String table1 = "";
  19.  
  20.     if (comp.equals("779"))
  21.     {
  22.         table1 = "dealers"+comp;
  23.     }else
  24.     {
  25.         table1 = "dealers";
  26.     }
  27.  
  28. %>
  29. <%
  30.  
  31.     String deal = "";
  32.     String dsca = "";
  33.     String locn = "";
  34.     String telp = "";
  35.     String telx = "";
  36.     String psts = "";
  37.  
  38.     String updateparam = "";
  39.     String updateflag = "";
  40.     String option = "";
  41.  
  42.     String sql = "";
  43.  
  44.     String zoom = request.getParameter("zoom");
  45.     if (zoom == null) zoom = "False";
  46.     String zoomtarget = request.getParameter("zoomtarget");
  47.     if (zoomtarget == null) zoomtarget = "";
  48.     String cmd = request.getParameter("cmd");
  49.     if (cmd == null) cmd = "";
  50.  
  51.     int ret = -1;
  52.  
  53.         Calendar calendar = Calendar.getInstance();
  54.         String year = ""+calendar.get(Calendar.YEAR);
  55.         String month = ""+(calendar.get(Calendar.MONTH)+1);
  56.         if (month.length() < 2) month = "0"+month;
  57.         String day = "" + calendar.get(Calendar.DAY_OF_MONTH);
  58.         if (day.length() < 2) day= "0"+day;
  59.         String currdate = day+"/"+month+"/"+year;
  60.         String hour = ""+calendar.get(Calendar.HOUR_OF_DAY);
  61.         if (hour.length() < 2) hour= "0"+hour;
  62.         String mins = ""+calendar.get(Calendar.MINUTE);
  63.         if (mins.length() < 2) mins= "0"+mins;
  64.         String currtime = hour+mins;
  65.  
  66. %>
  67. <%
  68. //***************** Get Values From Form
  69.            deal = request.getParameter("deal");
  70.             if (deal == null) deal = "";
  71.             dsca = request.getParameter("dsca");
  72.             if (dsca == null) dsca = "";
  73.             locn = request.getParameter("locn");
  74.             if (locn == null) locn = "";
  75.             telp = request.getParameter("telp");
  76.             if (telp == null) telp = "";
  77.             telx = request.getParameter("telx");
  78.             if (telx == null) telx = "";
  79.             psts = request.getParameter("psts");
  80.             if (psts == null) psts = "";
  81.     
  82.             updateparam = request.getParameter("updateparam");
  83.             if (updateparam == null) updateparam = "";
  84.  
  85.             option = request.getParameter("option");
  86.             if (option == null) option = "";
  87.  
  88.     %>
  89.  
  90. <%@ include file="include\Header.inc" %>
  91.  
  92. <% 
  93. /* code start for text field */
  94. String lflname = "" + lUser;
  95. /* code end for text field */
  96. %>
  97. <table border="0" cellpadding="0" cellspacing="0" width="780">
  98. <script>
  99. function calladd()
  100. {
  101.             document.addform.option.value='Add';
  102.             document.addform.submit() 
  103. }
  104.             
  105.  
  106. function toUpper()
  107. {
  108.     document.addform.deal.value = document.addform.deal.value.toUpperCase();
  109.     document.addform.dsca.value = document.addform.dsca.value.toUpperCase();
  110.     document.addform.locn.value = document.addform.locn.value.toUpperCase();
  111. }
  112.  
  113.  
  114.     function isDate(dd , mm, yy)
  115.     {
  116.         document.addform.tempdate.value="" ;
  117.         if (dd=="" && mm=="" && yy=="") return true;
  118.         var day = parseInt(dd, 10);
  119.         var month = parseInt(mm, 10);
  120.         /*******************/
  121.         //var year1 = yy.substring(2,4);
  122.         /*******************/
  123.         var year = parseInt(yy, 10);        
  124.         var date = new Date();
  125.         if ((yy.length != 2)&&(yy.length != 4)) return false;
  126.         if (((isNaN(day))||(isNaN(month)))||(isNaN(year))) return false;
  127.         if ((day < 1)||(day > 31)) return false;
  128.         if ((month < 1)||(month > 12)) return false;
  129.         if (((((month == 4)||(month == 6))||(month == 9))||(month == 11))&&(day > 30))             return false;
  130.         if (year < 100){
  131.             if (year < 61) year = 2000 + year
  132.             else year = 1900 + year
  133.         }
  134.         date.setDate(day); date.setMonth(month); date.setYear(year);
  135.         if (month == 2) {
  136.              if (((year % 4 == 0)&&(year % 100 != 0))||(year % 400 == 0))
  137.                 {if (day > 29) return false;}
  138.              else
  139.                 {if (day > 28) return false;}
  140.         }
  141.         if (dd.length < 2) dd="0"+dd
  142.         if (mm.length < 2) mm="0"+mm        
  143.         document.addform.tempdate.value = dd+"/"+mm+"/"+year        
  144.         //document.addform.tempdate.value = dd+mm+year        
  145.         //alert(document.addform.tempdate.value);
  146.         return true;
  147.     }
  148.     
  149. </script>
  150.     <form method="post" action="addDealers.jsp" name="addform">
  151.     <input type="hidden" name="option" value="">
  152.     <input type="hidden" name="cmd" value="">
  153.     <input type="hidden" name="tempdate">
  154. <tr>
  155. <td valign="middle" align="center">
  156.    <table border="0" cellpadding="0" cellspacing="1" width="90%">
  157.     <tr>
  158.         <td  class=tableHeading colspan="4">
  159.             Maintain Dealers
  160.            <br>
  161.         </td>
  162.     </tr>
  163.     <tr>
  164.     <td class=tdHeading>Dealer</td>
  165.     <td class=tdInput>
  166.         <input class=Inputs type='text'  name='deal' size=10 maxlength=6 tabindex=1 value="<%=deal%>" onblur="toUpper()"></input>
  167.     </td>
  168. </tr>
  169. <tr>
  170.     <td class=tdHeading>Dealer Name</td>
  171.     <td class=tdInput>
  172.         <input class=Inputs type='text'  name='dsca' size=30 maxlength=30 tabindex=2 value="<%=dsca%>" onblur="toUpper()"></input>
  173.     </td>
  174. </tr>
  175. <tr>
  176.     <td class=tdHeading>Location Desc.</td>
  177.     <td class=tdInput>
  178.         <input class=Inputs type='text'  name='locn' size=30 maxlength=30 tabindex=3 value="<%=locn%>" onblur="toUpper()"></input>
  179.     </td>
  180. </tr>
  181. <tr>
  182.     <td class=tdHeading>Telephone </td>
  183.     <td class=tdInput>
  184.         <input class=Inputs type='text'  name='telp' size=10 maxlength=8 tabindex=4 value="<%=telp%>"></input>
  185.     </td>
  186. </tr>
  187. <tr>
  188.     <td class=tdHeading>Mobile</td>
  189.     <td class=tdInput>
  190.         <input class=Inputs type='text'  name='telx' size=15 maxlength=10 tabindex=5 value="<%=telx%>"></input>
  191.     </td>
  192. </tr>
  193. <tr>
  194.     <td class=tdHeading>Project Status</td>
  195.     <td class=tdInput>
  196.     <select name='psts' size='1' tabindex=6>
  197.     <option value='1'>Active</option>
  198.     <option value='2'>Inactive</option>
  199.     </select>
  200.     </td>
  201. </tr>
  202.     <script>
  203.         document.addform.psts.value = '<%=psts%>'
  204.     </script>
  205.     <script>
  206.         if(document.addform.psts.value == '')
  207.             document.addform.psts.value = '1'
  208.     </script>
  209. <tr>
  210. <td bgcolor="#FFFFFF" valign="bottom" align="center" colspan="2">
  211. <a href = "javascript:calladd();" tabindex = 7>
  212.  <img border="0" src="gif/save.gif" width="46" height="25"></img>
  213.  </a>
  214.  </td>
  215. </tr>
  216.     </table>
  217.    </td>
  218.   </tr>
  219. </table>
  220.  
  221. <%
  222.     option = request.getParameter("option");
  223.     if (option == null) option = "";
  224.     if (option!=null && option.equals("Add"))
  225.     {
  226.             boolean     val=false;
  227.             boolean     val1=false;
  228.         
  229.                 try {
  230.  
  231.                 sql = "";
  232.  
  233.                 sql = "insert into "+table1+" values ('"+deal+"','"+dsca+"','"+locn+"','"+telp+"','"+telx+"', '"+psts+"')";
  234.                 
  235.                 val = database.execute(sql);
  236.  
  237.             } catch (Exception e){}
  238.             if (val)
  239.             {
  240.      %>
  241.                 <table border="0" cellpadding="0" cellspacing="0" width="90%">
  242.                 <tr><td colspan="6" class=tdMessage>   ADDED SUCCESSFULLY</td></tr>
  243.                 </table>
  244.     <%
  245.             }
  246.             else
  247.             {
  248.     %>
  249.                 <table border="0" cellpadding="0" cellspacing="0" width="90%">
  250.                 <tr>
  251.                  <td  colspan="2" class=tdError> Error in Add </b>
  252.                  </td>
  253.                  </tr>
  254.                  </table>
  255.     <%
  256.             }        
  257.     }
  258.     
  259.     
  260. %>
  261.  
  262. </html>
  263.