void spic_OnProductChanged(object sender, EventArgs e) { Cursor.Current = Cursors.WaitCursor; SoldProductInfoControl spicSender = sender as SoldProductInfoControl; foreach (Control c in pnlProductList.Controls) { if (!(c is SoldProductInfoControl)) { continue; } if (c.Equals(sender)) { continue; } SoldProductInfoControl spic = c as SoldProductInfoControl; if (spic.SelectedProductInfo.Id.Equals(spicSender.SelectedProductInfo.Id)) { MessageBox.Show(this, "此商品已存在于列表中, 请不要重复选择.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); spicSender.SetSelectedProduct("0"); return; } } RefreshProductText(); _productInfoChanged = true; Cursor.Current = Cursors.Default; }
private void tsbtnAddProduct_Click(object sender, EventArgs e) { SoldProductInfoControl spic = new SoldProductInfoControl(null, false); spic.OnRemove += new EventHandler(spic_OnRemove); spic.OnProductChanged += new EventHandler(spic_OnProductChanged); spic.OnCountChanged += new EventHandler(spic_OnCountChanged); pnlProductList.Controls.Add(spic); pnlProductList.Controls.SetChildIndex(spic, pnlProductList.Controls.IndexOf(tsAddProduct)); spic.Margin = new Padding(3, 2, 3, 0); RefreshProductText(); _productInfoChanged = true; LayoutControls(); }
void RefreshProductText() { txtProducts.Text = string.Empty; foreach (Control c in pnlProductList.Controls) { if (!(c is SoldProductInfoControl)) { continue; } SoldProductInfoControl spic = c as SoldProductInfoControl; if (0 == spic.Count) { continue; } if (spic.SelectedProductInfo.Id.Equals("0")) { continue; } txtProducts.Text += string.Format("{0} x {1}\r\n", spic.SelectedProductInfo.ShortName, spic.Count); } }
private int GetProductTotalCount() { int count = 0; foreach (Control c in pnlProductList.Controls) { if (!(c is SoldProductInfoControl)) { continue; } SoldProductInfoControl spic = c as SoldProductInfoControl; if (spic.Count == 0) { continue; } if (spic.SelectedProductInfo.Id.Equals("0")) { continue; } count += spic.Count; } return(count); }
private void btnGo_Click(object sender, EventArgs e) { // 出库登记. try { if (0 == GetProductTotalCount()) { MessageBox.Show(this, "没有任何产品, 无需执行出库操作!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } Application.DoEvents(); Cursor.Current = Cursors.WaitCursor; List <SoldProductInfo> soldProductInfos = new List <SoldProductInfo>(); foreach (Control c in pnlProductList.Controls) { if (!(c is SoldProductInfoControl)) { continue; } SoldProductInfoControl spic = c as SoldProductInfoControl; if (spic.Count == 0) { continue; } if (spic.SelectedProductInfo.Id.Equals("0")) { continue; } SoldProductInfo spi = new SoldProductInfo(spic.SelectedProductInfo); spi.Count = spic.Count; soldProductInfos.Add(spi); } string result = StockActionAdvForm.StockAction( true, soldProductInfos, string.Format("德国e购\\{0} [{1},{2}]", txtTaobaoId.Text, txtRecipientName.Text, txtMobile.Text), (rdoSf.Checked ? "sf" : "yto") + txtBillNumber.Text, OrderLib.ShippingOrigins.Shanghai); MessageBox.Show( this, "Result from server: \n" + result, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); if (result.StartsWith("Succeeded")) { btnClose.Enabled = true; } } catch (Exception ex) { MessageBox.Show(this, ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } finally { Cursor.Current = Cursors.Default; } }