Example #1
0
        private void UpdateDocument(CompanyLayoutType documentType)
        {
            bool showUpdateInv = api.CompanyEntity.Storage;
            var  generateDoc   = new CWGenerateInvoice(false, documentType.ToString(), false, true, true, false, isQuickPrintVisible: false, isShowUpdateInv: showUpdateInv);

#if !SILVERLIGHT
            generateDoc.DialogTableId = 2000000000;
            generateDoc.HideOutlookOption(true);
#endif
            generateDoc.Closed += async delegate
            {
                if (generateDoc.DialogResult == true)
                {
                    busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("SendingWait");
                    busyIndicator.IsBusy      = true;

                    var crVisibleOrders = dgMultiInvGrid.GetVisibleRows() as IEnumerable <CreditorOrderClient>;

                    var invoicePostingPrintGenerator = new InvoicePostingPrintGenerator(api, this);
                    invoicePostingPrintGenerator.SetUpInvoicePosting(crVisibleOrders, generateDoc.GenrateDate, !generateDoc.UpdateInventory, documentType, false, false, false,
                                                                     generateDoc.SendByEmail, generateDoc.sendOnlyToThisEmail, generateDoc.Emails, false);

                    await invoicePostingPrintGenerator.Execute();

                    busyIndicator.IsBusy = false;
                }
            };
            generateDoc.Show();
        }
Example #2
0
        private void GenerateInvoice()
        {
            UnicontaClient.Pages.CWGenerateInvoice GenrateInvoiceDialog = new UnicontaClient.Pages.CWGenerateInvoice(true, string.Empty, false, true, true, isOrderOrQuickInv: true, isQuickPrintVisible: true, isPageCountVisible: false, isDebtorOrder: true);
            GenrateInvoiceDialog.DialogTableId = 2000000011;
            GenrateInvoiceDialog.HideOutlookOption(true);
            GenrateInvoiceDialog.SetInvPrintPreview(printPreview);
            GenrateInvoiceDialog.SetOIOUBLLabelText(api.CompanyEntity._OIOUBLSendOnServer);
            GenrateInvoiceDialog.Closed += async delegate
            {
                if (GenrateInvoiceDialog.DialogResult == true)
                {
                    printPreview = GenrateInvoiceDialog.ShowInvoice;
                    busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("SendingWait");
                    busyIndicator.IsBusy      = true;
                    var InvoiceDate     = GenrateInvoiceDialog.GenrateDate;
                    var dbVisibleOrders = dgMultiInvGrid.GetVisibleRows() as IEnumerable <ProjectInvoiceProposalClient>;

                    var invoicePostingPrintGenerator = new InvoicePostingPrintGenerator(api, this);
                    invoicePostingPrintGenerator.SetUpInvoicePosting(dbVisibleOrders, InvoiceDate, GenrateInvoiceDialog.IsSimulation, CompanyLayoutType.Invoice, GenrateInvoiceDialog.ShowInvoice, GenrateInvoiceDialog.PostOnlyDelivered, GenrateInvoiceDialog.InvoiceQuickPrint,
                                                                     GenrateInvoiceDialog.SendByEmail, GenrateInvoiceDialog.sendOnlyToThisEmail, GenrateInvoiceDialog.Emails, GenrateInvoiceDialog.GenerateOIOUBLClicked);

                    await invoicePostingPrintGenerator.Execute();

                    busyIndicator.IsBusy = false;
                }
            };
            GenrateInvoiceDialog.Show();
        }
Example #3
0
        private void GenerateInvoice()
        {
            UnicontaClient.Pages.CWGenerateInvoice GenrateInvoiceDialog = new UnicontaClient.Pages.CWGenerateInvoice(true, string.Empty, false, true, true, false, isQuickPrintVisible: false);
#if !SILVERLIGHT
            GenrateInvoiceDialog.DialogTableId = 2000000000;
            GenrateInvoiceDialog.HideOutlookOption(true);
#endif
            GenrateInvoiceDialog.Closed += async delegate
            {
                if (GenrateInvoiceDialog.DialogResult == true)
                {
                    busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("SendingWait");
                    busyIndicator.IsBusy      = true;

                    var crVisibleOrders = dgMultiInvGrid.GetVisibleRows() as IEnumerable <CreditorOrderClient>;

                    var postingprintGenerator = new InvoicePostingPrintGenerator(api, this);
                    postingprintGenerator.SetUpInvoicePosting(crVisibleOrders, GenrateInvoiceDialog.GenrateDate, GenrateInvoiceDialog.IsSimulation, CompanyLayoutType.PurchaseInvoice, false, false, false,
                                                              GenrateInvoiceDialog.SendByEmail, GenrateInvoiceDialog.sendOnlyToThisEmail, GenrateInvoiceDialog.Emails, false);

                    await postingprintGenerator.Execute();

                    busyIndicator.IsBusy = false;
                }
            };
            GenrateInvoiceDialog.Show();
        }
        async private void OpenOutlook()
        {
            try
            {
                busyIndicator.IsBusy      = true;
                busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("LaunchingWaitMsg");
                var debtorStatementList = ((IEnumerable <DebtorStatementList>)dgDebtorTrans.ItemsSource).Where(m => m.Mark).FirstOrDefault();
                if (debtorStatementList != null)
                {
                    var hasCurrency         = debtorStatementList.ChildRecords.Where(p => p._AmountCur != 0.0d).Any();
                    var debtStatementReport = await GeneratePrintReport(new List <DebtorStatementList>(1) { debtorStatementList }, true, hasCurrency, false);

                    if (debtStatementReport != null && debtStatementReport.Count() == 1)
                    {
                        InvoicePostingPrintGenerator.OpenReportInOutlook(api, debtStatementReport.Single(), debtorStatementList.deb,
                                                                         CompanyLayoutType.AccountStatement, DefaultFromDate, DefaultToDate, hasCurrency);
                    }
                }
            }
            catch (Exception ex)
            {
                UnicontaMessageBox.Show(ex.Message, Uniconta.ClientTools.Localization.lookup("Exception"));
            }
            finally { busyIndicator.IsBusy = false; }
        }
Example #5
0
        private InvoicePostingPrintGenerator SetupInvoicePostingPrintGenerator(ProjectInvoiceProposalClient dbOrder, DateTime generateDate, bool isSimulation, bool showInvoice, bool postOnlyDelivered,
                                                                               bool isQuickPrint, int pagePrintCount, bool invoiceSendByEmail, bool invoiceSendByOutlook, bool sendOnlyToEmail, string sendOnlyToEmailList, bool OIOUBLgenerate)
        {
            var invoicePostingResult = new InvoicePostingPrintGenerator(api, this);

            invoicePostingResult.SetUpInvoicePosting(dbOrder, null, CompanyLayoutType.Invoice, generateDate, null, isSimulation, showInvoice, postOnlyDelivered, isQuickPrint, pagePrintCount,
                                                     invoiceSendByEmail, !isSimulation && invoiceSendByOutlook, sendOnlyToEmail, sendOnlyToEmailList, OIOUBLgenerate, null, false);
            return(invoicePostingResult);
        }
