毕业论文论文范文课程设计实践报告法律论文英语论文教学论文医学论文农学论文艺术论文行政论文管理论文计算机安全
您现在的位置: 毕业论文 >> 论文 >> 正文

ASP.NET网上购物系统毕业论文(致谢+开题报告+任务书+答辩PPT) 第5页

更新时间:2010-4-5:  来源:毕业论文
ASP.NET网上购物系统毕业论文(致谢+开题报告+任务书+答辩PPT) 第5页
 MyError.Text = "购物车内没有商品。";
   }
   else
   { // 绑定购物车信息到DataGrid
    MyList.DataSource = cart.GetItems(cartID);
    MyList.DataBind();
    //显示总金额
    lblTotal.Text = String.Format( "{0:c}", cart.GetTotal(cartID));
   }
  }
  void UpdateShoppingCartDatabase()
  { BLL.ShoppingCart cart = new BLL.ShoppingCart();
   // 获得用户的cartID
   String cartID = cart.GetShoppingCartId();
   // 遍历DataGrid的每一行
   for (int i=0; i < MyList.Items.Count; i++)
   { // 找到某行的数量信息和删除信息。
    TextBox quantityTxt = (TextBox) MyList.Items[i].FindControl("Quantity");
    CheckBox remove = (CheckBox) MyList.Items[i].FindControl("Remove");
    // 出错处理。防止用户的非法输入,如quanlity为负数等
    int quantity;
    try
    { quantity = Int32.Parse(quantityTxt.Text);
     // 如果数量被修改或者Remove复选框被选中
     if (quantity != Convert.ToInt32(MyList.DataKeys[i]) || remove.Checked == true)
     { Label lblBookID = (Label) MyList.Items[i].FindControl("bookID");
      //数量为0或用户选择删除
      if (quantity == 0 || remove.Checked == true)
      { cart.RemoveItem(cartID, Int32.Parse(lblBookID.Text));
      }
      else
      { cart.UpdateItem(cartID, Int32.Parse(lblBookID.Text),quantity);
      }
     }
    }
    catch
    { MyError.Text = "对不起,您的输入信息有误!";
    }
   }
  }
  private void UpdateBtn_Click(object sender, System.EventArgs e)
  { //更新购物车记录,并重新显示记录
   UpdateShoppingCartDatabase();
   ShowShoppingCartList();
  }
  private void CheckoutBtn_Click(object sender, System.EventArgs e)
  { //更新购物车记录
   UpdateShoppingCartDatabase();
   //如果购物车不为空,跳转到CheckOut页面
   //否则,给出错误提示信息
   BLL.ShoppingCart cart = new BLL.ShoppingCart();
   //获得购物车ID
   string cartID = cart.GetShoppingCartId();
   //检查购物记录是否为0
   if (cart.GetItemCount(cartID) != 0)
   { Response.Redirect("CheckOut.aspx");
   }
   else
   { MyError.Text = "购物车为空,不能提交!";
   } 
 }
4、后台管理模块的实现:
后台管理模块是一个完整的电子商务系统不可或缺的部分,其实现代码如下:
登录(Login.aspx.cs)的代码实现:
private void Page_Load(object sender, System.EventArgs e)
  { // 在此处放置用户代码以初始化页面
  }
  private void Submit_Click(object sender, System.EventArgs e)
  { AdminDB admin = new AdminDB();
   int adminId = admin.Login(LoginName.Text.Trim(), Password.Text.Trim());
   if (adminId == 0)
   { Message.Text = "用户名或密码错误!";
   }
   else
   {    System.Web.Security.FormsAuthentication.RedirectFromLoginPage(adminId.ToString(), false);
    Session["RoleId"] = admin.GetAdminRole(adminId.ToString());
AdminDB.InsertAction("登录", System.DateTime.Now, adminId.ToString());      }     
}

添加商品信息(AddProduct.aspx.cs)的代码实现:
private void Page_Load(object sender, System.EventArgs e)
  { if (!Page.IsPostBack)
   { BindList();
   }
  }
  private void Add_Click(object sender, System.EventArgs e)
  { AdminDB admin = new AdminDB();
   try
{ admin.AddNewProduct(ProductName.Text.Trim(), decimal.Parse(Price.Text.Trim()), Intro.Text, int.Parse(ListCat.SelectedValue));
    MyError.Text = "添加成功!";
AdminDB.InsertAction("添加新的商品"+ ProductName.Text.Trim(), System.DateTime.Now, User.Identity.Name);
   }
   catch
   { MyError.Text = "出错了";
   }
  }
  void BindList()
  { ListCat.DataSource = eshop.BLL.Product.GetCategoryList();
   ListCat.DataTextField = "CategoryName";
   ListCat.DataValueField = "CategoryId";
   ListCat.DataBind();
  }

查询用户信息、添加用户账户存款(UserList.aspx.cs)的代码实现:
private void Page_Load(object sender, System.EventArgs e)
  { if (!Page.IsPostBack)
   { BindGrid();
AdminDB.InsertAction("查看用户列表", System.DateTime.Now,User.Identity.Name);
   }
  }
  void BindGrid()
  { AdminDB admin = new AdminDB();
   GridUsers.DataSource = admin.GetUserList();
   GridUsers.DataBind();
  }
  private void GridUsers_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
  { GridUsers.CurrentPageIndex = e.NewPageIndex;
   BindGrid();
  }
  private void GridUsers_EditCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
www.youerw.com
  private void GridUsers_CancelCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
  { GridUsers.EditItemIndex = -1;
   BindGrid();
  }
  private void GridUsers_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
  { //获得输入的预存款金额
   decimal money = decimal.Parse(((TextBox)e.Item.FindControl("Acount")).Text.Trim());
   //获得要更改的用户的UserId
   int userId = Convert.ToInt32(GridUsers.DataKeys[e.Item.ItemIndex]);
   AdminDB admin = new AdminDB();
   //执行更新操作
   admin.UpdateUserAcount(money, userId.ToString());
   //插入日志
   AdminDB.InsertAction("修改用户Id为" + userId.ToString() + "的帐户金额", System.DateTime.Now, User.Identity.Name);
   //退出编辑状态
   GridUsers.EditItemIndex = -1;
   //绑定
   BindGrid();       

上一页  [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]  ... 下一页  >> 

ASP.NET网上购物系统毕业论文(致谢+开题报告+任务书+答辩PPT) 第5页下载如图片无法显示或论文不完整,请联系qq752018766
设为首页 | 联系站长 | 友情链接 | 网站地图 |

copyright©youerw.com 优文论文网 严禁转载
如果本毕业论文网损害了您的利益或者侵犯了您的权利,请及时联系,我们一定会及时改正。