Shopping _Car.aspx.cs

(开头部分) 3KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using ClassLibrary2;

public partial class Shopping__Car : System.Web.UI.Page
{
    string str = System.Configuration.ConfigurationManager.AppSettings["str_con"].ToString(); //连接数据库
    SqlConnection con = null;
    SqlCommand cmd = null; 
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack) {
            bind();
        }
    }
    public void bind() {
        con = new SqlConnection(str);
        string str_cmd = "select 英雄信息表.英雄名称,英雄类型,单价,photo,购物车信息表.Num from 英雄信息表,购物车信息表 where 购物车信息表.Commodity_Name=英雄信息表.英雄名称 and yh_id='" + Session["login"] + "'";
        con.Open();
        SqlDataAdapter dr = new SqlDataAdapter(str_cmd,con);
        DataSet ds = new DataSet();
        dr.Fill(ds);
        GridView1.DataSource = ds;
        GridView1.DataBind();
        con.Close();
    }

    protected void count_Click(object sender, EventArgs e)   //提交订单
    {
        con = new SqlConnection(str);
        string str_cmd="";
        
        for (int i = 0; i < GridView1.Rows.Count; i++) {
            if (((CheckBox)GridView1.Rows[i].FindControl("cb")).Checked == true)
            {
                str_cmd = "UPDATE [dbo].[购物车信息表] SET flag = '1' where yh_id = '" + Session["login"] + "'and Commodity_Name = '" + GridView1.DataKeys[i].Value.ToString().Trim() + "'";             
            }
            else
            {
                str_cmd = "UPDATE [dbo].[购物车信息表] SET flag = '0' where yh_id = '" + Session["login"] + "'and Commodity_Name = '" + GridView1.DataKeys[i].Value.ToString().Trim() + "'";
            }
            con.Open();
            cmd = new SqlCommand(str_cmd, con);
            cmd.ExecuteNonQuery();
            con.Close();
        }
         Server.Transfer("Settlement.aspx"); //结算界面
    }
    protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
    {
        //编辑
        GridView1.EditIndex = e.NewEditIndex;//获取当前编辑序列号
        bind();
    }
后面还有 43 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。