Example #6
0
        private InvoicePostingPrintGenerator SetupInvoicePostingPrintGenerator(CreditorOrderClient crOrder, IEnumerable <DCOrderLineClient> lines, DateTime generateDate, string invoiceNumber, bool isSimulated, bool showInvoice,
                                                                               bool postOnlyDelivered, bool isQuickPrint, int printPageCount, bool sendInvoiceByEmail, bool sendInvoiceByOutlook, bool sendOnlyToEmail, string SendOnlyEmailList, List <TableAddOnData> documents)
        {
            var invoicePostingResult = new InvoicePostingPrintGenerator(api, this);

            invoicePostingResult.SetUpInvoicePosting(crOrder, lines, CompanyLayoutType.PurchaseInvoice, generateDate, invoiceNumber, isSimulated, showInvoice,
                                                     postOnlyDelivered, isQuickPrint, printPageCount, sendInvoiceByEmail, sendInvoiceByOutlook, sendOnlyToEmail, SendOnlyEmailList, false, documents, false);

            return(invoicePostingResult);
        }
Example #7
0
        private void GenerateInvoice(CreditorOrderClient creditorOrderClient)
        {
            var  accountName     = string.Format("{0} ({1})", creditorOrderClient._DCAccount, creditorOrderClient.Name);
            var  creditor        = ClientHelper.GetRef(creditorOrderClient.CompanyId, typeof(Uniconta.DataModel.Creditor), creditorOrderClient._DCAccount) as Uniconta.DataModel.Creditor;
            bool showSendByEmail = creditor != null ? (!string.IsNullOrEmpty(creditor._InvoiceEmail) || creditor._EmailDocuments) : false;

            CWGenerateInvoice GenrateInvoiceDialog = new CWGenerateInvoice(true, string.Empty, true, true, showNoEmailMsg: !showSendByEmail, AccountName: accountName);

#if !SILVERLIGHT
            GenrateInvoiceDialog.DialogTableId = 2000000002;
#endif
            GenrateInvoiceDialog.SetSendAsEmailCheck(false);
            GenrateInvoiceDialog.SetInvoiceNumber(creditorOrderClient._InvoiceNumber);
            if (creditorOrderClient._InvoiceDate != DateTime.MinValue)
            {
                GenrateInvoiceDialog.SetInvoiceDate(creditorOrderClient._InvoiceDate);
            }
            var additionalOrdersList = Utility.GetAdditionalOrders(api, creditorOrderClient);
            if (additionalOrdersList != null)
            {
                GenrateInvoiceDialog.SetAdditionalOrders(additionalOrdersList);
            }

            GenrateInvoiceDialog.Closed += async delegate
            {
                if (GenrateInvoiceDialog.DialogResult == true)
                {
                    var isSimulated          = GenrateInvoiceDialog.IsSimulation;
                    var invoicePostingResult = new InvoicePostingPrintGenerator(api, this);
                    invoicePostingResult.SetUpInvoicePosting(creditorOrderClient, null, CompanyLayoutType.PurchaseInvoice, GenrateInvoiceDialog.GenrateDate, GenrateInvoiceDialog.InvoiceNumber, isSimulated,
                                                             GenrateInvoiceDialog.ShowInvoice, false, GenrateInvoiceDialog.InvoiceQuickPrint, GenrateInvoiceDialog.NumberOfPages, GenrateInvoiceDialog.SendByEmail, !isSimulated && GenrateInvoiceDialog.SendByOutlook,
                                                             GenrateInvoiceDialog.sendOnlyToThisEmail, GenrateInvoiceDialog.Emails, false, null, false);
                    invoicePostingResult.SetAdditionalOrders(GenrateInvoiceDialog.AdditionalOrders?.Cast <DCOrder>().ToList());
                    busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("SendingWait");
                    busyIndicator.IsBusy      = true;
                    var result = await invoicePostingResult.Execute();

                    busyIndicator.IsBusy = false;

                    if (result)
                    {
                        if (invoicePostingResult.PostingResult.OrderDeleted)
                        {
                            dgCreditorOrdersGrid.UpdateItemSource(3, dgCreditorOrdersGrid.SelectedItem as CreditorOrderClient);
                        }
                    }
                    else
                    {
                        Utility.ShowJournalError(invoicePostingResult.PostingResult.ledgerRes, dgCreditorOrdersGrid);
                    }
                }
            };
            GenrateInvoiceDialog.Show();
        }
        private void PickingListReport(DebtorOrderClient dbOrder)
        {
            InvoiceAPI Invapi = new InvoiceAPI(api);
            var        debtor = dbOrder.Debtor;
            string     debtorName = string.Empty, accountName = string.Empty;
            bool       showSendByMail = false;

            if (debtor != null)
            {
                debtorName     = debtor._Name ?? dbOrder._DCAccount;
                accountName    = string.Format("{0} ({1})", dbOrder._DCAccount, dbOrder.Name);
                showSendByMail = !string.IsNullOrEmpty(debtor.InvoiceEmail) || debtor.EmailDocuments;
            }

#if !SILVERLIGHT
            var cwPickingList = new CWGeneratePickingList(accountName, true, true, debtorName, showSendByMail);
            cwPickingList.DialogTableId = 2000000049;
#else
            var cwPickingList = new CWGeneratePickingList();
#endif
            cwPickingList.Closed += async delegate
            {
                if (cwPickingList.DialogResult == true)
                {
                    var selectedDate = cwPickingList.SelectedDate;

#if !SILVERLIGHT
                    var printDoc = cwPickingList.PrintDocument;
#else
                    var printDoc = false;
#endif
                    var invoicePostingResult = new InvoicePostingPrintGenerator(api, this);
                    invoicePostingResult.SetUpInvoicePosting(dbOrder, null, CompanyLayoutType.PickingList, selectedDate, null, false, cwPickingList.ShowDocument, false, printDoc, cwPickingList.NumberOfPages,
                                                             cwPickingList.SendByEmail, cwPickingList.SendByOutlook, cwPickingList.sendOnlyToThisEmail, cwPickingList.EmailList, false, null, false);

                    busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("GeneratingPage");
                    busyIndicator.IsBusy      = true;
                    var result = await invoicePostingResult.Execute();

                    busyIndicator.IsBusy = false;

                    if (result)
                    {
                        Updatedata(dbOrder, CompanyLayoutType.PickingList);
                    }
                    else
                    {
                        Utility.ShowJournalError(invoicePostingResult.PostingResult.ledgerRes, dgDebtorOrdersGrid);
                    }
                }
            };
            cwPickingList.Show();
        }
