protected void Page_Load(object sender, EventArgs e) { IList<ManagerOrderItem> managerorderitemlist = new OrderControl().GetOrderItemByStatus(2); foreach (var v in managerorderitemlist) { Response.Write("*************欢迎光临一乐订餐*************<br/>"); Response.Write("订单号:" + v.OrderReference + "<br/>"); Response.Write("用户名:" + v.UserName + "<br/>"); Response.Write("--------------销售--------------<br/>"); Response.Write("<table><tr><td>商品名称</td><td>单价</td><td>数量</td><td>销售量</td></tr>"); foreach(var u in v.FoodList) { Response.Write( "<tr><td>"+u.FoodName+"</td>" + "<td>" + Convert.ToString(u.FoodPrice) + "</td>" + "<td>" + u.FoodNum + "</td>" + "<td>" + u.MoneyCount + "</td></tr>"); } Response.Write("<br/>"); Response.Write("</table>"); Response.Write("--------------------------------</br>"); Response.Write("数量合计:" + Convert.ToString(v.FoodNum) + "<br/>"); Response.Write("交易合计:" + Convert.ToString(v.Total) + "元<br/>"); Response.Write("交易时间:" + v.PayTime.ToString() + "<br/>"); Response.Write("收货地址:" + v.Address + "<br/>"); Response.Write("联系电话:" + v.PhoneNum + "<br/>"); Response.Write("*************非常感谢您的支持*************<br/>"); Response.Write("<br/><br/><br/>"); } }
/// <summary> /// 确认订单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void ConfirmLink_Click(object sender, EventArgs e) { //提示是否确认收货!! OrderControl oc = new OrderControl(); oc.ConfirmOrderByOrderId(Convert.ToInt32(Session["OrderId"])); Response.Write("<script language=javascript>window.location.href=window.location.href;</script>"); }
/// <summary> /// 删除一条食物 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void LinkButton1_Click(object sender, EventArgs e) { //获取要删除的食物的索引 LinkButton lbton = (LinkButton)sender; DataListItem gvr = (DataListItem)lbton.Parent; int foodindex = gvr.ItemIndex; OrderFoodControl ofc = new OrderFoodControl(); OrderControl oc = new OrderControl(); foodlist = oc.GetProductCarFoodList(userid); fooditemlist = oc.GetFoodItemByOrderFoodList(foodlist); int foodid = fooditemlist.ElementAt(foodindex).FoodId; int orderid = fooditemlist.ElementAt(foodindex).OrderId; Session["OrderId"] = orderid; //删除订单食物,如果订单里面没有食物了,就删除这个订单 ofc.DeleteOrderFood(orderid, foodid); if(1 == foodlist.Count) { OrderData _order = new OrderData(); _order.DeleteOrder(_order.GetOrderById(orderid)); } Response.Write("<script language=javascript>window.location.href=window.location.href;</script>"); }
//确认并提交订单 protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { string userid = Convert.ToString(Session["UserId"]); if ("" == userid) { Page.Response.Write("<script>alert('请重新登录!')</script>"); return; } string address = AddressBox.Text; string phonenum = PhoneNumBox.Text; string otherreq = OtherReqBox.Text; if ("" != address && "" != phonenum) { OrderControl ordercontrol = new OrderControl(); int orderid = ordercontrol.SubmitOrder(Convert.ToInt32(userid),address, phonenum, otherreq); //orderid保存到Session中,以便付款时取出 Session["OrderId"] = Convert.ToString(orderid); Response.Write("<script language=javascript>window.location.href='Pay.aspx';</script>"); } else { Page.Response.Write("<script>alert('请正确填写信息!')</script>"); } }
/// <summary> /// 点击已完成付款的处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void FinishPayLink_Click(object sender, EventArgs e) { OrderControl oc = new OrderControl(); string orderid = Convert.ToString(Session["OrderId"]); if("" != orderid && null != orderid) { int OrderId = Convert.ToInt32(orderid); oc.PayOrderByOrderId(OrderId); Session["OrderId"] = null; Response.Write("<script language=javascript>window.location.href='MyOrder.aspx';</script>"); } }
/// <summary> /// 用户模块中设置购物车中食物数量 /// </summary> /// <param name="orderControl"></param> public void GetProductNum() { //设置购物车数量 int userid = Convert.ToInt32(Session["UserId"].ToString()); OrderControl orderControl = new OrderControl(); IList<OrderFood> orderfoodlist = orderControl.GetProductCarFoodList(userid); int productnum = 0; foreach (var u in orderfoodlist) { productnum += u.FoodNum; } this.MyCar.Text = "我的购物车[" + productnum.ToString() + "]"; }
protected void Page_Load(object sender, EventArgs e) { Panel1.Visible = false; Panel2.Visible = true; int userid = Convert.ToInt32(Session["UserId"]); OrderControl oc = new OrderControl(); IList<OrderFood> foodlist = oc.GetProductCarFoodList(userid); if (0 == foodlist.Count) { Panel1.Visible = true; Panel2.Visible = false; return; } }
///用户点击购买食物,处理订单(购物车) protected void FoodListView_OnItemCommand(object sender, DataListCommandEventArgs e) { //未登录 if (Session["UserName"] == null) { Page.Response.Write("<script>alert('请登录!')</script>"); return; } //从Session获取userId,从ItemIndex获取foodId,调用逻辑层的购物车 //从DataList中选择,得到foodid int foodselectindex = FoodListView.SelectedIndex = e.Item.ItemIndex; int foodid = foodlist.ElementAt(foodselectindex).FoodId; int userId = Convert.ToInt32(Session["UserId"].ToString()); //调用逻辑层实现加入购物车 OrderControl oc = new OrderControl(); oc.ProductCarAddFood(userId, foodid); Response.Write("<script language=javascript>window.location.href='index.aspx';</script>"); }
protected void FoodNum_TextChanged(object sender, EventArgs e) { //获取修改了的TextBox的FoodItem项的索引 TextBox tb = (TextBox)sender; if (tb.Text == "0") { Page.Response.Write("<script>alert('食物数量不能为0!您可以选择删除该食物。')</script>"); Response.Write("<script language=javascript>window.location.href=window.location.href;</script>"); return; } DataListItem gvr = (DataListItem)tb.Parent; int foodindex = gvr.ItemIndex; //调用逻辑层修改食物数量 int userid = Convert.ToInt32(Session["UserId"]); OrderFoodControl ofc = new OrderFoodControl(); OrderControl oc = new OrderControl(); foodlist = oc.GetProductCarFoodList(userid); fooditemlist = oc.GetFoodItemByOrderFoodList(foodlist); int foodid = fooditemlist.ElementAt(foodindex).FoodId; int foodnum = Convert.ToInt32(tb.Text.ToString()); ofc.ModifyFoodNum(userid, foodid, foodnum); Response.Write("<script language=javascript>window.location.href=window.location.href;</script>"); }
/// <summary> /// 按了查看后显示OrderDetailPanel,隐藏OrderListPanel /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void LinkButton1_Click(object sender, EventArgs e) { //获取订单的索引 LinkButton lbton = (LinkButton)sender; DataListItem gvr = (DataListItem)lbton.Parent; int foodindex = gvr.ItemIndex; //获取这个页面上的所有OrderItem,通过foodindex索引得到orderid userid = Convert.ToInt32(Session["UserId"]); OrderControl oc = new OrderControl(); IList<OrderItem> orderlisttemp = oc.GetOrderItemListByUserId(userid); //按时间排序 var orderlist1 = orderlisttemp.OrderByDescending(st => st.OrderTime); IList<OrderItem> orderlist = new List<OrderItem>(); foreach (var v in orderlist1) { orderlist.Add(v); } //将订单信息保存在Session中 Session["OrderId"] = orderlist[foodindex].OrderId; //Session["OrderReference"] = orderlist[foodindex].OrderReference; //Session["OrderTime"] = orderlist[foodindex].OrderTime; //Session["OrderStatus"] = orderlist[foodindex].Status; Session["OrderTotal"] = orderlist[foodindex].Total; //Session["OrderRequest"] = orderlist[foodindex].OtherReq; //显示OrderDetailPanel,隐藏OrderListPanel OrderDetailPanel.Visible = true; OrderListPanel.Visible = false; //在OrderDetailPanel中显示该订单信息 OrderReferenceLabel.Text = orderlist[foodindex].OrderReference; OrderTimeLabel.Text = orderlist[foodindex].OrderTime.ToLongDateString() + orderlist[foodindex].OrderTime.ToLongTimeString(); UserNameLabel.Text = Convert.ToString(Session["UserName"]); StatusLabel.Text = orderlist[foodindex].Status; Total.Text = orderlist[foodindex].Total.ToString(); //根据订单状态判断显示内容 switch (orderlist[foodindex].Status) { case "未付款": StatusLabel.ForeColor = System.Drawing.Color.Red; PayNowLink.Visible = true; CancelLink.Visible = true; ConfirmLink.Visible = false; break; case "已付款": StatusLabel.ForeColor = System.Drawing.Color.Green; PayNowLink.Visible = false; CancelLink.Visible = false; ConfirmLink.Visible = false; break; case "正在送": StatusLabel.ForeColor = System.Drawing.Color.Green; PayNowLink.Visible = false; CancelLink.Visible = false; ConfirmLink.Visible = true; break; case "交易成功": StatusLabel.ForeColor = System.Drawing.Color.Green; PayNowLink.Visible = false; CancelLink.Visible = false; ConfirmLink.Visible = false; break; case "订单已取消": StatusLabel.ForeColor = System.Drawing.Color.Gray; PayNowLink.Visible = false; CancelLink.Visible = false; ConfirmLink.Visible = false; break; } //绑定订单食物的菜单到DataList中显示 //获取购物车信息:食物图片、食物名字、单价、数量、总价 //从OrderFood中获取的项有:订单Id(购物车)、食物Id、数量 OrderFoodData _orderFood = new OrderFoodData(); IList<OrderFood> foodlist = _orderFood.GetOrderFoodListByOrderId(orderlist[foodindex].OrderId); if (0 == foodlist.Count)//购物车没有食物,将不显示 { FoodList.Visible = false; return; } else { FoodList.Visible = true; } IList<FoodItem> fooditemlist = oc.GetFoodItemByOrderFoodList(foodlist); //Total.Text = totalmomey.ToString(); //将所有菜单绑定到DataList中显示出来 FoodList.DataSource = fooditemlist; FoodList.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { //OrderListPanel.Visible = true; //OrderDetailPanel.Visible = false; string struserid = Convert.ToString(Session["UserId"]); if ("" == struserid) return; userid = Convert.ToInt32(Session["UserId"]); //要获取的订单信息:订单号(日期跟订单ID的组合)、下单时间、数量、总价、留言、订单状态(1下单2付款3完成交易) //从Order中获取的项有:orderid,userid,ordertime,address,phonenum,otherquest,status OrderControl oc = new OrderControl(); IList<OrderItem> orderlisttemp = oc.GetOrderItemListByUserId(userid); //按时间排序 var orderlist = orderlisttemp.OrderByDescending(st => st.OrderTime); if (!IsPostBack) { OrderList.DataSource = orderlist; OrderList.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { Panel1.Visible = true; userid = Convert.ToInt32(Session["UserId"]); //获取购物车信息:食物图片、食物名字、单价、数量、总价 //从OrderFood中获取的项有:订单Id(购物车)、食物Id、数量 OrderControl oc = new OrderControl(); foodlist = oc.GetProductCarFoodList(userid); if (0 == foodlist.Count)//购物车没有食物,将不显示 { Panel1.Visible = false; return; } fooditemlist = oc.GetFoodItemByOrderFoodList(foodlist); double totalmomey = GetTotalMomey(fooditemlist); Total.Text = totalmomey.ToString(); Session["OrderTotal"] = Convert.ToString(totalmomey); //将所有菜单绑定到DataList中显示出来 if (!IsPostBack) { ProductCar.DataSource = fooditemlist; ProductCar.DataBind(); //ProductCar. } }
/// <summary> /// 修改购物车食物数量 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void ProductCar_SelectedIndexChanged(object sender, EventArgs e) { //未登录 if (Session["UserName"] == null) { Page.Response.Write("<script>alert('请重新登录!')</script>"); return; } //从Session获取userId,从ItemIndex获取foodId,调用逻辑层的购物车 //从DataList中选择,得到foodid int foodid = ProductCar.SelectedIndex; int userId = Convert.ToInt32(Session["UserId"].ToString()); //调用逻辑层实现加入购物车 OrderControl oc = new OrderControl(); /*oc.ProductCarAddFood(userId, foodid); Response.Write("<script language=javascript>window.location.href='index.aspx';</script>");*/ }