Example #1
0
        /// <summary>
        /// Ryan Spurgetis
        /// 4/28/2017
        ///
        /// Sends the create product lot info from pickup
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnCreateFromPickup_Click(object sender, RoutedEventArgs e)
        {
            int lotQuantity = 0;

            Pickup pickup        = _pickupManager.RetrievePickupById(_pickupLine.PickupId);
            var    productId     = (int)_pickupLine.ProductId;
            var    lotSupplierId = (int)pickup.SupplierId;
            var    warehouseId   = (int)lblWarehouseIDVal.Content;

            if (null == txtQuantity.Text)
            {
                MessageBox.Show("Add a quantity for the product lot.");
            }
            else
            {
                bool canConvertQ = int.TryParse(txtQuantity.Text, out lotQuantity);
                if (canConvertQ == false)
                {
                    MessageBox.Show("Quantity needs a whole number value");
                }
            }
            if (null == cboLocationIDVal.SelectedItem)
            {
                MessageBox.Show("Select a location for lot.");
                return;
            }
            //if (null == cboSupplyManagerIDVal.SelectedItem)
            //{
            //    MessageBox.Show("Select a supply manager for lot.");
            //    return;
            //}
            if (null == dpDateReceived.SelectedDate)
            {
                MessageBox.Show("Add a date for Date Received");
                return;
            }
            if (null == dpExpirationDate.SelectedDate)
            {
                MessageBox.Show("Add a date for the Expiration Date");
                return;
            }
            ProductLot newLot = new ProductLot()
            {
                WarehouseId     = warehouseId,
                SupplierId      = lotSupplierId,
                LocationId      = _locationList[cboLocationIDVal.SelectedIndex].LocationId,
                ProductId       = productId,
                SupplyManagerId = _employee.EmployeeId,
                //SupplyManagerId = (int)_employeeList[cboSupplyManagerIDVal.SelectedIndex].EmployeeId,
                Quantity          = lotQuantity,
                AvailableQuantity = lotQuantity,
                DateReceived      = dpDateReceived.SelectedDate,
                ExpirationDate    = dpExpirationDate.SelectedDate
            };

            try
            {
                _productLotManager.CreateProductLot(newLot);
                MessageBox.Show("Product lot added. Be sure to create an inspection for lot.");
                _pickupManager.DeletePickupLine(_pickupLine);
                Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("An error occured. " + ex.Message + ex.StackTrace);
            }
        }