protected void Page_Load(object sender, EventArgs e) { if (string.Compare(base.Request.RequestType, "post", true) != 0) { btnSubmit.Enabled = false; } else if (base.IsPostBack) { tbOrders = (IList<tbOrder>)Session["tbOrders"]; } else { XmlDocument document = new XmlDocument(); if (string.IsNullOrEmpty(base.Request.Form["data"])) { ShowMsg("数据丢失,请关闭此页重新操作", false); } else { document.LoadXml(base.Request.Form["data"]); tbOrders = new List<tbOrder>(); XmlNodeList list = document.FirstChild.SelectNodes("order"); string innerText = null; string str2 = null; for (int i = 0; i < list.Count; i++) { string str3; tbOrder order = new tbOrder(); XmlNode node = list.Item(i); if (innerText == null) { innerText = node.SelectSingleNode("ship_addr").InnerText; str2 = node.SelectSingleNode("ship_name").InnerText; } else { str3 = node.SelectSingleNode("ship_addr").InnerText; string str4 = node.SelectSingleNode("ship_name").InnerText; if ((innerText != str3) || (str2 != str4)) { ShowMsg("收货人地址/姓名不一致不能合并下单!", false); break; } str2 = str4; innerText = str3; } string[] strArray = innerText.Split(new char[] { ' ' }); txtShipTo.Text = str2; if (strArray.Length >= 4) { str3 = strArray[0] + "," + strArray[1] + "," + strArray[2]; rsddlRegion.SelectedRegions = str3; txtAddress.Text = strArray[3]; } txtZipcode.Text = node.SelectSingleNode("ship_zipcode").InnerText; txtTel.Text = node.SelectSingleNode("ship_tel").InnerText; txtMobile.Text = node.SelectSingleNode("ship_mobile").InnerText; radioShippingMode.DataBind(); if (radioShippingMode.Items.Count > 0) { radioShippingMode.Items[0].Selected = true; } order.orderId = node.SelectSingleNode("order_id").InnerText; order.buyer = node.SelectSingleNode("buyer").InnerText; order.createTime = node.SelectSingleNode("createtime").InnerText; order.orderMemo = node.SelectSingleNode("order_memo").InnerText; XmlNode node2 = node.SelectSingleNode("items"); double num2 = 0.0; for (int j = 0; j < node2.ChildNodes.Count; j++) { tbOrderItem item2 = new tbOrderItem(); item2.id = string.Format("{0}_{1}", order.orderId, j); item2.title = node2.ChildNodes[j].SelectSingleNode("title").InnerText; item2.spec = node2.ChildNodes[j].SelectSingleNode("spec").InnerText; item2.price = node2.ChildNodes[j].SelectSingleNode("price").InnerText; item2.number = node2.ChildNodes[j].SelectSingleNode("number").InnerText; item2.url = node2.ChildNodes[j].SelectSingleNode("url").InnerText; tbOrderItem item = item2; HttpRequest request = HttpContext.Current.Request; if (request.Cookies[Globals.UrlEncode(item.title + item.spec)] != null) { ProductQuery query2 = new ProductQuery(); query2.PageSize = 1; query2.PageIndex = 1; query2.ProductCode = Globals.UrlDecode(request.Cookies[Globals.UrlEncode(item.title + item.spec)].Value); ProductQuery query = query2; int count = 0; DataTable puchaseProducts = SubSiteProducthelper.GetPuchaseProducts(query, out count); if (puchaseProducts.Rows.Count > 0) { item.localSkuId = puchaseProducts.Rows[0]["SkuId"].ToString(); item.localSKU = puchaseProducts.Rows[0]["SKU"].ToString(); item.localProductId = puchaseProducts.Rows[0]["ProductId"].ToString().Trim(); item.localProductName = puchaseProducts.Rows[0]["ProductName"].ToString(); item.thumbnailUrl100 = puchaseProducts.Rows[0]["ThumbnailUrl100"].ToString(); item.localPrice = puchaseProducts.Rows[0]["PurchasePrice"].ToString(); item.localStock = puchaseProducts.Rows[0]["Stock"].ToString(); num2 += Convert.ToDouble(puchaseProducts.Rows[0]["PurchasePrice"]) * Convert.ToInt32(item.number); } } else { ProductQuery query4 = new ProductQuery(); query4.PageSize = 1; query4.PageIndex = 1; query4.Keywords = item.title; ProductQuery query3 = query4; int num5 = 0; DataTable table2 = SubSiteProducthelper.GetPuchaseProducts(query3, out num5); if (num5 == 1) { item.localSkuId = table2.Rows[0]["SkuId"].ToString(); item.localSKU = table2.Rows[0]["SKU"].ToString(); item.localProductId = table2.Rows[0]["ProductId"].ToString().Trim(); item.localProductName = table2.Rows[0]["ProductName"].ToString(); item.thumbnailUrl100 = table2.Rows[0]["ThumbnailUrl100"].ToString(); item.localPrice = table2.Rows[0]["PurchasePrice"].ToString(); item.localStock = table2.Rows[0]["Stock"].ToString(); num2 += Convert.ToDouble(table2.Rows[0]["PurchasePrice"]) * Convert.ToInt32(item.number); } } order.items.Add(item); order.orderCost = num2; } tbOrders.Add(order); } Session["tbOrders"] = tbOrders; pageDataBind(); } } }
protected void Page_Load(object sender, EventArgs e) { if (string.Compare(base.Request.RequestType, "post", true) != 0) { this.btnSubmit.Enabled = false; } else if (base.IsPostBack) { this.tbOrders = (IList <tbOrder>) this.Session["tbOrders"]; } else { XmlDocument document = new XmlDocument(); if (string.IsNullOrEmpty(base.Request.Form["data"])) { this.ShowMsg("数据丢失,请关闭此页重新操作", false); } else { document.LoadXml(base.Request.Form["data"]); this.tbOrders = new List <tbOrder>(); XmlNodeList list = document.FirstChild.SelectNodes("order"); string innerText = null; string str2 = null; for (int i = 0; i < list.Count; i++) { string str3; tbOrder order = new tbOrder(); XmlNode node = list.Item(i); if (innerText == null) { innerText = node.SelectSingleNode("ship_addr").InnerText; str2 = node.SelectSingleNode("ship_name").InnerText; } else { str3 = node.SelectSingleNode("ship_addr").InnerText; string str4 = node.SelectSingleNode("ship_name").InnerText; if ((innerText != str3) || (str2 != str4)) { this.ShowMsg("收货人地址/姓名不一致不能合并下单!", false); break; } str2 = str4; innerText = str3; } string[] strArray = innerText.Split(new char[] { ' ' }); this.txtShipTo.Text = str2; if (strArray.Length >= 4) { str3 = strArray[0] + "," + strArray[1] + "," + strArray[2]; this.rsddlRegion.SelectedRegions = str3; this.txtAddress.Text = strArray[3]; } this.txtZipcode.Text = node.SelectSingleNode("ship_zipcode").InnerText; this.txtTel.Text = node.SelectSingleNode("ship_tel").InnerText; this.txtMobile.Text = node.SelectSingleNode("ship_mobile").InnerText; this.radioShippingMode.DataBind(); if (this.radioShippingMode.Items.Count > 0) { this.radioShippingMode.Items[0].Selected = true; } order.orderId = node.SelectSingleNode("order_id").InnerText; order.buyer = node.SelectSingleNode("buyer").InnerText; order.createTime = node.SelectSingleNode("createtime").InnerText; order.orderMemo = node.SelectSingleNode("order_memo").InnerText; XmlNode node2 = node.SelectSingleNode("items"); double num2 = 0.0; for (int j = 0; j < node2.ChildNodes.Count; j++) { tbOrderItem item = new tbOrderItem(); item.id = string.Format("{0}_{1}", order.orderId, j); item.title = node2.ChildNodes[j].SelectSingleNode("title").InnerText; item.spec = node2.ChildNodes[j].SelectSingleNode("spec").InnerText; item.price = node2.ChildNodes[j].SelectSingleNode("price").InnerText; item.number = node2.ChildNodes[j].SelectSingleNode("number").InnerText; if (string.IsNullOrEmpty(item.number)) { item.number = "1"; } item.url = node2.ChildNodes[j].SelectSingleNode("url").InnerText; HttpRequest request = HttpContext.Current.Request; if (request.Cookies[Globals.UrlEncode(item.title + item.spec)] != null) { ProductQuery query = new ProductQuery(); query.PageSize = 1; query.PageIndex = 1; query.ProductCode = Globals.UrlDecode(request.Cookies[Globals.UrlEncode(item.title + item.spec)].Value); int count = 0; DataTable puchaseProducts = SubSiteProducthelper.GetPuchaseProducts(query, out count); if (puchaseProducts.Rows.Count > 0) { item.localSkuId = puchaseProducts.Rows[0]["SkuId"].ToString(); item.localSKU = puchaseProducts.Rows[0]["SKU"].ToString(); item.localProductId = puchaseProducts.Rows[0]["ProductId"].ToString().Trim(); item.localProductName = puchaseProducts.Rows[0]["ProductName"].ToString(); item.thumbnailUrl100 = puchaseProducts.Rows[0]["ThumbnailUrl100"].ToString(); item.localPrice = puchaseProducts.Rows[0]["PurchasePrice"].ToString(); item.localStock = puchaseProducts.Rows[0]["Stock"].ToString(); num2 += Convert.ToDouble(puchaseProducts.Rows[0]["PurchasePrice"]) * Convert.ToInt32(item.number); } } else { ProductQuery query2 = new ProductQuery(); query2.PageSize = 1; query2.PageIndex = 1; query2.Keywords = item.title; int num5 = 0; DataTable table2 = SubSiteProducthelper.GetPuchaseProducts(query2, out num5); if (num5 == 1) { item.localSkuId = table2.Rows[0]["SkuId"].ToString(); item.localSKU = table2.Rows[0]["SKU"].ToString(); item.localProductId = table2.Rows[0]["ProductId"].ToString().Trim(); item.localProductName = table2.Rows[0]["ProductName"].ToString(); item.thumbnailUrl100 = table2.Rows[0]["ThumbnailUrl100"].ToString(); item.localPrice = table2.Rows[0]["PurchasePrice"].ToString(); item.localStock = table2.Rows[0]["Stock"].ToString(); num2 += Convert.ToDouble(table2.Rows[0]["PurchasePrice"]) * Convert.ToInt32(item.number); } } order.items.Add(item); order.orderCost = num2; } this.tbOrders.Add(order); } this.Session["tbOrders"] = this.tbOrders; this.pageDataBind(); } } }