快要答辩了,求大哥哥,大姐姐帮帮忙

fengzhiqingreng 2012-04-24 10:19:10
哪位大哥,大姐,可以帮助小弟的 ,快要考试答辩了,还有点购物车不怎么懂,求帮完善一下,可以留下联系方式,asp.net,不会耽误大家太多时间的,因为很简单(嘿嘿),拜托了,拜托了
...全文
159 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
love_yyou 2012-04-25
  • 打赏
  • 举报
回复
什么学校,看起来学的东西还可以。。。。。
xuan.ye 2012-04-25
  • 打赏
  • 举报
回复
淘宝上有卖毕业答辩的
a402485188 2012-04-25
  • 打赏
  • 举报
回复
毕业答辩怕个鸟 只不过是一个垃圾形式 学费交齐 考试都过60分就能 毕业了 如果你已经找到工作饿了 立马把毕业证扔给你
a402485188 2012-04-25
  • 打赏
  • 举报
回复
前台用这么多服务器控件。。。。。看得都头晕。。。。。。。。。。。
想念旧时光 2012-04-25
  • 打赏
  • 举报
回复
楼主是大学的么?
  • 打赏
  • 举报
回复
LZ给力啊,还没毕业就能自己写代码了,我大学时候只顾着玩CS了
Im_yours 2012-04-25
  • 打赏
  • 举报
回复
<asp:TemplateField ShowHeader="False" HeaderText="操作" Visible="true">
<ItemTemplate>
<asp:LinkButton ID="Linkbutton1" runat="server" Text="修改" CommandName="lb_modify"
CommandArgument='<%#Eval("Base_ID")%>'></asp:LinkButton>
<asp:LinkButton ID="Linkbutton2" runat="server" Text="删除" CommandName="lb_del"
CommandArgument='<%#Eval("Base_ID")%>'></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>

后台:
protected void GridView_BD_RowCommand(object sender, GridViewCommandEventArgs e)
{
string _id = e.CommandArgument.ToString();

if(e.CommandName=="lb_modify")
{
修改写这里
}
if (e.CommandName == "lb_del")
{
删除写这里
}
}
IT-Style 2012-04-25
  • 打赏
  • 举报
回复
用Hashtable或者Dictionary保存数据.
键保存的是商品的ID,值保存的是商品的数据.
fengzhiqingreng 2012-04-25
  • 打赏
  • 举报
回复
感谢提醒帮助,搞定了。。。我是用gridview内置的编辑、删除,还有小计合计都做完了。。就差提交生成订单了。。嘿嘿[Quote=引用 4 楼 的回复:]
<asp:TemplateField ShowHeader="False" HeaderText="操作" Visible="true">
<ItemTemplate>
<asp:LinkButton ID="Linkbutton1" runat="server" Text="修改" CommandName="lb_modify"
CommandArgument='<%#Eval……
[/Quote]
fengzhiqingreng 2012-04-25
  • 打赏
  • 举报
回复
是的啊[Quote=引用 6 楼 的回复:]
楼主是大学的么?
[/Quote]
fengzhiqingreng 2012-04-24
  • 打赏
  • 举报
回复
还有删除。编辑购物车商品不会做。。。是单层架构。。
前台代码:
<%@ Page Title="" Language="C#" MasterPageFile="~/MemberPortal/MainSite.master" AutoEventWireup="true" CodeFile="Shopping.aspx.cs" Inherits="MemberPortal_Shopping" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div style=" text-align:left;">
<h1><img src="image/shopping.gif" width="121" height="21" /></h1>
<p style=" font-size:18px; font:幼圆;" >您选好的商品:<asp:Label ID="Label1" runat="server"
Text="Label" Visible="False"></asp:Label>
</p>

</div>
<br /><div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
Width="100%" BackColor="White" BorderColor="#999999" BorderStyle="None"
BorderWidth="1px" CellPadding="3" GridLines="Vertical" ShowFooter="True"
onrowdatabound="GridView1_RowDataBound"
onrowcommand="GridView1_RowCommand" onrowdeleting="GridView1_RowDeleting">
<AlternatingRowStyle BackColor="#DCDCDC" />
<Columns>
<asp:TemplateField HeaderText="图书编号">

<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("BookId") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="图书名称" FooterText="合计">

