📄 qianbao.aspx.cs
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class qianbao : System.Web.UI.Page
{
static decimal sum1,sum2,sum3 ;
protected void Page_Load(object sender, EventArgs e)
{
//接受传送数据
Label7.Text = Request.QueryString["id"];
sum2 = decimal.Parse(Request.QueryString["total"]);
Label3.Text = sum2.ToString();
string strCon = "Data Source=(local);Database=db_11;Uid=sa;Pwd=";
string sqlstr = "select money from tb_Member111 where id ='" + Label7.Text.Trim() + " '";
SqlConnection sqlcon = new SqlConnection(strCon);
SqlCommand com=new SqlCommand(sqlstr,sqlcon);
sqlcon.Open();
SqlDataAdapter da = new SqlDataAdapter(sqlstr, sqlcon);
DataSet ds = new DataSet();
da.Fill(ds);
sqlcon.Close();
DataRow[] row1=ds.Tables[0].Select();
foreach (DataRow dr in row1)
{
sum1 =decimal.Parse(dr["money"].ToString().Trim());
}
this.Label2.Text= sum1.ToString();
}
protected void Button1_Click(object sender, EventArgs e)
{
if (sum1 >= sum2)
{
sum3 = sum1 - sum2;
string strCon3 = "Data Source=(local);Database=db_11;Uid=sa;Pwd=";
string sqlstr3 = "update tb_Member111 set money = "+sum3+" where id= '" + this.Label7.Text.Trim() + " '";
SqlConnection sqlcon3 = new SqlConnection(strCon3);
SqlCommand com3 = new SqlCommand(sqlstr3, sqlcon3);
sqlcon3.Open();
com3.ExecuteNonQuery();
sqlcon3.Close();
string sUrl = "CheckOut.aspx?id=" + Label7.Text ;
Response.Redirect(sUrl);
}
else
{
Response.Write("<script>alert('余额不足,请充值')</script>");
}
}
protected void Button2_Click(object sender, EventArgs e)
{
string sUrl = "chongqian.aspx?id=" + Label7.Text + "&total=" + sum2.ToString() + "&yue=" + Label2.Text;
Response.Redirect(sUrl);
}
protected void Button3_Click(object sender, EventArgs e)
{
Response.Redirect("Default.aspx");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -