private void tsbtnStockin_Click(object sender, EventArgs e) { Cursor.Current = Cursors.WaitCursor; // Removed by KK on 2015/12/26. // Replaced by new stockout form. //string brand = string.Empty, product = string.Empty; //if (lvwStock.SelectedItems.Count > 0) //{ // brand = ((ProductInfo)lvwStock.SelectedItems[0].Tag).BrandId; // product = ((ProductInfo)lvwStock.SelectedItems[0].Tag).Id; //} //StockActionForm saf = new StockActionForm(false, brand, product); //if (DialogResult.OK == saf.ShowDialog(this)) // StockAction(saf.Product.Id, saf.Count, saf.FromTo, Settings.Operator, saf.Comment); List <SoldProductInfo> selectedProductInfos = new List <SoldProductInfo>(); foreach (ListViewItem lvi in lvwStock.SelectedItems) { SoldProductInfo spi = new SoldProductInfo(lvi.Tag as ProductInfo); spi.Count = 0; selectedProductInfos.Add(spi); } StockActionAdvForm saaf = new StockActionAdvForm(false, selectedProductInfos); if (DialogResult.OK == saaf.ShowDialog(this)) { // 入库登记. try { StockAction(false, saaf.SelectedProductInfos, saaf.FromToFull, saaf.Comment); } catch (Exception ex) { MessageBox.Show(this, ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } Cursor.Current = Cursors.Default; }
private void btnStockout_Click(object sender, EventArgs e) { int cSucceeded = 0, cFailed = 0; foreach (NingboOrderListViewItem item in lvwNingboOrders.SelectedItems) { Order order = MainForm.Instance.GetOrder(item.NingboOrder.TaobaoOrderId); try { // 切换到手动出库. if (null == item.NingboOrder.SoldProducts || item.NingboOrder.SoldProducts.Count <= 0) { StockActionAdvForm saaf = new StockActionAdvForm(true, null); saaf.FromToPart1 = "eur8"; //(ShopProfile.Current.Shop == ShopEnum.Egode ? string.Empty : ShopProfile.Current.ShortName); saaf.FromToPart2 = string.Format("{0} [{1},{2}]", (null == order ? string.Empty: order.BuyerAccount), item.NingboOrder.RecipientName, item.NingboOrder.Mobile); saaf.Comment = item.NingboOrder.LogisticsCompany.Trim() + item.NingboOrder.MailNumber.Trim(); if (DialogResult.OK == saaf.ShowDialog(this)) { // 出库登记. try { Application.DoEvents(); Cursor.Current = Cursors.WaitCursor; string result = StockActionAdvForm.StockAction(true, saaf.SelectedProductInfos, saaf.FromToFull, saaf.Comment, ShippingOrigins.Ningbo); if (result.StartsWith("Succeeded")) { cSucceeded++; } else { cFailed++; } MessageBox.Show( this, "Result from server: \n" + result, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(this, ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } finally { Cursor.Current = Cursors.Default; } } continue; } string url = string.Format(Common.URL_DATA_CENTER, "stocknb"); url += string.Format( "&productids={0}&counts=-{1}&dest={2}&op={3}&comment={4}{5}", item.NingboOrder.SoldProducts[0].Id, item.NingboOrder.SoldProducts[0].Count, (ShopProfile.Current.Shop == ShopEnum.Egode ? string.Empty : (ShopProfile.Current.ShortName + "\\")) + string.Format("{0} [{1},{2}]", order.BuyerAccount, item.NingboOrder.RecipientName, item.NingboOrder.Mobile), Settings.Operator, GetLogisticsShortName(item.NingboOrder.LogisticsCompany), item.NingboOrder.MailNumber); HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url); request.Method = "GET"; request.ContentType = "text/xml"; WebResponse response = request.GetResponse(); StreamReader reader = new StreamReader(response.GetResponseStream()); string result1 = reader.ReadToEnd(); reader.Close(); //Trace.WriteLine(result1); if (result1.StartsWith("Succeeded")) { cSucceeded++; } else { cFailed++; } MessageBox.Show( this, "Result from server: \n" + result1, string.Format("{0} [{1}\\{2}]", this.Text, cSucceeded + cFailed, lvwNingboOrders.SelectedItems.Count), MessageBoxButtons.OK, result1.StartsWith("Succeeded") ? MessageBoxIcon.Information : MessageBoxIcon.Exclamation); // Added by KK on 2015/12/16. if (result1.StartsWith("Succeeded")) { item.ForeColor = Color.DarkGreen; } else { item.ForeColor = Color.Red; } } catch (Exception ex) { MessageBox.Show(this, ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } MessageBox.Show( this, string.Format("批量出库完成.\n成功: {0}\n失败: {1}", cSucceeded, cFailed), this.Text, MessageBoxButtons.OK, cFailed == 0 ? MessageBoxIcon.Information : MessageBoxIcon.Exclamation); }