<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Eval("BookName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="单价">

<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Eval("UnitPrice") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="商品个数">
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%# Bind("Number") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Number") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="小计">
<ItemTemplate>

<asp:Label ID="Label5" Text="" runat="server"></asp:Label>

</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>

<asp:TemplateField HeaderText="操作" ShowHeader="False">
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Delete" Text="删除"></asp:LinkButton>
<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Edit" Text="编辑"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
<HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<RowStyle BackColor="#EEEEEE" ForeColor="Black" />
<SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="#0000A9" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#000065" />
</asp:GridView></div>
<div style=" text-align:right; margin-top:10px;">
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/MemberPortal/image/balance.gif" /></div>
</asp:Content>

后台代码:

public partial class MemberPortal_Shopping : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if(Request.QueryString["Op"]=="BuyBooks"){
int bookId = Convert.ToInt32(Request.QueryString["bookId"]);
BuyBooks(bookId);
}
if (Session["Cart"] != null)
{
BindCart();

}
else {
Label1.Text = "目前还没有购买任何图书";
}
}


}

private void BindCart() {
GridView1.DataSource = Session["Cart"];
GridView1.DataBind();

}
private void BuildCart() {
DataTable cart = new DataTable();
cart.Columns.Add("BookId",typeof(Int32));
cart.Columns.Add("BookName",typeof(string));
cart.Columns.Add("UnitPrice", typeof(double));
cart.Columns.Add("Number", typeof(Int32));

Session["Cart"] = cart;
}
private void AppendBooks(int bookId,string bookName,double unitPrice,int number) {
DataTable cart =Session["Cart"] as DataTable;

DataRow dr = cart.NewRow();
dr["BookId"]=bookId;
dr["BookName"]=bookName;
dr["UnitPrice"] = unitPrice;
dr["Number"] = number;
cart.Rows.Add(dr);
Session["Cart"] = cart;

}
private bool ExistBook(int bookId) {
DataTable cart = Session["Cart"] as DataTable;

foreach (DataRow dr in cart.Rows) {
if (Convert.ToInt32(dr["BookId"]) == bookId) {
return true;
}
}
return false;

}

private void UpdateBooks(int bookId)
{
DataTable cart = Session["Cart"] as DataTable;

foreach (DataRow dr in cart.Rows)
{
if (Convert.ToInt32(dr["BookId"]) == bookId)
{
dr["Number"] = Convert.ToInt32(dr["Number"])+1;

}
}

Session["Cart"] = cart;


}
private void BuyBooks(int bookId) {
string strConn = ConfigurationManager.ConnectionStrings["conn"].ConnectionString;
SqlConnection conn = new SqlConnection(strConn);
conn.Open();

string sql = "select * from Books where Id=@Id";
SqlDataAdapter dr = new SqlDataAdapter(sql, conn);
DataSet ds = new DataSet();
SqlParameter[] paras = new SqlParameter[]{
new SqlParameter("@Id",bookId),

};
dr.SelectCommand.Parameters.AddRange(paras);
dr.Fill(ds, "CategoryTable");
string bookName = ds.Tables["CategoryTable"].Rows[0][1].ToString();
double unitPrice = Convert.ToDouble(ds.Tables["CategoryTable"].Rows[0][7].ToString());
if (Session["Cart"] == null)
{
this.BuildCart();
this.AppendBooks(bookId,bookName, unitPrice ,1);
}
else {
if (ExistBook(bookId))
{

this.UpdateBooks(bookId);

}
else {
this.AppendBooks(bookId, bookName, unitPrice ,1);
}
}

}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#D3D7F5'");
e.Row.Attributes.Add("onmouseout", "currentcolor=this.style.backgroundColor=currentcolor");

Label lblPrice = e.Row.FindControl("Label3") as Label;
Label lblNumber = e.Row.FindControl("Label4") as Label;
Label lblTotal = e.Row.FindControl("Label5") as Label;

double UnitPrice = Convert.ToDouble(lblPrice.Text);
int Number = Convert.ToInt32(lblNumber.Text);
double Total = UnitPrice * Number;
lblTotal.Text = Total.ToString();

}


}
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{

}
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{

}
}
test2050 2012-04-24
  • 打赏
  • 举报
回复
这种事求人不如自己多花点时间搞定它。
threenewbee 2012-04-24
  • 打赏
  • 举报
回复
网上很多,使用cookie或者session保存一张表,记录产品id、数量。

62,046

社区成员

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

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

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

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