Beispiel #1
0
        private void ShowOrderLines(ProjectInvoiceProposalClient order)
        {
            var msg = string.Format(Uniconta.ClientTools.Localization.lookup("CreatedOBJ"), Uniconta.ClientTools.Localization.lookup("InvoiceProposal"));
            var confrimationText = string.Format(" {0}. {1}:{2},{3}:{4}\r\n{5}", msg, Uniconta.ClientTools.Localization.lookup("OrderNumber"), order._OrderNumber,
                                                 Uniconta.ClientTools.Localization.lookup("Account"), order._DCAccount, string.Concat(string.Format(Uniconta.ClientTools.Localization.lookup("GoTo"), Uniconta.ClientTools.Localization.lookup("Lines")), " ?"));

            var confirmationBox = new CWConfirmationBox(confrimationText, string.Empty, false);

            confirmationBox.Closing += delegate
            {
                if (confirmationBox.DialogResult == null)
                {
                    return;
                }

                switch (confirmationBox.ConfirmationResult)
                {
                case CWConfirmationBox.ConfirmationResultEnum.Yes:
                    AddDockItem(TabControls.ProjInvoiceProposalLine, order, string.Format("{0}:{1},{2}", Uniconta.ClientTools.Localization.lookup("InvoiceProposalLine"), order._OrderNumber, order._DCAccount));
                    break;

                case CWConfirmationBox.ConfirmationResultEnum.No:
                    break;
                }
            };
            confirmationBox.Show();
        }
Beispiel #2
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);
        }
Beispiel #3
0
        void InitPage(CrudAPI crudapi)
        {
            RemoveMenuItem();
            BusyIndicator                = busyIndicator;
            dAddress.Header              = Uniconta.ClientTools.Localization.lookup("DeliveryAddr");
            layoutControl                = layoutItems;
            PrCategorylookupeditor.api   = Projectlookupeditor.api =
                Employeelookupeditor.api = leAccount.api = lePayment.api = cmbDim1.api = cmbDim2.api =
                    cmbDim3.api          = cmbDim4.api = cmbDim5.api = leTransType.api = leGroup.api = lePostingAccount.api
                                                                                                           = leLayoutGroup.api = leInvoiceAccount.api =
                                                                                                                 leDeliveryAddress.api = leApprover.api = leSplit.api = leVat.api = prTasklookupeditor.api = lePrWorkSpace.api = crudapi;

            cbDeliveryCountry.ItemsSource = Enum.GetValues(typeof(Uniconta.Common.CountryCode));
            AdjustLayout();
            if (editrow == null)
            {
                frmRibbon.DisableButtons("Delete");
                liCreatedTime.Visibility = Visibility.Collapsed;
                editrow          = CreateNew() as ProjectInvoiceProposalClient;
                editrow._Created = DateTime.MinValue;
                if (Debtor != null)
                {
                    SetFieldFromDebtor(editrow, Debtor);
                    leAccount.IsEnabled = txtName.IsEnabled = false;
                }
                if (Contact != null)
                {
                    editrow.SetMaster(Contact);
                    leAccount.IsEnabled = txtName.IsEnabled = cmbContactName.IsEnabled = false;
                }
                else if (Project != null)
                {
                    editrow.SetMaster(Project);
                    leAccount.IsEnabled           = txtName.IsEnabled = false;
                    Projectlookupeditor.IsEnabled = false;
                    SetPrCategory(editrow);
                }
            }
            else
            {
                BindContact(editrow.Debtor);
            }

            layoutItems.DataContext  = editrow;
            frmRibbon.OnItemClicked += frmRibbon_OnItemClicked;

            AcItem.ButtonClicked += AcItem_ButtonClicked;
#if !SILVERLIGHT
            editrow.PropertyChanged += Editrow_PropertyChanged;
            AcItem.ToolTip           = string.Format(Uniconta.ClientTools.Localization.lookup("CreateOBJ"), Uniconta.ClientTools.Localization.lookup("Debtor"));
#endif
            StartLoadCache();
        }
