public FrmEditDeliveryNote(String noteId) { InitializeComponent(); mEditMode = EditMode.EditExisting; mDeliveryNote = DeliveryNoteDAL.GetOneDeliveryNote(noteId); }
public static bool DeleteOneDeliveryNote(String noteId) { bool result = false; DeliveryNoteType deliveryNote = DeliveryNoteDAL.GetOneDeliveryNote(noteId); if (deliveryNote == null) { return(false); } String sql = string.Format("delete from [DeliveryNote] where DeliveryNoteId={0}", noteId); DataFactory.ExecuteSql(sql); result = true; return(result); }
private void ToolStripMenuItemDelDeliveryNote_Click(object sender, EventArgs e) { if (MessageBox.Show("你确认刪除该进货单么?\r\n。", "确认删除?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.No) { return; } int rowIdx = this.pagedDgvDeliveryNote.DgvData.CurrentRow.Index; String deliveryNoteId = this.pagedDgvDeliveryNote.DgvData.Rows[rowIdx].Cells[0].Value.ToString(); DeliveryNoteType note = DeliveryNoteDAL.GetOneDeliveryNote(deliveryNoteId); if (note == null) { return; } // Restore the stock. String tranIdStr = note.DeliveryOrderIds; String[] tranIds = tranIdStr.Split(new char[] { ',', ' ' }); String promptString = ""; foreach (String tranId in tranIds) { EbayTransactionType trans = EbayTransactionDAL.GetOneTransactonById(tranId); if (trans == null || trans.ItemSKU == null || trans.ItemSKU == "") { MessageBox.Show(String.Format("订单号{0}异常", tranId), "抱歉", MessageBoxButtons.OK, MessageBoxIcon.Error); continue; } String itemSku = trans.ItemSKU; int saleQuantity = trans.SaleQuantity; InventoryItemType item = ItemDAL.GetItemBySKU(itemSku); if (item == null) { MessageBox.Show(String.Format("无此sku商品{0}", itemSku), "抱歉", MessageBoxButtons.OK, MessageBoxIcon.Error); continue; } ItemDAL.IncreaseItem(itemSku, saleQuantity); promptString += String.Format("\nsku:{0} 原库存 {1} => 现库存 {2}", itemSku, item.ItemStockNum, item.ItemStockNum + saleQuantity); // // Update transaction delivery status. // EbayTransactionDAL.UpdateTransactionDeliveryStatus(tranId, false, -1); } DeliveryNoteDAL.DeleteOneDeliveryNote(deliveryNoteId); pagedDgvDeliveryNote.LoadData(); // Indicate main form to update view. Deleted = true; MessageBox.Show(String.Format("删除发货单成功 {0}", promptString), "恭喜", MessageBoxButtons.OK, MessageBoxIcon.Information); }