Ejemplo n.º 1
0
        private void localMenu_OnItemClicked(string ActionType)
        {
            switch (ActionType)
            {
            case "AddRow":
                var row = dgCreditorOrderLineGrid.AddRow() as DCOrderLine;
                row._ExchangeRate = this.exchangeRate;
                break;

            case "CopyRow":
                dgCreditorOrderLineGrid.CopyRow();
                break;

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

            case "Storage":
                AddDockItem(TabControls.InvItemStoragePage, dgCreditorOrderLineGrid.syncEntity, true);
                break;

            case "ShowInvoice":
            case "GenerateInvoice":
                if (!string.IsNullOrEmpty(Order.Account))
                {
                    if (Utility.HasControlRights("GenerateInvoice", api.CompanyEntity))
                    {
                        GenerateInvoice(Order, ActionType == "ShowInvoice" ? true: false);
                    }
                    else
                    {
                        UtilDisplay.ShowControlAccessMsg("GenerateInvoice");
                    }
                }
                else
                {
                    string strmg = string.Format(Uniconta.ClientTools.Localization.lookup("CannotBeBlank"),
                                                 Uniconta.ClientTools.Localization.lookup("Account"));
                    UnicontaMessageBox.Show(strmg, Uniconta.ClientTools.Localization.lookup("Error"),
                                            MessageBoxButton.OK);
                }
                break;

            case "RefVoucher":
                var _refferedVouchers = new List <int>();
                if (Order._DocumentRef != 0)
                {
                    _refferedVouchers.Add(Order._DocumentRef);
                }

                AddDockItem(TabControls.AttachVoucherGridPage, new object[1] {
                    _refferedVouchers
                }, true);
                break;

            case "ShowVoucher":
                busyIndicator.IsBusy = true;
                ViewVoucher(TabControls.VouchersPage3, Order);
                busyIndicator.IsBusy = false;
                break;

            case "ImportVoucher":
                if (Order == null)
                {
                    return;
                }
                VouchersClient voucher = new VouchersClient();
                voucher._Content         = ContentTypes.PurchaseInvoice;
                voucher._Amount          = Order.InvoiceAmount;
                voucher._CreditorAccount = Order._DCAccount;
                CWAddVouchers addVouvhersDialog = new CWAddVouchers(api, voucher: voucher);
                addVouvhersDialog.Closed += delegate
                {
                    if (addVouvhersDialog.DialogResult == true)
                    {
                        if (addVouvhersDialog.VoucherRowIds.Length > 0)
                        {
                            Order.DocumentRef   = addVouvhersDialog.VoucherRowIds[0];
                            Order.InvoiceAmount = addVouvhersDialog.vouchersClient._Amount;
                            Order.InvoiceNumber = addVouvhersDialog.vouchersClient.Invoice;
                        }
                    }
                };
                addVouvhersDialog.Show();
                break;

            case "RemoveVoucher":
                RemoveVoucher(Order);
                break;

            case "InsertSubTotal":
                var dbOrderLineClient = new CreditorOrderLineClient {
                    Subtotal = true
                };
                dgCreditorOrderLineGrid.AddRow(dbOrderLineClient);
                break;

            case "ReadOIOUBL":
                ReadOIOUBL();
                break;

            case "StockLines":
                if (dgCreditorOrderLineGrid.SelectedItem == null)
                {
                    return;
                }

                var credOrderLine = dgCreditorOrderLineGrid.SelectedItem as CreditorOrderLineClient;
                if (!string.IsNullOrEmpty(credOrderLine._Item))
                {
                    AddDockItem(TabControls.CreditorInvoiceLine, credOrderLine, string.Format("{0}: {1}", Uniconta.ClientTools.Localization.lookup("InvTransaction"), credOrderLine._Item));
                }
                break;

            case "AttachDoc":
                AttachDocuments();
                break;

            case "AddItems":
                if (this.items == null)
                {
                    return;
                }
                object[] paramArray = new object[3] {
                    new InvItemPurchaseCacheFilter(this.items), dgCreditorOrderLineGrid.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 "AddVariants":
                if (dgCreditorOrderLineGrid.SelectedItem == null)
                {
                    return;
                }
                var orderLine = dgCreditorOrderLineGrid.SelectedItem as CreditorOrderLineClient;
                var itm       = orderLine?.InvItem;
                if (itm?._StandardVariant != null)
                {
                    var paramItem = new object[] { orderLine, Order };
                    dgCreditorOrderLineGrid.SetLoadedRow(orderLine);
                    AddDockItem(TabControls.ItemVariantAddPage, paramItem, true,
                                string.Format(Uniconta.ClientTools.Localization.lookup("AddOBJ"), Uniconta.ClientTools.Localization.lookup("Variants")), null, floatingLoc: Utility.GetDefaultLocation());
                }
                break;

            default:
                gridRibbon_BaseActions(ActionType);
                break;
            }
            RecalculateAmount();
        }
Ejemplo n.º 2
0
        private void localMenu_OnItemClicked(string ActionType)
        {
            var    dgDebtorOrdersGrid = this.dgDebtorOrdersGrid;
            var    selectedItem       = dgDebtorOrdersGrid.SelectedItem as DebtorOrderClient;
            string salesHeader        = string.Empty;

            if (selectedItem != null)
            {
                salesHeader = string.Format("{0}:{1}", Uniconta.ClientTools.Localization.lookup("Orders"), selectedItem._OrderNumber);
            }
            switch (ActionType)
            {
            case "AddRow":
                if (dgDebtorOrdersGrid.masterRecords != null)
                {
                    object[] arr = new object[2] {
                        api, dgDebtorOrdersGrid.masterRecord
                    };
                    AddDockItem(TabControls.DebtorOrdersPage2, arr, Uniconta.ClientTools.Localization.lookup("Orders"), "Add_16x16.png");
                }
                else
                {
                    AddDockItem(TabControls.DebtorOrdersPage2, api, Uniconta.ClientTools.Localization.lookup("Orders"), "Add_16x16.png");
                }
                break;

            case "EditRow":
                if (selectedItem == null)
                {
                    return;
                }
                if (dgDebtorOrdersGrid.masterRecords != null)
                {
                    object[] arr = new object[2] {
                        selectedItem, dgDebtorOrdersGrid.masterRecord
                    };
                    AddDockItem(TabControls.DebtorOrdersPage2, arr, salesHeader);
                }
                else
                {
                    AddDockItem(TabControls.DebtorOrdersPage2, selectedItem, salesHeader);
                }
                break;

            case "OrderLine":
                if (selectedItem == null)
                {
                    return;
                }
                var olheader = string.Format("{0}:{1},{2}", Uniconta.ClientTools.Localization.lookup("OrdersLine"), selectedItem._OrderNumber, selectedItem.Name);
                AddDockItem(TabControls.DebtorOrderLines, dgDebtorOrdersGrid.syncEntity, olheader);
                break;

            case "Invoices":
                AddDockItem(TabControls.Invoices, selectedItem, salesHeader);
                break;

            case "AddNote":
                if (selectedItem != null)
                {
                    string header = string.Format("{0} : {1}", Uniconta.ClientTools.Localization.lookup("UserNotesInfo"), selectedItem._OrderNumber);
                    AddDockItem(TabControls.UserNotesPage, dgDebtorOrdersGrid.syncEntity, header);
                }
                break;

            case "AddDoc":
                if (selectedItem != null)
                {
                    string header = string.Format("{0} : {1}", Uniconta.ClientTools.Localization.lookup("Documents"), selectedItem._OrderNumber);
                    AddDockItem(TabControls.UserDocsPage, dgDebtorOrdersGrid.syncEntity, header);
                }
                break;

            case "Contacts":
                if (selectedItem == null)
                {
                    return;
                }
                AddDockItem(TabControls.ContactPage, selectedItem);
                break;

            case "OrderConfirmation":
                if (selectedItem != null)
                {
                    OrderConfirmation(selectedItem, CompanyLayoutType.OrderConfirmation);
                }
                break;

            case "PackNote":
                if (selectedItem != null)
                {
                    OrderConfirmation(selectedItem, CompanyLayoutType.Packnote);
                }
                break;

            case "PickList":
                if (selectedItem != null)
                {
                    PickingListReport(selectedItem);
                }
                break;

            case "EditDebtor":
                if (selectedItem?._DCAccount != null)
                {
                    jumpToDebtor(selectedItem);
                }
                break;

            case "CreateOrder":
                if (selectedItem != null)
                {
                    CWOrderFromOrder cwOrderFromOrder = new CWOrderFromOrder(api);
#if !SILVERLIGHT
                    cwOrderFromOrder.DialogTableId = 2000000020;
#endif
                    cwOrderFromOrder.Closed += async delegate
                    {
                        if (cwOrderFromOrder.DialogResult == true)
                        {
                            var perSupplier = cwOrderFromOrder.orderPerPurchaseAccount;
                            if (!perSupplier && string.IsNullOrEmpty(cwOrderFromOrder.Account))
                            {
                                return;
                            }
                            busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("SendingWait");
                            busyIndicator.IsBusy      = true;
                            var orderApi       = new OrderAPI(api);
                            var inversign      = cwOrderFromOrder.InverSign;
                            var account        = cwOrderFromOrder.Account;
                            var copyAttachment = cwOrderFromOrder.copyAttachment;
                            var dcOrder        = cwOrderFromOrder.dcOrder;
                            dcOrder._DeliveryDate = cwOrderFromOrder.DeliveryDate;
                            var copyDelAddress   = cwOrderFromOrder.copyDeliveryAddress;
                            var reCalPrice       = cwOrderFromOrder.reCalculatePrice;
                            var onlyItemsWthSupp = cwOrderFromOrder.onlyItemsWithSupplier;
                            var result           = await orderApi.CreateOrderFromOrder(selectedItem, dcOrder, account, inversign, CopyAttachments : copyAttachment, CopyDeliveryAddress : copyDelAddress, RecalculatePrices : reCalPrice, OrderPerPurchaseAccount : perSupplier, OnlyItemsWithSupplier : onlyItemsWthSupp);

                            busyIndicator.IsBusy = false;
                            if (result != ErrorCodes.Succes)
                            {
                                UtilDisplay.ShowErrorCode(result);
                            }
                            else
                            {
                                CreditorOrders.ShowOrderLines(1, dcOrder, this, dgDebtorOrdersGrid);
                            }
                        }
                    };
                    cwOrderFromOrder.Show();
                }
                break;

            case "EditAll":
                if (dgDebtorOrdersGrid.Visibility == Visibility.Visible)
                {
                    EditAll();
                }
                break;

            case "AddLine":
                dgDebtorOrdersGrid.AddRow();
                break;

            case "CopyRow":
                dgDebtorOrdersGrid.CopyRow();
                break;

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

            case "UndoDelete":
                dgDebtorOrdersGrid.UndoDeleteRow();
                break;

            case "SaveGrid":
                Save();
                break;

            case "CreateInvoice":
                if (selectedItem != null)
                {
                    if (Utility.HasControlRights("GenerateInvoice", api.CompanyEntity))
                    {
                        GenerateInvoice(selectedItem);
                    }
                    else
                    {
                        UtilDisplay.ShowControlAccessMsg("GenerateInvoice");
                    }
                }
                break;

            case "ProjectTransaction":
                if (selectedItem?._Project != null)
                {
                    AddDockItem(TabControls.DebtorOrderProjectLinePage, dgDebtorOrdersGrid.syncEntity, string.Format("{0}: {1}", Uniconta.ClientTools.Localization.lookup("ProjectAdjustments"), selectedItem._OrderNumber));
                }
                break;

            case "RefreshGrid":
                TestDebtorReload(true, dgDebtorOrdersGrid.ItemsSource as IEnumerable <DebtorOrder>);
                break;

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

            case "ApproveOrder":
                if (selectedItem != null && api.CompanyEntity.ApproveSalesOrders)
                {
                    Utility.ApproveOrder(api, selectedItem);
                }
                break;

            default:
                gridRibbon_BaseActions(ActionType);
                break;
            }
        }
Ejemplo n.º 3
0
        private void LocalMenu_OnItemClicked(string ActionType)
        {
            var selectedItem = dgMultiInvGrid.SelectedItem as CreditorOrderClient;

            switch (ActionType)
            {
            case "EditRow":
                if (selectedItem == null)
                {
                    return;
                }
                string salesHeader = string.Format("{0}:{1}", Uniconta.ClientTools.Localization.lookup("Orders"), selectedItem._OrderNumber);
                if (dgMultiInvGrid.masterRecords != null)
                {
                    object[] arr = new object[2] {
                        selectedItem, dgMultiInvGrid.masterRecord
                    };
                    AddDockItem(TabControls.CreditorOrdersPage2, arr, salesHeader);
                }
                else
                {
                    AddDockItem(TabControls.CreditorOrdersPage2, selectedItem, salesHeader);
                }
                break;

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

            case "OrderLine":
                if (selectedItem == null)
                {
                    return;
                }
                var olheader = string.Format("{0}:{1},{2}", Uniconta.ClientTools.Localization.lookup("PurchaseLines"), selectedItem._OrderNumber, selectedItem.Name);
                AddDockItem(TabControls.CreditorOrderLines, dgMultiInvGrid.syncEntity, olheader);
                break;

            case "GenerateInvoice":
                if (Utility.HasControlRights("GenerateInvoice", api.CompanyEntity))
                {
                    GenerateInvoice();
                }
                else
                {
                    UtilDisplay.ShowControlAccessMsg("GenerateInvoice");
                }
                break;

            case "RefVoucher":
                if (selectedItem == null)
                {
                    return;
                }
                var _refferedVouchers = new List <int>();
                if (selectedItem._DocumentRef != 0)
                {
                    _refferedVouchers.Add(selectedItem._DocumentRef);
                }

                AddDockItem(TabControls.AttachVoucherGridPage, new object[1] {
                    _refferedVouchers
                }, true);
                break;

            case "ViewVoucher":
                if (selectedItem == null)
                {
                    return;
                }
                busyIndicator.IsBusy = true;
                ViewVoucher(TabControls.VouchersPage3, selectedItem);
                busyIndicator.IsBusy = false;
                break;

            case "ImportVoucher":
                if (selectedItem == null)
                {
                    return;
                }
                var voucher = new VouchersClient();
                voucher._Content         = ContentTypes.PurchaseInvoice;
                voucher._PurchaseNumber  = selectedItem._OrderNumber;
                voucher._CreditorAccount = selectedItem._InvoiceAccount ?? selectedItem._DCAccount;
                CWAddVouchers addVouvhersDialog = new CWAddVouchers(api, false, voucher);
                addVouvhersDialog.Closed += delegate
                {
                    if (addVouvhersDialog.DialogResult == true)
                    {
                        if (addVouvhersDialog.VoucherRowIds.Length > 0)
                        {
                            selectedItem._DocumentRef = addVouvhersDialog.VoucherRowIds[0];
                        }
                    }
                };
                addVouvhersDialog.Show();
                break;

            case "RemoveVoucher":
                if (selectedItem != null)
                {
                    RemoveVoucher(selectedItem);
                }
                break;

            case "UpdateRequisition":
                UpdateDocument(CompanyLayoutType.Requisition);
                break;

            case "UpdatePurchaseOrder":
                UpdateDocument(CompanyLayoutType.PurchaseOrder);
                break;

            case "UpdateDeliveryNote":
                UpdateDocument(CompanyLayoutType.PurchasePacknote);
                break;

            case "RecalculateOrderPrices":
                RecalculateOrderPrices();
                break;

            default:
                gridRibbon_BaseActions(ActionType);
                break;
            }
        }
Ejemplo n.º 4
0
        private void LocalMenu_OnItemClicked(string ActionType)
        {
            var selectedItem = dgMultiInvGrid.SelectedItem as DebtorOrderClient;

            switch (ActionType)
            {
            case "EditRow":
                if (selectedItem == null)
                {
                    return;
                }
                string salesHeader = string.Format("{0}:{1}", Uniconta.ClientTools.Localization.lookup("Orders"), selectedItem._OrderNumber);
                if (dgMultiInvGrid.masterRecords != null)
                {
                    object[] arr = new object[2] {
                        selectedItem, dgMultiInvGrid.masterRecord
                    };
                    AddDockItem(TabControls.DebtorOrdersPage2, arr, salesHeader);
                }
                else
                {
                    AddDockItem(TabControls.DebtorOrdersPage2, selectedItem, salesHeader);
                }
                break;

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

            case "OrderLine":
                if (selectedItem == null)
                {
                    return;
                }
                var olheader = string.Format("{0}:{1},{2}", Uniconta.ClientTools.Localization.lookup("OrdersLine"), selectedItem._OrderNumber, selectedItem.Name);
                AddDockItem(TabControls.DebtorOrderLines, dgMultiInvGrid.syncEntity, olheader);
                break;

            case "GenerateInvoice":
                if (Utility.HasControlRights("GenerateInvoice", api.CompanyEntity))
                {
                    GenerateInvoice();
                }
                else
                {
                    UtilDisplay.ShowControlAccessMsg("GenerateInvoice");
                }
                break;

            case "GenerateInvoice2":
                if (selectedItem != null)
                {
                    if (Utility.HasControlRights("GenerateInvoice", api.CompanyEntity))
                    {
                        var debtor = ClientHelper.GetRef(selectedItem.CompanyId, typeof(Debtor), selectedItem._DCAccount) as Debtor;
                        if (debtor != null)
                        {
                            var InvoiceAccount = selectedItem._InvoiceAccount ?? debtor._InvoiceAccount;
                            if (InvoiceAccount != null)
                            {
                                debtor = ClientHelper.GetRef(selectedItem.CompanyId, typeof(Debtor), InvoiceAccount) as Debtor;
                            }
                            if (debtor._PricesInclVat != selectedItem._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;
                                }
                            }
                        }
                        GenerateRecordInvoice(selectedItem);
                    }
                    else
                    {
                        UtilDisplay.ShowControlAccessMsg("GenerateInvoice");
                    }
                }
                break;

            case "OrderConfirmation":
                OrderConfirmation(CompanyLayoutType.OrderConfirmation);
                break;

            case "PackNote":
                OrderConfirmation(CompanyLayoutType.Packnote);
                break;

            case "PickList":
                PickList();
                break;

            default:
                gridRibbon_BaseActions(ActionType);
                break;
            }
        }