Beispiel #4
0
        async void SetFieldFromDebtor(ProjectInvoiceProposalClient editrow, Debtor debtor)
        {
            if (debtor == null)
            {
                return;
            }
            var loadedOrder = LoadedRow as DCOrder;

            editrow.SetMaster(debtor);
            if (!RecordLoadedFromTemplate || debtor._DeliveryAddress1 != null)
            {
                editrow.DeliveryName     = debtor._DeliveryName;
                editrow.DeliveryAddress1 = debtor._DeliveryAddress1;
                editrow.DeliveryAddress2 = debtor._DeliveryAddress2;
                editrow.DeliveryAddress3 = debtor._DeliveryAddress3;
                editrow.DeliveryCity     = debtor._DeliveryCity;
                if (editrow.DeliveryZipCode != debtor._DeliveryZipCode)
                {
                    lookupZipCode           = false;
                    editrow.DeliveryZipCode = debtor._DeliveryZipCode;
                }
                if (debtor._DeliveryCountry != 0)
                {
                    editrow.DeliveryCountry = debtor._DeliveryCountry;
                }
                else
                {
                    editrow.DeliveryCountry = null;
                }
            }
            if (ProjectCache != null)
            {
                Projectlookupeditor.cache = ProjectCache;
            }

            TableField.SetUserFieldsFromRecord(debtor, editrow);
            BindContact(debtor);
            if (installationCache != null)
            {
                leDeliveryAddress.cacheFilter = new AccountCacheFilter(installationCache, 1, debtor._Account);
                leDeliveryAddress.InvalidCache();
            }
            layoutItems.DataContext = null;
            layoutItems.DataContext = editrow;

            await api.Read(debtor);

            editrow.RefreshBalance();
        }
Beispiel #5
0
        async private void ShowProformaInvoice(ProjectInvoiceProposalClient order)
        {
            var invoicePostingResult = SetupInvoicePostingPrintGenerator(order, DateTime.Now, true, true, false, false, 0, false, false, false, null, false);

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

            busyIndicator.IsBusy = false;

            if (!result)
            {
                Utility.ShowJournalError(invoicePostingResult.PostingResult.ledgerRes, dgProjInvProposedLineGrid);
            }
        }
Beispiel #6
0
        async void SetPrCategory(ProjectInvoiceProposalClient editrow)
        {
            var cats = api.GetCache(typeof(Uniconta.DataModel.PrCategory)) ?? await api.LoadCache(typeof(Uniconta.DataModel.PrCategory));

            foreach (var rec in (Uniconta.DataModel.PrCategory[])cats.GetNotNullArray)
            {
                if (rec._CatType == CategoryType.OnAccountInvoicing)
                {
                    editrow.PrCategory = rec._Number;
                    if (rec._Default)
                    {
                        break;
                    }
                }
            }
        }
Beispiel #7
0
        private void GenerateRecordInvoice(ProjectInvoiceProposalClient 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);
            GenrateInvoiceDialog.DialogTableId = 2000000013;
            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();
        }
        async void jumpToDebtor(ProjectInvoiceProposalClient selectedItem)
        {
            var dc = selectedItem.Debtor;

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

                dc = selectedItem.Debtor;
                if (dc == null)
                {
                    return;
                }
            }
            var param = new object[2] {
                dc, true
            };

            AddDockItem(TabControls.DebtorAccountPage2, param, string.Format("{0}: {1}", Uniconta.ClientTools.Localization.lookup("DebtorAccount"), dc._Account));
        }
