⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 als.aspx.cs

📁 购物车主要是为广大网上顾客购物的资源平台。购物车主要目标是建设在网上对用户进行信息服务互动平台。
💻 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 ALS : System.Web.UI.Page
{

    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["Aname"] == null)
        { Response.Redirect("Default.aspx"); }
        this.Label3.Visible = false;
        this.TextBox2.Visible = false;
        this.Button1.Visible = false;
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        if (this.TextBox1.Text != "")
        {
            SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["connstring"].ConnectionString);
            string sql = "select Uname as '用户名',Umomey as '账户余额' from Userlist where Uid='" + this.TextBox1.Text + "'";
            conn.Open();
            SqlCommand cmd = new SqlCommand(sql, conn);
            int a =cmd.ExecuteNonQuery();
             DataSet ds = new DataSet();
             SqlDataAdapter da = new SqlDataAdapter(cmd);
             da.Fill(ds);
             conn.Close();
             GridView1.DataSource = ds.Tables[0];
             GridView1.DataBind();
             if (GridView1.Rows.Count != 0)//判断用户是否存在
             {
                 this.Label3.Visible = true;
                 this.TextBox2.Visible = true;
                 this.Button1.Visible = true;

             }
             else
             {

                 Response.Write("该用户不存在!");
             }

        }
        else
        {
            Response.Write("请输入要充值的用户ID!");
        }

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (this.TextBox2.Text != "")
        {
            SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["connstring"].ConnectionString);
            float a = float.Parse(this.GridView1.Rows[0].Cells[1].Text);
            float b = float.Parse(this.TextBox2.Text.ToString());
            float c = a + b;
            string sql = "update  userlist set Umomey='" + c + "'";
            conn.Open();
            SqlCommand cmd = new SqlCommand(sql, conn);
            cmd.ExecuteNonQuery();
            conn.Close();



            string sql2 = "select Uname as '用户名',Umomey as '账户余额' from Userlist where Uid='" + this.TextBox1.Text + "'";
            conn.Open();
            SqlCommand cmd2 = new SqlCommand(sql2, conn);
            DataSet ds = new DataSet();
            SqlDataAdapter da = new SqlDataAdapter(cmd2);
            da.Fill(ds);
            conn.Close();
            GridView1.DataSource = ds.Tables[0];
            GridView1.DataBind();
            this.TextBox2.Text = "";
            Response.Write("充值成功!");
        }
        else
        {
            Response.Write("请输入要充入的金额!");
        }
    }
    protected void Button3_Click(object sender, EventArgs e)
    {
        Session.Abandon();
        Response.Redirect("Default.aspx");//管理员退出
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -