protected void Page_Load(object sender, EventArgs e) { BLL.Card_wx.Card_BaseInfo bll = new BLL.Card_wx.Card_BaseInfo(); string cardtype = Request.Params["cardtype"]; string cardid = Request.QueryString["cardid"]; string acctoken = Token(); if (!IsPostBack) { Label1.Text = cardtype; Label2.Text = cardid; Model.Card_wx.Card_BaseInfo dd = bll.Getmodel(cardid); brand_name.Text = dd.brand_name.ToString(); title.Text = dd.title; sub_title.Text = dd.sub_title; imagetext.Text = dd.logo_url; Card_color.Text = dd.color; notice.Text = dd.notice; description.InnerText = dd.description; service_phone.Text = dd.service_phone; url_name.Text = dd.custom_url_name; custom_url.Text = dd.custom_url; sub_url_name.Text = dd.custom_url_sub_title; pro_url.Text = dd.promotion_url; pro_url_name.Text = dd.promotion_url_name; time_day.Text = dd.end_timestamp; user_limit.Text = dd.use_limit.ToString(); get_limit.Text = dd.get_limit.ToString(); share_page.Checked = dd.can_share; share_card.Checked = dd.can_give_friend; paycell.Checked = dd.Paycell; hexiao.Checked = dd.hexiao; imgbjurl.ImageUrl = imagetext.Text; } }
/// <summary> /// 得到一个实体对象 /// </summary> /// <param name="row"></param> /// <returns></returns> public Model.Card_wx.Card_BaseInfo DataRowToModel(DataRow row) { Model.Card_wx.Card_BaseInfo model = new Model.Card_wx.Card_BaseInfo(); if (row != null) { model.BaseInfoID = int.Parse(row["BaseInfoID"].ToString()); model.wid = int.Parse(row["wid"].ToString()); model.Card_type = row["Card_type"].ToString(); model.logo_url = row["logo_url"].ToString(); model.brand_name = row["brand_name"].ToString(); model.title = row["title"].ToString(); model.sub_title = row["sub_title"].ToString(); model.color = row["color"].ToString(); model.notice = row["notice"].ToString(); model.service_phone = row["service_phone"].ToString(); model.source = row["source"].ToString(); model.description = row["description"].ToString(); model.use_limit = int.Parse(row["use_limit"].ToString()); model.get_limit = int.Parse(row["get_limit"].ToString()); model.custom_url_name = row["custom_url_name"].ToString(); model.custom_url = row["custom_url"].ToString(); model.custom_url_sub_title = row["custom_url_sub_title"].ToString(); model.promotion_url = row["promotion_url"].ToString(); model.promotion_url_name = row["promotion_url_name"].ToString(); model.least_cost = row["least_cost"].ToString(); model.reduce_cost = row["reduce_cost"].ToString(); model.default_detail = row["default_detail"].ToString(); model.begin_timestamp = row["begin_timestamp"].ToString(); model.end_timestamp = row["end_timestamp_day"].ToString(); model.quantity = int.Parse(row["quantity"].ToString()); model.can_give_friend = bool.Parse(row["can_give_friend"].ToString()); model.can_share = bool.Parse(row["can_share"].ToString()); model.default_detail = row["default_detail"].ToString(); model.deal_detail = row["Deal_detail"].ToString(); model.discount = row["discount"].ToString(); model.Paycell = bool.Parse(row["Paycell"].ToString()); model.hexiao = bool.Parse(row["hexiao"].ToString()); } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public XCWeiXin.Model.Card_wx.Card_BaseInfo GetModel(string Wx_Card_id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 BaseInfoID,wid,Card_type,logo_url,brand_name,title,sub_title,color,notice,service_phone,source,description,use_limit,get_limit,use_custom_code,bind_openid,can_share,type,begin_timestamp,end_timestamp_day,quantity,can_give_friend,url_name_type,custom_url,custom_url_name,custom_url_sub_title,promotion_url,promotion_url_name,least_cost,reduce_cost,default_detail,Deal_detail,discount,Wx_Card_id,Paycell,hexiao FROM Card_BaseInfo "); strSql.Append(" where Wx_Card_id=@Wx_Card_id"); SqlParameter[] parameters = { new SqlParameter("@Wx_Card_id", SqlDbType.VarChar, 100) }; parameters[0].Value = Wx_Card_id; XCWeiXin.Model.Card_wx.Card_BaseInfo model = new Model.Card_wx.Card_BaseInfo(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
protected void rptList_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName == "toufang") { // int dd = int.Parse(lbtn_Update.CommandArgument.ToString()); int dd = int.Parse(e.Item.ItemIndex.ToString()); string Cardid = ((HiddenField)rptList.Items[dd].FindControl("HiddenField1")).Value; var cardId = Cardid; string accessToken = Token(); var result = CardApi.CreateQR(accessToken, cardId); string ticket = result.ticket; string url_image = GetShowQrCodeUrl(ticket); int ss = int.Parse(e.Item.ItemIndex.ToString()); Image sss = (Image)rptList.Items[ss].FindControl("Image2"); sss.ImageUrl = url_image; } else if (e.CommandName == "deletecard") { DropDownList dr = new DropDownList(); dr = (DropDownList)rptList.Controls[0].FindControl("DropDownList2"); string dd = dr.SelectedValue; int cardid = int.Parse(e.Item.ItemIndex.ToString()); string card_wx_id = ((HiddenField)rptList.Items[cardid].FindControl("HiddenField1")).Value; var result = CardApi.CardDelete(Token(), card_wx_id); if (result.errmsg == "ok") { bll.delete(card_wx_id); } else { string ss = result.errmsg; } string where = "wid=" + wid() + " and Card_type=团购券"; Rqlistb(where); } else if (e.CommandName == "update_q") { int dd = int.Parse(e.Item.ItemIndex.ToString()); string Cardid = ((HiddenField)rptList.Items[dd].FindControl("HiddenField1")).Value; var cardId = Cardid; string Cardtype = ((HiddenField)rptList.Items[dd].FindControl("hd2")).Value; string accessToken = Token(); int ss = int.Parse(e.Item.ItemIndex.ToString()); TextBox sss = (TextBox)rptList.Items[ss].FindControl("quantity"); var result = CardApi.CardDetailGet(accessToken, cardId); if (Cardtype == "团购券") { sss.Text = result.card.groupon.base_info.sku.quantity.ToString(); } else if (Cardtype == "代金券") { sss.Text = result.card.cash.base_info.sku.quantity.ToString(); } else if (Cardtype == "折扣券") { sss.Text = result.card.discount.base_info.sku.quantity.ToString(); } else if (Cardtype == "优惠券") { sss.Text = result.card.general_coupon.base_info.sku.quantity.ToString(); } Model.Card_wx.Card_BaseInfo Base = new Model.Card_wx.Card_BaseInfo(); Base.quantity = int.Parse(sss.Text); Base.Wx_Card_id = cardId; Base.wid = wid(); bll.Upadata_kucun(Base); // var result= CardApi.ModifyStock(Token(), Cardid, int.Parse(sss.Text)); // try // { // if (result.errmsg == "ok") // { // } // } // catch (Exception ex) // { // } } else if (e.CommandName == "exit") { int dd = int.Parse(e.Item.ItemIndex.ToString()); string Cardid = ((HiddenField)rptList.Items[dd].FindControl("HiddenField1")).Value; var cardId = Cardid; string Cardtype = ((HiddenField)rptList.Items[dd].FindControl("hd2")).Value; Response.Redirect("Card_wx_exid.aspx?cardtype=" + Cardtype + "&cardid=" + cardId + "&type=exit"); } }
/// <summary> /// 更新卡券(编辑) /// </summary> /// <param name="model"></param> /// <returns></returns> public bool Exit_card(Model.Card_wx.Card_BaseInfo model) { return(dal.Exit_card(model)); }
/// <summary> /// 更改库存 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool Upadata_kucun(Model.Card_wx.Card_BaseInfo model) { return(dal.Upadata_kucun(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Model.Card_wx.Card_BaseInfo model) { return(dal.Add(model)); }