private void btnSubmit_Click(object sender, EventArgs e) { if (this.ValidateCreateOrder()) { PurchaseOrderInfo purchaseOrderInfo = this.GetPurchaseOrderInfo(); if (purchaseOrderInfo.PurchaseOrderItems.Count == 0) { this.ShowMsg("您暂时未选择您要添加的商品", false); } else if (SubsiteSalesHelper.CreatePurchaseOrder(purchaseOrderInfo)) { SubsiteSalesHelper.ClearPurchaseShoppingCart(); int.Parse(this.radioPaymentMode.SelectedValue); PaymentModeInfo paymentMode = SubsiteStoreHelper.GetPaymentMode(int.Parse(this.radioPaymentMode.SelectedValue)); if ((paymentMode != null) && paymentMode.Gateway.ToLower().Equals("hishop.plugins.payment.podrequest")) { this.ShowMsg("您选择的是货到付款方式,请等待主站发货", true); } else if ((paymentMode != null) && paymentMode.Gateway.ToLower().Equals("hishop.plugins.payment.bankrequest")) { this.ShowMsg("您选择的是线下付款方式,请与主站管理员联系", true); } else { base.Response.Redirect(Globals.ApplicationPath + "/Shopadmin/purchaseOrder/Pay.aspx?PurchaseOrderId=" + purchaseOrderInfo.PurchaseOrderId + "&PayMode=" + this.radioPaymentMode.SelectedValue); } } else { this.ShowMsg("提交采购单失败", false); } } }
private void btnSubmit_Click(object sender, EventArgs e) { if (ValidateCreateOrder()) { PurchaseOrderInfo purchaseOrderInfo = GetPurchaseOrderInfo(); if (purchaseOrderInfo.PurchaseOrderItems.Count == 0) { ShowMsg("您暂时未选择您要添加的商品", false); } else if (SubsiteSalesHelper.CreatePurchaseOrder(purchaseOrderInfo)) { SubsiteSalesHelper.ClearPurchaseShoppingCart(); Response.Redirect(Globals.ApplicationPath + "/Shopadmin/purchaseOrder/Pay.aspx?PurchaseOrderId=" + purchaseOrderInfo.PurchaseOrderId); } else { 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); } } } }
protected void btnSubmit_Click(object sender, System.EventArgs e) { if (!this.ValidateCreateOrder()) { return; } string text = ""; PurchaseOrderInfo purchaseOrderInfo = new PurchaseOrderInfo(); Hidistro.Membership.Context.Distributor distributor = Hidistro.Membership.Context.Users.GetUser(Hidistro.Membership.Context.HiContext.Current.User.UserId) as Hidistro.Membership.Context.Distributor; string purchaseOrderId = this.GeneratePurchaseOrderId(); purchaseOrderInfo.PurchaseOrderId = purchaseOrderId; decimal num = 0m; for (int i = 0; i < this.rpTaobaoOrder.Items.Count; i++) { System.Web.UI.WebControls.CheckBox checkBox = (System.Web.UI.WebControls.CheckBox) this.rpTaobaoOrder.Items[i].FindControl("chkTbOrder"); if (checkBox.Checked) { text += this.tbOrders[i].orderId; text += ","; System.Web.UI.WebControls.Repeater repeater = (System.Web.UI.WebControls.Repeater) this.rpTaobaoOrder.Items[i].FindControl("reOrderItems"); System.Collections.Generic.IList <SubmitTaobaoPurchaseorderCart.tbOrderItem> items = this.tbOrders[i].items; for (int j = 0; j < repeater.Items.Count; j++) { if (items[j].localSkuId.Trim() == "") { string string_ = string.Format("在授权给分销商的商品中没有找到淘宝商品:{0}!请重新查找", items[j].title); this.ShowMsg(string_, false); return; } string localSkuId = items[j].localSkuId; System.Web.UI.WebControls.TextBox textBox = (System.Web.UI.WebControls.TextBox)repeater.Items[j].FindControl("productNumber"); int num2 = System.Convert.ToInt32(textBox.Text); bool flag = false; foreach (PurchaseOrderItemInfo current in purchaseOrderInfo.PurchaseOrderItems) { if (current.SKU == localSkuId) { flag = true; current.Quantity += num2; num += current.ItemWeight * num2; } } if (!flag) { System.Data.DataTable skuContentBySku = SubSiteProducthelper.GetSkuContentBySku(localSkuId); PurchaseOrderItemInfo purchaseOrderItemInfo = new PurchaseOrderItemInfo(); if (num2 > (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())) { PurchaseOrderItemInfo expr_23B = purchaseOrderItemInfo; object sKUContent = expr_23B.SKUContent; expr_23B.SKUContent = string.Concat(new object[] { sKUContent, dataRow["AttributeName"], ":", dataRow["ValueStr"], "; " }); } } purchaseOrderItemInfo.PurchaseOrderId = purchaseOrderId; purchaseOrderItemInfo.SkuId = localSkuId; purchaseOrderItemInfo.ProductId = (int)skuContentBySku.Rows[0]["ProductId"]; if (skuContentBySku.Rows[0]["SKU"] != System.DBNull.Value) { purchaseOrderItemInfo.SKU = (string)skuContentBySku.Rows[0]["SKU"]; } if (skuContentBySku.Rows[0]["Weight"] != System.DBNull.Value) { purchaseOrderItemInfo.ItemWeight = (decimal)skuContentBySku.Rows[0]["Weight"]; } purchaseOrderItemInfo.ItemPurchasePrice = (decimal)skuContentBySku.Rows[0]["PurchasePrice"]; purchaseOrderItemInfo.Quantity = num2; purchaseOrderItemInfo.ItemListPrice = (decimal)skuContentBySku.Rows[0]["SalePrice"]; if (skuContentBySku.Rows[0]["CostPrice"] != System.DBNull.Value) { purchaseOrderItemInfo.ItemCostPrice = (decimal)skuContentBySku.Rows[0]["CostPrice"]; } purchaseOrderItemInfo.ItemDescription = (string)skuContentBySku.Rows[0]["ProductName"]; purchaseOrderItemInfo.ItemHomeSiteDescription = (string)skuContentBySku.Rows[0]["ProductName"]; if (skuContentBySku.Rows[0]["ThumbnailUrl40"] != System.DBNull.Value) { purchaseOrderItemInfo.ThumbnailsUrl = (string)skuContentBySku.Rows[0]["ThumbnailUrl40"]; } num += purchaseOrderItemInfo.ItemWeight * num2; purchaseOrderInfo.PurchaseOrderItems.Add(purchaseOrderItemInfo); } } } } if (text == "") { this.ShowMsg("至少选择一个淘宝订单!!", false); return; } 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, num, shippingMode); purchaseOrderInfo.Freight = purchaseOrderInfo.AdjustedFreight; purchaseOrderInfo.ShippingRegion = this.rsddlRegion.SelectedRegions; purchaseOrderInfo.PurchaseStatus = OrderStatus.WaitBuyerPay; 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; purchaseOrderInfo.RefundStatus = RefundStatus.None; purchaseOrderInfo.Weight = num; purchaseOrderInfo.Remark = null; purchaseOrderInfo.TaobaoOrderId = text; if (purchaseOrderInfo.PurchaseOrderItems.Count == 0) { this.ShowMsg("您暂时未选择您要添加的商品", false); return; } if (SubsiteSalesHelper.CreatePurchaseOrder(purchaseOrderInfo)) { SubsiteSalesHelper.ClearPurchaseShoppingCart(); this.ResponseCookies(); base.Response.Redirect(Globals.ApplicationPath + "/Shopadmin/purchaseOrder/ChoosePayment.aspx?PurchaseOrderId=" + purchaseOrderInfo.PurchaseOrderId); return; } this.ShowMsg("提交采购单失败", false); }