示例#1
0
        /// <summary>
        /// Ryan Spurgetis
        /// 4/29/2017
        ///
        /// Loads the form window based on values from pickup selected
        /// </summary>
        /// <param name="_pickupLine"></param>
        private void SetValuesFromPickupLine(PickupLine _pickupLine)
        {
            _supplierManager = new SupplierManager();
            ProductManager _productManager = new ProductManager();

            btnCreateFromPickup.Visibility = Visibility.Visible;

            try
            {
                Pickup _pickup      = _pickupManager.RetrievePickupById(_pickupLine.PickupId);
                var    supplierName = _supplierManager.RetrieveSupplierBySupplierID((int)_pickup.SupplierId);
                var    productName  = _productManager.RetrieveProductById((int)_pickupLine.ProductId).Name;
                lblSupplierVal.Content          = supplierName;
                cboSupplierIDVal.SelectedIndex  = (int)_pickup.SupplierId;
                cboSupplierIDVal.Visibility     = Visibility.Collapsed;
                lblWarehouseIDVal.Content       = (int)_pickup.WarehouseId;
                cboWarehouseIDVal.SelectedIndex = (int)_pickup.WarehouseId;
                cboWarehouseIDVal.Visibility    = Visibility.Collapsed;
                lblProductVal.Content           = productName;
                cboProductIDVal.SelectedItem    = (int)_pickupLine.ProductId;
                cboProductIDVal.Visibility      = Visibility.Collapsed;
                txtQuantity.Text                 = _pickupLine.Quantity.ToString();
                _locationList                    = (new LocationManager()).ListLocations();
                cboLocationIDVal.ItemsSource     = _locationList;
                cboLocationIDVal.Visibility      = Visibility.Visible;
                lblSupplyManagerID.Visibility    = Visibility.Hidden;
                cboSupplyManagerIDVal.Visibility = Visibility.Hidden;
                dpDateReceived.SelectedDate      = DateTime.Now;
            }
            catch (Exception ex)
            {
                MessageBox.Show("An error occured" + ex.Message + ex.StackTrace);
            }
        }
        /// <summary>
        /// Alissa Duffy
        /// Updated: 2017/04/21
        ///
        /// Loads the Supplier Invoice Details Window.
        /// Standardized method.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            lblInvoiceId.Content        = "Invoice " + _supplierInvoice.SupplierInvoiceId;
            lblTotalAmount.Content      = _supplierInvoice.Total.ToString("c");
            lblAmountPaidAmount.Content = _supplierInvoice.AmountPaid.ToString("c");
            Supplier supplierAssociated = null;

            try
            {
                supplierAssociated = _supplierManager.RetrieveSupplierBySupplierID(_supplierInvoice.SupplierId);
                if (null != supplierAssociated)
                {
                    lblSupplierName.Content = _supplierManager.RetrieveSupplierName(supplierAssociated.UserId);
                    lblFarmName.Content     = supplierAssociated.FarmName;
                }
            }
            catch (Exception ex)
            {
                if (null != ex.InnerException)
                {
                    MessageBox.Show(ex.Message + "\n\n" + ex.InnerException.Message);
                }
                else
                {
                    MessageBox.Show(ex.Message);
                }
            }

            try
            {
                _invoiceLines = _supplierInvoiceManager.RetrieveSupplierInvoiceLinesByInvoiceId(_supplierInvoice.SupplierInvoiceId);
            }
            catch (Exception ex)
            {
                if (null != ex.InnerException)
                {
                    MessageBox.Show(ex.Message + "\n\n" + ex.InnerException.Message);
                }
                else
                {
                    MessageBox.Show(ex.Message);
                }
            }

            dgSupplierInvoiceLines.ItemsSource = _invoiceLines;
        }
        /// <summary>
        ///Created by Michael Takrama
        ///2017/03/02
        /// Parses the lots into a View Model for Datagrid
        /// </summary>
        private void ParseLotsIntoViewModel()
        {
            _productManager  = new ProductManager();
            _supplierManager = new SupplierManager();
            _locationManager = new LocationManager();

            try
            {
                _manageStockViewModels.Clear();
                foreach (var a in _productLotList)
                {
                    var manageStockViewModel = new ManageStockViewModel
                    {
                        ProductId         = a.ProductId,
                        ProductName       = _productManager.RetrieveProductById((int)a.ProductId).Name,
                        SupplierId        = a.SupplierId,
                        SupplierName      = _supplierManager.RetrieveSupplierBySupplierID((int)a.SupplierId).FarmName,
                        LocationDesc      = _locationManager.RetrieveLocationByID((int)a.LocationId).Description,
                        Quantity          = a.Quantity,
                        AvailableQuantity = a.AvailableQuantity,
                        ProductLotId      = a.ProductLotId
                    };

                    if (manageStockViewModel.AvailableQuantity != 0 || _checkBoxOverride)
                    {
                        _manageStockViewModels.Add(manageStockViewModel);
                    }
                }
            }
            catch (Exception ex)
            {
                if (null != ex.InnerException)
                {
                    MessageBox.Show(ex.Message + "\n\n" + ex.InnerException.Message);
                }
                else
                {
                    MessageBox.Show("Catastrophic Error: " + ex.Message);
                }
            }
        }
        /// <summary>
        /// Christian Lopez
        /// Created: 2017/02/22
        /// </summary>
        ///
        /// <remarks>
        /// Aaron Usher
        /// Updated: 2017/04/07
        ///
        /// Changed string array of grades to list of string of grades.
        /// </remarks>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Window_Initialized(object sender, EventArgs e)
        {
            try
            {
                var grades = _gradeManager.RetrieveGradeList();
                cboGradeSelect.ItemsSource = grades;
            }
            catch (Exception ex)
            {
                if (null != ex.InnerException)
                {
                    MessageBox.Show(ex.Message + "\n\n" + ex.InnerException.Message);
                }
                else
                {
                    MessageBox.Show(ex.Message);
                }
            }

            try
            {
                txtProduct.Text = _productManager.RetrieveProductById((int)_productLot.ProductId).Name;
                Supplier s = _supplierManager.RetrieveSupplierBySupplierID((int)_productLot.SupplierId);
                txtSupplier.Text = _supplierManager.RetrieveSupplierName(s.UserId);
                txtFarm.Text     = s.FarmName;
            }
            catch (Exception ex)
            {
                if (null != ex.InnerException)
                {
                    MessageBox.Show(ex.Message + "\n\n" + ex.InnerException.Message);
                }
                else
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }