zoukankan      html  css  js  c++  java
  • 分页

    js: //分页
                $(document).on("click", '#page a', function () {
                    if ($(this).attr('disabled'))
                        return;
                    switch ($(this).attr('id')) {
                        case 'prevpage':
                            pageIdx--;
                            break;
                        case 'nextpage':
                            pageIdx++;
                            break;
                    }
                    load(pageIdx, 1);
                });

    C#:

    #region 房仓客房订单列表        
            private DatabaseHelper helper = DatabaseHelper.GetHelper(GlobalVariables.Order2DBConnReadonly);
            /// <summary>
            /// 房仓客房订单列表
            /// </summary>
            /// <param name="paystatus"></param>
            /// <param name="payway"></param>
            /// <param name="page">页码</param>
            /// <param name="statustype"></param>
            /// <param name="startTime">搜索开始时间</param>
            /// <param name="endTime">搜索结束时间</param>
            /// <param name="status">订单状态</param>
            /// <param name="isRefundStatus"></param>
            /// <returns></returns>
            [OutputCache(Duration = 60 * 10)]        
            public ActionResult List(int? paystatus, int? payway, int page = 0, int statustype = 1, DateTime? startTime = null, DateTime? endTime = null, string status = "|-15| -10|-6|-5|-1|1|5|10|15|20|25|", int isRefundStatus = 0)
            {
                StringBuilder condition = new StringBuilder();
                int[] ostatus = (status ?? string.Empty).Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.ToInt()).ToArray();
                if (string.IsNullOrEmpty(status))
                {
                    condition.Append("  OStatus <= 25");
                }
                else
                {
                    condition.Append("  OStatus IN(").Append(String.Join(",", status.Split('|').Select(x => x.ToInt()))).Append(")");
                }
                StringBuilder condition2 = new StringBuilder();
                if (startTime != null && endTime!=null)
                {
                    condition2.Append("AND  o.ODateTime>=@startTime and o.ODateTime<=@endTime");
                }
                else if (startTime != null && endTime == null)
                {
                    condition2.Append("AND  o.ODateTime>=@startTime");
                }
                else if (startTime == null && endTime != null)
                {
                    condition2.Append("AND  o.ODateTime<=@endTime");
                }
                else
                {
                    condition2.Append("AND  o.ODateTime>='1978-01-01' and o.ODateTime<='9999-01-01'");
                }

                string sql = @"select *
                                FROM
                                    Order2.dbo.FangCangOrderRef(nolock) as f JOIN Order2.dbo.OrderInfo(nolock) as o
                                    on f.OID=o.OID
                                where {0} {1}";
                sql = string.Format(sql, condition.ToString(), condition2.ToString());
                ParameterCollection p = helper.CreateParamterCollection();
                p.Append("status", status);
                p.Append("startTime", startTime);
                p.Append("endTime", endTime);
                DataSet ds = helper.ExecuteDataSet(sql, p);
                DataTable dt = ds.Tables[0];
                List<string[]> list = new List<string[]>();
                foreach (DataRow r in dt.Rows)
                {
                    int colCount = r.ItemArray.Count();
                    string[] items = new string[colCount];
                    for (int i = 0; i < colCount; i++)
                    {
                        items[i] = Convert.ToString(r.ItemArray[i]);
                    }
                    list.Add(items);
                }
                int total = list.Count();
                ViewBag.intTotal = total;

                StringBuilder condition1 = new StringBuilder();
                if (string.IsNullOrEmpty(status))
                {
                    condition1.Append(" OStatus <= 25");
                }
                else
                {
                    condition1.Append(" OStatus IN(").Append(String.Join(",", status.Split('|').Select(x => x.ToInt()))).Append(")");
                }
                StringBuilder condition3 = new StringBuilder();
                if (startTime != null && endTime != null)
                {
                    condition3.Append("AND  o.ODateTime>=@startTime and o.ODateTime<=@endTime");
                }
                else if (startTime != null && endTime == null)
                {
                    condition3.Append("AND  o.ODateTime>=@startTime");
                }
                else if (startTime == null && endTime != null)
                {
                    condition3.Append("AND  o.ODateTime<=@endTime");
                }
                else
                {
                    condition3.Append("AND  o.ODateTime>='1978-01-01' and o.ODateTime<='9999-01-01'");
                }
                string sql1 = @" select * from (
                            select
                            o.OID,
                            o.CID,
                            o.CGuid,
                            o.CLevelID,
                            o.HID,
                            o.HGuid,
                            o.OContact,
                            o.OTel,
                            o.OEmail,
                            o.ONeedConfirm,
                            o.OType,
                            o.PaymentType,
                            o.OStatus,
                            o.OPayAmount,
                            o.OAmount,
                            o.OOriAmount,
                            o.ETA,
                            o.ETD,
                            o.ODateTime,
                            o.OExpireTime,
                            o.ORefundStatus,
                            o.ORefundAmount,
                            o.ORefundAmount2,
                            o.ORefundAmount3,
                            o.IsRefund,
                            o.PId,
                            o.PNum,
                            o.FormHid,
                            o.FormType,
                            o.PName,
                            o.OPayStatus,
                            ROW_NUMBER() OVER ( ORDER BY o.OID asc )  rownumber
                        FROM
                            Order2.dbo.FangCangOrderRef(nolock) as f JOIN Order2.dbo.OrderInfo(nolock) as o
                            on f.OID=o.OID
                            where {0} {1} ) AS list  where  rownumber between @page*10+1 and @page*10+10";
                sql1 = string.Format(sql1, condition1.ToString(), condition3.ToString());           
                ParameterCollection p1 = helper.CreateParamterCollection();
                p1.Append("startTime", startTime);
                p1.Append("endTime", endTime);
                p1.Append("status", status);
                p1.Append("page", page);
                DataSet ds1 = helper.ExecuteDataSet(sql1, p1);
                var result = new List<WareHouseInfoModel>();
                for (int i = 0; i < ds1.Tables[0].Rows.Count; i++)
                {
                    result.Add(new WareHouseInfoModel
                    {
                        OID = Convert.ToInt64(ds1.Tables[0].Rows[i]["OID"]),
                        CID = Convert.ToInt32(ds1.Tables[0].Rows[i]["CID"]),
                        CGuid = ds1.Tables[0].Rows[i]["CGuid"].ToString(),
                        CLevelID = Convert.ToInt32(ds1.Tables[0].Rows[i]["CLevelID"]),
                        HID = Convert.ToInt32(ds1.Tables[0].Rows[i]["HID"]),
                        HGuid = ds1.Tables[0].Rows[i]["HGuid"].ToString(),
                        OContact = ds1.Tables[0].Rows[i]["OContact"].ToString(),
                        OTel = ds1.Tables[0].Rows[i]["OTel"].ToString(),
                        OEmail = ds1.Tables[0].Rows[i]["OEmail"].ToString(),
                        ONeedConfirm = Convert.ToInt32(ds1.Tables[0].Rows[i]["ONeedConfirm"]),
                        OType = Convert.ToInt32(ds1.Tables[0].Rows[i]["OType"]),
                        PaymentType = Convert.ToInt32(ds1.Tables[0].Rows[i]["PaymentType"]),
                        OStatus = Convert.ToInt32(ds1.Tables[0].Rows[i]["OStatus"]),
                        OStatusStr=GetOStatus(Convert.ToInt32(ds1.Tables[0].Rows[i]["OStatus"]).ToString()),
                        OPayAmount = Convert.ToInt32(ds1.Tables[0].Rows[i]["OPayAmount"]),
                        OAmount = Convert.ToInt32(ds1.Tables[0].Rows[i]["OAmount"]),
                        OOriAmount = Convert.ToInt32(ds1.Tables[0].Rows[i]["OOriAmount"]),
                        ETA = Convert.ToDateTime(ds1.Tables[0].Rows[i]["ETA"]),
                        ETD = Convert.ToDateTime(ds1.Tables[0].Rows[i]["ETD"]),
                        ODateTime = Convert.ToDateTime(ds1.Tables[0].Rows[i]["ODateTime"]),
                        OExpireTime = Convert.ToDateTime(ds1.Tables[0].Rows[i]["OExpireTime"]),
                        ORefundStatus = Convert.ToInt32(ds1.Tables[0].Rows[i]["ORefundStatus"]),
                        ORefundAmount = (decimal)ds1.Tables[0].Rows[i]["ORefundAmount"],
                        ORefundAmount2 = (decimal)ds1.Tables[0].Rows[i]["ORefundAmount2"],
                        ORefundAmount3 = (decimal)ds1.Tables[0].Rows[i]["ORefundAmount3"],
                        IsRefund = Convert.ToInt32(ds1.Tables[0].Rows[i]["IsRefund"]),
                        PId = Convert.ToInt64(ds1.Tables[0].Rows[i]["PId"]),
                        PNum = Convert.ToInt32(ds1.Tables[0].Rows[i]["PNum"]),
                        FormHid = Convert.ToInt32(ds1.Tables[0].Rows[i]["FormHid"]),
                        FormType = Convert.ToInt32(ds1.Tables[0].Rows[i]["FormType"]),
                        PName = ds1.Tables[0].Rows[i]["PName"].ToString(),
                        OPayStatus = Convert.ToInt32(ds1.Tables[0].Rows[i]["OPayStatus"]),
                        ORefundStatusStr = GetORefundStatus(ds1.Tables[0].Rows[i]["ORefundStatus"].ToString()),
                    });
                }
                int[] hids = result.Select(x => x.HID).Distinct().ToArray();
                if (hids.Length == 0)
                {
                    return View(new List<WareHouseInfoModel> { });
                }
                var hotellist = new HotelInfoRepository().GetList(x => (object)x.Hid == hids);
                ViewBag.page = page;
                ViewBag.hotelinfo = hotellist;
                ViewBag.totelpage = Math.Ceiling(Convert.ToDecimal(total / 10));
                return View(result);
            }

            private string GetORefundStatus(string orefundstatus)
            {
                switch (orefundstatus)
                {
                    case "-1":
                        return "审核不通过";
                    case "1":
                        return "退款待审核";
                    case "5":
                        return "审核通过";
                    case "10":
                        return "已退款";
                    case "15":
                        return "已处理,但不退";
                    default:
                        return "";
                }
            }
            //订单状态(-15系统拦截 -10系统取消 -6酒店取消-5客户取消-1删除1新单5未确认10已确认15未入住(用餐) 20入住(用餐) 25完成)
            private string GetOStatus(string ostatus)
            {
                switch (ostatus)
                {
                    case "-15":
                        return "系统拦截";
                    case "-10":
                        return "系统取消";
                    case "-6":
                        return "酒店取消";
                    case "-5":
                        return "客户取消";
                    case "-1":
                        return "客户取消";
                    case "1":
                        return "新订单";
                    case "5":
                        return "未确认";
                    case "10":
                        return "已确认";
                    case "15":
                        return "未入住(用餐)";
                    case "20":
                        return "入住(用餐)";
                    case "25":
                        return "完成";                
                    default:
                        return "";
                }
            }
            //1未支付5已支付10支付失败
            private string GetOPayStatus(string opaystatus)
            {
                switch (opaystatus)
                {
                    case "1":
                        return "未支付";
                    case "5":
                        return "已支付";
                    case "10":
                        return "支付失败";                
                    default:
                        return "";
                }
            }
            #endregion

  • 相关阅读:
    Mybatis 延迟加载策略
    Mybatis中的多表查询 多对多
    Mybatis中的多表查询 多对一,一对多
    Mybatis 的动态 SQL 语句
    Mybatis中的连接池
    判断一个对象是否为数组
    包装对象概念 (做好事不留名的雷锋)
    javascript 继承之拷贝,原型,类式
    ajax参数
    面向对象小实例之 选项卡
  • 原文地址:https://www.cnblogs.com/zhangxiaolei521/p/5179012.html
Copyright © 2011-2022 走看看