예제 #1
0
        public void AskDeleteStockMessage(StockRowViewModel selectedStock)
        {
            string msg    = string.Format("You are sure to delete this stock?");
            var    result = MessageBox.Show(this, msg, "Delete stock", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);

            if (result == DialogResult.Yes)
            {
                _presenter.DeleteStock(selectedStock);
            }
        }
예제 #2
0
        public static StockRowViewModel ToStockRowViewModel(this Item it)
        {
            var vm = new StockRowViewModel();

            vm.Identifier    = it.Identifier;
            vm.Name          = it.Name;
            vm.Description   = it.Description;
            vm.Manufacturer  = it.Manufacturer;
            vm.StockLevel    = it.StockLevel;
            vm.ReOrderLevel  = it.ReOrderLevel;
            vm.MajorSupplier = it.MajorSupplier;
            vm.PurchasePrice = it.PurchasePrice;
            vm.SellingPrice  = it.SellingPrice;

            return(vm);
        }
예제 #3
0
        internal void DeleteStock(StockRowViewModel selectedStock)
        {
            try
            {
                using (var ctx = new InventoryModel())
                {
                    var stockToDelete = ctx.Items
                                        .Single(x => x.Identifier == selectedStock.Identifier);

                    ctx.Items.Remove(stockToDelete);

                    ctx.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                View.ShowError(ex);
            }
        }
예제 #4
0
        public void ShowUpdateStockForm(StockRowViewModel selectedStock)
        {
            var form = new UpdateStockForm(selectedStock.Identifier);

            form.Show(this);
        }