Exemplo n.º 1
0
        /// <summary>
        /// Retrieves all the shipments from the DB and populates the FBAShipments list.
        /// </summary>
        void PopulateShipments()
        {
            using (var db = new Models.AppContext())
            {
                //grab all shipments from DB
                List <Shipment> shipments = db.Shipments.ToList();

                //sort by shipment date
                shipments.Sort((s1, s2) => DateTime.Compare(s2.ShipmentDate, s1.ShipmentDate));

                //iterate through all shipments and add to list
                foreach (Shipment ship in shipments)
                {
                    FBAShipment fba = new FBAShipment();
                    fba.ShipmentID         = ship.ShipmentId;
                    fba.FullfillmentShipTo = new AmzWarehouseModel(ship.ShipToCenter);
                    fba.CompanyShipFrom    = new CompanyAddressModel(ship.ShipFromCenter);
                    fba.Boxes        = new List <FBABox>();
                    fba.ShipmentDate = ship.ShipmentDate;

                    //fill in the boxes.
                    foreach (ShipmentBox bx in ship.Boxes)
                    {
                        fba.Boxes.Add(new FBABox()
                        {
                            BoxID = bx.BoxId, ContentString = bx.BoxContentString, BoxNumber = bx.BoxNumber
                        });
                    }

                    FBAShipments.Add(fba);
                }
            }
        }
 /// <summary>
 /// Default constructor.
 /// </summary>
 public ProcessShipmentViewModel()
 {
     AmzWarehouses = new List <AmzWarehouseModel>();
     Shipment      = new FBAShipment();
     LabelsFactory = new LabelFactory();
     PopulateAmazonWarehouse();
     PopulateSettingDefaults();
 }
Exemplo n.º 3
0
        /// <summary>
        /// Reprints the selected boxes to the default label printer in the settings.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void printBoxBtn_Click(object sender, RoutedEventArgs e)
        {
            //Get selected boxes from listBox to print
            List <FBABox> printBoxes = GetSelectedBoxes();

            //get selected shipments for details
            FBAShipment shipment = GetShipment();

            //send the objects to viewmodel for reprinting.
            historyViewModel.ReprintLabels(printBoxes, shipment.FullfillmentShipTo, shipment.CompanyShipFrom, shipment.Boxes.Count);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Grabs the selected shipment from the List Box.
        /// </summary>
        /// <returns>FBAShipment model.</returns>
        private FBAShipment GetShipment()
        {
            FBAShipment shipment = new FBAShipment();

            //get the amz warehouse for the shipment
            if (shipmentListBox.SelectedItem is FBAShipment)
            {
                shipment = (FBAShipment)shipmentListBox.SelectedItem;
            }

            return(shipment);
        }
        /// <summary>
        /// Overloaded constructor that takes in a file (expected to be an Excel Workbook, '.xlsx' extension) to process
        /// and get create a shipment based on that file. Each Worksheet in the file is expected to
        /// represent one box in the shipment.
        /// </summary>
        /// <param name="file"></param>
        public ProcessShipmentViewModel(string file)
        {
            //initialize properties
            AmzWarehouses = new List <AmzWarehouseModel>();
            PopulateAmazonWarehouse();

            Shipment      = new FBAShipment();
            LabelsFactory = new LabelFactory();

            PopulateSettingDefaults();
            //process the excel file to add box contents to Shipment.Boxes model.
            ReadExcelBook(file);
        }
Exemplo n.º 6
0
        private void printPDFBtn_Click(object sender, RoutedEventArgs e)
        {
            //get selected boxes from listbox
            List <FBABox> selectedBoxes = GetSelectedBoxes();

            //get the selected shipment
            FBAShipment shipment = GetShipment();

            //send objects to ViewModel to print to PDF
            try
            {
                historyViewModel.ReprintToPDF(selectedBoxes, shipment.FullfillmentShipTo, shipment.CompanyShipFrom, shipment.Boxes.Count, shipment.ShipmentID);
                MessageBox.Show("Labels successfully printed to PDF. Reprinted labels were saved to: \n" + Properties.Settings.Default.SaveFileDir, "Successfully Printed to PDF");
            }
            catch (Exception ex)
            {
                MessageBox.Show("There was an error trying to print to PDF.\n" + ex.Message, "Unsuccessful Print to PDF");
            }
        }