private void ToolStripMenuItemDelItemStockInNote_Click(object sender, EventArgs e) { if (MessageBox.Show("你确认删除入库单么?\r\n删除后,相应商品的库存将被扣除。", "确认删除?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.No) { return; } int rowIdx = this.pagedDgvItem.DgvData.CurrentRow.Index; String noteId = this.pagedDgvItem.DgvData.Rows[rowIdx].Cells[0].Value.ToString(); ItemStockInNoteType note = ItemStockInNoteDAL.GetOneItemStockInNote(noteId); if (note == null) { return; } // Decrease the stock. // First check validity. String itemSKU = note.ItemSKU; InventoryItemType item = ItemDAL.GetItemBySKU(itemSKU); if (item == null) { return; } if (item.ItemStockNum < note.StockInNum) { MessageBox.Show(String.Format("商品{0}的原库存为{1},删除入库单后其库存为{2},非法操作", itemSKU, item.ItemStockNum, item.ItemStockNum - note.StockInNum), "抱歉", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } ItemDAL.DecreaseItem(itemSKU, note.StockInNum); ItemStockInNoteDAL.DeleteOneItemStockInNote(noteId); MessageBox.Show(String.Format("入库单{0}已删除", noteId), "恭喜", MessageBoxButtons.OK, MessageBoxIcon.Information); pagedDgvItem.LoadData(); }
public static bool DeleteOneItemStockInNote(String noteId) { bool result = false; ItemStockInNoteType note = ItemStockInNoteDAL.GetOneItemStockInNote(noteId); if (note == null) { return(false); } String sql = string.Format("delete from [ItemStockInNote] where NoteId={0}", noteId); DataFactory.ExecuteSql(sql); result = true; return(result); }