/// <summary> /// 列表 /// </summary> /// <returns></returns> protected string GetList() { ChangeHope.WebPage.Table table = new ChangeHope.WebPage.Table(); ShowShop.BLL.Order.OrderProduct bll = new ShowShop.BLL.Order.OrderProduct(); ShowShop.BLL.Order.Orders orderBll = new ShowShop.BLL.Order.Orders(); ChangeHope.DataBase.DataByPage dataPage = bll.GetListByPage(); //第一步先添加表头 table.AddHeadCol("", "订单号"); table.AddHeadCol("", "用户账号"); table.AddHeadCol("", "收货人"); table.AddHeadCol("", "商品名称"); table.AddHeadCol("", "实际价格"); table.AddHeadCol("", "下单时间"); table.AddHeadCol("", "状态"); table.AddRow(); //添加表的内容 if (dataPage.DataReader != null) { while (dataPage.DataReader.Read()) { ShowShop.Model.Order.Orders orderModel = orderBll.GetModel(Convert.ToInt32(dataPage.DataReader["OrderId"].ToString())); if (orderModel != null) { table.AddCol(orderModel.OrderId); table.AddCol(orderModel.UserId); table.AddCol(orderModel.ConsigneeName); table.AddCol(dataPage.DataReader["ProName"].ToString()); table.AddCol(dataPage.DataReader["ProPrice"].ToString()); table.AddCol(orderModel.OrderDate.ToString()); table.AddCol(this.ShowStatu(orderModel.OrderStatus)); table.AddRow(); } } } string view = table.GetTable() + dataPage.PageToolBar; dataPage.Dispose(); dataPage = null; return view; }
private double TotalPrice(string orderId) { ShowShop.BLL.Order.OrderProduct bll = new ShowShop.BLL.Order.OrderProduct(); DataTable dt = bll.GetListOrderProduct(orderId); double totalPrice = 0; if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { totalPrice += Convert.ToDouble(dt.Rows[i]["ProPrice"].ToString()) * Convert.ToDouble(dt.Rows[i]["ProNum"].ToString()); } } return totalPrice; }
private void OrdersProduct(int orderId) { ChangeHope.WebPage.Table table = new ChangeHope.WebPage.Table(); ShowShop.BLL.Order.OrderProduct bll = new ShowShop.BLL.Order.OrderProduct(); ChangeHope.DataBase.DataByPage dataPage = bll.GetListByPage(" and OrderId=" + orderId); table.AddHeadCol("50%", "商品名称"); table.AddHeadCol("", "单价"); table.AddHeadCol("", "数量"); table.AddHeadCol("", "小计(单位:元)"); table.AddRow(); double ProductTotalPrice = 0; if (dataPage.DataReader != null) { while (dataPage.DataReader.Read()) { string fittingsProductId = dataPage.DataReader["FittingsProductId"].ToString(); string fittingsId = dataPage.DataReader["FittingsId"].ToString(); string fittingsProductCount = dataPage.DataReader["FittingsProductCount"].ToString(); string fittingProductInfo = ""; double fittingTotalPrice = 0; if (!string.IsNullOrEmpty(fittingsProductId.Trim()) && !string.IsNullOrEmpty(fittingsId.Trim()) && Convert.ToInt32(fittingsId) > 0) { //配件 int fittingProductCount = 0; double fittingProductWeight = 0; double fittingProductIntergal = 0; ShowShop.Common.ProductInfo.FittingDisposal(fittingsId, fittingsProductId, fittingsProductCount, out fittingProductCount, out fittingProductInfo, out fittingTotalPrice, out fittingProductWeight, out fittingProductIntergal); } string specificationValue = dataPage.DataReader["Specification"].ToString(); string specVa = ""; if (specificationValue != "") { specVa = " " + specificationValue + ""; } table.AddCol("<a href='../../product/productcontent.aspx?q_productid=" + dataPage.DataReader["ProId"].ToString() + "' target='_blank'>" + dataPage.DataReader["ProName"].ToString() + specVa + fittingProductInfo + "</a>"); table.AddCol(Convert.ToDouble(dataPage.DataReader["ProPrice"].ToString()).ToString("f2")); table.AddCol(dataPage.DataReader["ProNum"].ToString()); table.AddCol((Convert.ToDouble(dataPage.DataReader["ProPrice"].ToString()) * Convert.ToDouble(dataPage.DataReader["ProNum"].ToString()) + fittingTotalPrice).ToString("f2")); table.AddRow(); ProductTotalPrice += Convert.ToDouble(dataPage.DataReader["ProPrice"].ToString()) * Convert.ToDouble(dataPage.DataReader["ProNum"].ToString()) + fittingTotalPrice ; } table.AddCol("4", "<strong>本页金额合计:" + ProductTotalPrice.ToString("f2") + "</strong>"); table.AddRow(); string view = table.GetTable() + dataPage.PageToolBar; dataPage.Dispose(); dataPage = null; this.litData.Text = view; } else { this.litData.Text = "没有找到该订单的商品信息"; } }
private void HandleOrder(int id) { ShowShop.BLL.Order.Orders ordersbll = new ShowShop.BLL.Order.Orders(); ShowShop.Model.Order.Orders ordersModel = ordersbll.GetModel(id); if (ordersModel != null) { ShowShop.BLL.Order.OrderProduct orderProductbll = new ShowShop.BLL.Order.OrderProduct(); DataTable orderProductDT = orderProductbll.GetListOrderProduct(id.ToString()); ShowShop.BLL.Member.MemberAccount memberaccountbll = new ShowShop.BLL.Member.MemberAccount(); ShowShop.Model.Member.MemberAccount memberaccounModel = memberaccountbll.GetModel(ordersModel.UserId); // ShowShop.BLL.Product.ProductSpecification spebll = new ShowShop.BLL.Product.ProductSpecification(); decimal DonateIntegral = 0; if (orderProductDT.Rows.Count > 0) { ShowShop.BLL.Product.ProductInfo productinfoBll = new ShowShop.BLL.Product.ProductInfo(); for (int i = 0; i < orderProductDT.Rows.Count; i++) { ShowShop.Model.Product.ProductInfo productInfoModel = productinfoBll.GetModel(Convert.ToInt32(orderProductDT.Rows[i]["ProId"].ToString())); if (productInfoModel != null) { // DonateIntegral += Convert.ToDecimal(productInfoModel.pro_DonateIntegral); // productinfoBll.Amend(productInfoModel.pro_ID, "pro_SaleNum", productInfoModel.pro_SaleNum + Convert.ToInt32(orderProductDT.Rows[i]["ProNum"].ToString())); if (!string.IsNullOrEmpty(orderProductDT.Rows[i]["Specification"].ToString())) { // List<ShowShop.Model.Product.ProductSpecification> spcList = spebll.GetSpecification(" and ProductId=" + orderProductDT.Rows[i]["ProId"].ToString() + " and Specifications='" + orderProductDT.Rows[i]["Specification"].ToString() + "'"); // if (spcList.Count > 0) // { // spebll.Amend(spcList[0].Id, "ProductStock", Convert.ToInt32(spcList[0].ProductStock) - Convert.ToInt32(orderProductDT.Rows[i]["ProNum"].ToString())); // } } else { //if (Convert.ToInt32(productInfoModel.pro_Stock) >= Convert.ToInt32(orderProductDT.Rows[i]["ProNum"].ToString())) { // productinfoBll.Amend(productInfoModel.pro_ID, "pro_Stock", Convert.ToInt32(productInfoModel.pro_Stock) - Convert.ToInt32(orderProductDT.Rows[i]["ProNum"].ToString())); } } } } //购买商品赠送积分 if (memberaccounModel != null) { if (DonateIntegral > 0) { if (memberaccountbll.Amend(memberaccounModel.UID, "Points", memberaccounModel.Points + DonateIntegral) > 0) { ShowShop.BLL.Member.Integral integralBll = new ShowShop.BLL.Member.Integral(); ShowShop.Model.Member.Integral integral = new ShowShop.Model.Member.Integral(); integral.Userid = memberaccounModel.UID; integral.OrderId = ordersModel.OrderId; integral.IntegralClass = 1; integral.IntegralNum = memberaccounModel.Points + DonateIntegral; integral.GainDate = Convert.ToDateTime(System.DateTime.Now); integral.NoteDate = Convert.ToDateTime(System.DateTime.Now); integral.NoteName = "系统"; integral.Remark = "购买商品后赠送的积分"; integral.IntegralStatus = 0; integral.Origin = "订单"; integralBll.Add(integral); } } } } } }
protected void Button2_Click(object sender, EventArgs e) { string orderId = this.hfOrderId.Value.Trim(); if (string.IsNullOrEmpty(this.hfid.Value)) { ChangeHope.WebPage.BasePage.PageError("请选择商品.", "order_modify.aspx?OrderId=" + orderId, ""); } ShowShop.Model.Order.OrderProduct model = new ShowShop.Model.Order.OrderProduct(); ShowShop.BLL.Order.OrderProduct bll = new ShowShop.BLL.Order.OrderProduct(); ShowShop.BLL.Order.Orders ordbll = new ShowShop.BLL.Order.Orders(); ShowShop.BLL.Product.ProductInfo bllProductInfo = new ShowShop.BLL.Product.ProductInfo(); string[] idStr = this.hfid.Value.Split(','); string productId = idStr[0]; string specificationId = idStr.Length > 1 ? idStr[1] : ""; string specificationVa = ""; decimal spePrice = 0; //if (!string.IsNullOrEmpty(specificationId.Trim())) //{ // ShowShop.BLL.Product.ProductSpecification proSpe = new ShowShop.BLL.Product.ProductSpecification(); // ShowShop.Model.Product.ProductSpecification proModel = proSpe.GetModelID(Convert.ToInt32(specificationId)); //if (proModel != null) //{ // specificationVa = proModel.Specifications; // spePrice = Convert.ToDecimal(proModel.SalePrice); //} // } ChangeHope.DataBase.DataByPage db = bll.GetListByPage(" and ProId=" + productId + " and OrderId=" + orderId + " and Specification='" + specificationVa + "'"); ShowShop.Model.Order.Orders ordModel = ordbll.GetModel(this.blOrderNo.Text.Trim()); if (db.DataReader == null) { ShowShop.Model.Product.ProductInfo modelProductInfo = bllProductInfo.GetModel(Convert.ToInt32(productId)); if (modelProductInfo != null) { model.AddTime = System.DateTime.Now; model.OrderId =Convert.ToInt32(orderId); model.ProId = Convert.ToInt32(modelProductInfo.ProductID); model.ProClass = modelProductInfo.ClassID.ToString(); model.ProImg = modelProductInfo.Thumbnail; model.ProName = modelProductInfo.ProductName; model.ProNum = 1; model.ProOtherPara = ""; model.ProPrice = spePrice; model.Specification = specificationVa; model.FittingsId = 0; model.FittingsProductCount = ""; model.FittingsProductId = ""; model.FittingsProductPrice = ""; bll.Add(model); if (ordModel != null) { ordbll.Amend(ordModel.Id, "TotalPrice",Convert.ToDecimal(ordModel.TotalPrice)+Convert.ToDecimal(spePrice)); ordbll.Amend(ordModel.Id, "FactPrice", Convert.ToDecimal(ordModel.FactPrice) + Convert.ToDecimal(spePrice)); } } } else { if(db.DataReader.Read()) { bll.Amend(Convert.ToInt32(db.DataReader["Id"].ToString()), "ProNum", Convert.ToInt32(db.DataReader["ProNum"].ToString()) + 1); if (ordModel != null) { ordbll.Amend(ordModel.Id, "TotalPrice", Convert.ToDecimal(ordModel.TotalPrice) + Convert.ToDecimal(db.DataReader["ProPrice"].ToString())); ordbll.Amend(ordModel.Id, "FactPrice", Convert.ToDecimal(ordModel.FactPrice) + Convert.ToDecimal(db.DataReader["ProPrice"].ToString())); } } } DataTable ordProductdt = bll.GetListOrderProduct(orderId); if (ordProductdt.Rows.Count > 0) { } ChangeHope.WebPage.BasePage.PageRight("向" + this.blOrderNo.Text + "添加商品成功.", "order_modify.aspx?OrderId="+orderId, ""); }
protected void Page_Load(object sender, EventArgs e) { if (ChangeHope.WebPage.PageRequest.GetFormString("Option") != string.Empty) { string types = Request["Option"].Trim(); string id = ChangeHope.WebPage.PageRequest.GetFormString("Id"); if (types == "ModifyPrice") { string price = ChangeHope.WebPage.PageRequest.GetFormString("Price"); ShowShop.BLL.Order.OrderProduct bll = new ShowShop.BLL.Order.OrderProduct(); ShowShop.Model.Order.OrderProduct orderProductModel = bll.GetModel(Convert.ToInt32(id)); if (orderProductModel != null) { ShowShop.BLL.Order.Orders ordbll = new ShowShop.BLL.Order.Orders(); ShowShop.Model.Order.Orders ordModel = ordbll.GetModel(Convert.ToInt32(orderProductModel.OrderId)); if (ordModel != null) { if (Convert.ToDecimal(orderProductModel.ProPrice) > Convert.ToDecimal(price)) { decimal productPrice = Convert.ToDecimal(orderProductModel.ProPrice) - Convert.ToDecimal(price); ordbll.Amend(ordModel.Id, "TotalPrice", Convert.ToDecimal(ordModel.TotalPrice) - (Convert.ToDecimal(orderProductModel.ProNum) * Convert.ToDecimal(productPrice))); ordbll.Amend(ordModel.Id, "FactPrice", Convert.ToDecimal(ordModel.FactPrice) - (Convert.ToDecimal(orderProductModel.ProNum) * Convert.ToDecimal(productPrice))); } else { decimal productPrice = Convert.ToDecimal(price) - Convert.ToDecimal(orderProductModel.ProPrice); ordbll.Amend(ordModel.Id, "TotalPrice", Convert.ToDecimal(ordModel.TotalPrice) + (Convert.ToDecimal(orderProductModel.ProNum) * Convert.ToDecimal(productPrice))); ordbll.Amend(ordModel.Id, "FactPrice", Convert.ToDecimal(ordModel.FactPrice) + (Convert.ToDecimal(orderProductModel.ProNum) * Convert.ToDecimal(productPrice))); } if (bll.Amend(Convert.ToInt32(id), "ProPrice", price) != 1) { Response.Write("ok"); } } } } else if (types == "ModifyCount") { string Count = ChangeHope.WebPage.PageRequest.GetFormString("Count"); ShowShop.BLL.Order.OrderProduct bll = new ShowShop.BLL.Order.OrderProduct(); ShowShop.Model.Order.OrderProduct orderProductModel = bll.GetModel(Convert.ToInt32(id)); if (orderProductModel != null) { ShowShop.BLL.Order.Orders ordbll = new ShowShop.BLL.Order.Orders(); ShowShop.Model.Order.Orders ordModel = ordbll.GetModel(Convert.ToInt32(orderProductModel.OrderId)); if (ordModel != null) { if (Convert.ToInt32(orderProductModel.ProNum) > Convert.ToInt32(Count)) { int productCount = Convert.ToInt32(orderProductModel.ProNum) - Convert.ToInt32(Count); ordbll.Amend(ordModel.Id, "TotalPrice", Convert.ToDecimal(ordModel.TotalPrice) - (Convert.ToDecimal(orderProductModel.ProPrice) * Convert.ToDecimal(productCount))); ordbll.Amend(ordModel.Id, "FactPrice", Convert.ToDecimal(ordModel.FactPrice) - (Convert.ToDecimal(orderProductModel.ProPrice) * Convert.ToDecimal(productCount))); } else { int productCount = Convert.ToInt32(Count) - Convert.ToInt32(orderProductModel.ProNum); ordbll.Amend(ordModel.Id, "TotalPrice", Convert.ToDecimal(ordModel.TotalPrice) + (Convert.ToDecimal(orderProductModel.ProPrice) * Convert.ToDecimal(productCount))); ordbll.Amend(ordModel.Id, "FactPrice", Convert.ToDecimal(ordModel.FactPrice) + (Convert.ToDecimal(orderProductModel.ProPrice) * Convert.ToDecimal(productCount))); } if (bll.Amend(Convert.ToInt32(id), "ProNum", Count) != 1) { Response.Write("ok"); } } } } else if (types == "DelProduct") { string OrderID = ChangeHope.WebPage.PageRequest.GetFormString("OrderID"); ShowShop.BLL.Order.OrderProduct bll = new ShowShop.BLL.Order.OrderProduct(); DataTable dt = bll.GetListOrderProduct(OrderID.Trim()); if (dt.Rows.Count > 1) { ShowShop.Model.Order.OrderProduct orderProductModel = bll.GetModel(Convert.ToInt32(id)); if (orderProductModel != null) { ShowShop.BLL.Order.Orders ordbll = new ShowShop.BLL.Order.Orders(); ShowShop.Model.Order.Orders ordModel = ordbll.GetModel(Convert.ToInt32(OrderID)); if (ordModel != null) { ordbll.Amend(ordModel.Id, "TotalPrice", Convert.ToDecimal(ordModel.TotalPrice) - (Convert.ToDecimal(orderProductModel.ProPrice)*Convert.ToDecimal(orderProductModel.ProNum))); ordbll.Amend(ordModel.Id, "FactPrice", Convert.ToDecimal(ordModel.FactPrice) - (Convert.ToDecimal(orderProductModel.ProPrice) * Convert.ToDecimal(orderProductModel.ProNum))); bll.Delete(Convert.ToInt32(id)); } } } else { Response.Write("删除失败,该订单删除后没有商品列表!"); } } Response.End(); } int orderId = ChangeHope.WebPage.PageRequest.GetQueryInt("OrderId"); if (!IsPostBack) { this.DeliverBind(); this.OrderInfo(orderId); this.OrdersProduct(orderId); } }