⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 create_coupon.jsp

📁 Sun公司Dream项目
💻 JSP
字号:
<%@ include file="common_imports.jsp" %>



<%    

    if(jspPath == null)

        jspPath = "/shop/my_account.jsp";



    //if (!isSignin) {

      //  request.getRequestDispatcher("/shop/login.jsp?jsp_path=/shop/create_coupon.jsp").forward(request,response);

    

    //} else 

    

    if (! "admin".equals(userID)) {

        request.getRequestDispatcher(jspPath).forward(request,response);

    }        

                

    String error = "";       

    String formTitle = "Create New Coupon";

    String buttonLabel = "Create Coupon";

    String savedMsg = "";

    

    String insertCouponSQL = "INSERT INTO OPERA_COUPON_INFO (couponid, contentid, shopid, value, description) VALUES (?,?,?,?,?)";

    

    String verifySQL = "SELECT contentid,shopid,value,description FROM OPERA_COUPON_INFO WHERE couponid=?";



    String action = request.getParameter("action");

    

    String description = request.getParameter("description");

    String contentID = request.getParameter("content_id");

    String couponID = request.getParameter("couponid");

    String shopID = request.getParameter("shopid");

    String couponValue = request.getParameter("couponvalue");

    

    if ("create".equals(action)) {

        if (couponID == null || "".equals(couponID.trim()))

            error += "&nbsp;&nbsp;&nbsp;&nbsp;Coupon ID is required.<br/>";

        else {

            String[] existingCoupon = DBUtil.getRecord(verifySQL, 

                            new int[] {java.sql.Types.VARCHAR,java.sql.Types.VARCHAR,java.sql.Types.FLOAT,java.sql.Types.VARCHAR},

                            null, new String[] {couponID});

            if (existingCoupon != null) {

                error += "&nbsp;&nbsp;&nbsp;&nbsp;Coupon code has already existed.<br/>";           

            }

        }

                           

        if (contentID == null || "".equals(contentID.trim()))

            error += "&nbsp;&nbsp;&nbsp;&nbsp;Content ID is required.<br/>";

    

        if (shopID == null || "".equals(shopID.trim()))

            error += "&nbsp;&nbsp;&nbsp;&nbsp;Shop ID is required.<br/>";

    

        if (couponValue == null || "".equals(couponValue.trim()))

            error += "&nbsp;&nbsp;&nbsp;&nbsp;Coupon Value is required.<br/>";

        else {

            try {

                Float.parseFloat(couponValue);

            }catch (Exception ex) {

                error += "&nbsp;&nbsp;&nbsp;&nbsp;Invalid Coupon value.<br/>";

            }

        }

        

        if ("".equals(error)) {

            DBUtil.execute(insertCouponSQL, new Object[] {couponID, contentID,shopID, Float.valueOf(couponValue),description});

            

            savedMsg = "&nbsp;&nbsp;&nbsp;&nbsp;" +  couponID + " coupon has been created.<br/>";       

        }

    

    }

    

    if (couponID == null) couponID ="";

    if (contentID == null) contentID = "";

    if (couponValue == null) couponValue = "";

    if (description == null) description = "";

    

        

                            

%>



<%@ include file="top_body.jsp" %>



        <td width="500" valign="top">

          <table width="480" border="0" cellspacing="0" cellpadding="0">

            <tr>

              <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

              <a href="coupon.jsp" style="text-decoration:none;font-size:11px">Go back to coupon list</a></td>

            </tr>

            <tr>

              <td class="song_title">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

              <%=formTitle%></td>

            </tr>

            <tr>

              <td class="subsong_detail" style="font-size:9px">&nbsp;&nbsp;<span class="star">*</span> Indicates required field</td>

            </tr>

            <tr>

              <td>&nbsp;</td>

            </tr>

<%

    if (!"".equals(error)) {

%>

            <tr>

              <td class="star" style="font-weight:normal;"><%=error%></td>

            </tr>

            <tr>

              <td>&nbsp;</td>

            </tr>

            

<%

    } else if (! "".equals(savedMsg)) {

%>

            <tr>

              <td class="subsong_detail"><%=savedMsg%></td>

            </tr>

            <tr>

              <td>&nbsp;</td>

            </tr>



<%

    }

%>                    

            <tr>

              <td>

                <form method="post">

                <input type="hidden" name="action" value="create"> 

                <table cellspacing="0" cellpadding="4">

                  <tr>

                    <td class="subsong_detail">&nbsp;<b>Coupon Code:</b><span class="star">*</span> </td>                  

                    <td class="subsong_detail">&nbsp;&nbsp;&nbsp;<input type="text" class="body_text" name="couponid" size="25" value="<%=couponID%>"/></td>                                  

                  </tr>

                  <tr>

                    <td class="subsong_detail" valign="top">&nbsp;<b>Content ID:</b><span class="star">*</span> </td>

                    <td class="subsong_detail">&nbsp;&nbsp;&nbsp;<input type="text" class="body_text" name="content_id" size="25" value="<%=contentID%>"/><br/>

                    <span class="body_text" style="font-size:9px">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Type: <b>total</b> if the coupon is for total purchase, NOT for specific content.                    

                    </td>

                  </tr>                  

                  <tr>

                    <td class="subsong_detail">&nbsp;<b>Shop ID:</b> </td>                  

                    <td class="subsong_detail">&nbsp;&nbsp;&nbsp;<%=operaShopID%></td> 

                    <input type="hidden" name="shopid" value="<%=operaShopID%>">                                 

                  </tr>

                  <tr>

                    <td class="subsong_detail">&nbsp;<b>Value:</b><span class="star">*</span> </td>                  

                    <td class="subsong_detail">$ <input type="text" class="body_text" name="couponvalue" size="25" value="<%=couponValue%>"/></td>                                  

                  </tr>                  

                  <tr>

                    <td class="subsong_detail">&nbsp;<b>Description:</b> </td>                  

                    <td class="subsong_detail">&nbsp;&nbsp;&nbsp;<input type="text" class="body_text" name="description" size="25" value="<%=description%>"/></td>                                  

                  </tr>

                  <tr>

                    <td colspan="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

                    <input type="submit" class="body_text" value="<%=buttonLabel%>"/></td>

                  </tr>                                                        

                </table>

                </form>

              </td>

            </tr>

            <tr>

              <td> &nbsp;</td>

            </tr>

          </table>

        </td>

                  

<%@ include file = "footer.jsp" %>                                     

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -