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; } } 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); pnlProductList.Controls.Add(spic); pnlProductList.Controls.SetChildIndex(spic, pnlProductList.Controls.IndexOf(tsAddProduct)); spic.Margin = new Padding(3, 2, 3, 0); spic.Width = pnlProductList.Width - tsAddProduct.Margin.Right - spic.Margin.Left - 7; }
private void tsbtnAddProduct_Click(object sender, EventArgs e) { SoldProductInfoControl spic = new SoldProductInfoControl(null, true); 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 bool _stockout; // 是否出库. 否则入库. public StockActionAdvForm(bool stockout, List <SoldProductInfo> defaultSelectedProductInfos) { _stockout = stockout; InitializeComponent(); if (null != defaultSelectedProductInfos) { foreach (SoldProductInfo spi in defaultSelectedProductInfos) { SoldProductInfoControl spic = new SoldProductInfoControl(spi, false); spic.OnRemove += new EventHandler(spic_OnRemove); spic.OnProductChanged += new EventHandler(spic_OnProductChanged); pnlProductList.Controls.Add(spic); pnlProductList.Controls.SetChildIndex(spic, pnlProductList.Controls.IndexOf(tsAddProduct)); spic.Margin = new Padding(3, 2, 3, 0); spic.Width = pnlProductList.Width - tsAddProduct.Margin.Right - spic.Margin.Left - 7; } } this.Text = (stockout ? "出库" : "入库"); pnlProductList.BackColor = (stockout ? Color.FromArgb(255, 255, 192, 192) : Color.LightGreen); lblProducts.Text = (stockout ? "出库商品" : "入库商品"); lblFromTo.Text = (stockout ? "出库目标" : "入库来源"); }
private void btnAdd_Click(object sender, EventArgs e) { Cursor.Current = Cursors.WaitCursor; try { if (string.IsNullOrEmpty(txtRecipientName.Text.Trim())) { MessageBox.Show(this, "收件人姓名不能为空.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (string.IsNullOrEmpty(txtMobile.Text.Trim())) { MessageBox.Show(this, "收件人电话能为空.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (string.IsNullOrEmpty(txtIdInfo.Text.Trim())) { MessageBox.Show(this, "身份证信息不能为空.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } Regex r = new Regex(@"\d{17}[\d|x|X]"); if (!r.Match(txtIdInfo.Text).Success) { MessageBox.Show(this, "身份证信息格式不正确.\n身份证信息格式为: 张三,000000000000000000", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (!txtIdInfo.Text.Contains(",") && !txtIdInfo.Text.Contains(",")) { MessageBox.Show(this, "身份证信息格式不正确.\n身份证信息格式为: 张三,000000000000000000", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (txtIdInfo.Text.Length < 21) // 18位数字+逗号+至少2个字名字=21 { MessageBox.Show(this, "身份证信息格式不正确.\n身份证信息格式为: 张三,000000000000000000", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (string.IsNullOrEmpty(txtProvince.Text.Trim())) { MessageBox.Show(this, "省份信息不能为空.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (string.IsNullOrEmpty(txtCity1.Text.Trim())) { MessageBox.Show(this, "城市信息不能为空.\n直辖市填入省份名即可.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (string.IsNullOrEmpty(txtCity2.Text.Trim()) && string.IsNullOrEmpty(txtDistrict.Text.Trim())) { MessageBox.Show(this, "区县信息不能为空.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (string.IsNullOrEmpty(txtStreetAddress.Text.Trim())) { MessageBox.Show(this, "详细地址不能为空.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (pnlProductList.Controls.Count <= 1) { MessageBox.Show(this, "产品信息不能为空.\n至少需要选择1个产品.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } List <SoldProductInfo> products = new List <SoldProductInfo>(); foreach (Control c in pnlProductList.Controls) { if (!(c is SoldProductInfoControl)) { continue; } SoldProductInfoControl spic = c as SoldProductInfoControl; SoldProductInfo spi = new SoldProductInfo(spic.SelectedProductInfo); spi.Count = spic.Count; products.Add(spi); } NingboOrder ningboOrder = new NingboOrder( cboLogistics.SelectedItem.ToString(), string.Empty, _orders[0].OrderId, txtRecipientName.Text, txtMobile.Text, txtProvince.Text, txtCity1.Text, string.IsNullOrEmpty(txtDistrict.Text)?txtCity2.Text:txtDistrict.Text, txtStreetAddress.Text, products, txtIdInfo.Text, _orders[0].AlipayNumber); if (_orders.Count > 1) { string linkedOrderIds = string.Empty; for (int i = 1; i < _orders.Count; i++) { linkedOrderIds += _orders[i].OrderId; if (i < _orders.Count - 1) { linkedOrderIds += ","; } } ningboOrder.LinkedTaobaoOrderIds = linkedOrderIds; } NingboOrder.Orders.Add(ningboOrder); //this.DialogResult = DialogResult.OK; //this.Close(); // motion effect. ResourceManager rm = new ResourceManager("Egode.Properties.Resources", System.Reflection.Assembly.GetExecutingAssembly()); Image imgNb = (Image)rm.GetObject("nb1"); Point p = MainForm.Instance.NbStatusLocation; p.Offset(2, 8); FlyingForm flying = new FlyingForm(imgNb, p); flying.FlyingCompleted += new EventHandler(flying_FlyingCompleted); flying.Show(); } finally { Cursor.Current = Cursors.Default; } }
//public NingboOrder NingboOrder //{ // get { return _ningboOrder; } //} private void ConsignShForm_Load(object sender, EventArgs e) { if (_orders.Count > 1) { this.Text += string.Format(" [{0}个订单合并发货]", _orders.Count); } StringBuilder sbRemark = new StringBuilder(); foreach (Order o in _orders) { if (string.IsNullOrEmpty(o.Remark)) { continue; } if (_orders.Count > 1) { sbRemark.Append(string.Format("#{0}: ", _orders.IndexOf(o) + 1)); } sbRemark.Append(o.Remark); if (_orders.IndexOf(o) < _orders.Count - 1) { sbRemark.Append("\r\n"); } } StringBuilder sbBuyerRemark = new StringBuilder(); foreach (Order o in _orders) { if (string.IsNullOrEmpty(o.BuyerRemark)) { continue; } if (_orders.Count > 1) { sbBuyerRemark.Append(string.Format("#{0}: ", _orders.IndexOf(o) + 1)); } sbBuyerRemark.Append(o.BuyerRemark); if (_orders.IndexOf(o) < _orders.Count - 1) { sbBuyerRemark.Append("\r\n"); } } txtRemark.Text = sbRemark.ToString().Trim(); txtBuyerRemark.Text = sbBuyerRemark.ToString().Trim(); SizeF size = Graphics.FromHwnd(this.Handle).MeasureString(txtRemark.Text, this.Font, txtRemark.Width - 6); txtRemark.Height = size.ToSize().Height + 6; // address info. if (string.IsNullOrEmpty(_orders[0].EditedRecipientAddress)) { AddressParser ap = new AddressParser(_orders[0].RecipientAddress); txtRecipientName.Text = _orders[0].RecipientName.Trim(); txtProvince.Text = ap.Province.Trim(); txtCity1.Text = ap.City1.Trim(); txtCity2.Text = ap.City2.Trim(); txtDistrict.Text = ap.District.Trim(); txtStreetAddress.Text = ap.StreetAddress.Trim(); txtMobile.Text = _orders[0].MobileNumber.Trim(); } else { txtRecipientName.BackColor = Color.FromArgb(255, 200, 200); txtProvince.BackColor = Color.FromArgb(255, 200, 200); txtCity1.BackColor = Color.FromArgb(255, 200, 200); txtCity2.BackColor = Color.FromArgb(255, 200, 200); txtDistrict.BackColor = Color.FromArgb(255, 200, 200); txtStreetAddress.BackColor = Color.FromArgb(255, 200, 200); txtMobile.BackColor = Color.FromArgb(255, 200, 200); ParseEditedAddress(); //MessageBox.Show(this, "需要手动输入地址!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } if (string.IsNullOrEmpty(txtCity1.Text)) { if (txtProvince.Text.StartsWith("北京") || txtProvince.Text.StartsWith("上海") || txtProvince.Text.StartsWith("天津") || txtProvince.Text.StartsWith("重庆")) { txtCity1.Text = txtProvince.Text; } } // Product info. if (!_isRefundingOrder) { int cMustSendFromDe = 0, cBonded = 0; _soldProductInfos = GetProducts(_orders, out cMustSendFromDe, out cBonded); foreach (SoldProductInfo spi in _soldProductInfos) { txtProducts.Text += string.Format("{0} x {1}{2}\r\n", spi.ShortName, spi.Count, string.IsNullOrEmpty(spi.Comment) ? string.Empty : (" " + spi.Comment)); } if (txtProducts.Text.Length > 2 && txtProducts.Text.EndsWith("\r\n")) { txtProducts.Text = txtProducts.Text.Remove(txtProducts.Text.Length - 2, 2); // remove return at the end of string. } foreach (SoldProductInfo spi in _soldProductInfos) { SoldProductInfoControl spic = new SoldProductInfoControl(spi, true); 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); } } pnlProductList.Height = Math.Max(115, tsAddProduct.Bottom); txtProducts.Height = pnlProductList.Height; txtProducts.TextChanged += new EventHandler(txtProducts_TextChanged); // float money = 0; foreach (Order o in _orders) { money += o.TotalMoney; } lblMoney.Text = money.ToString("0.00"); cboLogistics.Items.Add("邮政国内小包"); cboLogistics.Items.Add("EMS"); cboLogistics.Items.Add("中通"); cboLogistics.SelectedIndex = 0; LayoutControls(); }