/// <summary>
 /// 执行更新操作
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int UpdateWithModify(MODEL.Good model)
 {
     return(BuildSql.UpdateWithModify(strSql, model));
 }
 /// <summary>
 /// 执行增加操作
 /// </summary>
 /// <param name="model"></param>
 /// <param name="newID"></param>
 /// <returns></returns>
 public int Add(MODEL.Good model, out int newID)
 {
     return(BuildSql.Add(strSql, model, out newID));
 }
 /// <summary>
 /// 执行增加操作
 /// </summary>
 /// <param name="model"></param>
 /// <param name="newID"></param>
 /// <returns></returns>
 public bool Add(MODEL.Good model, out int newID)
 {
     return(dal.Add(model, out newID) > 0);
 }
 /// <summary>
 /// 执行更新操作
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool UpdateWithModify(MODEL.Good model)
 {
     return(dal.UpdateWithModify(model) > 0);
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                if (Request.QueryString["type"] == "新增")
                {
                    MODEL.Good model = new MODEL.Good();
                    model.GBuyTime  = DateTime.Parse(Request.Form["gBuyTime"]);
                    model.GName     = Request.Form["gName"];
                    model.GPayWay   = Request.Form["gBuyWay"];
                    model.GPrice    = decimal.Parse(Request.Form["gPrice"]);
                    model.GTime     = DateTime.Now;
                    model.GCount    = int.Parse(Request.Form["gCount"]);
                    model.GIsDel    = false;
                    model.GDes      = Request.Form["gDes"];
                    model.GBuyPlace = Request.Form["gPlace"];
                    model.GBuyUser  = int.Parse(Session["uID"].ToString());

                    int newID;
                    if (bll.Add(model, out newID))
                    {
                        Response.Write("ok");
                    }
                    else
                    {
                        Response.Write("busy");
                    }
                    Response.End();
                }
                else if (Request.QueryString["type"] == "修改")
                {
                    MODEL.Good mosd = bll.GetModelByID(Request.Form["uisd"]);
                    mosd.GBuyTime  = DateTime.Parse(Request.Form["gBuyTime"]);
                    mosd.GName     = Request.Form["gName"];
                    mosd.GPayWay   = Request.Form["gBuyWay"];
                    mosd.GPrice    = decimal.Parse(Request.Form["gPrice"]);
                    mosd.GCount    = int.Parse(Request.Form["gCount"]);
                    mosd.GDes      = Request.Form["gDes"];
                    mosd.GBuyPlace = Request.Form["gPlace"];
                    mosd.GBuyUser  = int.Parse(Session["uID"].ToString());
                    if (bll.UpdateWithModify(mosd))
                    {
                        Response.Write("ok");
                    }
                    else
                    {
                        Response.Write("busy");
                    }
                    Response.End();
                }
                else
                {
                }
            }
            else
            {
                if (Session["uID"] != null)
                {
                    usname = bll2.GetModelByID(Session["uID"].ToString()).UNick;
                }
                if (!string.IsNullOrEmpty(Request.QueryString["kw"]))
                {
                    keyword  = " WHERE gName LIKE '%" + Request.QueryString["kw"] + "%' or gBuyPlace LIKE '%" + Request.QueryString["kw"] + "%'  or gPayWay LIKE '%" + Request.QueryString["kw"] + "%' ";
                    countPay = bll.GetCountForWhere(keyword);
                }
                else
                {
                    countPay = bll.GetCountForWhere();
                }
                if (!string.IsNullOrEmpty(Request.QueryString["ts"]))
                {
                    arr = Request.QueryString["ts"].Split('|');

                    keyword  = " WHERE gBuyTime BETWEEN '" + arr[0] + "' AND '" + arr[1] + "' ";
                    countPay = bll.GetCountForPay(DateTime.Parse(arr[0]), DateTime.Parse(arr[1]));
                }
                cp        = Request.QueryString["page"];
                pageCount = bll.GetPageCount(20, keyword);  //总页数
                totalSize = bll.GetCount(keyword).ToString();


                string currentU = Request.RawUrl;  //当前网址
                if (currentU.IndexOf("ts") > -1)
                {
                    us = "&ts=" + Request.QueryString["ts"];
                }
                if (currentU.IndexOf("kw") > -1)
                {
                    us += "&kw=" + Request.QueryString["kw"];
                }
                //Response.Write(currentU);
                if (string.IsNullOrEmpty(cp))
                {
                    cp       = "1";
                    prevHtml = "javascript:void(0)";
                    if (int.Parse(cp) < pageCount)
                    {
                        nextHtml = "?page=" + (int.Parse(cp) + 1) + us;
                    }
                    else
                    {
                        nextHtml = "javascript:void(0)";
                    }
                }
                else
                {
                    if (int.Parse(cp) + 1 <= pageCount)
                    {
                        nextHtml = "?page=" + (int.Parse(cp) + 1) + us;
                    }
                    else
                    {
                        nextHtml = "javascript:void(0)";
                    }
                    if (int.Parse(cp) - 1 > 0)
                    {
                        prevHtml = "?page=" + (int.Parse(cp) - 1) + us;
                    }
                    else
                    {
                        prevHtml = "javascript:void(0)";
                    }
                }
                List <MODEL.Good> list = bll.GetSimplePageList("20", cp, keyword);
                rp.DataSource = list;
                rp.DataBind();
            }
        }