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 <DebtorOrderClient>(); 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); 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("Order"))); 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(); }
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(); }
private void GenerateInvoice() { #if !SILVERLIGHT invoicePosted = new Dictionary <InvoicePostingResult, ProjectClient>(); #elif SILVERLIGHT invoicePosted = new List <InvoicePostingResult>(); #endif var generateProjectInvoice = new CWProjectGenerateInvoice(api, BasePage.GetSystemDefaultDate(), true, true, false, true, false, true, true, true); #if SILVERLIGHT generateProjectInvoice.Height = 360.0d; #else generateProjectInvoice.DialogTableId = 2000000050; #endif generateProjectInvoice.Closed += async delegate { if (generateProjectInvoice.DialogResult == true) { busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("SendingWait"); busyIndicator.IsBusy = true; var invoiceApi = new Uniconta.API.Project.InvoiceAPI(api); int count = 0; var errorlist = new List <string>(); var projects = dgProjectMultiLineGrid.GetVisibleRows() as IEnumerable <ProjectClient>; foreach (var proj in projects) { var result = await invoiceApi.PostInvoice(proj, null, generateProjectInvoice.GenrateDate, generateProjectInvoice.IsSimulation, generateProjectInvoice.FromDate, generateProjectInvoice.ToDate, generateProjectInvoice.InvoiceCategory, new DebtorInvoiceClient(), new InvTransClient(), generateProjectInvoice.SendByEmail, true, Uniconta.DataModel.CompanyLayoutType.Invoice, generateProjectInvoice.EmailList, generateProjectInvoice.SendOnlyEmail, new GLTransClient(), null); if (result != null && result.Err == 0) { #if !SILVERLIGHT invoicePosted.Add(result, proj); #elif SILVERLIGHT invoicePosted.Add(result); #endif count++; } else { var error = string.Format("{0}:{1}", proj._Number, Uniconta.ClientTools.Localization.lookup(result.Err.ToString())); errorlist.Add(error); } } busyIndicator.IsBusy = false; string updateMsg = Uniconta.ClientTools.Localization.lookup("Success"); if (!generateProjectInvoice.IsSimulation) { updateMsg = string.Format(Uniconta.ClientTools.Localization.lookup("RecordsUpdated"), count, Uniconta.ClientTools.Localization.lookup("Project")); } if (errorlist.Count == 0) { if (UnicontaMessageBox.Show(updateMsg, Uniconta.ClientTools.Localization.lookup("Message"), MessageBoxButton.OK) == MessageBoxResult.OK) { if (generateProjectInvoice.ShowInvoice) { ShowMultipleInvoicePreview(); } } } else { var errorDialog = new CWErrorBox(errorlist.ToArray(), true); errorDialog.Closed += delegate { ShowMultipleInvoicePreview(); }; errorDialog.Show(); } } }; generateProjectInvoice.Show(); }
private void CreateMulitOrder(bool IsMultiOrder = true) { var cwCreateOrder = new CWCreateOrderFromProject(api); #if !SILVERLIGHT cwCreateOrder.DialogTableId = 2000000052; #endif cwCreateOrder.Closed += async delegate { if (cwCreateOrder.DialogResult == true) { busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("LoadingMsg"); busyIndicator.IsBusy = true; IList projectList = null; if (!IsMultiOrder) { var Arr = Array.CreateInstance(dgProjectMultiLineGrid.TableTypeUser, 1); Arr.SetValue(dgProjectMultiLineGrid.SelectedItem, 0); projectList = Arr; } else { projectList = dgProjectMultiLineGrid.GetVisibleRows(); } var invoiceApi = new Uniconta.API.Project.InvoiceAPI(api); var debtorOrderType = api.CompanyEntity.GetUserTypeNotNull(typeof(DebtorOrderClient)); var errorlist = new List <string>(); DebtorOrderClient debtorOrderInstance = null; foreach (var proj in projectList) { var selectedItem = proj as ProjectClient; debtorOrderInstance = Activator.CreateInstance(debtorOrderType) as DebtorOrderClient; var result = await invoiceApi.CreateOrderFromProject(debtorOrderInstance, selectedItem._Number, CWCreateOrderFromProject.InvoiceCategory, CWCreateOrderFromProject.GenrateDate, CWCreateOrderFromProject.FromDate, CWCreateOrderFromProject.ToDate); if (result != Uniconta.Common.ErrorCodes.Succes) { var error = string.Format("{0}: {1} - {2}", Uniconta.ClientTools.Localization.lookup("Project"), selectedItem._Number, Uniconta.ClientTools.Localization.lookup(result.ToString())); errorlist.Add(error); } } busyIndicator.IsBusy = false; if (errorlist.Count > 1) { var errorDialog = new CWErrorBox(errorlist.ToArray(), true); errorDialog.Show(); } else if (!IsMultiOrder && errorlist.Count == 0) { ShowOrderLines(debtorOrderInstance); } else if (errorlist.Count == 1) { UnicontaMessageBox.Show(errorlist[0], Uniconta.ClientTools.Localization.lookup("Error"), MessageBoxButton.OK); } else { UnicontaMessageBox.Show(Uniconta.ClientTools.Localization.lookup("SalesOrderCreated"), Uniconta.ClientTools.Localization.lookup("Message"), MessageBoxButton.OK); } } }; cwCreateOrder.Show(); }