Beispiel #9
0
        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(ProjectInvoiceProposalClient));
                    var errorlist       = new List <string>();
                    ProjectInvoiceProposalClient debtorOrderInstance = null;
                    foreach (var proj in projectList)
                    {
                        var selectedItem = proj as ProjectClient;
                        debtorOrderInstance = Activator.CreateInstance(debtorOrderType) as ProjectInvoiceProposalClient;
                        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("InvProposalCreated"), Uniconta.ClientTools.Localization.lookup("Message"), MessageBoxButton.OK);
                    }
                }
            };
            cwCreateOrder.Show();
        }
        private void GenerateInvoice(ProjectInvoiceProposalClient projInvProp)
        {
            InvoiceAPI Invapi         = new InvoiceAPI(api);
            bool       showSendByMail = false;

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

            if (debtor != null)
            {
                var InvoiceAccount = projInvProp._InvoiceAccount ?? debtor._InvoiceAccount;
                if (InvoiceAccount != null)
                {
                    debtor = ClientHelper.GetRef(projInvProp.CompanyId, typeof(Debtor), InvoiceAccount) as Debtor;
                }
                if (debtor != null)
                {
                    if (debtor._PricesInclVat != projInvProp._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(projInvProp._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), projInvProp.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 ?? projInvProp._DCAccount;
            bool              invoiceInXML         = debtor?._InvoiceInXML ?? false;
            var               accountName          = string.Format("{0} ({1})", projInvProp._DCAccount, projInvProp.Name);
            CWGenerateInvoice GenrateInvoiceDialog = new CWGenerateInvoice(true, string.Empty, false, true, true, showNoEmailMsg: !showSendByMail, debtorName: debtorName, isOrderOrQuickInv: true, isDebtorOrder: true,
                                                                           InvoiceInXML: invoiceInXML, AccountName: accountName);

            GenrateInvoiceDialog.DialogTableId = 2000000085;
            if (projInvProp._InvoiceDate != DateTime.MinValue)
            {
                GenrateInvoiceDialog.SetInvoiceDate(projInvProp._InvoiceDate);
            }
            var additionalOrdersList = Utility.GetAdditionalOrders(api, projInvProp);

            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(projInvProp, 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)
                        {
                            dgProjInvProposalGrid.UpdateItemSource(3, dgProjInvProposalGrid.SelectedItem as ProjectInvoiceProposalClient);
                        }
                    }
                    else
                    {
                        Utility.ShowJournalError(invoicePostingResult.PostingResult.ledgerRes, dgProjInvProposalGrid);
                    }
                }
            };
            GenrateInvoiceDialog.Show();
        }
Beispiel #11
0
        private void GenerateInvoice(ProjectInvoiceProposalClient dbOrder, bool showProformaInvoice)
        {
            var savetask = saveGridLocal();
            var curpanel = dockCtrl.Activpanel;

            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("Warning"), 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("Warning"), MessageBoxButton.OKCancel);
                        if (confirmationMsgBox != MessageBoxResult.OK)
                        {
                            return;
                        }
                    }
                    showSendByMail = (!string.IsNullOrEmpty(debtor._InvoiceEmail) || debtor._EmailDocuments);
                }
            }

            if (showProformaInvoice)
            {
                ShowProformaInvoice(dbOrder);
                return;
            }

            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);

            GenrateInvoiceDialog.DialogTableId = 2000000086;
            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)
                {
                    if (savetask != null)
                    {
                        var err = await savetask;
                        if (err != ErrorCodes.Succes)
                        {
                            return;
                        }
                    }
                    busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("SendingWait");
                    busyIndicator.IsBusy      = true;
                    InvoiceAPI Invapi               = new InvoiceAPI(api);
                    var        isSimulated          = GenrateInvoiceDialog.IsSimulation;
                    var        invoicePostingResult = SetupInvoicePostingPrintGenerator(dbOrder, GenrateInvoiceDialog.GenrateDate, isSimulated, GenrateInvoiceDialog.ShowInvoice, GenrateInvoiceDialog.PostOnlyDelivered, GenrateInvoiceDialog.InvoiceQuickPrint,
                                                                                        GenrateInvoiceDialog.NumberOfPages, GenrateInvoiceDialog.SendByEmail, !isSimulated && GenrateInvoiceDialog.SendByOutlook, GenrateInvoiceDialog.sendOnlyToThisEmail, GenrateInvoiceDialog.Emails,
                                                                                        GenrateInvoiceDialog.GenerateOIOUBLClicked);
                    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)
                    {
                        Utility.ShowJournalError(invoicePostingResult.PostingResult.ledgerRes, dgProjInvProposedLineGrid);
                    }
                    else
                    {
                        Task reloadTask = null;
                        if (!GenrateInvoiceDialog.IsSimulation && dbOrder._DeleteLines)
                        {
                            reloadTask = Filter(null);
                        }

                        if (reloadTask != null)
                        {
                            CloseOrderLineScreen(reloadTask, curpanel);
                        }
                    }
                }
            };
            GenrateInvoiceDialog.Show();
        }