Ejemplo n.º 5
0
        private void LocalMenu_OnItemClicked(string ActionType)
        {
            var selectedItem = dgMultiInvGrid.SelectedItem as ProjectInvoiceProposalClient;

            switch (ActionType)
            {
            case "EditRow":
                if (selectedItem == null)
                {
                    return;
                }
                string salesHeader = string.Format("{0}:{1}", Uniconta.ClientTools.Localization.lookup("InvoiceProposal"), selectedItem._OrderNumber);
                if (dgMultiInvGrid.masterRecords != null)
                {
                    object[] arr = new object[2] {
                        selectedItem, dgMultiInvGrid.masterRecord
                    };
                    AddDockItem(TabControls.ProjInvProposalPage2, arr, salesHeader);
                }
                else
                {
                    AddDockItem(TabControls.ProjInvProposalPage2, selectedItem, salesHeader);
                }
                break;

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

            case "OrderLine":
                if (selectedItem == null)
                {
                    return;
                }
                var olheader = string.Format("{0}:{1},{2}", Uniconta.ClientTools.Localization.lookup("InvoiceProposalLine"), selectedItem._OrderNumber, selectedItem._DCAccount);
                AddDockItem(TabControls.ProjInvoiceProposalLine, dgMultiInvGrid.syncEntity, olheader);
                break;

            case "GenerateInvoice":
                if (Utility.HasControlRights("GenerateInvoice", api.CompanyEntity))
                {
                    GenerateInvoice();
                }
                else
                {
                    UtilDisplay.ShowControlAccessMsg("GenerateInvoice");
                }
                break;

            case "GenerateInvoice2":
                if (selectedItem != null)
                {
                    if (Utility.HasControlRights("GenerateInvoice", api.CompanyEntity))
                    {
                        var debtor = ClientHelper.GetRef(selectedItem.CompanyId, typeof(Debtor), selectedItem._DCAccount) as Debtor;
                        if (debtor != null)
                        {
                            var InvoiceAccount = selectedItem._InvoiceAccount ?? debtor._InvoiceAccount;
                            if (InvoiceAccount != null)
                            {
                                debtor = ClientHelper.GetRef(selectedItem.CompanyId, typeof(Debtor), InvoiceAccount) as Debtor;
                            }
                            if (debtor._PricesInclVat != selectedItem._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;
                                }
                            }
                        }
                        GenerateRecordInvoice(selectedItem);
                    }
                    else
                    {
                        UtilDisplay.ShowControlAccessMsg("GenerateInvoice");
                    }
                }
                break;

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

            case "ApproveOrder":
                if (selectedItem != null && api.CompanyEntity.ApproveSalesOrders)
                {
                    Utility.ApproveOrder(api, selectedItem);
                }
                break;

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

            default:
                gridRibbon_BaseActions(ActionType);
                break;
            }
        }
