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(); }
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(); }
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 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 GenerateInvoice() { #if SILVERLIGHT invoicePosted = new List <InvoicePostingResult>(); #else invoicePosted = new Dictionary <InvoicePostingResult, DebtorOrderClient>(); #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; #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; InvoiceAPI Invapi = new InvoiceAPI(api); int cnt = 0; List <string> errorList = new List <string>(); var dbVisibleOrders = dgMultiInvGrid.GetVisibleRows() as IEnumerable <DebtorOrderClient>; foreach (var dbOrder in dbVisibleOrders) { if (dbOrder._SubscriptionEnded != DateTime.MinValue && dbOrder._SubscriptionEnded < InvoiceDate) { continue; } var result = await Invapi.PostInvoice(dbOrder, null, InvoiceDate, 0, GenrateInvoiceDialog.IsSimulation, new DebtorInvoiceClient(), new DebtorInvoiceLines(), GenrateInvoiceDialog.SendByEmail, (GenrateInvoiceDialog.ShowInvoice || GenrateInvoiceDialog.InvoiceQuickPrint || GenrateInvoiceDialog.GenerateOIOUBLClicked), 0, GenrateInvoiceDialog.Emails, GenrateInvoiceDialog.sendOnlyToThisEmail, null, null, GenrateInvoiceDialog.PostOnlyDelivered); if (result != null && result.Err == 0) { #if SILVERLIGHT invoicePosted.Add(result); #else invoicePosted.Add(result, dbOrder); #endif cnt++; var dc = dbOrder.Debtor; if (dc == null) { await api.CompanyEntity.LoadCache(typeof(Debtor), api, 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")); } #if !SILVERLIGHT if (GenrateInvoiceDialog.GenerateOIOUBLClicked && !GenrateInvoiceDialog.IsSimulation) { GenerateOIOXmlForAll(errorList, !GenrateInvoiceDialog.SendByEmail); } #endif int previewInvoiceCount = invoicePosted.Count; updatedMsg = updatedMsg + "\n" + string.Format(Uniconta.ClientTools.Localization.lookup("MulitDocPrintConfirmationMsg"), previewInvoiceCount, Uniconta.ClientTools.Localization.lookup("Invoices")); if (errorList.Count == 0) { if ((GenrateInvoiceDialog.ShowInvoice || GenrateInvoiceDialog.InvoiceQuickPrint) && previewInvoiceCount > 0) { InitMultiplePreviewDocument(updatedMsg, CompanyLayoutType.Invoice, GenrateInvoiceDialog.InvoiceQuickPrint); } } else { CWErrorBox errorDialog = new CWErrorBox(errorList.ToArray(), true); errorDialog.Closed += delegate { if ((GenrateInvoiceDialog.ShowInvoice || GenrateInvoiceDialog.InvoiceQuickPrint) && previewInvoiceCount > 0) { InitMultiplePreviewDocument(updatedMsg, CompanyLayoutType.Invoice, GenrateInvoiceDialog.InvoiceQuickPrint); } }; errorDialog.Show(); } } }; GenrateInvoiceDialog.Show(); }