Ejemplo n.º 1
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.º 2
0
        private void localMenu_OnItemClicked(string ActionType)
        {
            var    selectedItem = dgDebtorOffers.SelectedItem as DebtorOfferClient;
            string salesHeader  = string.Empty;

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

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

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

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

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

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

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

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

            case "CreateOrder":
                if (selectedItem != null)
                {
                    CWOrderFromOrder cwOrderFromOrder = new CWOrderFromOrder(api);
#if !SILVERLIGHT
                    cwOrderFromOrder.DialogTableId = 2000000026;
#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 copyDelAddress = cwOrderFromOrder.copyDeliveryAddress;
                            var dcOrder        = cwOrderFromOrder.dcOrder;
                            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
                            {
                                CreditorOrders.ShowOrderLines(3, dcOrder, this, dgDebtorOffers);
                            }
                        }
                    };
                    cwOrderFromOrder.Show();
                }
                break;

            case "FollowUp":
                if (selectedItem != null)
                {
                    AddDockItem(TabControls.CrmFollowUpPage, dgDebtorOffers.syncEntity);
                }
                break;

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

            case "SaveGrid":
                Save();
                break;

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

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

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

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

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

            case "ProductionLines":
                if (selectedItem != null)
                {
                    var olheader = string.Format("{0}: {1}, {2}", Uniconta.ClientTools.Localization.lookup("ProductionLines"), selectedItem._OrderNumber, selectedItem._DCAccount);
                    AddDockItem(TabControls.ProductionOrderLines, dgProductionOrders.syncEntity, olheader);
                }
                break;

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

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

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

            case "MarkOrderLine":
                if (selectedItem?._ProdItem != null)
                {
                    MarkedOrderLine(selectedItem);
                }
                break;

#if !SILVERLIGHT
            case "ProductionReport":
                if (selectedItem != null)
                {
                    CreateProductionReport(selectedItem);
                }
                break;
#endif
            case "EditAll":
                if (dgProductionOrders.Visibility == Visibility.Visible)
                {
                    EditAll();
                }
                break;

            case "SaveGrid":
                Save();
                break;

            case "ViewPhoto":
                if (selectedItem != null && selectedItem?.ProdItemRef != null)
                {
                    AddDockItem(TabControls.UserDocsPage, selectedItem.ProdItemRef, string.Format("{0}: {1}", Uniconta.ClientTools.Localization.lookup("Documents"), selectedItem?.ProdItemRef?._Name));
                }
                break;

            case "ViewNotes":
                if (selectedItem != null && selectedItem?.ProdItemRef != null)
                {
                    AddDockItem(TabControls.UserNotesPage, selectedItem.ProdItemRef, string.Format("{0}: {1}", Uniconta.ClientTools.Localization.lookup("Notes"), selectedItem?.ProdItemRef?._Name));
                }
                break;

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

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

            case "CreateOrder":
                if (selectedItem != null)
                {
                    CWOrderFromOrder cwOrderFromOrder = new CWOrderFromOrder(api);
#if !SILVERLIGHT
                    cwOrderFromOrder.DialogTableId = 2000000084;
#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, dgProductionOrders);
                            }
                        }
                    };
                    cwOrderFromOrder.Show();
                }
                break;

            default:
                gridRibbon_BaseActions(ActionType);
                break;
            }
        }