Example #1
0
        /*Precondition: Needs an order to be loaded
         Postcondition: Creates a .docx file containing the invoice and opens it */
        private void btnCreateInvoice_Click(object sender, EventArgs e)
        {
            bool haveStorageLocation = checkForStorageLocation();
            bool foldersExists = fileManager.haveStorageFolders();

            if (haveStorageLocation)
            {
                if (foldersExists)
                {
                    if (currOrder != null)
                    {
                        InvoiceCreator wdm = new InvoiceCreator(this, currCustomer, currOrder, currOrderedStock);

                        string documentName = currOrder.orderID.ToString() + ".docx";

                        string filePath = fileManager.getStorageFilePath() + @"\Invoices\" + documentName;
                        bool successfulFileCreation = wdm.createInvoice(filePath);

                        if (successfulFileCreation)
                            System.Diagnostics.Process.Start(filePath);
                    }
                }
                else
                    MessageBox.Show("Storage folders don't exist.\nTry going to the setup menu and clicking the set storage location button");
            }
        }
Example #2
0
        /*Precondition:
         Postcondition: Creates an invoice for the current order and opens it */
        private void btnInvoice_Click(object sender, EventArgs e)
        {
            bool haveStorageLocation = checkForStorageLocation();

            //Check if storage location is setup
            if (haveStorageLocation)
            {
                //Check that there is a customer selected because one is required for the invoice
                if (currentCustomer != null)
                {
                    //Get details about the current order
                    Order currOrder = createOrder();

                    //Get all of the stock being ordered
                    List<OrderedStock> newOrderedStock = createOrderedStock(currOrder);

                    currOrder.orderID = dbManager.getNextOrderID();

                    //Create the .docx file containing the invoice
                    InvoiceCreator wdm = new InvoiceCreator(null, currentCustomer, currOrder, newOrderedStock);

                    string documentName = currOrder.orderID.ToString() + ".docx";

                    string filePath = fileManager.getStorageFilePath() + @"\Invoices\" + documentName;
                    bool successfulFileCreation = wdm.createInvoice(filePath);

                    //Open the invoice automatically
                    if (successfulFileCreation)
                        System.Diagnostics.Process.Start(filePath);
                }
                else
                {
                    MessageBox.Show("No Customer selected");
                }

            }
        }