コード例 #1
0
        // 扣费SQL操作
        public string WithdrawMoney(string QRCode)
        {
            //返回的字符串
            string    callBack = null;
            DataTable dt       = null;
            //判读二维码,并执行相应的操作
            int status = IfUsedOrOutTime(QRCode);

            switch (status)
            {
            case 100:
                callBack = "判读餐票状态错误";
                break;

            case 101:
                callBack = "已消费,请勿重刷";
                break;

            case 102:
                callBack = "已退款,请勿重刷";
                break;

            case 1:
                callBack = "就餐时间已过,请按时就餐";
                break;

            case -1:
                callBack = "未到就餐时间,请耐心等待";
                break;

            case 0:
                //判读有效
                try
                {
                    SqlDbOperHandler doh = new SqlDbOperHandler();    //开启连接数据库
                    doh.Reset();
                    doh.SqlCmd = "update [m_t_application] set ticketStatus = '已消费',UsedTime = GETDATE() where identification = '" + QRCode + "'";
                    doh.AddConditionParameter("@identification", QRCode);
                    dt = doh.GetDataTable(); //获取返回的表格
                    doh.Dispose();           //释放资源
                }
                catch (Exception e)
                {
                    LogClass.CreateLog(e.Message.ToString());
                }
                callBack = "二维码验证成功";
                break;

            case 404:
                callBack = "找不到该二维码";
                break;

            default:
                callBack = "扣费查询错误,请联系行政管理员";
                break;
            }
            return(callBack);
        }
コード例 #2
0
        /// <summary>
        /// 返回此次生成的二维码
        /// </summary>
        /// <param name="meal_date">就餐日期</param>
        /// <param name="TicketCount">生成数量</param>
        /// <returns></returns>
        public DataTable SelectQRCode(DateTime meal_date, int TicketCount)
        {
            DataTable dt = null;

            try
            {
                SqlDbOperHandler doh = new SqlDbOperHandler();//开启连接数据库
                doh.Reset();
                doh.SqlCmd = "select top(@TicketCount) * from [m_t_application] where meal_date = @meal_date order by ticketCreate desc";
                doh.AddConditionParameter("@TicketCount", TicketCount);
                doh.AddConditionParameter("@meal_date", meal_date.ToString("yyyy-MM-dd"));
                dt = doh.GetDataTable(); //获取返回的表格
                doh.Dispose();           //释放资源
            }
            catch (Exception e)
            {
                LogClass.CreateLog(e.Message.ToString());
            }
            return(dt);
        }