protected void BTsubmit_Click(object sender, EventArgs e) { if (Request.QueryString["idd"] != null) { string qq = Request.QueryString["idd"]; CashKaAct kaAct = new CashKaAct(); string ka = txtChongzhika.Text.Trim(); CashKa chongzhika = kaAct.GetByNumber(ka); if (string .IsNullOrEmpty( chongzhika.QQ)==false ) { MessageBox("充值卡已经被使用"); return; } try { kaAct.Chongzhi(ka, qq); UserAct userAct = new UserAct(); User user = userAct.GetByid(qq); user.Jifen+=chongzhika .Cash; userAct.Edit(user); JifenChangeAct jifenAct = new JifenChangeAct(); jifenAct.Add(qq, chongzhika.Cash, JifenChangeType.充值, true); MessageBox("充值成功!"); } catch (Exception ex) { MessageBox(ex.Message); } } }
protected void BTadd_Click(object sender, EventArgs e) { int cash = 0; try { cash = Convert.ToInt32(TextBox1.Text.Trim()); } catch (Exception ex) { MessageBox("请填写正确的面值"); return; } int amount = 0; try { amount = Convert.ToInt32(TextBox2.Text.Trim()); } catch (Exception ex) { MessageBox("请填写正确的数量"); return; } CashKaAct cashAct = new CashKaAct(); string result=null ; try { Random r = new Random((int)DateTime.Now.Ticks); for (int i = 0; i < amount; i++) { byte [] bytes=new byte [5]; r.NextBytes (bytes ); string no = bytes[0].ToString() + bytes[1].ToString() + bytes[2].ToString() + bytes[3].ToString() + bytes[4].ToString(); cashAct.Add(no, cash); result += no + "\r\n"; } } catch (Exception ex) { MessageBox(ex.Message); return; } Response.Clear(); Response.Buffer = false; Response.ContentType = "application/octet-stream"; Response.AppendHeader("content-disposition", "attachment;filename=Chonghzika.txt;"); // 读取数据库,循环 Response.Write(result); Response.Flush(); Response.End(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { CashKaAct userAct = new CashKaAct(); if (Request.QueryString["id"] != null) { userAct.Del(Request.QueryString["id"]); MessageBox("删除成功!"); } Ruserlist.DataSource = userAct.GetAll (); Ruserlist.DataBind(); } }