private void OrderConfirmation(CompanyLayoutType docType) { #if SILVERLIGHT confirmOrder = new List <InvoicePostingResult>(); #else confirmOrder = new Dictionary <InvoicePostingResult, DebtorOrderClient>(); #endif UnicontaClient.Pages.CWGenerateInvoice GenrateInvoiceDialog = new UnicontaClient.Pages.CWGenerateInvoice(false, Uniconta.ClientTools.Localization.lookup(docType.ToString()), isShowInvoiceVisible: true, askForEmail: true, showInputforInvNumber: false, showInvoice: true, isShowUpdateInv: true, isQuickPrintVisible: true, isDebtorOrder: true, isPageCountVisible: false); #if !SILVERLIGHT GenrateInvoiceDialog.DialogTableId = 2000000012; #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; InvoiceAPI Invapi = new InvoiceAPI(api); int cnt = 0; List <string> errorList = new List <string>(); var dgOrderVisible = dgMultiInvGrid.GetVisibleRows() as IEnumerable <DebtorOrderClient>; foreach (var dbOrder in dgOrderVisible) { var result = await Invapi.PostInvoice(dbOrder, null, GenrateInvoiceDialog.GenrateDate, 0, !updateStatus, new DebtorInvoiceClient(), new DebtorInvoiceLines(), GenrateInvoiceDialog.SendByEmail, GenrateInvoiceDialog.ShowInvoice || GenrateInvoiceDialog.InvoiceQuickPrint, docType, GenrateInvoiceDialog.Emails, GenrateInvoiceDialog.sendOnlyToThisEmail, null, null, GenrateInvoiceDialog.PostOnlyDelivered); if (result != null && result.Err == 0 && (GenrateInvoiceDialog.ShowInvoice || GenrateInvoiceDialog.InvoiceQuickPrint)) { DebtorOrders.Updatedata(dbOrder, docType); var dc = dbOrder.Debtor; if (dc == null) { await api.CompanyEntity.LoadCache(typeof(Debtor), api, true); dc = dbOrder.Debtor; } DebtorOrders.SetDeliveryAdress(result.Header, dc, api); #if SILVERLIGHT confirmOrder.Add(result); #else confirmOrder.Add(result, dbOrder); #endif 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) { if ((GenrateInvoiceDialog.ShowInvoice || GenrateInvoiceDialog.InvoiceQuickPrint) && confirmOrder.Count > 0) { InitMultiplePreviewDocument(updatedMsg, docType, GenrateInvoiceDialog.InvoiceQuickPrint); } } else { CWErrorBox errorDialog = new CWErrorBox(errorList.ToArray(), true); errorDialog.Closed += delegate { if ((GenrateInvoiceDialog.ShowInvoice || GenrateInvoiceDialog.InvoiceQuickPrint) && confirmOrder.Count > 0) { InitMultiplePreviewDocument(updatedMsg, docType, GenrateInvoiceDialog.InvoiceQuickPrint); } }; errorDialog.Show(); } } }; GenrateInvoiceDialog.Show(); }
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(); }