Beispiel #12
0
        private void localMenu_OnItemClicked(string ActionType)
        {
            ProjectInvoiceProposalLineClient row;
            ProjectInvoiceProposalClient     ord = this.Order;
            var selectedItem = dgProjInvProposedLineGrid.SelectedItem as ProjectInvoiceProposalLineClient;

            switch (ActionType)
            {
            case "AddRow":
                addingRow         = true;
                row               = dgProjInvProposedLineGrid.AddRow() as ProjectInvoiceProposalLineClient;
                row._ExchangeRate = this.exchangeRate;
                break;

            case "CopyRow":
                if (selectedItem != null)
                {
                    row = dgProjInvProposedLineGrid.CopyRow() as ProjectInvoiceProposalLineClient;
                    row._ExchangeRate  = this.exchangeRate;
                    row._CostPriceLine = selectedItem._CostPriceLine;
                    row._QtyDelivered  = 0;
                    row._QtyInvoiced   = 0;
                }
                break;

            case "SaveGrid":
                saveGridLocal();
                break;

            case "DeleteRow":
                dgProjInvProposedLineGrid.DeleteRow();
                break;

            case "ShowInvoice":
            case "CreateInvoice":
                if (ord != null)
                {
                    if (Utility.HasControlRights("GenerateInvoice", api.CompanyEntity))
                    {
                        GenerateInvoice(ord, ActionType == "ShowInvoice" ? true : false);
                    }
                    else
                    {
                        UtilDisplay.ShowControlAccessMsg("GenerateInvoice");
                    }
                }
                break;

            case "InsertSubTotal":
                row = dgProjInvProposedLineGrid.AddRow() as ProjectInvoiceProposalLineClient;
                if (row != null)
                {
                    row.Subtotal = true;
                }
                break;

            case "AddItems":
                if (this.items != null)
                {
                    object[] paramArray = new object[3] {
                        new InvItemSalesCacheFilter(this.items), dgProjInvProposedLineGrid.TableTypeUser, Order
                    };
                    AddDockItem(TabControls.AddMultipleInventoryItem, paramArray, true,
                                string.Format(Uniconta.ClientTools.Localization.lookup("AddOBJ"), Uniconta.ClientTools.Localization.lookup("InventoryItems")), null, floatingLoc: Utility.GetDefaultLocation());
                }
                break;

            case "EditOrder":
                if (ord != null)
                {
                    AddDockItem(TabControls.ProjInvProposalPage2, ord, string.Format("{0}: {1}", Uniconta.ClientTools.Localization.lookup("Orders"), ord._OrderNumber));
                }
                break;

            case "ProjectTransaction":
                if (ord != null)
                {
                    saveGridLocal();
                    AddDockItem(TabControls.ProjectInvoiceProjectLinePage, ord, string.Format("{0}: {1} ({2})", Uniconta.ClientTools.Localization.lookup("ProjectAdjustments"), ord._OrderNumber, ord._Project));
                }
                break;

            case "RegenerateOrderFromProject":
                if (ord != null)
                {
                    AddDockItem(TabControls.RegenerateOrderFromProjectPage, ord, string.Format("{0}: {1}", Uniconta.ClientTools.Localization.lookup("RegenerateOrder"), ord._OrderNumber));
                }
                break;

            case "AddVariants":
                var itm = selectedItem?.InvItem;
                if (itm?._StandardVariant != null)
                {
                    var paramItem = new object[] { selectedItem, ord };
                    dgProjInvProposedLineGrid.SetLoadedRow(selectedItem);
                    AddDockItem(TabControls.ItemVariantAddPage, paramItem, true,
                                string.Format(Uniconta.ClientTools.Localization.lookup("AddOBJ"), Uniconta.ClientTools.Localization.lookup("Variants")), null, floatingLoc: Utility.GetDefaultLocation());
                }
                break;

            case "CreateFromInvoice":
                try
                {
                    CWCreateOrderFromQuickInvoice createOrderCW = new CWCreateOrderFromQuickInvoice(api, ord.Account, true, ord);
                    createOrderCW.Closing += delegate
                    {
                        if (createOrderCW.DialogResult == true)
                        {
                            var orderApi          = new OrderAPI(api);
                            var checkIfCreditNote = createOrderCW.chkIfCreditNote.IsChecked.HasValue ? createOrderCW.chkIfCreditNote.IsChecked.Value : false;
                            var debtorInvoice     = createOrderCW.dgCreateOrderGrid.SelectedItem as DebtorInvoiceClient;
                            dgProjInvProposedLineGrid.PasteRows(createOrderCW.DCOrderLines);
                        }
                    };
                    createOrderCW.Show();
                }
                catch (Exception ex)
                {
                    UnicontaMessageBox.Show(ex);
                }
                break;

            case "RefreshGrid":
                RefreshGrid();
                break;

            default:
                gridRibbon_BaseActions(ActionType);
                break;
            }
            RecalculateAmount();
        }