Example #9
0
        async private void OpenOutlook()
        {
            try
            {
                busyIndicator.IsBusy      = true;
                busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("LaunchingWaitMsg");
                var    selectedAccount = ((DebtorTransPayment)dgDebtorTranOpenGrid.SelectedItem).Account;
                byte[] logo            = await UtilDisplay.GetLogo(api);

                var Comp = api.CompanyEntity;

                var companyClient = Comp.CreateUserType <CompanyClient>();
                StreamingManager.Copy(Comp, companyClient);

                lastMessage = null; // just to reload message in case it has changed
                LoadDataForReport();

                int indexDebtorEmailType = 0;

                if (string.IsNullOrEmpty(collectionType))
                {
                    indexDebtorEmailType = SelectCollectionType();
                }
                else
                {
                    indexDebtorEmailType = AppEnums.DebtorEmailType.IndexOf(collectionType);
                }
                if (indexDebtorEmailType == -1)
                {
                    return;
                }

                var debtor          = accountCache.Get(selectedAccount) as Uniconta.DataModel.Debtor;
                var debtorEmailType = (DebtorEmailType)indexDebtorEmailType;
                var date            = BasePage.GetSystemDefaultDate();
                var selectedAccountstatementList = statementList.Where(p => p.AccountNumber == selectedAccount);
                var paymentStandardReport        = await GeneratePrintReport(selectedAccountstatementList, companyClient, date, logo, debtorEmailType);

                if (paymentStandardReport != null && paymentStandardReport.Count() == 1)
                {
                    InvoicePostingPrintGenerator.OpenReportInOutlook(api, paymentStandardReport.First(), debtor, debtorEmailType);

                    //Update Last dateTime
                    UpdateDate(date, selectedAccountstatementList.FirstOrDefault()?.ChildRecords, debtorEmailType == DebtorEmailType.InterestNote ? true : false);
                }
            }
            catch (Exception ex)
            {
                UnicontaMessageBox.Show(ex.Message, Uniconta.ClientTools.Localization.lookup("Exception"));
            }
            finally { busyIndicator.IsBusy = false; }
        }
        private void GenerateOffer()
        {
            saveGridLocal();
            bool   showSendByMail = false;
            var    dbOrder        = Order;
            string debtorName;
            var    debtor = dbOrder.Debtor;

            if (debtor != null)
            {
                debtorName     = debtor?._Name ?? dbOrder._DCAccount;
                showSendByMail = (!string.IsNullOrEmpty(debtor.InvoiceEmail) || debtor.EmailDocuments);
            }
            else if (dbOrder._Prospect == 0)
            {
                UtilDisplay.ShowErrorCode(ErrorCodes.AccountIsMissing);
                return;
            }
            else
            {
                debtorName     = Uniconta.ClientTools.Localization.lookup("Prospect");
                showSendByMail = true;
            }

            var generateOfferDialog = new CWGenerateInvoice(false, CompanyLayoutType.Offer.ToString(), askForEmail: true, showNoEmailMsg: !showSendByMail, debtorName: debtorName, isDebtorOrder: true);

#if !SILVERLIGHT
            generateOfferDialog.DialogTableId = 2000000075;
#endif
            generateOfferDialog.Closed += async delegate
            {
                if (generateOfferDialog.DialogResult == true)
                {
                    var invoicePostingResult = new InvoicePostingPrintGenerator(api, this);
                    invoicePostingResult.SetUpInvoicePosting(dbOrder, null, CompanyLayoutType.Offer, generateOfferDialog.GenrateDate, null, true, generateOfferDialog.ShowInvoice, generateOfferDialog.PostOnlyDelivered,
                                                             generateOfferDialog.InvoiceQuickPrint, generateOfferDialog.NumberOfPages, generateOfferDialog.SendByEmail, generateOfferDialog.SendByOutlook, generateOfferDialog.sendOnlyToThisEmail,
                                                             generateOfferDialog.Emails, false, null, false);
                    busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("GeneratingPage");
                    busyIndicator.IsBusy      = true;
                    var result = await invoicePostingResult.Execute();

                    busyIndicator.IsBusy = false;

                    if (!result)
                    {
                        Utility.ShowJournalError(invoicePostingResult.PostingResult.ledgerRes, dgDebtorOfferLineGrid);
                    }
                }
            };
            generateOfferDialog.Show();
        }
Example #11
0
        private void OrderConfirmation(DebtorOrderClient dbOrder, CompanyLayoutType doctype)
        {
            InvoiceAPI Invapi         = new InvoiceAPI(api);
            var        debtor         = dbOrder.Debtor;
            bool       showSendByMail = true;

            if (debtor != null)
            {
                showSendByMail = !string.IsNullOrEmpty(debtor.InvoiceEmail);
            }
            string            debtorName         = debtor?._Name ?? dbOrder._DCAccount;
            bool              showUpdateInv      = api.CompanyEntity.Storage || (doctype == CompanyLayoutType.Packnote && api.CompanyEntity.Packnote);
            CWGenerateInvoice GenrateOfferDialog = new CWGenerateInvoice(false, Uniconta.ClientTools.Localization.lookup(doctype.ToString()), isShowInvoiceVisible: true, askForEmail: true, showNoEmailMsg: !showSendByMail, debtorName: debtorName, isShowUpdateInv: showUpdateInv, isDebtorOrder: true);

#if !SILVERLIGHT
            if (doctype == CompanyLayoutType.OrderConfirmation)
            {
                GenrateOfferDialog.DialogTableId = 2000000009;
            }
            else if (doctype == CompanyLayoutType.Packnote)
            {
                GenrateOfferDialog.DialogTableId = 2000000018;
            }
#endif
            GenrateOfferDialog.SetInvPrintPreview(showPrintPreview);
            GenrateOfferDialog.Closed += async delegate
            {
                if (GenrateOfferDialog.DialogResult == true)
                {
                    showPrintPreview = GenrateOfferDialog.ShowInvoice || GenrateOfferDialog.InvoiceQuickPrint;
                    var invoicePostingResult = new InvoicePostingPrintGenerator(api, this, dbOrder, null, GenrateOfferDialog.GenrateDate, 0, !GenrateOfferDialog.UpdateInventory, doctype, showPrintPreview, GenrateOfferDialog.InvoiceQuickPrint,
                                                                                GenrateOfferDialog.NumberOfPages, GenrateOfferDialog.SendByEmail, GenrateOfferDialog.Emails, GenrateOfferDialog.sendOnlyToThisEmail, false, GenrateOfferDialog.PostOnlyDelivered, null);
                    busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("GeneratingPage");
                    busyIndicator.IsBusy      = true;
                    var result = await invoicePostingResult.Execute();

                    busyIndicator.IsBusy = false;

                    if (result)
                    {
                        Updatedata(dbOrder, doctype);
                    }
                    else
                    {
                        Utility.ShowJournalError(invoicePostingResult.PostingResult.ledgerRes, dgDebtorOrdersGrid);
                    }
                }
            };
            GenrateOfferDialog.Show();
        }
        private void PrintOffer(DebtorOfferClient dbOrder)
        {
            InvoiceAPI Invapi         = new InvoiceAPI(api);
            var        debtor         = dbOrder.Debtor;
            bool       showSendByMail = true;
            string     debtorName;

            if (debtor != null)
            {
                debtorName     = debtor._Name ?? dbOrder._DCAccount;
                showSendByMail = !string.IsNullOrEmpty(debtor.InvoiceEmail);
            }
            else if (dbOrder._Prospect == 0)
            {
                UtilDisplay.ShowErrorCode(ErrorCodes.AccountIsMissing);
                return;
            }
            else
            {
                debtorName     = Uniconta.ClientTools.Localization.lookup("Prospect");
                showSendByMail = true;
            }

            CWGenerateInvoice GenrateOfferDialog = new CWGenerateInvoice(false, Uniconta.ClientTools.Localization.lookup("Offer"), askForEmail: true, showNoEmailMsg: !showSendByMail, debtorName: debtorName, isDebtorOrder: true);

#if !SILVERLIGHT
            GenrateOfferDialog.DialogTableId = 2000000006;
#endif
            GenrateOfferDialog.Closed += async delegate
            {
                if (GenrateOfferDialog.DialogResult == true)
                {
                    var showOrPrintOffer     = GenrateOfferDialog.InvoiceQuickPrint || GenrateOfferDialog.ShowInvoice;
                    var invoicePostingResult = new InvoicePostingPrintGenerator(api, this, dbOrder, null, GenrateOfferDialog.GenrateDate, 0, true, CompanyLayoutType.Offer, showOrPrintOffer, GenrateOfferDialog.InvoiceQuickPrint,
                                                                                GenrateOfferDialog.NumberOfPages, GenrateOfferDialog.SendByEmail, GenrateOfferDialog.Emails, GenrateOfferDialog.sendOnlyToThisEmail, false, GenrateOfferDialog.PostOnlyDelivered, null);

                    busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("GeneratingPage");
                    busyIndicator.IsBusy      = true;
                    var result = await invoicePostingResult.Execute();

                    busyIndicator.IsBusy = false;

                    if (!result)
                    {
                        Utility.ShowJournalError(invoicePostingResult.PostingResult.ledgerRes, dgDebtorOffers);
                    }
                }
            };
            GenrateOfferDialog.Show();
        }
Example #13
0
        private void GenerateRecordInvoice(DebtorOrderClient dbOrder)
        {
            InvoiceAPI Invapi         = new InvoiceAPI(api);
            var        debtor         = dbOrder.Debtor;
            bool       showSendByMail = true;

            if (debtor != null)
            {
                showSendByMail = (!string.IsNullOrEmpty(debtor.InvoiceEmail) || debtor.EmailDocuments);
            }
            else
            {
                api.LoadCache(typeof(Debtor), true);
            }

            string debtorName   = debtor?.Name ?? dbOrder._DCAccount;
            bool   invoiceInXML = debtor?._InvoiceInXML ?? false;

            UnicontaClient.Pages.CWGenerateInvoice GenrateInvoiceDialog = new UnicontaClient.Pages.CWGenerateInvoice(true, string.Empty, false, true, true, showNoEmailMsg: !showSendByMail, debtorName: debtorName, isDebtorOrder: true, isOrderOrQuickInv: true, InvoiceInXML: invoiceInXML);
#if !SILVERLIGHT
            GenrateInvoiceDialog.DialogTableId = 2000000013;
#endif
            GenrateInvoiceDialog.SetOIOUBLLabelText(api.CompanyEntity._OIOUBLSendOnServer);
            GenrateInvoiceDialog.Closed += async delegate
            {
                if (GenrateInvoiceDialog.DialogResult == true)
                {
                    busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("SendingWait");
                    busyIndicator.IsBusy      = true;
                    var isSimulated          = GenrateInvoiceDialog.IsSimulation;
                    var invoicePostingResult = new InvoicePostingPrintGenerator(api, this);
                    invoicePostingResult.SetUpInvoicePosting(dbOrder, null, CompanyLayoutType.Invoice, GenrateInvoiceDialog.GenrateDate, null, isSimulated, GenrateInvoiceDialog.ShowInvoice, GenrateInvoiceDialog.PostOnlyDelivered,
                                                             GenrateInvoiceDialog.InvoiceQuickPrint, GenrateInvoiceDialog.NumberOfPages, GenrateInvoiceDialog.SendByEmail, !isSimulated && GenrateInvoiceDialog.SendByOutlook, GenrateInvoiceDialog.sendOnlyToThisEmail,
                                                             GenrateInvoiceDialog.Emails, GenrateInvoiceDialog.GenerateOIOUBLClicked, null, false);
                    busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("GeneratingPage");
                    var result = await invoicePostingResult.Execute();

                    busyIndicator.IsBusy = true;
                    busyIndicator.IsBusy = false;

                    if (!result)
                    {
                        Utility.ShowJournalError(invoicePostingResult.PostingResult.ledgerRes, dgMultiInvGrid);
                    }
                }
            };
            GenrateInvoiceDialog.Show();
        }
        private void GenerateInvoice(ProjectClient dbProject)
        {
            var Invapi   = new Uniconta.API.Project.InvoiceAPI(api);
            var savetask = saveGrid();
            CWProjectGenerateInvoice GenrateInvoiceDialog = new CWProjectGenerateInvoice(api, GetSystemDefaultDate(), true, true, true, true, true);

#if SILVERLIGHT
            GenrateInvoiceDialog.Height = 210.0d;
#else
            GenrateInvoiceDialog.DialogTableId = 2000000047;
#endif
            GenrateInvoiceDialog.Closed += async delegate
            {
                if (GenrateInvoiceDialog.DialogResult == true)
                {
                    busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("GeneratingPage");
                    busyIndicator.IsBusy      = true;
                    if (savetask != null)
                    {
                        await savetask;
                    }

                    var invoicePostingResult = new InvoicePostingPrintGenerator(api, this);
                    invoicePostingResult.SetUpInvoicePosting(dbProject, GenrateInvoiceDialog.GenrateDate, GenrateInvoiceDialog.IsSimulation, GenrateInvoiceDialog.InvoiceCategory, GenrateInvoiceDialog.ShowInvoice,
                                                             GenrateInvoiceDialog.InvoiceQuickPrint, GenrateInvoiceDialog.NumberOfPages, GenrateInvoiceDialog.SendByEmail, GenrateInvoiceDialog.GenerateOIOUBLClicked, null, false);
                    var result = await invoicePostingResult.Execute();

                    busyIndicator.IsBusy = false;

                    if (result)
                    {
                        Task reloadTask = null;
                        if (!GenrateInvoiceDialog.IsSimulation)
                        {
                            reloadTask = Filter(null);
                        }
                    }
                    else
                    {
                        Utility.ShowJournalError(invoicePostingResult.PostingResult.ledgerRes, dgProjectOnAccountInvoiceLineGrid);
                    }
                }
            };
            GenrateInvoiceDialog.Show();
        }
Example #15
0
        private void PickingListReport(DebtorOrderClient dbOrder)
        {
            InvoiceAPI Invapi     = new InvoiceAPI(api);
            var        debtor     = dbOrder.Debtor;
            string     debtorName = debtor?._Name ?? dbOrder._DCAccount;

            var cwPickingList = new CWGeneratePickingList();

#if !SILVERLIGHT
            cwPickingList.DialogTableId = 2000000049;
#endif
            cwPickingList.Closed += async delegate
            {
                if (cwPickingList.DialogResult == true)
                {
                    var selectedDate = cwPickingList.SelectedDate;

#if !SILVERLIGHT
                    var printDoc = cwPickingList.PrintDocument;
#else
                    var printDoc = false;
#endif
                    var invoicePostingResult = new InvoicePostingPrintGenerator(api, this, dbOrder, null, selectedDate, 0, false, CompanyLayoutType.PickingList, true, printDoc,
                                                                                cwPickingList.NumberOfPages, cwPickingList.EmailList);

                    busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("GeneratingPage");
                    busyIndicator.IsBusy      = true;
                    var result = await invoicePostingResult.Execute();

                    busyIndicator.IsBusy = false;

                    if (result)
                    {
                        Updatedata(dbOrder, CompanyLayoutType.PickingList);
                    }
                    else
                    {
                        Utility.ShowJournalError(invoicePostingResult.PostingResult.ledgerRes, dgDebtorOrdersGrid);
                    }
                }
            };
            cwPickingList.Show();
        }
