private void MenuDelete_Click(object sender, EventArgs e) { if (this.lvPurchas.SelectedItems == null || this.lvPurchas.SelectedItems.Count < 1) { MessageBox.Show(this.ParentForm, "请选择要删除的进货!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } DialogResult dr = MessageBox.Show(this.ParentForm, "所选择的进货将被删除,请确认!", "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (dr != DialogResult.OK) { return; } Purchas purchas = new Purchas { GoodsNO = Convert.ToInt32(this.lvPurchas.SelectedItems[0].Tag.ToString()) }; if (purchas.Delete()) { this.labelTotal.Text = (Convert.ToDecimal(this.labelTotal.Text) - Convert.ToDecimal(this.lvPurchas.SelectedItems[0].SubItems[8].Text)).ToString(); this.lvPurchas.Items.Remove(this.lvPurchas.SelectedItems[0]); if (PurchasChanged != null) { PurchasChanged(null, null); } tabControlGoods_SelectedIndexChanged(null, null); } }
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); }
private void btnOK_Click(object sender, EventArgs e) { if (!CheckData()) { return; } this.Purcha.GoodsName = this.txtGoodsname.Text; this.Purcha.GoodsCode = this.txtGoodscode.Text; this.Purcha.UnitNO = Convert.ToInt32((this.cbbUnit.SelectedItem as ComboBoxItem).Value); this.Purcha.TypeNO = Convert.ToInt32((this.cbbType.SelectedItem as ComboBoxItem).Value); this.Purcha.ProviderNO = Convert.ToInt32((this.cbbProvider.SelectedItem as ComboBoxItem).Value); this.Purcha.UnitName = Common.Foundation.GetDictName(DictType.GoodsUnit, this.Purcha.UnitNO.ToString()); this.Purcha.TypeName = Common.Foundation.GetDictName(DictType.GoodsType, this.Purcha.TypeNO.ToString()); this.Purcha.ProviderName = Common.Foundation.GetDictName(DictType.Providers, this.Purcha.ProviderNO.ToString()); this.Purcha.FixPrice = this.numFixPrice.Value; this.Purcha.InCount = Convert.ToInt32(this.numCount.Value); this.Purcha.InPrice = this.numPrice.Value; this.Purcha.Remarks = this.txtRemarks.Text; this.Purcha.InTime = this.dtpInTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); if (m_OperationType == OperationType.Add) { if (!this.Purcha.Save()) { MessageBox.Show(this.ParentForm, "进货添加失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (AddedPurcha != null) { AddedPurcha(this, this.Purcha); } if (this.cbAdds.Checked) { this.Purcha = new Purchas(); this.txtGoodsname.Text = string.Empty; this.txtGoodscode.Text = string.Empty; this.cbbUnit.SelectedIndex = -1; this.cbbProvider.SelectedIndex = -1; this.cbbType.SelectedIndex = -1; this.numCount.Value = 1; this.numPrice.Value = 1; this.numFixPrice.Value = 1; this.txtRemarks.Text = string.Empty; } else { this.Close(); } } else if (m_OperationType == OperationType.Modify) { if (this.Purcha.Update()) { this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); } else { MessageBox.Show(this.ParentForm, "进货修改失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }