protected void btnExport_Click(object sender, EventArgs e) { GridView GridViewExport = new GridView(); string strWhere = string.Empty; strWhere = " SiteCode = '" + Session["strSiteCode"].ToString() + "' AND CreateTime BETWEEN '" + this.txtStartDate.Text + " 00:00:00' AND '" + this.txtEndDate.Text + " 23:59:59' "; if (!this.txtMemNo.Text.Trim().Equals("")) { strWhere = strWhere + " AND MemberShipNo = '" + this.txtMemNo.Text.Trim() + "'"; } if (!this.txtConFee.Text.Trim().Equals("")) { strWhere = strWhere + " AND Price = " + this.txtConFee.Text.Trim(); } strWhere = strWhere + " ORDER BY CreateTime DESC "; DAL.Site.ConRecordsDAL dal = new DAL.Site.ConRecordsDAL(); DataSet ds = dal.GetMemConRecord(strWhere); GridViewExport.DataSource = ds.Tables[0].DefaultView; GridViewExport.DataBind(); if (GridViewExport.Rows.Count > 0) { //调用导出方法 //ExportGridViewForUTF8(GridViewExport, DateTime.Now.ToShortDateString() + ".xls"); ExportGridViewForUTF8(GridViewExport, "ConRecord_" + DateTime.Now.ToString() + ".xls"); } else { Common.MessageBox.Show(this, "没有数据可导出,请先查询数据!"); } }
void LoadData(string strWhere) { DAL.Site.ConRecordsDAL dal = new DAL.Site.ConRecordsDAL(); DataSet ds = dal.GetMemConRecord(strWhere); DataView dv = ds.Tables[0].DefaultView; AspNetPager1.RecordCount = dv.Count; PagedDataSource pds = new PagedDataSource(); pds.DataSource = dv; pds.AllowPaging = true; pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1; pds.PageSize = AspNetPager1.PageSize; GridView1.DataSource = pds; GridView1.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { string strOpenID = string.Empty; string strSiteCode = string.Empty; string strMemNo = string.Empty; string strAction = string.Empty; string strPrice = string.Empty; string strCode = string.Empty; if (null == Request.QueryString["SiteCode"]) { return; } if (null == Request.QueryString["MemNo"]) { return; } if (null == Request.QueryString["OpenId"]) { return; } strOpenID = Common.Common.NoHtml(Request.QueryString["OpenId"].ToString()); strSiteCode = Common.Common.NoHtml(Request.QueryString["SiteCode"].ToString()); strMemNo = Common.Common.NoHtml(Request.QueryString["MemNo"].ToString()); if (null != Request.QueryString["action"]) { strAction = Request.QueryString["action"]; if (string.IsNullOrEmpty(strSiteCode)) { return; } strPrice = Request.Form["txtFee"].ToString(); strCode = Request.Form["txtCode"].ToString(); if (strAction == "checkout" && strCode == "888666") { DAL.Site.ConRecordsDAL dal = new DAL.Site.ConRecordsDAL(); Model.Site.ConRecords modelAdd = new Model.Site.ConRecords { ID = Guid.NewGuid().ToString("N").ToUpper(), SiteCode = strSiteCode, MemberShipNo = strMemNo, OpenID = strOpenID, CreateTime = DateTime.Now, Price = float.Parse(strPrice) }; if (dal.InsertInfo(modelAdd)) { strInfo = "消费记录生成完成。"; #region 消费完成发生消息 //string strAppID = string.Empty; //string strSecret = string.Empty; //Model.WeiXin.WXConfig wc = new Model.WeiXin.WXConfig(); //WXConfigDAL wcdal = new WXConfigDAL(); //wc = wcdal.GetWXConfigBySiteCode(strSiteCode); //if (null != wc) //{ // strAppID = wc.WXAppID; // strSecret = wc.WXAppSecret; //} //string strToken = WeiXinHelper.GetAccessToken(strAppID, strSecret); //var KeyToken = new { access_token = "" }; //var b = JsonConvert.DeserializeAnonymousType(strToken, KeyToken); //string strRToken = b.access_token; //WeiXinHelper.SendCustomTextMessage(strRToken, strOpenID, "欢迎到海立方消费!"); #endregion strOpenID = string.Empty; strSiteCode = string.Empty; strMemNo = string.Empty; strAction = string.Empty; strPrice = string.Empty; } } } string text = System.IO.File.ReadAllText(Server.MapPath("CustMemNo.html")); JinianNet.JNTemplate.TemplateContext context = new JinianNet.JNTemplate.TemplateContext(); context.TempData["sitecode"] = strSiteCode; context.TempData["openid"] = strOpenID; context.TempData["memno"] = strMemNo; context.TempData["title"] = "会员消费处理"; context.TempData["errinfo"] = strInfo; context.TempData["footer"] = "奥琦微商易"; JinianNet.JNTemplate.Template t = new JinianNet.JNTemplate.Template(context, text); t.Render(Response.Output); }