Exemplo n.º 1
0
        private void AddButton_Click(object sender, EventArgs e)
        {
            var componentIDs = ComponentGrid.SelectedRows.Cast <DataGridViewRow>()
                               .Select(x => (int)x.Cells[ComponentGrid_ID.Name].Value.AsInt())
                               .ToList();

            using (var repository = new InventoryRepository())
            {
                repository.AddInventoryItems(inventoryID, componentIDs);
                repository.Commit();
            }

            Close();
        }
Exemplo n.º 2
0
        private void RemoveInventoryItemButton_Click(object sender, EventArgs e)
        {
            var inventoryItemOrders = InventoryItemGrid.SelectedRows.Cast <DataGridViewRow>()
                                      .Select(x => (short)x.Cells[InventoryItemGrid_Order.Name].Value.AsShort())
                                      .ToList();

            using (var repository = new InventoryRepository())
            {
                repository.RemoveInventoryItems(inventoryID, inventoryItemOrders);
                repository.Commit();
            }

            ViewInventoryDetailTab(inventoryID, true);
        }
Exemplo n.º 3
0
        private void SaveButton_Click(object sender, EventArgs e)
        {
            if (!Validation.IsAllValid(Detail.Controls))
            {
                return;
            }

            using (var repository = new InventoryRepository())
            {
                if (inventoryID > 0)
                {
                    var inventory = repository.GetInventory(inventoryID);

                    inventory.Entered = EnteredDatePicker.Value.Date;

                    repository.UpdateInventory(inventory);
                    repository.Commit();

                    inventoryID = inventory.ID;
                }
                else
                {
                    var inventory = new Inventory
                    {
                        ID      = (int)IDTextBox.Text.AsInt(),
                        Entered = EnteredDatePicker.Value.Date
                    };

                    repository.InsertInventory(inventory);
                    repository.Commit();

                    inventoryID = inventory.ID;
                }
            }

            ViewInventoryDetailTab(inventoryID, false);
        }
Exemplo n.º 4
0
        private void SaveInventoryItemButton_Click(object sender, EventArgs e)
        {
            foreach (DataGridViewRow row in InventoryItemGrid.Rows)
            {
                short order = (short)row.Cells[InventoryItemGrid_Order.Name].Value.AsShort();

                using (var repository = new InventoryRepository())
                {
                    var inventoryItem = repository.GetInventoryItem(inventoryID, order);

                    inventoryItem.ActualQuantity = (int)row.Cells[InventoryItemGrid_ActualQuantity.Name].Value.AsInt();

                    repository.UpdateInventoryItem(inventoryItem);
                    repository.Commit();
                }
            }

            ViewInventoryDetailTab(inventoryID, true);
        }
Exemplo n.º 5
0
        private void ApproveButton_Click(object sender, EventArgs e)
        {
            DialogResult result;

            if (IsInventoryItemChanged)
            {
                result = MessageBox.Show(Resources.InventoryApproveUnsavedItemsText.FormatWith(inventoryID), Resources.InventoryApproveConfirmationCaption, MessageBoxButtons.YesNoCancel);

                switch (result)
                {
                case DialogResult.Yes:
                    SaveInventoryItemButton_Click(sender, e);
                    break;

                case DialogResult.Cancel:
                    return;
                }
            }
            else
            {
                result = MessageBox.Show(Resources.InventoryApproveConfirmationText.FormatWith(inventoryID), Resources.InventoryApproveConfirmationCaption, MessageBoxButtons.YesNo);

                if (result == DialogResult.No)
                {
                    return;
                }
            }

            using (var repository = new InventoryRepository())
            {
                repository.ApproveInventory(inventoryID);
                repository.CalculateComponentStockQuantity(inventoryID);
                repository.Commit();
            }

            ViewInventoryDetailTab(inventoryID, true);
        }