Example #16
0
        private void OrderConfirmation(CreditorOrderClient dbOrder, CompanyLayoutType doctype)
        {
            InvoiceAPI Invapi         = new InvoiceAPI(api);
            var        creditor       = dbOrder.Creditor;
            bool       showSendByMail = true;

            if (creditor != null)
            {
                showSendByMail = !string.IsNullOrEmpty(creditor._InvoiceEmail);
            }
            string            creditorName       = creditor?._Name ?? dbOrder._DCAccount;
            var               comp               = api.CompanyEntity;
            bool              showUpdateInv      = comp.Storage || (doctype == CompanyLayoutType.PurchasePacknote && comp.CreditorPacknote);
            CWGenerateInvoice GenrateOfferDialog = new CWGenerateInvoice(false, doctype.ToString(), showInputforInvNumber: doctype == CompanyLayoutType.PurchasePacknote ? true : false,
                                                                         isShowInvoiceVisible: true, askForEmail: true, showNoEmailMsg: !showSendByMail, debtorName: creditorName, isShowUpdateInv: showUpdateInv);

#if !SILVERLIGHT
            switch (doctype)
            {
            case CompanyLayoutType.PurchaseOrder:
                GenrateOfferDialog.DialogTableId = 2000000003;
                break;

            case CompanyLayoutType.PurchasePacknote:
                GenrateOfferDialog.DialogTableId = 2000000056;
                break;

            case CompanyLayoutType.Requisition:
                GenrateOfferDialog.DialogTableId = 2000000057;
                break;
            }
#endif
            GenrateOfferDialog.SetInvPrintPreview(showInvPrintPreview);
            var additionalOrdersList = Utility.GetAdditionalOrders(api, dbOrder);
            if (additionalOrdersList != null)
            {
                GenrateOfferDialog.SetAdditionalOrders(additionalOrdersList);
            }
            GenrateOfferDialog.Closed += async delegate
            {
                if (GenrateOfferDialog.DialogResult == true)
                {
                    showInvPrintPreview = GenrateOfferDialog.ShowInvoice || GenrateOfferDialog.InvoiceQuickPrint || GenrateOfferDialog.SendByOutlook;
                    string documentNumber = null;
                    if (doctype == CompanyLayoutType.PurchasePacknote)
                    {
                        documentNumber         = GenrateOfferDialog.InvoiceNumber;
                        dbOrder._InvoiceNumber = documentNumber;
                    }
                    var openOutlook          = doctype == CompanyLayoutType.PurchasePacknote ? GenrateOfferDialog.UpdateInventory && GenrateOfferDialog.SendByOutlook : GenrateOfferDialog.SendByOutlook;
                    var invoicePostingResult = new InvoicePostingPrintGenerator(api, this);
                    invoicePostingResult.SetUpInvoicePosting(dbOrder, null, doctype, GenrateOfferDialog.GenrateDate, documentNumber, !GenrateOfferDialog.UpdateInventory, GenrateOfferDialog.ShowInvoice, false,
                                                             GenrateOfferDialog.InvoiceQuickPrint, GenrateOfferDialog.NumberOfPages, GenrateOfferDialog.SendByEmail, openOutlook, GenrateOfferDialog.sendOnlyToThisEmail, GenrateOfferDialog.Emails,
                                                             false, null, false);
                    invoicePostingResult.SetAdditionalOrders(GenrateOfferDialog.AdditionalOrders?.Cast <DCOrder>().ToList());

                    busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("GeneratingPage");
                    busyIndicator.IsBusy      = true;
                    var result = await invoicePostingResult.Execute();

                    busyIndicator.IsBusy = false;

                    if (result)
                    {
                        DebtorOrders.Updatedata(dbOrder, doctype);
                    }

                    else
                    {
                        Utility.ShowJournalError(invoicePostingResult.PostingResult.ledgerRes, dgCreditorOrdersGrid);
                    }
                }
            };
            GenrateOfferDialog.Show();
        }
