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

📄 adminorderlistmanger.aspx.cs

📁 完成一个网上书店系统
💻 CS
字号:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
public partial class AdminOrderListManger : System.Web.UI.Page
{
    Class1 db = new Class1();
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    //感觉这个函数没有用,只会修改Orders的值,而不会修改用户表中的金钱总数
    protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
    {
        for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
        {
            CheckBox chk = (CheckBox)GridView1.Rows[i].FindControl("CheckBox1");
            if (chk.Checked)
            {
                //审核通过
                int orderid = Convert.ToInt32(GridView1.DataKeys[i].Value);
                string str = "update Orders set ischecked=1 where OrderID=" + orderid + "";
                db.ExecSql(str);
                int uid = Convert.ToInt32(((Label)GridView1.Rows[i].FindControl("Label1")).Text);
                Decimal money = FindMoneyCount(orderid);
                 string uqdate_money = "update Users set MoneyCount=MoneyCount - " + money + " where UserID=" +uid;
                 db.ExecSql(uqdate_money);
            }
           
        }
    }
    protected Decimal FindMoneyCount(int orderid)
    {
        string sql = "select Sum(MoneyCount)as MoneyCount from OrderContent where OrderID=" + orderid;
        SqlDataReader dr = db.Reader(sql);
        if(dr.Read())
        {
            return dr.GetDecimal(0);
        }
        else 
        return 0;
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
        {
             CheckBox chk = (CheckBox)GridView1.Rows[i].FindControl("CheckBox1");
             if (chk.Checked)
             {
                 int orderid = Convert.ToInt32(GridView1.DataKeys[i].Value);
                 string str = "update Orders set ischecked=1 where OrderID=" + orderid + "";
                 db.ExecSql(str);
                 int uid = Convert.ToInt32(((Label)GridView1.Rows[i].FindControl("Label1")).Text);
                 Decimal money = FindMoneyCount(orderid);
                 string uqdate_money = "update Users set MoneyCount=MoneyCount - " + money + " where UserID=" + uid;
                 db.ExecSql(uqdate_money);
             }
        }
    }
}

⌨️ 快捷键说明

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