后台动态绑定数据
发布日期:2021-08-17 10:07:43 浏览次数:63 分类:技术文章

本文共 3248 字,大约阅读时间需要 10 分钟。

直接上代码

aspx页面

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Couponlist.aspx.cs" Inherits="Coupon_Couponlist" %>    优惠券页面    
    <%=str %>
View Code

aspx.cs后台

public string str="";    protected void Page_Load(object sender, EventArgs e)    {       string bbid=Request.QueryString["bbid"];       string ppid = Request.QueryString["ppid"];       if (!string.IsNullOrEmpty(bbid) && !string.IsNullOrEmpty(ppid))       {           getCouponList(bbid, ppid);//获取优惠券列表       }       else {           ClientScript.RegisterStartupScript(this.GetType(), "message", "");       }    }    private void getCouponList(string bbid,string ppid)    {        string sql = string.Format("select * from v_couponlist where bbid={0} and ppid={1}",bbid,ppid);        DataTable dt = SqlHelper.ExecuteTable(sql);        if (dt!=null&&dt.Rows.Count > 0)        {              for (int i = 0; i < dt.Rows.Count; i++)            {                string thisdate = "";                if (Convert.ToInt32(dt.Rows[i]["LastDay"]) > 0)                {                    thisdate = "发券后" + Convert.ToInt32(dt.Rows[i]["LastDay"]) + "天有效";                }                else                {                    thisdate = "有效期" + php.GetFormatDatedian(dt.Rows[i]["StartDate"].ToString()) + "-" + php.GetFormatDatedian(dt.Rows[i]["EndDate"].ToString());                }                 if (Convert.ToInt32(dt.Rows[i]["CouponType"]) == 1)                 {                                         str += "
  • "+ ""+ "
    "+ "

    满减券

    "+ "

    消费金额满 " + Convert.ToDecimal(dt.Rows[i]["PayMoney"]).ToString("f2") + "元可用

    " +//Convert.ToDecimal(Eval("sale")).ToString("f2") "

    " + thisdate + "

    " + "
    "+ "
    ¥" + Convert.ToDecimal(dt.Rows[i]["CouponMoney"]).ToString("f2") + "
    " + "
    "+ "
  • "; } else { str += "
  • "+ ""+ "
    "+ "

    礼品券

    "+ "

    到店消费领取[" + dt.Rows[i]["Gift"] + "]

    " + "

    "+thisdate+"

    "+ "
    "+ "
    "+ "
    "+ "
  • "; } } } }
    View Code

     

    静态页效果

        
    ID 名称 优惠详情 每人限领 库存 创建时间 操作
    19 满减券 aaaaaaaaaaaaaaaaaa 2 100 2016/11/18 21:11:57 修改 删除
    10 礼品券 仅限周一到周五使用 2 100 2016/11/18 14:41:43 修改 删除
    View Code

     

    转载于:https://www.cnblogs.com/chenlihong-886/p/6079300.html

    转载地址:https://blog.csdn.net/weixin_30846599/article/details/99202863 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

    上一篇:tarjan
    下一篇:mpvue开发小程序项目遇到的问题

    发表评论

    最新留言

    路过按个爪印,很不错,赞一个!
    [***.219.124.196]2024年03月23日 05时58分20秒