Example #17
0
        private void GenerateInvoice(DCOrder dbOrder)
        {
            InvoiceAPI Invapi         = new InvoiceAPI(api);
            bool       showSendByMail = false;
            var        debtor         = ClientHelper.GetRef(dbOrder.CompanyId, typeof(Debtor), dbOrder._DCAccount) as Debtor;

            if (debtor != null)
            {
                var InvoiceAccount = dbOrder._InvoiceAccount ?? debtor._InvoiceAccount;
                if (InvoiceAccount != null)
                {
                    debtor = ClientHelper.GetRef(dbOrder.CompanyId, typeof(Debtor), InvoiceAccount) as Debtor;
                }
                if (debtor != null)
                {
                    if (debtor._PricesInclVat != dbOrder._PricesInclVat)
                    {
                        var confirmationMsgBox = UnicontaMessageBox.Show(string.Format("{0}.\n{1}", string.Format(Uniconta.ClientTools.Localization.lookup("DebtorAndOrderMix"), Uniconta.ClientTools.Localization.lookup("InclVat")),
                                                                                       Uniconta.ClientTools.Localization.lookup("ProceedConfirmation")), Uniconta.ClientTools.Localization.lookup("Confirmation"), MessageBoxButton.OKCancel);
                        if (confirmationMsgBox != MessageBoxResult.OK)
                        {
                            return;
                        }
                    }
                    if (!api.CompanyEntity.SameCurrency(dbOrder._Currency, debtor._Currency))
                    {
                        var confirmationMsgBox = UnicontaMessageBox.Show(string.Format("{0}.\n{1}", string.Format(Uniconta.ClientTools.Localization.lookup("CurrencyMismatch"), AppEnums.Currencies.ToString((int)debtor._Currency), dbOrder.Currency),
                                                                                       Uniconta.ClientTools.Localization.lookup("ProceedConfirmation")), Uniconta.ClientTools.Localization.lookup("Confirmation"), MessageBoxButton.OKCancel);
                        if (confirmationMsgBox != MessageBoxResult.OK)
                        {
                            return;
                        }
                    }
                    showSendByMail = !string.IsNullOrEmpty(debtor._InvoiceEmail);
                }
            }
            else
            {
                api.CompanyEntity.LoadCache(typeof(Debtor), api, true);
            }

            string            debtorName           = debtor?._Name ?? dbOrder._DCAccount;
            bool              invoiceInXML         = debtor?._InvoiceInXML ?? false;
            CWGenerateInvoice GenrateInvoiceDialog = new CWGenerateInvoice(true, string.Empty, false, true, true, showNoEmailMsg: !showSendByMail, debtorName: debtorName, isOrderOrQuickInv: true, isDebtorOrder: true, InvoiceInXML: invoiceInXML);

#if !SILVERLIGHT
            GenrateInvoiceDialog.DialogTableId = 2000000010;
#endif
            GenrateInvoiceDialog.Closed += async delegate
            {
                if (GenrateInvoiceDialog.DialogResult == true)
                {
                    busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("SendingWait");
                    busyIndicator.IsBusy      = true;
                    var showOrPrint = GenrateInvoiceDialog.ShowInvoice || GenrateInvoiceDialog.InvoiceQuickPrint;

                    var invoicePostingResult = new InvoicePostingPrintGenerator(api, this, dbOrder, null, GenrateInvoiceDialog.GenrateDate, 0, GenrateInvoiceDialog.IsSimulation, CompanyLayoutType.Invoice, showOrPrint,
                                                                                GenrateInvoiceDialog.InvoiceQuickPrint, GenrateInvoiceDialog.NumberOfPages, GenrateInvoiceDialog.SendByEmail, GenrateInvoiceDialog.Emails, GenrateInvoiceDialog.sendOnlyToThisEmail,
                                                                                GenrateInvoiceDialog.GenerateOIOUBLClicked, GenrateInvoiceDialog.PostOnlyDelivered, null);

                    busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("GeneratingPage");
                    busyIndicator.IsBusy      = true;
                    var result = await invoicePostingResult.Execute();

                    busyIndicator.IsBusy = false;

                    if (result)
                    {
                        Task reloadTask = null;
                        if (!GenrateInvoiceDialog.IsSimulation && dbOrder._DeleteLines)
                        {
                            reloadTask = BindGrid();
                        }

                        if (invoicePostingResult.PostingResult.Header._InvoiceNumber != 0)
                        {
                            var msg = string.Format(Uniconta.ClientTools.Localization.lookup("InvoiceHasBeenGenerated"), invoicePostingResult.PostingResult.Header._InvoiceNumber);
                            msg = string.Format("{0}{1}{2} {3}", msg, Environment.NewLine, Uniconta.ClientTools.Localization.lookup("LedgerVoucher"), invoicePostingResult.PostingResult.Header._Voucher);
                            UnicontaMessageBox.Show(msg, Uniconta.ClientTools.Localization.lookup("Message"), MessageBoxButton.OK);

#if !SILVERLIGHT
                            if (GenrateInvoiceDialog.GenerateOIOUBLClicked && !GenrateInvoiceDialog.IsSimulation)
                            {
                                GenerateOIOXml(this.api, invoicePostingResult.PostingResult);
                            }
#endif
                        }
                    }
                    else
                    {
                        Utility.ShowJournalError(invoicePostingResult.PostingResult.ledgerRes, dgDebtorOrdersGrid);
                    }
                }
            };
            GenrateInvoiceDialog.Show();
        }
        private void GenerateInvoice(DebtorOrderClient dbOrder)
        {
            InvoiceAPI Invapi         = new InvoiceAPI(api);
            bool       showSendByMail = false;

            var debtor = ClientHelper.GetRef(dbOrder.CompanyId, typeof(Debtor), dbOrder._DCAccount) as Debtor;

            if (debtor != null)
            {
                var InvoiceAccount = dbOrder._InvoiceAccount ?? debtor._InvoiceAccount;
                if (InvoiceAccount != null)
                {
                    debtor = ClientHelper.GetRef(dbOrder.CompanyId, typeof(Debtor), InvoiceAccount) as Debtor;
                }
                if (debtor != null)
                {
                    if (debtor._PricesInclVat != dbOrder._PricesInclVat)
                    {
                        var confirmationMsgBox = UnicontaMessageBox.Show(string.Format("{0}.\n{1}", string.Format(Uniconta.ClientTools.Localization.lookup("DebtorAndOrderMix"), Uniconta.ClientTools.Localization.lookup("InclVat")),
                                                                                       Uniconta.ClientTools.Localization.lookup("ProceedConfirmation")), Uniconta.ClientTools.Localization.lookup("Confirmation"), MessageBoxButton.OKCancel);
                        if (confirmationMsgBox != MessageBoxResult.OK)
                        {
                            return;
                        }
                    }
                    if (!api.CompanyEntity.SameCurrency(dbOrder._Currency, debtor._Currency))
                    {
                        var confirmationMsgBox = UnicontaMessageBox.Show(string.Format("{0}.\n{1}", string.Format(Uniconta.ClientTools.Localization.lookup("CurrencyMismatch"), AppEnums.Currencies.ToString((int)debtor._Currency), dbOrder.Currency),
                                                                                       Uniconta.ClientTools.Localization.lookup("ProceedConfirmation")), Uniconta.ClientTools.Localization.lookup("Confirmation"), MessageBoxButton.OKCancel);
                        if (confirmationMsgBox != MessageBoxResult.OK)
                        {
                            return;
                        }
                    }
                    showSendByMail = (!string.IsNullOrEmpty(debtor._InvoiceEmail) || debtor._EmailDocuments);
                }
            }
            else
            {
                api.LoadCache(typeof(Debtor), true);
            }

            string            debtorName           = debtor?._Name ?? dbOrder._DCAccount;
            bool              invoiceInXML         = debtor?._InvoiceInXML ?? false;
            var               accountName          = string.Format("{0} ({1})", dbOrder._DCAccount, dbOrder.Name);
            CWGenerateInvoice GenrateInvoiceDialog = new CWGenerateInvoice(true, string.Empty, false, true, true, showNoEmailMsg: !showSendByMail, debtorName: debtorName, isOrderOrQuickInv: true, isDebtorOrder: true,
                                                                           InvoiceInXML: invoiceInXML, AccountName: accountName);

#if !SILVERLIGHT
            GenrateInvoiceDialog.DialogTableId = 2000000010;
#endif
            if (dbOrder._InvoiceDate != DateTime.MinValue)
            {
                GenrateInvoiceDialog.SetInvoiceDate(dbOrder._InvoiceDate);
            }
            var additionalOrdersList = Utility.GetAdditionalOrders(api, dbOrder);
            if (additionalOrdersList != null)
            {
                GenrateInvoiceDialog.SetAdditionalOrders(additionalOrdersList);
            }
            GenrateInvoiceDialog.SetOIOUBLLabelText(api.CompanyEntity._OIOUBLSendOnServer);

            GenrateInvoiceDialog.Closed += async delegate
            {
                if (GenrateInvoiceDialog.DialogResult == true)
                {
                    busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("SendingWait");
                    busyIndicator.IsBusy      = true;
                    var isSimulated          = GenrateInvoiceDialog.IsSimulation;
                    var invoicePostingResult = new InvoicePostingPrintGenerator(api, this);
                    invoicePostingResult.SetUpInvoicePosting(dbOrder, null, CompanyLayoutType.Invoice, GenrateInvoiceDialog.GenrateDate, null, isSimulated, GenrateInvoiceDialog.ShowInvoice, GenrateInvoiceDialog.PostOnlyDelivered,
                                                             GenrateInvoiceDialog.InvoiceQuickPrint, GenrateInvoiceDialog.NumberOfPages, GenrateInvoiceDialog.SendByEmail, !isSimulated && GenrateInvoiceDialog.SendByOutlook, GenrateInvoiceDialog.sendOnlyToThisEmail,
                                                             GenrateInvoiceDialog.Emails, GenrateInvoiceDialog.GenerateOIOUBLClicked, null, false);
                    invoicePostingResult.SetAdditionalOrders(GenrateInvoiceDialog.AdditionalOrders?.Cast <DCOrder>().ToList());
                    busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("GeneratingPage");
                    busyIndicator.IsBusy      = true;
                    var result = await invoicePostingResult.Execute();

                    busyIndicator.IsBusy = false;

                    if (result)
                    {
                        if (invoicePostingResult.PostingResult.OrderDeleted)
                        {
                            dgDebtorOrdersGrid.UpdateItemSource(3, dgDebtorOrdersGrid.SelectedItem as DebtorOrderClient);
                        }
                    }
                    else
                    {
                        Utility.ShowJournalError(invoicePostingResult.PostingResult.ledgerRes, dgDebtorOrdersGrid);
                    }
                }
            };
            GenrateInvoiceDialog.Show();
        }
