private void MenuAdd_Click(object sender, EventArgs e) { frmPurchasGoods frmPurcha = new frmPurchasGoods(OperationType.Add); //直接写方法 frmPurcha.AddedPurcha += new EventHandler <Purchas>((o, purcha) => { this.lvPurchas.Items.Insert(0, new ListViewItem(new string[] { (this.lvPurchas.Items.Count + 1).ToString().PadLeft(3, ' '), purcha.InTime, purcha.GoodsName, purcha.GoodsCode, purcha.UnitName, purcha.TypeName, purcha.ProviderName, purcha.InCount.ToString(), purcha.InPrice.ToString(), Convert.ToString(purcha.InPrice * purcha.InCount), purcha.FixPrice.ToString(), purcha.Remarks }) { Tag = purcha.GoodsNO, Name = "0" }); this.labelTotal.Text = (Convert.ToDecimal(this.labelTotal.Text) + purcha.InPrice * purcha.InCount).ToString(); if (PurchasChanged != null) { PurchasChanged(null, null); } tabControlGoods_SelectedIndexChanged(null, null); }); frmPurcha.Purcha = new Purchas(); frmPurcha.ShowDialog(this.ParentForm); }
private void MenuModify_Click(object sender, EventArgs e) { if (this.lvPurchas.SelectedItems == null || this.lvPurchas.SelectedItems.Count < 1) { return; } frmPurchasGoods frmPurchas = new frmPurchasGoods(OperationType.Modify); Purchas purchas = new Purchas(Convert.ToInt32(this.lvPurchas.SelectedItems[0].Tag.ToString())); frmPurchas.Purcha = purchas; if (frmPurchas.ShowDialog(this) != DialogResult.OK) { return; } purchas.InTime = m_strCurrentGoodsDatetime; int iIndex = 1; this.lvPurchas.SelectedItems[0].SubItems[iIndex++].Text = purchas.InTime; this.lvPurchas.SelectedItems[0].SubItems[iIndex++].Text = purchas.GoodsName; this.lvPurchas.SelectedItems[0].SubItems[iIndex++].Text = purchas.GoodsCode; this.lvPurchas.SelectedItems[0].SubItems[iIndex++].Text = purchas.UnitName; // this.cbbUnit.SelectedItem.ToString(); this.lvPurchas.SelectedItems[0].SubItems[iIndex++].Text = purchas.TypeName; //this.cbbType.SelectedItem.ToString(); this.lvPurchas.SelectedItems[0].SubItems[iIndex++].Text = purchas.ProviderName; //this.cbbProvider.SelectedItem.ToString(); this.lvPurchas.SelectedItems[0].SubItems[iIndex++].Text = purchas.InCount.ToString(); this.lvPurchas.SelectedItems[0].SubItems[iIndex++].Text = purchas.InPrice.ToString(); this.lvPurchas.SelectedItems[0].SubItems[iIndex++].Text = Convert.ToString(purchas.InPrice * purchas.InCount); this.lvPurchas.SelectedItems[0].SubItems[iIndex++].Text = purchas.FixPrice.ToString(); this.lvPurchas.SelectedItems[0].SubItems[iIndex++].Text = purchas.Remarks; this.labelTotal.Text = (Convert.ToDecimal(this.labelTotal.Text) - Convert.ToDecimal(this.lvPurchas.SelectedItems[0].SubItems[9].Text) + purchas.InPrice * purchas.InCount).ToString(); if (PurchasChanged != null) { PurchasChanged(null, null); } tabControlGoods_SelectedIndexChanged(null, null); }