变量解释

litengfei001 2010-04-12 01:41:20
麻烦各位看下 bool P_bool_reVal1 这个是什么意思啊 看不懂这里了


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;

public partial class ShoppingCart : System.Web.UI.Page
{
public static string M_str_Count;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
if (Session["UserID"] != null)


{
//向购物车中添加商品,如果购物车中已经存在该商品,则商品数量加1,如果是第一次购买,则向购物车中添加一条商品信息

string P_str_CartID = Session["UserID"].ToString();


string P_str_GoodsID = Request["GoodsID"];
DataSet ds = DB.reDs("select count(*) from tb_Cart where CartID=" + P_str_CartID + "and GoodsID=" + P_str_GoodsID);
if (ds.Tables[0].Rows[0][0].ToString() == "0")
{

DataSet ds1 = DB.reDs("select GoodsName,GoodsPrice from tb_GoodsInfo where GoodsID=" + P_str_GoodsID);
string P_str_GoodsName = ds1.Tables[0].Rows[0][0].ToString();
string P_str_GoodsPrice = ds1.Tables[0].Rows[0][1].ToString();
string P_str_Num = "1";
DB.ExSql("insert into tb_Cart values(" + P_str_CartID + "," + P_str_GoodsID + ",'" + P_str_GoodsName + "'," + P_str_GoodsPrice + "," + P_str_Num + ")");
}
else
{
DB.ExSql("update tb_Cart set Num=Num+1 where CartID=" + P_str_CartID + "and GoodsID=" + P_str_GoodsID);
}


//显示购物车中的商品信息
Bind();
}
}
//绑定DataList控件
public void Bind()
{
DataSet ds2 = DB.reDs("select *,GoodsPrice*Num As Count from tb_Cart where CartID=" + Session["UserID"]);
float P_fl_Count = 0;
foreach (DataRow dr in ds2.Tables[0].Rows)
{
P_fl_Count += Convert.ToSingle(dr[6]);
}
M_str_Count = P_fl_Count.ToString();
dlShoppingCart.DataSource = ds2;
dlShoppingCart.DataBind();
}

protected void dlShoppingCart_ItemDataBound(object sender, DataListItemEventArgs e)
{
//用来实现数量文本框中只能输入数字
TextBox txtGoodsNum = (TextBox)e.Item.FindControl("txtGoodsNum");
if (txtGoodsNum != null)
{
txtGoodsNum.Attributes["onkeyup"] = "value=value.replace(/[^\\d]/g,'')";
}

}
//清空购物车
protected void lnkbtnClear_Click(object sender, EventArgs e)
{
bool P_bool_reVal = DB.ExSql("Delete from tb_Cart where CartID=" + Session["UserID"]);
if (!P_bool_reVal)
Response.Write("<script>清空失败,请重试!</script>");
else
Bind();
}
//清空购物车时的提示信息
protected void lnkbtnClear_Load(object sender, EventArgs e)
{
lnkbtnClear.Attributes["onclick"] = "javascript:return confirm('你确定要清空购物车吗?')";
}
//继续购物
protected void lnkbtnContinue_Click(object sender, EventArgs e)
{
Response.Redirect("~/Default.aspx");
}
//删除购物车中的商品
protected void dlShoppingCart_DeleteCommand(object source, DataListCommandEventArgs e)
{
bool P_bool_reVal = DB.ExSql("Delete from tb_Cart where CartID=" + Session["UserID"] + " and GoodsID=" + e.CommandArgument.ToString());
if (!P_bool_reVal)
Response.Write("<script>删除失败,请重试!</script>");
else
Bind();
}
//删除购物车中的商品时的提示信息
protected void lnkbtnDel_Load(object sender, EventArgs e)
{
((LinkButton)sender).Attributes["onclick"] = "javascript:return confirm('你确定要删除该物品吗?')";
}
//更新购物车
protected void dlShoppingCart_ItemCommand(object source, DataListCommandEventArgs e)
{
if (e.CommandName == "updateNum")
{
string P_str_Num = ((TextBox)e.Item.FindControl("txtGoodsNum")).Text;
bool P_bool_reVal = DB.ExSql("update tb_Cart set Num=" + P_str_Num + "where CartID=" + Session["UserID"] + "and GoodsID=" + e.CommandArgument.ToString());
if (P_bool_reVal)
Bind();
}
}
protected void lnkbtnSettleAccounts_Click(object sender, EventArgs e)
{
if (M_str_Count == "")
{
Response.Write("<script>alert('您的购物车中没有任何物品!');</script>");
}
else
if (Session["UserID"] != null)
{
DataSet ds = DB.reDs("select Money from tb_User where UserID=" + Session["UserID"].ToString());
decimal P_str_Money = Convert.ToDecimal(ds.Tables[0].Rows[0][0].ToString());
if (P_str_Money < Convert.ToDecimal(M_str_Count))
{
Response.Write("<script>alert('您的余额不足,请重新充值后再购买!');</script>");
}
else
{
bool P_bool_reVal1 = DB.ExSql("Delete from tb_Cart where CartID=" + Session["UserID"]);
bool P_bool_reval2 = DB.ExSql("update tb_User set Money=Money-" + M_str_Count + " where UserID=" + Session["UserID"]);
if (!P_bool_reVal1 & !P_bool_reval2)
{
Response.Write("<script>结账失败,请重试!</script>");
}
else
{
Bind();
//Response.Redirect("SuccessShop.aspx");
Response.Write("<script>window.open('SuccessShop.aspx','','Width=300px;Height=250px;status=no;help=no;scrollbars=no');</script>");
}
}
}
}
protected void dlShoppingCart_SelectedIndexChanged(object sender, EventArgs e)
{

}
}
...全文
125 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
yufenghua 2010-04-12
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 wx8849 的回复:]

这只是定义了一个bool类型的变量,变量名为P_bool_reVal1
[/Quote]顶
litengfei001 2010-04-12
  • 打赏
  • 举报
回复
好啊 我请多问几个啊 都有那几个可以定义变量啊 比如 string bool 还有什么啊
asdfa23rdadsdfa 2010-04-12
  • 打赏
  • 举报
回复
快点把份给我,没份了我
litengfei001 2010-04-12
  • 打赏
  • 举报
回复
明白了 谢谢 各位了
wx8849 2010-04-12
  • 打赏
  • 举报
回复
这只是定义了一个bool类型的变量,变量名为P_bool_reVal1
asdfa23rdadsdfa 2010-04-12
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 litengfei001 的回复:]
reVal 这个字符串 从何而来啊 他代表什么意思
[/Quote]
reVal这个字符串?你上面的代码有这个字符串吗?
都是附带在变量名身上
还有bool就是true/false
真的没什么意思。
litengfei001 2010-04-12
  • 打赏
  • 举报
回复
vip__888 什么意思啊
vip__888 2010-04-12
  • 打赏
  • 举报
回复
bool..
litengfei001 2010-04-12
  • 打赏
  • 举报
回复
reVal 这个字符串 从何而来啊 他代表什么意思
wx8849 2010-04-12
  • 打赏
  • 举报
回复
true 代表成功 false代表失败
wx8849 2010-04-12
  • 打赏
  • 举报
回复
就是一个bool的变量~

就是true 和 false 2个值
asdfa23rdadsdfa 2010-04-12
  • 打赏
  • 举报
回复
bool P_bool_reVal1 = DB.ExSql("Delete from tb_Cart where CartID=" + Session["UserID"]);
记录删除成功与否啊。。我狂晕 明名就是Delete 只有删除成功或失败或异常

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