Example #19
0
        private void PickList()
        {
#if SILVERLIGHT
            packListPosted = new List <InvoicePostingResult>();
#endif
            var cwPickingList = new CWGeneratePickingList(true);
#if !SILVERLIGHT
            cwPickingList.DialogTableId = 2000000024;
#endif
            cwPickingList.Closed += async delegate
            {
                if (cwPickingList.DialogResult == true)
                {
                    var selectedDate = cwPickingList.SelectedDate;
                    busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("LoadingMsg");
                    busyIndicator.IsBusy      = true;

                    var dbVisibleOrders = dgMultiInvGrid.GetVisibleRows() as IEnumerable <DebtorOrderClient>;
#if SILVERLIGHT
                    InvoiceAPI Invapi    = new InvoiceAPI(api);
                    int        cnt       = 0;
                    var        errorList = new List <string>();
                    foreach (var dbOrder in dbVisibleOrders)
                    {
                        var result = await Invapi.PostInvoice(dbOrder, null, selectedDate, null, false, new DebtorInvoiceClient(), new DebtorInvoiceLines(), false, cwPickingList.ShowDocument || cwPickingList.PrintDocument,
                                                              CompanyLayoutType.PickingList);

                        if (result.Err == ErrorCodes.Succes)
                        {
                            packListPosted.Add(result);
                            cnt++;
                        }
                        else
                        {
                            string error = string.Format("{0}:{1}", dbOrder.OrderNumber, Uniconta.ClientTools.Localization.lookup(result.Err.ToString()));
                            errorList.Add(error);
                        }
                    }
                    busyIndicator.IsBusy = false;

                    int    picklistPreviewCount = packListPosted.Count;
                    string updatedMsg           = string.Format(Uniconta.ClientTools.Localization.lookup("MulitDocPrintConfirmationMsg"), picklistPreviewCount,
                                                                string.Format("{0} {1}", Uniconta.ClientTools.Localization.lookup(CompanyLayoutType.PickingList.ToString()), Uniconta.ClientTools.Localization.lookup("Documents")));

                    if (errorList.Count == 0)
                    {
                        InitMultiplePreviewDocument(updatedMsg, CompanyLayoutType.PickingList, cwPickingList.PrintDocument);
                    }
                    else
                    {
                        CWErrorBox errorDialog = new CWErrorBox(errorList.ToArray(), true);
                        errorDialog.Closed += delegate { InitMultiplePreviewDocument(updatedMsg, CompanyLayoutType.PickingList, cwPickingList.PrintDocument); };
                        errorDialog.Show();
                    }
#else
                    var invoicePostringPrintGenerator = new InvoicePostingPrintGenerator(api, this);
                    invoicePostringPrintGenerator.SetUpInvoicePosting(dbVisibleOrders, selectedDate, false, CompanyLayoutType.PickingList, cwPickingList.ShowDocument, false, cwPickingList.PrintDocument,
                                                                      cwPickingList.SendByEmail, cwPickingList.sendOnlyToThisEmail, cwPickingList.EmailList, false);

                    await invoicePostringPrintGenerator.Execute();

                    busyIndicator.IsBusy = false;
#endif
                }
            };
            cwPickingList.Show();
        }
Example #20
0
        private void GenerateInvoice()
        {
#if SILVERLIGHT
            invoicePosted = new List <InvoicePostingResult>();
#endif
            UnicontaClient.Pages.CWGenerateInvoice GenrateInvoiceDialog = new UnicontaClient.Pages.CWGenerateInvoice(true, string.Empty, false, true, true, isOrderOrQuickInv: true, isQuickPrintVisible: true, isPageCountVisible: false, isDebtorOrder: true);
#if !SILVERLIGHT
            GenrateInvoiceDialog.DialogTableId = 2000000011;
            GenrateInvoiceDialog.HideOutlookOption(true);
#endif
            GenrateInvoiceDialog.SetInvPrintPreview(printPreview);
            GenrateInvoiceDialog.SetOIOUBLLabelText(api.CompanyEntity._OIOUBLSendOnServer);
            GenrateInvoiceDialog.Closed += async delegate
            {
                if (GenrateInvoiceDialog.DialogResult == true)
                {
                    printPreview = GenrateInvoiceDialog.ShowInvoice;
                    busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("SendingWait");
                    busyIndicator.IsBusy      = true;
                    var InvoiceDate     = GenrateInvoiceDialog.GenrateDate;
                    var dbVisibleOrders = dgMultiInvGrid.GetVisibleRows() as IEnumerable <DebtorOrderClient>;
#if SILVERLIGHT
                    InvoiceAPI    Invapi    = new InvoiceAPI(api);
                    int           cnt       = 0;
                    List <string> errorList = new List <string>();
                    foreach (var dbOrder in dbVisibleOrders)
                    {
                        if (dbOrder._SubscriptionEnded != DateTime.MinValue && dbOrder._SubscriptionEnded < InvoiceDate)
                        {
                            continue;
                        }

                        var result = await Invapi.PostInvoice(dbOrder, null, InvoiceDate,
                                                              null, GenrateInvoiceDialog.IsSimulation, new DebtorInvoiceClient(),
                                                              new DebtorInvoiceLines(), GenrateInvoiceDialog.SendByEmail, (GenrateInvoiceDialog.ShowInvoice || GenrateInvoiceDialog.InvoiceQuickPrint || GenrateInvoiceDialog.GenerateOIOUBLClicked), 0,
                                                              GenrateInvoiceDialog.Emails, GenrateInvoiceDialog.sendOnlyToThisEmail, null, null, GenrateInvoiceDialog.PostOnlyDelivered, false);

                        if (result != null && result.Err == 0)
                        {
                            invoicePosted.Add(result);
                            cnt++;

                            var dc = dbOrder.Debtor;
                            if (dc == null)
                            {
                                await api.LoadCache(typeof(Debtor), true);

                                dc = dbOrder.Debtor;
                            }

                            DebtorOrders.SetDeliveryAdress(result.Header, dc, api);
                        }
                        else
                        {
                            string error = string.Format("{0}:{1}", dbOrder._OrderNumber, Uniconta.ClientTools.Localization.lookup(result.Err.ToString()));
                            errorList.Add(error);
                        }
                    }

                    busyIndicator.IsBusy = false;
                    string updatedMsg = Uniconta.ClientTools.Localization.lookup("Succes");
                    if (!GenrateInvoiceDialog.IsSimulation)
                    {
                        updatedMsg = string.Format(Uniconta.ClientTools.Localization.lookup("RecordsUpdated"), cnt, Uniconta.ClientTools.Localization.lookup("DebtorOrders"));
                    }

                    int previewInvoiceCount = invoicePosted.Count;
                    updatedMsg = updatedMsg + "\n" + string.Format(Uniconta.ClientTools.Localization.lookup("MulitDocPrintConfirmationMsg"), previewInvoiceCount, Uniconta.ClientTools.Localization.lookup("Invoices"));

                    if (errorList.Count == 0)
                    {
                        PreInitMulitplePreviewDocument(updatedMsg, CompanyLayoutType.Invoice, GenrateInvoiceDialog.ShowInvoice, GenrateInvoiceDialog.InvoiceQuickPrint, previewInvoiceCount, GenrateInvoiceDialog.SendByEmail,
                                                       GenrateInvoiceDialog.sendOnlyToThisEmail);
                    }
                    else
                    {
                        CWErrorBox errorDialog = new CWErrorBox(errorList.ToArray(), true);
                        errorDialog.Closed += delegate
                        {
                            PreInitMulitplePreviewDocument(updatedMsg, CompanyLayoutType.Invoice, GenrateInvoiceDialog.ShowInvoice, GenrateInvoiceDialog.InvoiceQuickPrint, previewInvoiceCount, GenrateInvoiceDialog.SendByEmail,
                                                           GenrateInvoiceDialog.sendOnlyToThisEmail);
                        };
                        errorDialog.Show();
                    }
#else
                    var invoicePostingPrintGenerator = new InvoicePostingPrintGenerator(api, this);
                    invoicePostingPrintGenerator.SetUpInvoicePosting(dbVisibleOrders, InvoiceDate, GenrateInvoiceDialog.IsSimulation, CompanyLayoutType.Invoice, GenrateInvoiceDialog.ShowInvoice, GenrateInvoiceDialog.PostOnlyDelivered, GenrateInvoiceDialog.InvoiceQuickPrint,
                                                                     GenrateInvoiceDialog.SendByEmail, GenrateInvoiceDialog.sendOnlyToThisEmail, GenrateInvoiceDialog.Emails, GenrateInvoiceDialog.GenerateOIOUBLClicked);

                    await invoicePostingPrintGenerator.Execute();

                    busyIndicator.IsBusy = false;
#endif
                }
            };
            GenrateInvoiceDialog.Show();
        }