Ejemplo n.º 6
0
        private void localMenu_OnItemClicked(string ActionType)
        {
            var    dgCreditorOrdersGrid = this.dgCreditorOrdersGrid;
            var    selectedItem         = dgCreditorOrdersGrid.SelectedItem as CreditorOrderClient;
            string salesHeader          = string.Empty;

            if (selectedItem != null)
            {
                salesHeader = string.Format("{0}:{1}", Uniconta.ClientTools.Localization.lookup("Orders"), selectedItem._OrderNumber, true);
            }
            switch (ActionType)
            {
            case "AddRow":
                if (dgCreditorOrdersGrid.masterRecords != null)
                {
                    object[] arr = new object[2] {
                        api, dgCreditorOrdersGrid.masterRecord
                    };
                    AddDockItem(TabControls.CreditorOrdersPage2, arr, Uniconta.ClientTools.Localization.lookup("Orders"), "Add_16x16.png");
                }
                else
                {
                    AddDockItem(TabControls.CreditorOrdersPage2, api, Uniconta.ClientTools.Localization.lookup("Orders"), "Add_16x16.png");
                }
                break;

            case "EditRow":
                if (selectedItem == null)
                {
                    return;
                }
                if (dgCreditorOrdersGrid.masterRecords != null)
                {
                    object[] arr = new object[2] {
                        selectedItem, dgCreditorOrdersGrid.masterRecord
                    };
                    AddDockItem(TabControls.CreditorOrdersPage2, arr, salesHeader);
                }
                else
                {
                    AddDockItem(TabControls.CreditorOrdersPage2, selectedItem, salesHeader);
                }
                break;

            case "OrderLine":
                if (selectedItem == null)
                {
                    return;
                }
                var olheader = string.Format("{0}:{1},{2}", Uniconta.ClientTools.Localization.lookup("PurchaseLines"), selectedItem._OrderNumber, selectedItem._DCAccount);
                AddDockItem(TabControls.CreditorOrderLines, dgCreditorOrdersGrid.syncEntity, olheader);
                break;

            case "AddNote":
                if (selectedItem != null)
                {
                    string noteHeader = string.Format("{0} : {1}", Uniconta.ClientTools.Localization.lookup("UserNotesInfo"), selectedItem.Account);
                    AddDockItem(TabControls.UserNotesPage, dgCreditorOrdersGrid.syncEntity, noteHeader);
                }
                break;

            case "AddDoc":
                if (selectedItem != null)
                {
                    string docHeader = string.Format("{0} : {1}", Uniconta.ClientTools.Localization.lookup("Documents"), selectedItem.Account);
                    AddDockItem(TabControls.UserDocsPage, dgCreditorOrdersGrid.syncEntity, docHeader);
                }
                break;

            case "Contacts":
                if (selectedItem != null)
                {
                    AddDockItem(TabControls.ContactPage, selectedItem);
                }
                break;

            case "UpdateRequisition":
                if (selectedItem != null)
                {
                    OrderConfirmation(selectedItem, CompanyLayoutType.Requisition);
                }
                break;

            case "UpdatePurchaseOrder":
                if (selectedItem != null)
                {
                    OrderConfirmation(selectedItem, CompanyLayoutType.PurchaseOrder);
                }
                break;

            case "UpdateDeliveryNote":
                if (selectedItem != null)
                {
                    OrderConfirmation(selectedItem, CompanyLayoutType.PurchasePacknote);
                }
                break;

            case "EditCreditor":
                if (selectedItem != null)
                {
                    AddDockItem(TabControls.CreditorAccountPage2, new object[] { selectedItem.Creditor, true });
                }
                break;

            case "CreateOrder":
                if (selectedItem != null)
                {
                    CWOrderFromOrder cwOrderFromOrder = new CWOrderFromOrder(api);
#if !SILVERLIGHT
                    cwOrderFromOrder.DialogTableId = 2000000027;
#endif
                    cwOrderFromOrder.Closed += async delegate
                    {
                        if (cwOrderFromOrder.DialogResult == true)
                        {
                            var perSupplier = cwOrderFromOrder.orderPerPurchaseAccount;
                            if (!perSupplier && string.IsNullOrEmpty(cwOrderFromOrder.Account))
                            {
                                return;
                            }
                            busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("SendingWait");
                            busyIndicator.IsBusy      = true;
                            var orderApi       = new OrderAPI(api);
                            var inversign      = cwOrderFromOrder.InverSign;
                            var account        = cwOrderFromOrder.Account;
                            var copyAttachment = cwOrderFromOrder.copyAttachment;
                            var dcOrder        = cwOrderFromOrder.dcOrder;
                            dcOrder._DeliveryDate = cwOrderFromOrder.DeliveryDate;
                            var copyDelAddress = cwOrderFromOrder.copyDeliveryAddress;
                            var reCalPrice     = cwOrderFromOrder.reCalculatePrice;
                            var result         = await orderApi.CreateOrderFromOrder(selectedItem, dcOrder, account, inversign, CopyAttachments : copyAttachment, CopyDeliveryAddress : copyDelAddress, RecalculatePrices : reCalPrice, OrderPerPurchaseAccount : perSupplier);

                            busyIndicator.IsBusy = false;
                            if (result != ErrorCodes.Succes)
                            {
                                UtilDisplay.ShowErrorCode(result);
                            }
                            else
                            {
                                ShowOrderLines(2, dcOrder, this, dgCreditorOrdersGrid);
                            }
                        }
                    };
                    cwOrderFromOrder.Show();
                }
                break;

            case "RefVoucher":
                if (selectedItem == null)
                {
                    return;
                }
                var _refferedVouchers = new List <int>();
                if (selectedItem._DocumentRef != 0)
                {
                    _refferedVouchers.Add(selectedItem._DocumentRef);
                }

                VoucherOpen = true;
                AddDockItem(TabControls.AttachVoucherGridPage, new object[] { _refferedVouchers }, true);
                break;

            case "ViewVoucher":
                if (selectedItem != null)
                {
                    ViewVoucher(TabControls.VouchersPage3, dgCreditorOrdersGrid.syncEntity);
                }
                break;

            case "DragDrop":
            case "ImportVoucher":
                if (selectedItem != null)
                {
                    AddVoucher(selectedItem, ActionType);
                }
                break;

            case "RemoveVoucher":
                if (selectedItem != null)
                {
                    RemoveVoucher(selectedItem);
                }
                break;

            case "EditAll":
                if (dgCreditorOrdersGrid.Visibility == Visibility.Visible)
                {
                    EditAll();
                }
                break;

            case "AddLine":
                dgCreditorOrdersGrid.AddRow();
                break;

            case "CopyRow":
                dgCreditorOrdersGrid.CopyRow();
                break;

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

            case "UndoDelete":
                dgCreditorOrdersGrid.UndoDeleteRow();
                break;

            case "SaveGrid":
                Save();
                break;

            case "PurchaseCharges":
                if (selectedItem == null)
                {
                    return;
                }
                var header = string.Format("{0}: {1}, {2}", Uniconta.ClientTools.Localization.lookup("PurchaseCharges"), selectedItem._OrderNumber, selectedItem._DCAccount);
                AddDockItem(TabControls.CreditorOrderCostLinePage, dgCreditorOrdersGrid.syncEntity, header);
                break;

            case "CreateInvoice":
                if (selectedItem != null)
                {
                    if (Utility.HasControlRights("GenerateInvoice", api.CompanyEntity))
                    {
                        GenerateInvoice(selectedItem);
                    }
                    else
                    {
                        UtilDisplay.ShowControlAccessMsg("GenerateInvoice");
                    }
                }
                break;

            case "RefreshGrid":
                TestCreditorReload(true, dgCreditorOrdersGrid.ItemsSource as IEnumerable <CreditorOrder>);
                break;

            case "ReadOIOUBL":
#if !SILVERLIGHT
                var orderOIOCW = new CWOrderOIOUBLImport();
                orderOIOCW.Closing += delegate
                {
                    if (orderOIOCW.DialogResult != true)
                    {
                        return;
                    }

                    ReadOIOUBL(orderOIOCW.OneOrMultiple);
                };
                orderOIOCW.Show();


                gridRibbon_BaseActions("RefreshGrid");
#endif
                break;

            case "ApproveOrder":
                if (selectedItem != null && api.CompanyEntity.ApprovePurchaseOrders)
                {
                    Utility.ApproveOrder(api, selectedItem);
                }
                break;

            default:
                gridRibbon_BaseActions(ActionType);
                break;
            }
        }
        private void localMenu_OnItemClicked(string ActionType)
        {
            var    dgProjInvProposalGrid = this.dgProjInvProposalGrid;
            var    selectedItem          = dgProjInvProposalGrid.SelectedItem as ProjectInvoiceProposalClient;
            string salesHeader           = string.Empty;

            if (selectedItem != null)
            {
                salesHeader = string.Format("{0}:{1}", Uniconta.ClientTools.Localization.lookup("InvoiceProposal"), selectedItem._OrderNumber);
            }
            switch (ActionType)
            {
            case "AddRow":
                if (dgProjInvProposalGrid.masterRecords != null)
                {
                    AddDockItem(TabControls.ProjInvProposalPage2, new object[] { api, dgProjInvProposalGrid.masterRecord }, Uniconta.ClientTools.Localization.lookup("InvoiceProposal"), "Add_16x16.png");
                }
                else
                {
                    AddDockItem(TabControls.ProjInvProposalPage2, api, Uniconta.ClientTools.Localization.lookup("InvoiceProposal"), "Add_16x16.png");
                }
                break;

            case "EditRow":
                if (selectedItem == null)
                {
                    return;
                }
                if (dgProjInvProposalGrid.masterRecords != null)
                {
                    object[] arr = new object[2] {
                        selectedItem, dgProjInvProposalGrid.masterRecord
                    };
                    AddDockItem(TabControls.ProjInvProposalPage2, arr, salesHeader);
                }
                else
                {
                    AddDockItem(TabControls.ProjInvProposalPage2, selectedItem, salesHeader);
                }
                break;

            case "ProjInvProposalLine":
                if (selectedItem == null)
                {
                    return;
                }
                var olheader = string.Format("{0}:{1},{2}", Uniconta.ClientTools.Localization.lookup("InvoiceProposalLine"), selectedItem._OrderNumber, selectedItem.Name);
                AddDockItem(TabControls.ProjInvoiceProposalLine, dgProjInvProposalGrid.syncEntity, olheader);
                break;

            case "Invoices":
                AddDockItem(TabControls.Invoices, selectedItem, salesHeader);
                break;

            case "AddNote":
                if (selectedItem != null)
                {
                    string header = string.Format("{0} : {1}", Uniconta.ClientTools.Localization.lookup("UserNotesInfo"), selectedItem._OrderNumber);
                    AddDockItem(TabControls.UserNotesPage, dgProjInvProposalGrid.syncEntity, header);
                }
                break;

            case "AddDoc":
                if (selectedItem != null)
                {
                    string header = string.Format("{0} : {1}", Uniconta.ClientTools.Localization.lookup("Documents"), selectedItem._OrderNumber);
                    AddDockItem(TabControls.UserDocsPage, dgProjInvProposalGrid.syncEntity, header);
                }
                break;

            case "Contacts":
                if (selectedItem == null)
                {
                    return;
                }
                AddDockItem(TabControls.ContactPage, selectedItem);
                break;

            case "EditDebtor":
                if (selectedItem?._DCAccount != null)
                {
                    jumpToDebtor(selectedItem);
                }
                break;

            case "EditAll":
                if (dgProjInvProposalGrid.Visibility == Visibility.Visible)
                {
                    EditAll();
                }
                break;

            case "AddLine":
                dgProjInvProposalGrid.AddRow();
                break;

            case "CopyRow":
                dgProjInvProposalGrid.CopyRow();
                break;

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

            case "UndoDelete":
                dgProjInvProposalGrid.UndoDeleteRow();
                break;

            case "SaveGrid":
                Save();
                break;

            case "CreateInvoice":
                if (selectedItem != null)
                {
                    if (Utility.HasControlRights("GenerateInvoice", api.CompanyEntity))
                    {
                        GenerateInvoice(selectedItem);
                    }
                    else
                    {
                        UtilDisplay.ShowControlAccessMsg("GenerateInvoice");
                    }
                }
                break;

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

            case "RefreshGrid":
                TestDebtorReload(true, dgProjInvProposalGrid.ItemsSource as IEnumerable <ProjectInvoiceProposal>);
                break;

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

            case "ApproveOrder":
                if (selectedItem != null && api.CompanyEntity.ApproveSalesOrders)
                {
                    Utility.ApproveOrder(api, selectedItem);
                }
                break;

            default:
                gridRibbon_BaseActions(ActionType);
                break;
            }
        }
Ejemplo n.º 8
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();
        }