订单提醒功能

 

  //五秒刷新数据库,有新订单提醒
        if (!GetMessageCount) {

            var GetMessageCount = {};
        }

        $(document).ready(
        function () {
            //GetMessageCount.FindMessage();
            go();//计时器
        }
        );

        GetMessageCount.FindMessage = function () {
            $.ajax({
                //处理ajax请求
                type: "get",
                dataType: "json",
                url: "ajaxMesg.ashx",
                cache: false,
                success: function (response) {
                    //alert(response.MerchantName);
                    if (response.Num != 0) {
                        //alert(response.Num);
                        var context = "你有" + response.Num + "条新订单";
                        stop();
                        ymPrompt.alert({ message: context, title: '订单提醒', handler: myFun, btn: ['OK'], okTxt: ' 详   情 ', autoClose: true, winPos: 'rb', useSlide: true, slideCfg: { increment: 0.1, interval: 100} });   //这里是使用的一个 第三方 控件 可以在我网上找到!
                    }
                },
                error: function (data) {
                    alert("加载失败");
                }
            });
            //每隔5 秒递归调用一次,刷新未读短信数目
//            show();


        }  
        //开始计时

        var timerID;
        var time = 0;
        function show() {
            time++;
            //alert('time:' + time + '  timerID:' + timerID);
            timerID = setTimeout("show(" + time + ")", 5000);

            if (time > 10)  //n * (5000/1000)
            {
                //alert('>200):' + time);
                time = 0;
                GetMessageCount.FindMessage(); //核心语句
            }
        }
        //暂停
        function stop() {
            window.clearTimeout(timerID);
        }
        //继续
        function go() {
            window.clearTimeout(timerID);
            show();
        }

        function myFun(tp) {
            if (tp == 'ok') {
                addTab('发货订单查看', 'StoreMange/SentGoodsCheck.aspx', 'icon icon-nav', true)
            }
            go();
        }

 

//引用一般处理程序,使用IRequiresSessionState  这个接口

//必须有using System.Web.SessionState; 这个命名空间!

 public class ajaxMesg : IHttpHandler, IRequiresSessionState
    {
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string sql = "";
            string num = "";
            int number = 0;
            using (SqlConnection con = new SqlConnection(SqlHelper.ConnectionString))
            {
                con.Open();
                PageBase pb = new PageBase(); //记录当前登录用户的类
                
                string userId = pb.UserId; //获取当前登录用户Id
                string sqll = string.Format("select count(Name) from dbo.PUB_User"
                                + " where UserID = '{0}' and IsView = '0'", userId);

                SqlCommand cmd = new SqlCommand();
                cmd.Connection = con;

                cmd.CommandText = sqll;
                number = Convert.ToInt32(cmd.ExecuteScalar().ToString());
                //以上是判断那些人可以提醒!
            }
            if (number > 0)
            {
                using (SqlConnection con = new SqlConnection(SqlHelper.ConnectionString))
                {
                    con.Open();
                    sql = "select count(*) as Num from Match_SendGood where RemindOrNot='0'";

                    SqlCommand cmd = new SqlCommand();
                    cmd.Connection = con;
                    cmd.CommandText = sql;

                    num = "{\"Num\":\"" + cmd.ExecuteScalar().ToString() + "\"}";
                }
                context.Response.Write(num);
                //提醒的内容
            }
            else
            {
                num = "{\"Num\":\"" + "0" + "\"}";
                context.Response.Write(num);
            }
        }

 

 

  • 0
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值