Example #21
0
        private void OrderConfirmation(CompanyLayoutType docType)
        {
#if SILVERLIGHT
            confirmOrder = new List <InvoicePostingResult>();
#endif
            UnicontaClient.Pages.CWGenerateInvoice GenrateInvoiceDialog = new UnicontaClient.Pages.CWGenerateInvoice(false, docType.ToString(), isShowInvoiceVisible: true, askForEmail: true, showInputforInvNumber: false,
                                                                                                                     showInvoice: true, isShowUpdateInv: true, isQuickPrintVisible: true, isDebtorOrder: true, isPageCountVisible: false);
#if !SILVERLIGHT
            GenrateInvoiceDialog.DialogTableId = 2000000012;
            GenrateInvoiceDialog.HideOutlookOption(true);
#endif
            GenrateInvoiceDialog.SetInvPrintPreview(printPreview);
            GenrateInvoiceDialog.Closed += async delegate
            {
                if (GenrateInvoiceDialog.DialogResult == true)
                {
                    printPreview = GenrateInvoiceDialog.ShowInvoice;
                    busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("SendingWait");
                    busyIndicator.IsBusy      = true;
                    var InvoiceDate    = GenrateInvoiceDialog.GenrateDate;
                    var updateStatus   = GenrateInvoiceDialog.UpdateInventory;
                    var dgOrderVisible = dgMultiInvGrid.GetVisibleRows() as IEnumerable <DebtorOrderClient>;
#if SILVERLIGHT
                    InvoiceAPI    Invapi    = new InvoiceAPI(api);
                    int           cnt       = 0;
                    List <string> errorList = new List <string>();
                    foreach (var dbOrder in dgOrderVisible)
                    {
                        var result = await Invapi.PostInvoice(dbOrder, null, GenrateInvoiceDialog.GenrateDate, null,
                                                              !updateStatus, new DebtorInvoiceClient(),
                                                              new DebtorInvoiceLines(), GenrateInvoiceDialog.SendByEmail, GenrateInvoiceDialog.ShowInvoice || GenrateInvoiceDialog.InvoiceQuickPrint, docType,
                                                              GenrateInvoiceDialog.Emails, GenrateInvoiceDialog.sendOnlyToThisEmail, null, null, GenrateInvoiceDialog.PostOnlyDelivered, false);

                        if (result != null && result.Err == 0 && (GenrateInvoiceDialog.ShowInvoice || GenrateInvoiceDialog.InvoiceQuickPrint))
                        {
                            DebtorOrders.Updatedata(dbOrder, docType);

                            var dc = dbOrder.Debtor;
                            if (dc == null)
                            {
                                await api.LoadCache(typeof(Debtor), true);

                                dc = dbOrder.Debtor;
                            }
                            DebtorOrders.SetDeliveryAdress(result.Header, dc, api);
                            confirmOrder.Add(result);
                            cnt++;
                        }
                        else
                        {
                            string error = string.Format("{0}:{1}", dbOrder._OrderNumber, Uniconta.ClientTools.Localization.lookup(result.Err.ToString()));
                            errorList.Add(error);
                        }
                    }
                    busyIndicator.IsBusy = false;
                    string updatedMsg = Uniconta.ClientTools.Localization.lookup("Succes");


                    if (!GenrateInvoiceDialog.IsSimulation)
                    {
                        updatedMsg = string.Format(Uniconta.ClientTools.Localization.lookup("RecordsUpdated"), cnt, Uniconta.ClientTools.Localization.lookup("DebtorOrders"));
                    }

                    int documentsPreviewPrint = confirmOrder.Count;
                    updatedMsg = updatedMsg + "\n" + string.Format(Uniconta.ClientTools.Localization.lookup("MulitDocPrintConfirmationMsg"), documentsPreviewPrint,
                                                                   string.Format("{0} {1}", Uniconta.ClientTools.Localization.lookup(docType.ToString()), Uniconta.ClientTools.Localization.lookup("Documents")));

                    if (errorList.Count == 0)
                    {
                        PreInitMulitplePreviewDocument(updatedMsg, docType, GenrateInvoiceDialog.ShowInvoice, GenrateInvoiceDialog.InvoiceQuickPrint, documentsPreviewPrint, GenrateInvoiceDialog.SendByEmail,
                                                       GenrateInvoiceDialog.sendOnlyToThisEmail);
                    }
                    else
                    {
                        CWErrorBox errorDialog = new CWErrorBox(errorList.ToArray(), true);
                        errorDialog.Closed += delegate
                        {
                            PreInitMulitplePreviewDocument(updatedMsg, docType, GenrateInvoiceDialog.ShowInvoice, GenrateInvoiceDialog.InvoiceQuickPrint, documentsPreviewPrint, GenrateInvoiceDialog.SendByEmail,
                                                           GenrateInvoiceDialog.sendOnlyToThisEmail);
                        };
                        errorDialog.Show();
                    }
#else
                    var invoicePostingPrintGenerator = new InvoicePostingPrintGenerator(api, this);
                    invoicePostingPrintGenerator.SetUpInvoicePosting(dgOrderVisible, InvoiceDate, !updateStatus, docType, GenrateInvoiceDialog.ShowInvoice, GenrateInvoiceDialog.PostOnlyDelivered,
                                                                     GenrateInvoiceDialog.InvoiceQuickPrint, GenrateInvoiceDialog.SendByEmail, GenrateInvoiceDialog.sendOnlyToThisEmail, GenrateInvoiceDialog.Emails, false);
                    await invoicePostingPrintGenerator.Execute();

                    busyIndicator.IsBusy = false;
#endif
                }
            };
            GenrateInvoiceDialog.Show();
        }