protected void DoCallback() { this.LoadParameters(); ProductQuery query = new ProductQuery(); query.PageSize = this.pager.PageSize; query.PageIndex = this.pager.PageIndex; query.SaleStatus = ProductSaleStatus.OnSale; query.Keywords = this.productName; query.CategoryId = this.categoryId; if (this.categoryId.HasValue) { query.MaiCategoryPath = SubsiteCatalogHelper.GetCategory(this.categoryId.Value).Path; } query.IsIncludePromotionProduct = false; DbQueryResult products = SubSiteProducthelper.GetProducts(query); DataTable data = (DataTable)products.Data; this.pager1.TotalRecords = this.pager.TotalRecords = products.TotalRecords; this.rp_bindproduct.DataSource = data; this.rp_bindproduct.DataBind(); }
private void BindData() { ProductQuery productQuery = new ProductQuery(); productQuery.PageSize = this.pager.PageSize; productQuery.PageIndex = this.pager.PageIndex; productQuery.ProductCode = this.productCode; productQuery.Keywords = this.name; productQuery.ProductLineId = this.lineId; if (this.grdAuthorizeProducts.SortOrder.ToLower() == "desc") { productQuery.SortOrder = SortAction.Desc; } productQuery.SortBy = this.grdAuthorizeProducts.SortOrderBy; Globals.EntityCoding(productQuery, true); DbQueryResult authorizeProducts = SubSiteProducthelper.GetAuthorizeProducts(productQuery, false); this.grdAuthorizeProducts.DataSource = authorizeProducts.Data; this.grdAuthorizeProducts.DataBind(); this.pager.TotalRecords = authorizeProducts.TotalRecords; this.pager1.TotalRecords = authorizeProducts.TotalRecords; }
private void btnDelete_Click(object sender, EventArgs e) { string str = base.Request.Form["CheckBoxGroup"]; if (string.IsNullOrEmpty(str)) { this.ShowMsg("请先选择要删除的商品", false); } else { int num = SubSiteProducthelper.DeleteProducts(str); if (num > 0) { this.ShowMsg(string.Format("成功删除了选择的{0}件商品", num), true); this.BindProducts(); } else { this.ShowMsg("删除商品失败,未知错误", false); } } }
private void btnUpShelf_Click(object sender, EventArgs e) { string str = base.Request.Form["CheckBoxGroup"]; if (string.IsNullOrEmpty(str)) { ShowMsg("请先选择要上架的商品", false); } else if (!SubSiteProducthelper.IsOnSale(str)) { ShowMsg("选择要上架的商品中有一口价低于最低零售价的情况", false); } else if (SubSiteProducthelper.UpdateProductSaleStatus(str, ProductSaleStatus.OnSale) > 0) { ShowMsg("成功上架了选择的商品,您可以到出售中的商品中找到上架的商品", true); BindProducts(); } else { ShowMsg("上架商品失败,未知错误", false); } }
private void BindData() { ProductQuery entity = new ProductQuery(); entity.PageSize = this.pager.PageSize; entity.PageIndex = this.pager.PageIndex; entity.ProductCode = this.productCode; entity.Keywords = this.productName; entity.ProductLineId = this.productLineId; if (this.grdAuthorizeProducts.SortOrder.ToLower() == "desc") { entity.SortOrder = SortAction.Desc; } entity.SortBy = this.grdAuthorizeProducts.SortOrderBy; Globals.EntityCoding(entity, true); DbQueryResult submitPuchaseProducts = SubSiteProducthelper.GetSubmitPuchaseProducts(entity); this.grdAuthorizeProducts.DataSource = submitPuchaseProducts.Data; this.grdAuthorizeProducts.DataBind(); this.pager.TotalRecords = submitPuchaseProducts.TotalRecords; this.pager1.TotalRecords = submitPuchaseProducts.TotalRecords; }
private void lkbtnDownloadCheck_Click(object sender, EventArgs e) { int num = 0; foreach (GridViewRow row in this.grdAuthorizeProducts.Rows) { CheckBox box = (CheckBox)row.FindControl("checkboxCol"); if (box.Checked) { num++; int productId = (int)this.grdAuthorizeProducts.DataKeys[row.RowIndex].Value; SubSiteProducthelper.DownloadProduct(productId, this.isDownCategory.Checked); } } if (num == 0) { this.ShowMsg("请先选择要下载的商品", false); } else { this.ReBindData(false); } }
private void DoCallback() { base.Response.Clear(); base.Response.ContentType = "application/json"; string str = base.Request.QueryString["action"]; if (str.Equals("getGroupBuyProducts")) { int num; ProductQuery query = new ProductQuery(); int.TryParse(base.Request.QueryString["categoryId"], out num); string str2 = base.Request.QueryString["sku"]; string str3 = base.Request.QueryString["productName"]; query.Keywords = str3; query.ProductCode = str2; query.SaleStatus = ProductSaleStatus.OnSale; if (num > 0) { query.CategoryId = new int?(num); query.MaiCategoryPath = SubsiteCatalogHelper.GetCategory(num).Path; } DataTable groupBuyProducts = SubSiteProducthelper.GetGroupBuyProducts(query); if ((groupBuyProducts == null) || (groupBuyProducts.Rows.Count == 0)) { base.Response.Write("{\"Status\":\"0\"}"); } else { StringBuilder builder = new StringBuilder(); builder.Append("{\"Status\":\"OK\","); builder.AppendFormat("\"Product\":[{0}]", this.GenerateBrandString(groupBuyProducts)); builder.Append("}"); base.Response.Write(builder.ToString()); } } base.Response.End(); }
private void DoCallback() { base.Response.Clear(); base.Response.ContentType = "application/json"; string text = base.Request.QueryString["action"]; if (text.Equals("getGroupBuyProducts")) { ProductQuery productQuery = new ProductQuery(); int num; int.TryParse(base.Request.QueryString["categoryId"], out num); string productCode = base.Request.QueryString["sku"]; string keywords = base.Request.QueryString["productName"]; productQuery.Keywords = keywords; productQuery.ProductCode = productCode; productQuery.SaleStatus = ProductSaleStatus.OnSale; if (num > 0) { productQuery.CategoryId = new int?(num); productQuery.MaiCategoryPath = SubsiteCatalogHelper.GetCategory(num).Path; } System.Data.DataTable groupBuyProducts = SubSiteProducthelper.GetGroupBuyProducts(productQuery); if (groupBuyProducts != null && groupBuyProducts.Rows.Count != 0) { System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder(); stringBuilder.Append("{\"Status\":\"OK\","); stringBuilder.AppendFormat("\"Product\":[{0}]", this.GenerateBrandString(groupBuyProducts)); stringBuilder.Append("}"); base.Response.Write(stringBuilder.ToString()); } else { base.Response.Write("{\"Status\":\"0\"}"); } } base.Response.End(); }
private void btnUpShelf_Click(object sender, System.EventArgs e) { string text = base.Request.Form["CheckBoxGroup"]; if (string.IsNullOrEmpty(text)) { this.ShowMsg("请先选择要上架的商品", false); return; } if (!SubSiteProducthelper.IsOnSale(text)) { this.ShowMsg("选择要上架的商品中有一口价低于最低零售价的情况", false); return; } int num = SubSiteProducthelper.UpdateProductSaleStatus(text, ProductSaleStatus.OnSale); if (num > 0) { this.ShowMsg("成功上架了选择的商品,您可以到出售中的商品中找到上架的商品", true); this.BindProducts(); return; } this.ShowMsg("上架商品失败,未知错误", false); }
private void btnReplaceOK_Click(object sender, System.EventArgs e) { string text = base.Request.Form["CheckBoxGroup"]; if (string.IsNullOrEmpty(text)) { this.ShowMsg("请先选择要下架的商品", false); return; } if (string.IsNullOrEmpty(this.txtOleWord.Text.Trim())) { this.ShowMsg("查找字符串不能为空", false); return; } if (SubSiteProducthelper.ReplaceProductNames(text, Globals.HtmlEncode(this.txtOleWord.Text.Trim()), Globals.HtmlEncode(this.txtNewWord.Text.Trim()))) { this.ShowMsg("为商品名称替换字符串缀成功", true); } else { this.ShowMsg("为商品名称替换字符串缀失败", false); } this.BindProducts(); }
private void btnAddOK_Click(object sender, System.EventArgs e) { string text = base.Request.Form["CheckBoxGroup"]; if (string.IsNullOrEmpty(text)) { this.ShowMsg("请先选择要下架的商品", false); return; } if (string.IsNullOrEmpty(this.txtPrefix.Text.Trim()) && string.IsNullOrEmpty(this.txtSuffix.Text.Trim())) { this.ShowMsg("前后缀不能同时为空", false); return; } if (SubSiteProducthelper.UpdateProductNames(text, Globals.HtmlEncode(this.txtPrefix.Text.Trim()), Globals.HtmlEncode(this.txtSuffix.Text.Trim()))) { this.ShowMsg("为商品名称添加前后缀成功", true); } else { this.ShowMsg("为商品名称添加前后缀失败", false); } this.BindProducts(); }
protected void btnMatch_Click(object sender, EventArgs e) { if (Request.Form["radioSerachResult"] != null) { DataTable puchaseProduct = SubSiteProducthelper.GetPuchaseProduct(base.Request.Form["radioSerachResult"].Trim()); if ((puchaseProduct != null) && (puchaseProduct.Rows.Count > 0)) { string str = base.Request.Form["serachProductId"].Trim(); string str2 = str.Substring(0, str.IndexOf('_')); foreach (tbOrder order in tbOrders) { if (order.orderId == str2) { foreach (tbOrderItem item in order.items) { if (item.id == str) { order.orderCost -= Convert.ToDouble(item.localPrice) * Convert.ToInt32(item.number); item.localSkuId = puchaseProduct.Rows[0]["SkuId"].ToString(); item.localSKU = puchaseProduct.Rows[0]["SKU"].ToString(); item.localProductId = puchaseProduct.Rows[0]["ProductId"].ToString().Trim(); item.localProductName = puchaseProduct.Rows[0]["ProductName"].ToString(); item.thumbnailUrl100 = puchaseProduct.Rows[0]["ThumbnailUrl100"].ToString(); item.localPrice = puchaseProduct.Rows[0]["PurchasePrice"].ToString(); item.localStock = puchaseProduct.Rows[0]["Stock"].ToString(); order.orderCost += Convert.ToDouble(item.localPrice) * Convert.ToInt32(item.number); break; } } break; } } } pageDataBind(); } }
private void BindData() { ProductQuery entity = new ProductQuery(); entity.PageSize = pager.PageSize; entity.PageIndex = pager.PageIndex; entity.ProductCode = productCode; entity.Keywords = name; entity.ProductLineId = lineId; if (grdAuthorizeProducts.SortOrder.ToLower() == "desc") { entity.SortOrder = SortAction.Desc; } entity.SortBy = grdAuthorizeProducts.SortOrderBy; Globals.EntityCoding(entity, true); DbQueryResult authorizeProducts = SubSiteProducthelper.GetAuthorizeProducts(entity, false); grdAuthorizeProducts.DataSource = authorizeProducts.Data; grdAuthorizeProducts.DataBind(); pager.TotalRecords = authorizeProducts.TotalRecords; pager1.TotalRecords = authorizeProducts.TotalRecords; }
private void BindProducts() { ProductQuery entity = new ProductQuery(); entity.Keywords = productName; entity.ProductCode = productCode; entity.PageIndex = pager.PageIndex; entity.PageSize = pager.PageSize; entity.CategoryId = categoryId; if (categoryId.HasValue) { entity.MaiCategoryPath = SubsiteCatalogHelper.GetCategory(categoryId.Value).Path; } entity.SaleStatus = ProductSaleStatus.OnSale; entity.SortOrder = SortAction.Desc; entity.SortBy = "DisplaySequence"; Globals.EntityCoding(entity, true); DbQueryResult products = SubSiteProducthelper.GetProducts(entity); grdProducts.DataSource = products.Data; grdProducts.DataBind(); pager.TotalRecords = products.TotalRecords; pager1.TotalRecords = products.TotalRecords; }
private void BindProducts() { ProductQuery productQuery = new ProductQuery(); productQuery.Keywords = this.searchkey; productQuery.PageSize = this.pager.PageSize; productQuery.ProductCode = this.productcode; if (this.dropCategories.SelectedValue.HasValue) { productQuery.CategoryId = new int?(this.dropCategories.SelectedValue.Value); if (this.dropCategories.SelectedValue.Value != 0) { productQuery.MaiCategoryPath = SubsiteCatalogHelper.GetCategory(productQuery.CategoryId.Value).Path; } } productQuery.PageIndex = this.pager.PageIndex; productQuery.SortOrder = SortAction.Desc; productQuery.SortBy = "DisplaySequence"; DbQueryResult unclassifiedProducts = SubSiteProducthelper.GetUnclassifiedProducts(productQuery); this.grdProducts.DataSource = unclassifiedProducts.Data; this.grdProducts.DataBind(); this.pager.TotalRecords = unclassifiedProducts.TotalRecords; }
public void grdSkus_RowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e) { Grid grid = (Grid)sender; int rowIndex = ((System.Web.UI.WebControls.GridViewRow)((System.Web.UI.Control)e.CommandSource).NamingContainer).RowIndex; string skuId = (string)grid.DataKeys[rowIndex].Value; System.Web.UI.WebControls.TextBox textBox = (System.Web.UI.WebControls.TextBox)grid.Rows[rowIndex].Cells[1].FindControl("txtNum"); System.Web.UI.WebControls.LinkButton linkButton = (System.Web.UI.WebControls.LinkButton)grid.Rows[rowIndex].Cells[2].FindControl("lbtnAdd"); int num; if (int.TryParse(textBox.Text.Trim(), out num) && int.Parse(textBox.Text.Trim()) > 0 && !textBox.Text.Trim().Contains(".")) { if (e.CommandName == "add" && linkButton.Text == "添加") { PurchaseShoppingCartItemInfo purchaseShoppingCartItemInfo = new PurchaseShoppingCartItemInfo(); System.Data.DataTable skuContentBySku = SubSiteProducthelper.GetSkuContentBySku(skuId); if (num > (int)skuContentBySku.Rows[0]["Stock"]) { this.ShowMsg("商品库存不够", false); return; } foreach (System.Data.DataRow dataRow in skuContentBySku.Rows) { if (!string.IsNullOrEmpty(dataRow["AttributeName"].ToString()) && !string.IsNullOrEmpty(dataRow["ValueStr"].ToString())) { PurchaseShoppingCartItemInfo expr_18A = purchaseShoppingCartItemInfo; object sKUContent = expr_18A.SKUContent; expr_18A.SKUContent = string.Concat(new object[] { sKUContent, dataRow["AttributeName"], ":", dataRow["ValueStr"], "; " }); } } purchaseShoppingCartItemInfo.SkuId = skuId; purchaseShoppingCartItemInfo.ProductId = (int)skuContentBySku.Rows[0]["ProductId"]; if (skuContentBySku.Rows[0]["SKU"] != System.DBNull.Value) { purchaseShoppingCartItemInfo.SKU = (string)skuContentBySku.Rows[0]["SKU"]; } if (skuContentBySku.Rows[0]["Weight"] != System.DBNull.Value) { purchaseShoppingCartItemInfo.ItemWeight = (decimal)skuContentBySku.Rows[0]["Weight"]; } purchaseShoppingCartItemInfo.ItemPurchasePrice = (decimal)skuContentBySku.Rows[0]["PurchasePrice"]; purchaseShoppingCartItemInfo.Quantity = num; purchaseShoppingCartItemInfo.ItemListPrice = (decimal)skuContentBySku.Rows[0]["SalePrice"]; purchaseShoppingCartItemInfo.ItemDescription = (string)skuContentBySku.Rows[0]["ProductName"]; if (skuContentBySku.Rows[0]["CostPrice"] != System.DBNull.Value) { purchaseShoppingCartItemInfo.CostPrice = (decimal)skuContentBySku.Rows[0]["CostPrice"]; } if (skuContentBySku.Rows[0]["ThumbnailUrl40"] != System.DBNull.Value) { purchaseShoppingCartItemInfo.ThumbnailsUrl = (string)skuContentBySku.Rows[0]["ThumbnailUrl40"]; } if (SubsiteSalesHelper.AddPurchaseOrderItem(purchaseShoppingCartItemInfo, this.purchaseOrderId)) { this.UpdatePurchaseOrder(); this.BindOrderItems(); this.ReBindData(true, false); return; } this.ShowMsg("添加商品失败", false); } return; } this.ShowMsg("数量不能为空,必需为大于零的正整数", false); }
protected void btnSubmit_Click(object sender, EventArgs e) { if (this.ValidateCreateOrder()) { string str2 = ""; PurchaseOrderInfo purchaseOrderInfo = new PurchaseOrderInfo(); Distributor user = Users.GetUser(HiContext.Current.User.UserId) as Distributor; string str3 = this.GeneratePurchaseOrderId(); purchaseOrderInfo.PurchaseOrderId = str3; decimal totalWeight = 0M; for (int i = 0; i < this.rpTaobaoOrder.Items.Count; i++) { CheckBox box = (CheckBox)this.rpTaobaoOrder.Items[i].FindControl("chkTbOrder"); if (box.Checked) { str2 = str2 + this.tbOrders[i].orderId + ","; Repeater repeater = (Repeater)this.rpTaobaoOrder.Items[i].FindControl("reOrderItems"); IList <tbOrderItem> items = this.tbOrders[i].items; for (int j = 0; j < repeater.Items.Count; j++) { if (items[j].localSkuId.Trim() == "") { string msg = string.Format("在授权给分销商的商品中没有找到淘宝商品:{0}!请重新查找", items[j].title); this.ShowMsg(msg, false); return; } string localSkuId = items[j].localSkuId; TextBox box2 = (TextBox)repeater.Items[j].FindControl("productNumber"); int num4 = Convert.ToInt32(box2.Text); bool flag = false; foreach (PurchaseOrderItemInfo info2 in purchaseOrderInfo.PurchaseOrderItems) { if (info2.SKU == localSkuId) { flag = true; info2.Quantity += num4; totalWeight += info2.ItemWeight * num4; } } if (!flag) { DataTable skuContentBySku = SubSiteProducthelper.GetSkuContentBySku(localSkuId); PurchaseOrderItemInfo item = new PurchaseOrderItemInfo(); if (num4 > ((int)skuContentBySku.Rows[0]["Stock"])) { this.ShowMsg("商品库存不够", false); return; } foreach (DataRow row in skuContentBySku.Rows) { if (!string.IsNullOrEmpty(row["AttributeName"].ToString()) && !string.IsNullOrEmpty(row["ValueStr"].ToString())) { object sKUContent = item.SKUContent; item.SKUContent = string.Concat(new object[] { sKUContent, row["AttributeName"], ":", row["ValueStr"], "; " }); } } item.PurchaseOrderId = str3; item.SkuId = localSkuId; item.ProductId = (int)skuContentBySku.Rows[0]["ProductId"]; if (skuContentBySku.Rows[0]["SKU"] != DBNull.Value) { item.SKU = (string)skuContentBySku.Rows[0]["SKU"]; } if (skuContentBySku.Rows[0]["Weight"] != DBNull.Value) { item.ItemWeight = (decimal)skuContentBySku.Rows[0]["Weight"]; } item.ItemPurchasePrice = (decimal)skuContentBySku.Rows[0]["PurchasePrice"]; item.Quantity = num4; item.ItemListPrice = (decimal)skuContentBySku.Rows[0]["SalePrice"]; if (skuContentBySku.Rows[0]["CostPrice"] != DBNull.Value) { item.ItemCostPrice = (decimal)skuContentBySku.Rows[0]["CostPrice"]; } item.ItemDescription = (string)skuContentBySku.Rows[0]["ProductName"]; item.ItemHomeSiteDescription = (string)skuContentBySku.Rows[0]["ProductName"]; if (skuContentBySku.Rows[0]["ThumbnailUrl40"] != DBNull.Value) { item.ThumbnailsUrl = (string)skuContentBySku.Rows[0]["ThumbnailUrl40"]; } totalWeight += item.ItemWeight * num4; purchaseOrderInfo.PurchaseOrderItems.Add(item); } } } } if (str2 == "") { this.ShowMsg("至少选择一个淘宝订单!!", false); } else { ShippingModeInfo shippingMode = SubsiteSalesHelper.GetShippingMode(this.radioShippingMode.SelectedValue.Value, true); purchaseOrderInfo.ShipTo = this.txtShipTo.Text.Trim(); if (this.rsddlRegion.GetSelectedRegionId().HasValue) { purchaseOrderInfo.RegionId = this.rsddlRegion.GetSelectedRegionId().Value; } purchaseOrderInfo.Address = this.txtAddress.Text.Trim(); purchaseOrderInfo.TelPhone = this.txtTel.Text.Trim(); purchaseOrderInfo.ZipCode = this.txtZipcode.Text.Trim(); purchaseOrderInfo.CellPhone = this.txtMobile.Text.Trim(); purchaseOrderInfo.OrderId = null; purchaseOrderInfo.RealShippingModeId = this.radioShippingMode.SelectedValue.Value; purchaseOrderInfo.RealModeName = shippingMode.Name; purchaseOrderInfo.ShippingModeId = this.radioShippingMode.SelectedValue.Value; purchaseOrderInfo.ModeName = shippingMode.Name; purchaseOrderInfo.AdjustedFreight = SubsiteSalesHelper.CalcFreight(purchaseOrderInfo.RegionId, totalWeight, shippingMode); purchaseOrderInfo.Freight = purchaseOrderInfo.AdjustedFreight; purchaseOrderInfo.ShippingRegion = this.rsddlRegion.SelectedRegions; purchaseOrderInfo.PurchaseStatus = OrderStatus.WaitBuyerPay; purchaseOrderInfo.DistributorId = user.UserId; purchaseOrderInfo.Distributorname = user.Username; purchaseOrderInfo.DistributorEmail = user.Email; purchaseOrderInfo.DistributorRealName = user.RealName; purchaseOrderInfo.DistributorQQ = user.QQ; purchaseOrderInfo.DistributorWangwang = user.Wangwang; purchaseOrderInfo.DistributorMSN = user.MSN; purchaseOrderInfo.RefundStatus = RefundStatus.None; purchaseOrderInfo.Weight = totalWeight; purchaseOrderInfo.Remark = null; purchaseOrderInfo.TaobaoOrderId = str2; if (purchaseOrderInfo.PurchaseOrderItems.Count == 0) { this.ShowMsg("您暂时未选择您要添加的商品", false); } else if (SubsiteSalesHelper.CreatePurchaseOrder(purchaseOrderInfo)) { SubsiteSalesHelper.ClearPurchaseShoppingCart(); this.ResponseCookies(); base.Response.Redirect(Globals.ApplicationPath + "/Shopadmin/purchaseOrder/ChoosePayment.aspx?PurchaseOrderId=" + purchaseOrderInfo.PurchaseOrderId); } else { this.ShowMsg("提交采购单失败", false); } } } }
public void grdSkus_RowCommand(object sender, GridViewCommandEventArgs e) { int num2; Grid grid = (Grid)sender; int rowIndex = ((GridViewRow)((Control)e.CommandSource).NamingContainer).RowIndex; string skuId = (string)grid.DataKeys[rowIndex].Value; TextBox box = (TextBox)grid.Rows[rowIndex].Cells[1].FindControl("txtNum"); LinkButton button = (LinkButton)grid.Rows[rowIndex].Cells[2].FindControl("lbtnAdd"); if ((!int.TryParse(box.Text.Trim(), out num2) || (int.Parse(box.Text.Trim()) <= 0)) || box.Text.Trim().Contains(".")) { this.ShowMsg("数量不能为空,必需为大于零的正整数", false); } else if ((e.CommandName == "add") && (button.Text == "添加")) { PurchaseShoppingCartItemInfo item = new PurchaseShoppingCartItemInfo(); DataTable skuContentBySku = SubSiteProducthelper.GetSkuContentBySku(skuId); if (num2 > ((int)skuContentBySku.Rows[0]["Stock"])) { this.ShowMsg("商品库存不够", false); } else { foreach (DataRow row in skuContentBySku.Rows) { if (!string.IsNullOrEmpty(row["AttributeName"].ToString()) && !string.IsNullOrEmpty(row["ValueStr"].ToString())) { object sKUContent = item.SKUContent; item.SKUContent = string.Concat(new object[] { sKUContent, row["AttributeName"], ":", row["ValueStr"], "; " }); } } item.SkuId = skuId; item.ProductId = (int)skuContentBySku.Rows[0]["ProductId"]; if (skuContentBySku.Rows[0]["SKU"] != DBNull.Value) { item.SKU = (string)skuContentBySku.Rows[0]["SKU"]; } if (skuContentBySku.Rows[0]["Weight"] != DBNull.Value) { item.ItemWeight = (decimal)skuContentBySku.Rows[0]["Weight"]; } item.ItemPurchasePrice = (decimal)skuContentBySku.Rows[0]["PurchasePrice"]; item.Quantity = num2; item.ItemListPrice = (decimal)skuContentBySku.Rows[0]["SalePrice"]; item.ItemDescription = (string)skuContentBySku.Rows[0]["ProductName"]; if (skuContentBySku.Rows[0]["CostPrice"] != DBNull.Value) { item.CostPrice = (decimal)skuContentBySku.Rows[0]["CostPrice"]; } if (skuContentBySku.Rows[0]["ThumbnailUrl40"] != DBNull.Value) { item.ThumbnailsUrl = (string)skuContentBySku.Rows[0]["ThumbnailUrl40"]; } if (SubsiteSalesHelper.AddPurchaseOrderItem(item, this.purchaseOrderId)) { this.UpdatePurchaseOrder(); this.BindOrderItems(); this.ReBindData(true, false); } else { this.ShowMsg("添加商品失败", false); } } } }
private void btnClear_Click(object sender, EventArgs e) { SubSiteProducthelper.ClearRelatedProducts(this.productId); base.Response.Redirect(HttpContext.Current.Request.Url.ToString(), true); }
private void grdProducts_RowDeleting(object sender, GridViewDeleteEventArgs e) { SubSiteProducthelper.DeleteProducts(grdProducts.DataKeys[e.RowIndex].Value.ToString()); BindProducts(); }
void BindData() { grdProductLine.DataSource = SubSiteProducthelper.GetAuthorizeProductLines(); grdProductLine.DataBind(); }
private void ProcessPurchaseOrderAdd(HttpContext context) { PurchaseOrderInfo purchaseOrderInfo = new PurchaseOrderInfo(); decimal totalWeight = 0M; if (string.IsNullOrEmpty(context.Request["Products"])) { context.Response.Write("{\"PurchaseOrderAddResponse\":\"-1\"}"); } else { int distributorId = int.Parse(context.Request["distributorUserId"]); foreach (string str in context.Request["Products"].Split(new char[] { ';' })) { string[] strArray2 = str.Split(new char[] { ',' }); DataTable table = SubSiteProducthelper.GetSkuContent(long.Parse(strArray2[0]), strArray2[1], distributorId); if ((table != null) && (table.Rows.Count > 0)) { PurchaseOrderItemInfo item = new PurchaseOrderItemInfo(); foreach (DataRow row in table.Rows) { if (!string.IsNullOrEmpty(row["AttributeName"].ToString()) && !string.IsNullOrEmpty(row["ValueStr"].ToString())) { object sKUContent = item.SKUContent; item.SKUContent = string.Concat(new object[] { sKUContent, row["AttributeName"], ":", row["ValueStr"], "; " }); } } item.PurchaseOrderId = purchaseOrderInfo.PurchaseOrderId; item.SkuId = (string)table.Rows[0]["SkuId"]; item.ProductId = (int)table.Rows[0]["ProductId"]; if (table.Rows[0]["SKU"] != DBNull.Value) { item.SKU = (string)table.Rows[0]["SKU"]; } if (table.Rows[0]["Weight"] != DBNull.Value) { item.ItemWeight = (decimal)table.Rows[0]["Weight"]; } item.ItemPurchasePrice = (decimal)table.Rows[0]["PurchasePrice"]; item.Quantity = int.Parse(strArray2[2]); item.ItemListPrice = (decimal)table.Rows[0]["SalePrice"]; if (table.Rows[0]["CostPrice"] != DBNull.Value) { item.ItemCostPrice = (decimal)table.Rows[0]["CostPrice"]; } item.ItemDescription = (string)table.Rows[0]["ProductName"]; item.ItemHomeSiteDescription = (string)table.Rows[0]["ProductName"]; if (table.Rows[0]["ThumbnailUrl40"] != DBNull.Value) { item.ThumbnailsUrl = (string)table.Rows[0]["ThumbnailUrl40"]; } totalWeight += item.ItemWeight * item.Quantity; purchaseOrderInfo.PurchaseOrderItems.Add(item); } } if (purchaseOrderInfo.PurchaseOrderItems.Count <= 0) { context.Response.Write("{\"PurchaseOrderAddResponse\":\"-3\"}"); } else { purchaseOrderInfo.Weight = totalWeight; purchaseOrderInfo.TaobaoOrderId = context.Request["TaobaoOrderId"]; purchaseOrderInfo.PurchaseOrderId = "MPO" + purchaseOrderInfo.TaobaoOrderId; purchaseOrderInfo.ShipTo = context.Request["ShipTo"]; string province = context.Request["ReceiverState"]; string city = context.Request["ReceiverCity"]; string county = context.Request["ReceiverDistrict"]; purchaseOrderInfo.ShippingRegion = province + city + county; purchaseOrderInfo.RegionId = RegionHelper.GetRegionId(county, city, province); purchaseOrderInfo.Address = context.Request["Address"]; purchaseOrderInfo.TelPhone = context.Request["TelPhone"]; purchaseOrderInfo.CellPhone = context.Request["CellPhone"]; purchaseOrderInfo.ZipCode = context.Request["ZipCode"]; purchaseOrderInfo.OrderTotal = decimal.Parse(context.Request["OrderTotal"]); ShippingModeInfo shippingMode = ShoppingProcessor.GetShippingMode(HiContext.Current.SiteSettings.TaobaoShippingType, true); if (shippingMode != null) { purchaseOrderInfo.ModeName = shippingMode.Name; purchaseOrderInfo.AdjustedFreight = purchaseOrderInfo.Freight = ShoppingProcessor.CalcFreight(purchaseOrderInfo.RegionId, totalWeight, shippingMode); } purchaseOrderInfo.PurchaseStatus = OrderStatus.WaitBuyerPay; purchaseOrderInfo.RefundStatus = RefundStatus.None; Distributor user = Users.GetUser(distributorId) as Distributor; if (user != null) { purchaseOrderInfo.DistributorId = user.UserId; purchaseOrderInfo.Distributorname = user.Username; purchaseOrderInfo.DistributorEmail = user.Email; purchaseOrderInfo.DistributorRealName = user.RealName; purchaseOrderInfo.DistributorQQ = user.QQ; purchaseOrderInfo.DistributorWangwang = user.Wangwang; purchaseOrderInfo.DistributorMSN = user.MSN; } if (!SubsiteSalesHelper.CreatePurchaseOrder(purchaseOrderInfo)) { context.Response.Write("{\"PurchaseOrderAddResponse\":\"0\"}"); } else { context.Response.Write("{\"PurchaseOrderAddResponse\":\"1\"}"); } } } }
public void ProcessRequest(HttpContext context) { string appkey = context.Request.Form["appkey"]; string appsecret = context.Request.Form["appsecret"]; string sessionkey = context.Request.Form["sessionkey"]; string productIds = context.Request.Form["productIds"]; string approve_status = context.Request.Form["approve_status"]; string morepic = context.Request.Form["morepic"]; string repub = context.Request.Form["repub"]; string chkdesc = context.Request.Form["chkdesc"]; string chknormal = context.Request.Form["chknormal"]; string chktitle = context.Request.Form["chktitle"]; if (!string.IsNullOrEmpty(appkey) && !string.IsNullOrEmpty(appsecret)) { this.client = new DefaultTopClient("http://gw.api.taobao.com/router/rest", appkey, appsecret, "json"); } DataTable taobaoProducts = SubSiteProducthelper.GetTaobaoProducts(productIds); if (null != taobaoProducts && taobaoProducts.Rows.Count > 0) { Dictionary <int, long> taobaoReturnProductIds = new Dictionary <int, long>(); StringBuilder builder = new StringBuilder(); string pname = ""; int num = 0; string imgurl = ""; int stock = 0; decimal markprice = 0M; string issuccess = "true"; string msg = ""; string imgmsg = ""; string proTitle = "";// (string)row["ProTitle"]; foreach (DataRow row in taobaoProducts.Rows) { proTitle = (string)row["ProTitle"]; ResponseData(row, out imgurl, out stock, out markprice); if ((row["taobaoproductid"] != DBNull.Value) && (repub.ToLower() == "true")) { ItemUpdateRequest req = new ItemUpdateRequest(); req.NumIid = new long?(Convert.ToInt64(row["taobaoproductid"])); req.ApproveStatus = approve_status; if (!string.IsNullOrEmpty(chknormal) && (chknormal.ToLower() == "true")) { this.SetTaoBaoUpdateData(req, row); } if (!string.IsNullOrEmpty(chktitle) && (chktitle.ToLower() == "true")) { req.Title = (row["ProTitle"] == DBNull.Value) ? "请修改商品标题" : ((string)row["ProTitle"]); } if (!string.IsNullOrEmpty(chkdesc) && (chkdesc.ToLower() == "true")) { req.Desc = (row["Description"] == DBNull.Value) ? "暂无该商品的描述信息" : ((string)row["Description"]); } ItemUpdateResponse response = client.Execute <ItemUpdateResponse>(req, sessionkey); if (response.IsError) { num = (int)row["ProductId"]; pname = string.Format("<a href='{0}' target=_blank>{1} </a>", Globals.GetSiteUrls().UrlData.FormatUrl("productDetails", new object[] { num }), proTitle); imgurl = string.Format("<a href='{0}' target=_blank><img src={1} /></a>", Globals.GetSiteUrls().UrlData.FormatUrl("productDetails", new object[] { num }), imgurl); msg = string.Format("商品更新失败<br/>({0})", ":" + response.ErrMsg + ":" + response.SubErrMsg); issuccess = "false"; } else { imgurl = string.Format("<a href='http://item.taobao.com/item.htm?id={0}' target=_blank><img src={1} /></a>", response.Item.NumIid, imgurl); pname = string.Format("<a href='http://item.taobao.com/item.htm?id={0}'>{1}</a>", response.Item.NumIid, proTitle); msg = "商品更新成功"; issuccess = "true"; taobaoReturnProductIds.Add((int)row["ProductId"], response.Item.NumIid); } } else { ItemAddRequest req = new ItemAddRequest(); req.ApproveStatus = approve_status; SetTaoBaoAddData(req, row); ItemAddResponse response2 = client.Execute <ItemAddResponse>(req, sessionkey); if (response2.IsError) { num = (int)row["ProductId"]; pname = string.Format("<a href='{0}' target=_blank>{1} </a>", Globals.GetSiteUrls().UrlData.FormatUrl("productDetails", new object[] { num }), proTitle); imgurl = string.Format("<a href='{0}' target=_blank><img src={1} /></a>", Globals.GetSiteUrls().UrlData.FormatUrl("productDetails", new object[] { num }), imgurl); msg = string.Format("发布失败<br/>({0})", response2.ErrMsg + ":" + response2.SubErrMsg); issuccess = "false"; } else { imgurl = string.Format("<a href='http://item.taobao.com/item.htm?id={0}' target=_blank><img src={1} /></a>", response2.Item.NumIid, imgurl); pname = string.Format("<a href='http://item.taobao.com/item.htm?id={0}'>{1}</a>", response2.Item.NumIid, proTitle); msg = "商品发布成功"; issuccess = "true"; taobaoReturnProductIds.Add((int)row["ProductId"], response2.Item.NumIid); if (morepic == "true") { List <TbImage> productsImgs = this.GetProductsImgs(row, response2); StringBuilder builder2 = new StringBuilder(); foreach (TbImage image in productsImgs) { string path = Globals.ApplicationPath + image.Imgpath; if (File.Exists(Globals.MapPath(path))) { FileItem item = new FileItem(Globals.MapPath(path)); ItemImgUploadRequest request = new ItemImgUploadRequest(); request.Image = item; request.NumIid = new long?(image.TbProductId); request.IsMajor = false; ItemImgUploadResponse itemImgUploadResponse = this.client.Execute <ItemImgUploadResponse>(request, sessionkey); if (itemImgUploadResponse.IsError) { builder2.AppendFormat("[\"{0}发布图片错误,错误原因:{1}\"],", proTitle, itemImgUploadResponse.ErrMsg + ";" + itemImgUploadResponse.SubErrMsg); } } } if (builder2.Length > 0) { imgmsg = builder2.ToString().Substring(0, builder2.ToString().Length - 1); } } } } builder.Append(string.Concat(new object[] { "{\"pname\":\"", pname, "\",\"pimg\":\"", imgurl, "\",\"pmarkprice\":\"", markprice.ToString("F2"), "\",\"pstock\":\"", stock, "\",\"issuccess\":\"", issuccess, "\",\"msg\":\"", msg, "\",\"imgmsg\":[", imgmsg, "]}," })); } if (taobaoReturnProductIds.Count > 0) { SubSiteProducthelper.AddTaobaoReturnProductIds(taobaoReturnProductIds, 0); } if (builder.ToString().Length > 0) { builder.Remove(builder.Length - 1, 1); } context.Response.Write("{\"Status\":\"OK\",\"Result\":[" + builder.ToString() + "]}"); context.Response.Flush(); context.Response.End(); } else { context.Response.Write("{\"Status\":\"Error\",\"Result\":\"发布商品到淘宝出错!\"}"); context.Response.Flush(); context.Response.End(); } }
private void grdProducts_RowDeleting(object sender, System.Web.UI.WebControls.GridViewDeleteEventArgs e) { SubSiteProducthelper.DeleteProducts(this.grdProducts.DataKeys[e.RowIndex].Value.ToString()); this.BindProducts(); }
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(); } } }
private void btnClear_Click(object sender, EventArgs e) { SubSiteProducthelper.ClearSubjectProducts(subjectType); BindSubjectProducts(); }
private void ProcessProductDetails(System.Web.HttpContext context) { string str = "http://" + System.Web.HttpContext.Current.Request.Url.Host + ((System.Web.HttpContext.Current.Request.Url.Port == 80) ? "" : (":" + System.Web.HttpContext.Current.Request.Url.Port)); int distributorId = int.Parse(context.Request["distributorUserId"]); int productId = int.Parse(context.Request["productId"]); PublishToTaobaoProductInfo taobaoProduct = SubSiteProducthelper.GetTaobaoProduct(productId, distributorId); System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder(); stringBuilder.Append("{"); stringBuilder.AppendFormat("\"Cid\":\"{0}\",", taobaoProduct.Cid); stringBuilder.AppendFormat("\"StuffStatus\":\"{0}\",", taobaoProduct.StuffStatus); stringBuilder.AppendFormat("\"ProductId\":\"{0}\",", taobaoProduct.ProductId); stringBuilder.AppendFormat("\"ProTitle\":\"{0}\",", taobaoProduct.ProTitle); stringBuilder.AppendFormat("\"Num\":\"{0}\",", taobaoProduct.Num); stringBuilder.AppendFormat("\"LocationState\":\"{0}\",", taobaoProduct.LocationState); stringBuilder.AppendFormat("\"LocationCity\":\"{0}\",", taobaoProduct.LocationCity); stringBuilder.AppendFormat("\"FreightPayer\":\"{0}\",", taobaoProduct.FreightPayer); stringBuilder.AppendFormat("\"PostFee\":\"{0}\",", taobaoProduct.PostFee.ToString("F2")); stringBuilder.AppendFormat("\"ExpressFee\":\"{0}\",", taobaoProduct.ExpressFee.ToString("F2")); stringBuilder.AppendFormat("\"EMSFee\":\"{0}\",", taobaoProduct.EMSFee.ToString("F2")); stringBuilder.AppendFormat("\"HasInvoice\":\"{0}\",", taobaoProduct.HasInvoice); stringBuilder.AppendFormat("\"HasWarranty\":\"{0}\",", taobaoProduct.HasWarranty); stringBuilder.AppendFormat("\"HasDiscount\":\"{0}\",", taobaoProduct.HasDiscount); stringBuilder.AppendFormat("\"ValidThru\":\"{0}\",", taobaoProduct.ValidThru); stringBuilder.AppendFormat("\"ListTime\":\"{0}\",", taobaoProduct.ListTime); stringBuilder.AppendFormat("\"PropertyAlias\":\"{0}\",", taobaoProduct.PropertyAlias); stringBuilder.AppendFormat("\"InputPids\":\"{0}\",", taobaoProduct.InputPids); stringBuilder.AppendFormat("\"InputStr\":\"{0}\",", taobaoProduct.InputStr); stringBuilder.AppendFormat("\"SkuProperties\":\"{0}\",", taobaoProduct.SkuProperties); stringBuilder.AppendFormat("\"SkuQuantities\":\"{0}\",", taobaoProduct.SkuQuantities); stringBuilder.AppendFormat("\"SkuPrices\":\"{0}\",", taobaoProduct.SkuPrices); stringBuilder.AppendFormat("\"SkuOuterIds\":\"{0}\",", taobaoProduct.SkuOuterIds); stringBuilder.AppendFormat("\"FoodAttributes\":\"{0}\",", System.Web.HttpUtility.UrlEncode(taobaoProduct.FoodAttributes)); stringBuilder.AppendFormat("\"TaobaoProductId\":\"{0}\",", taobaoProduct.TaobaoProductId); stringBuilder.AppendFormat("\"ProductCode\":\"{0}\",", taobaoProduct.ProductCode); stringBuilder.AppendFormat("\"Description\":\"{0}\",", taobaoProduct.Description.Replace(string.Format("src=\"{0}/Storage/master/gallery", Globals.ApplicationPath), string.Format("src=\"{0}/Storage/master/gallery", str + Globals.ApplicationPath)).Replace('"', '“')); string text = str + Globals.ApplicationPath + taobaoProduct.ImageUrl1; if (System.IO.File.Exists(Globals.MapPath(Globals.ApplicationPath + taobaoProduct.ImageUrl1)) && (text.EndsWith(".jpg", System.StringComparison.CurrentCultureIgnoreCase) || text.EndsWith(".gif", System.StringComparison.CurrentCultureIgnoreCase) || text.EndsWith(".png", System.StringComparison.CurrentCultureIgnoreCase) || text.EndsWith(".jpeg", System.StringComparison.CurrentCultureIgnoreCase))) { stringBuilder.AppendFormat("\"ImageName\":\"{0}\",", text); } if (!string.IsNullOrEmpty(taobaoProduct.ImageUrl2)) { string text2 = str + Globals.ApplicationPath + taobaoProduct.ImageUrl2; if (System.IO.File.Exists(Globals.MapPath(Globals.ApplicationPath + taobaoProduct.ImageUrl2)) && (text2.EndsWith(".jpg", System.StringComparison.CurrentCultureIgnoreCase) || text2.EndsWith(".gif", System.StringComparison.CurrentCultureIgnoreCase) || text2.EndsWith(".png", System.StringComparison.CurrentCultureIgnoreCase) || text2.EndsWith(".jpeg", System.StringComparison.CurrentCultureIgnoreCase))) { stringBuilder.AppendFormat("\"ImageName2\":\"{0}\",", text2); } } if (!string.IsNullOrEmpty(taobaoProduct.ImageUrl3)) { string text3 = str + Globals.ApplicationPath + taobaoProduct.ImageUrl3; if (System.IO.File.Exists(Globals.MapPath(Globals.ApplicationPath + taobaoProduct.ImageUrl3)) && (text3.EndsWith(".jpg", System.StringComparison.CurrentCultureIgnoreCase) || text3.EndsWith(".gif", System.StringComparison.CurrentCultureIgnoreCase) || text3.EndsWith(".png", System.StringComparison.CurrentCultureIgnoreCase) || text3.EndsWith(".jpeg", System.StringComparison.CurrentCultureIgnoreCase))) { stringBuilder.AppendFormat("\"ImageName3\":\"{0}\",", text3); } } if (!string.IsNullOrEmpty(taobaoProduct.ImageUrl4)) { string text4 = str + Globals.ApplicationPath + taobaoProduct.ImageUrl4; if (System.IO.File.Exists(Globals.MapPath(Globals.ApplicationPath + taobaoProduct.ImageUrl4)) && (text4.EndsWith(".jpg", System.StringComparison.CurrentCultureIgnoreCase) || text4.EndsWith(".gif", System.StringComparison.CurrentCultureIgnoreCase) || text4.EndsWith(".png", System.StringComparison.CurrentCultureIgnoreCase) || text4.EndsWith(".jpeg", System.StringComparison.CurrentCultureIgnoreCase))) { stringBuilder.AppendFormat("\"ImageName4\":\"{0}\",", text4); } } if (!string.IsNullOrEmpty(taobaoProduct.ImageUrl5)) { string text5 = str + Globals.ApplicationPath + taobaoProduct.ImageUrl5; if (System.IO.File.Exists(Globals.MapPath(Globals.ApplicationPath + taobaoProduct.ImageUrl5)) && (text5.EndsWith(".jpg", System.StringComparison.CurrentCultureIgnoreCase) || text5.EndsWith(".gif", System.StringComparison.CurrentCultureIgnoreCase) || text5.EndsWith(".png", System.StringComparison.CurrentCultureIgnoreCase) || text5.EndsWith(".jpeg", System.StringComparison.CurrentCultureIgnoreCase))) { stringBuilder.AppendFormat("\"ImageName5\":\"{0}\",", text5); } } stringBuilder.AppendFormat("\"SalePrice\":\"{0}\"", taobaoProduct.SalePrice.ToString("F2")); stringBuilder.Append("}"); context.Response.Write(stringBuilder.ToString()); }
private void btnUpdateProductTags_Click(object sender, System.EventArgs e) { string text = base.Request.Form["CheckBoxGroup"]; if (string.IsNullOrEmpty(text)) { this.ShowMsg("请先选择要关联的商品", false); return; } System.Collections.Generic.IList <int> list = new System.Collections.Generic.List <int>(); if (!string.IsNullOrEmpty(this.txtProductTag.Text.Trim())) { string text2 = this.txtProductTag.Text.Trim(); string[] array; if (text2.Contains(",")) { array = text2.Split(new char[] { ',' }); } else { array = new string[] { text2 }; } string[] array2 = array; for (int i = 0; i < array2.Length; i++) { string value = array2[i]; list.Add(System.Convert.ToInt32(value)); } } string[] array3; if (text.Contains(",")) { array3 = text.Split(new char[] { ',' }); } else { array3 = new string[] { text }; } int num = 0; string[] array4 = array3; for (int j = 0; j < array4.Length; j++) { string value2 = array4[j]; SubSiteProducthelper.DeleteProductTags(System.Convert.ToInt32(value2), null); if (list.Count > 0 && SubSiteProducthelper.AddProductTags(System.Convert.ToInt32(value2), list, null)) { num++; } } if (num > 0) { this.ShowMsg(string.Format("已成功修改了{0}件商品的商品标签", num), true); } else { this.ShowMsg("已成功取消了商品关联的商品标签", true); } this.txtProductTag.Text = ""; }
private void ProcessPurchaseOrderAdd(System.Web.HttpContext context) { PurchaseOrderInfo purchaseOrderInfo = new PurchaseOrderInfo(); decimal num = 0m; if (string.IsNullOrEmpty(context.Request["Products"])) { context.Response.Write("{\"PurchaseOrderAddResponse\":\"-1\"}"); return; } int num2 = int.Parse(context.Request["distributorUserId"]); string[] array = context.Request["Products"].Split(new char[] { ';' }); string[] array2 = array; for (int i = 0; i < array2.Length; i++) { string text = array2[i]; string[] array3 = text.Split(new char[] { ',' }); System.Data.DataTable skuContent = SubSiteProducthelper.GetSkuContent(long.Parse(array3[0]), array3[1], num2); if (skuContent != null && skuContent.Rows.Count > 0) { PurchaseOrderItemInfo purchaseOrderItemInfo = new PurchaseOrderItemInfo(); foreach (System.Data.DataRow dataRow in skuContent.Rows) { if (!string.IsNullOrEmpty(dataRow["AttributeName"].ToString()) && !string.IsNullOrEmpty(dataRow["ValueStr"].ToString())) { PurchaseOrderItemInfo expr_124 = purchaseOrderItemInfo; object sKUContent = expr_124.SKUContent; expr_124.SKUContent = string.Concat(new object[] { sKUContent, dataRow["AttributeName"], ":", dataRow["ValueStr"], "; " }); } } purchaseOrderItemInfo.PurchaseOrderId = purchaseOrderInfo.PurchaseOrderId; purchaseOrderItemInfo.SkuId = (string)skuContent.Rows[0]["SkuId"]; purchaseOrderItemInfo.ProductId = (int)skuContent.Rows[0]["ProductId"]; if (skuContent.Rows[0]["SKU"] != System.DBNull.Value) { purchaseOrderItemInfo.SKU = (string)skuContent.Rows[0]["SKU"]; } if (skuContent.Rows[0]["Weight"] != System.DBNull.Value) { purchaseOrderItemInfo.ItemWeight = (decimal)skuContent.Rows[0]["Weight"]; } purchaseOrderItemInfo.ItemPurchasePrice = (decimal)skuContent.Rows[0]["PurchasePrice"]; purchaseOrderItemInfo.Quantity = int.Parse(array3[2]); purchaseOrderItemInfo.ItemListPrice = (decimal)skuContent.Rows[0]["SalePrice"]; if (skuContent.Rows[0]["CostPrice"] != System.DBNull.Value) { purchaseOrderItemInfo.ItemCostPrice = (decimal)skuContent.Rows[0]["CostPrice"]; } purchaseOrderItemInfo.ItemDescription = (string)skuContent.Rows[0]["ProductName"]; purchaseOrderItemInfo.ItemHomeSiteDescription = (string)skuContent.Rows[0]["ProductName"]; if (skuContent.Rows[0]["ThumbnailUrl40"] != System.DBNull.Value) { purchaseOrderItemInfo.ThumbnailsUrl = (string)skuContent.Rows[0]["ThumbnailUrl40"]; } num += purchaseOrderItemInfo.ItemWeight * purchaseOrderItemInfo.Quantity; purchaseOrderInfo.PurchaseOrderItems.Add(purchaseOrderItemInfo); } } if (purchaseOrderInfo.PurchaseOrderItems.Count <= 0) { context.Response.Write("{\"PurchaseOrderAddResponse\":\"-3\"}"); return; } purchaseOrderInfo.Weight = num; purchaseOrderInfo.TaobaoOrderId = context.Request["TaobaoOrderId"]; purchaseOrderInfo.PurchaseOrderId = "MPO" + purchaseOrderInfo.TaobaoOrderId; purchaseOrderInfo.ShipTo = context.Request["ShipTo"]; string text2 = context.Request["ReceiverState"]; string text3 = context.Request["ReceiverCity"]; string text4 = context.Request["ReceiverDistrict"]; purchaseOrderInfo.ShippingRegion = text2 + text3 + text4; purchaseOrderInfo.RegionId = RegionHelper.GetRegionId(text4, text3, text2); purchaseOrderInfo.Address = context.Request["Address"]; purchaseOrderInfo.TelPhone = context.Request["TelPhone"]; purchaseOrderInfo.CellPhone = context.Request["CellPhone"]; purchaseOrderInfo.ZipCode = context.Request["ZipCode"]; purchaseOrderInfo.OrderTotal = decimal.Parse(context.Request["OrderTotal"]); ShippingModeInfo shippingMode = ShoppingProcessor.GetShippingMode(Hidistro.Membership.Context.HiContext.Current.SiteSettings.TaobaoShippingType, true); if (shippingMode != null) { purchaseOrderInfo.ModeName = shippingMode.Name; purchaseOrderInfo.AdjustedFreight = (purchaseOrderInfo.Freight = ShoppingProcessor.CalcFreight(purchaseOrderInfo.RegionId, num, shippingMode)); } purchaseOrderInfo.PurchaseStatus = OrderStatus.WaitBuyerPay; purchaseOrderInfo.RefundStatus = RefundStatus.None; Hidistro.Membership.Context.Distributor distributor = Hidistro.Membership.Context.Users.GetUser(num2) as Hidistro.Membership.Context.Distributor; if (distributor != null) { purchaseOrderInfo.DistributorId = distributor.UserId; purchaseOrderInfo.Distributorname = distributor.Username; purchaseOrderInfo.DistributorEmail = distributor.Email; purchaseOrderInfo.DistributorRealName = distributor.RealName; purchaseOrderInfo.DistributorQQ = distributor.QQ; purchaseOrderInfo.DistributorWangwang = distributor.Wangwang; purchaseOrderInfo.DistributorMSN = distributor.MSN; } if (!SubsiteSalesHelper.CreatePurchaseOrder(purchaseOrderInfo)) { context.Response.Write("{\"PurchaseOrderAddResponse\":\"0\"}"); return; } context.Response.Write("{\"PurchaseOrderAddResponse\":\"1\"}"); }
/// <summary> /// 更新按钮事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnUpdate_Click(object sender, EventArgs e) { if (categoryId == 0) { categoryId = (int)ViewState["ProductCategoryId"]; } if (categoryId == 0) { ShowMsg("请选择店铺分类", false); return; } ProductInfo product = new ProductInfo(); product.ProductId = productId; product.CategoryId = categoryId; CategoryInfo category = SubsiteCatalogHelper.GetCategory(product.CategoryId); if (category != null) { product.MainCategoryPath = category.Path + "|"; } product.ProductName = txtProductName.Text; product.ShortDescription = txtShortDescription.Text; product.Description = fckDescription.Text; product.Title = txtTitle.Text; product.MetaDescription = txtMetaDescription.Text; product.MetaKeywords = txtMetaKeywords.Text; product.DisplaySequence = int.Parse(txtDisplaySequence.Text); if (!string.IsNullOrEmpty(txtMarketPrice.Text)) { product.MarketPrice = new decimal?(decimal.Parse(txtMarketPrice.Text)); } Dictionary <string, decimal> skuSalePrice = null; if (!string.IsNullOrEmpty(txtSkuPrice.Text)) { skuSalePrice = GetSkuPrices(); } ProductSaleStatus onStock = ProductSaleStatus.OnStock; if (radInStock.Checked) { onStock = ProductSaleStatus.OnStock; } if (radUnSales.Checked) { onStock = ProductSaleStatus.UnSale; } if (radOnSales.Checked) { onStock = ProductSaleStatus.OnSale; XmlDocument document = new XmlDocument(); document.LoadXml(txtSkuPrice.Text); XmlNodeList list = document.SelectNodes("//item"); if ((list != null) && (list.Count > 0)) { foreach (XmlNode node in list) { if (decimal.Parse(node.Attributes["price"].Value) < decimal.Parse(litLowestSalePrice.Text)) { ShowMsg("此商品的一口价已经低于了最低零售价,不允许上架", false); return; } } } } product.SaleStatus = onStock; if (SubSiteProducthelper.UpdateProduct(product, skuSalePrice)) { ShowMsg("修改商品成功", true); } else { ShowMsg("修改商品失败", false); } }