private void CreateOrder(ProjectClient selectedItem) { #if SILVERLIGHT var cwCreateOrder = new CWCreateOrderFromProject(api); #else var cwCreateOrder = new UnicontaClient.Pages.CWCreateOrderFromProject(api, true, selectedItem); cwCreateOrder.DialogTableId = 2000000053; #endif cwCreateOrder.Closed += async delegate { if (cwCreateOrder.DialogResult == true) { busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("LoadingMsg"); busyIndicator.IsBusy = true; var debtorOrderInstance = api.CompanyEntity.CreateUserType <ProjectInvoiceProposalClient>(); var invoiceApi = new Uniconta.API.Project.InvoiceAPI(api); var result = await invoiceApi.CreateOrderFromProject(debtorOrderInstance, selectedItem._Number, CWCreateOrderFromProject.InvoiceCategory, CWCreateOrderFromProject.GenrateDate, CWCreateOrderFromProject.FromDate, CWCreateOrderFromProject.ToDate, cwCreateOrder.ProjectTask, cwCreateOrder.ProjectWorkspace); busyIndicator.IsBusy = false; if (result != ErrorCodes.Succes) { if (result == ErrorCodes.NoLinesToUpdate) { var message = string.Format("{0}. {1}?", Uniconta.ClientTools.Localization.lookup(result.ToString()), string.Format(Uniconta.ClientTools.Localization.lookup("CreateOBJ"), Uniconta.ClientTools.Localization.lookup("InvoiceProposal"))); var res = UnicontaMessageBox.Show(message, Uniconta.ClientTools.Localization.lookup("Message"), UnicontaMessageBox.YesNo); if (res == MessageBoxResult.Yes) { debtorOrderInstance.SetMaster(selectedItem); debtorOrderInstance._PrCategory = CWCreateOrderFromProject.InvoiceCategory; debtorOrderInstance._NoItemUpdate = true; var er = await api.Insert(debtorOrderInstance); if (er == ErrorCodes.Succes) { ShowOrderLines(debtorOrderInstance); } } } else { UtilDisplay.ShowErrorCode(result); } } else { ShowOrderLines(debtorOrderInstance); } } }; cwCreateOrder.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(); }
void CreateZeroInvoice(ProjectClient selectedItem) { var cwCreateZeroInvoice = new UnicontaClient.Pages.CwCreateZeroInvoice(api); #if !SILVERLIGHT cwCreateZeroInvoice.DialogTableId = 2000000067; #endif cwCreateZeroInvoice.Closed += async delegate { if (cwCreateZeroInvoice.DialogResult == true) { busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("SendingWait"); busyIndicator.IsBusy = true; var invoiceApi = new Uniconta.API.Project.InvoiceAPI(api); var result = await invoiceApi.CreateZeroInvoice(selectedItem._Number, cwCreateZeroInvoice.InvoiceCategory, cwCreateZeroInvoice.AdjustmentCategory, cwCreateZeroInvoice.Employee, cwCreateZeroInvoice.InvoiceDate, cwCreateZeroInvoice.ToDate, cwCreateZeroInvoice.Simulate, new GLTransClientTotal()); busyIndicator.IsBusy = false; busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("LoadingMsg"); var ledgerRes = result.ledgerRes; if (ledgerRes == null) { return; } if (result.Err != ErrorCodes.Succes) { Utility.ShowJournalError(ledgerRes, dgProjectGrid); } else if (cwCreateZeroInvoice.Simulate && ledgerRes.SimulatedTrans != null) { AddDockItem(TabControls.SimulatedTransactions, ledgerRes.SimulatedTrans, Uniconta.ClientTools.Localization.lookup("SimulatedTransactions"), null, true); } else { var msg = string.Format("{0} {1}={2}", Uniconta.ClientTools.Localization.lookup("JournalHasBeenPosted"), Uniconta.ClientTools.Localization.lookup("JournalPostedId"), ledgerRes.JournalPostedlId); UnicontaMessageBox.Show(msg, Uniconta.ClientTools.Localization.lookup("Message")); } } }; cwCreateZeroInvoice.Show(); }