Exemple #1
0
        private void JoinAllOrdersToSelectedItem(DebtorOrderClient selectedItem, IEnumerable <DebtorOrderClient> allOrderList)
        {
            EraseYearWindow EraseYearWindowDialog = new EraseYearWindow("", true);

            EraseYearWindowDialog.Closed += async delegate
            {
                if (EraseYearWindowDialog.DialogResult == true)
                {
                    var        ordersApi = new OrderAPI(api);
                    List <int> errors    = new List <int>();
                    foreach (var order in allOrderList)
                    {
                        if (order._OrderNumber == selectedItem._OrderNumber)
                        {
                            continue;
                        }
                        var result = await ordersApi.JoinTwoOrders(order, selectedItem);

                        if (result != Uniconta.Common.ErrorCodes.Succes)
                        {
                            errors.Add(order._OrderNumber);
                        }
                    }
                    if (errors.Count > 0)
                    {
                        var failedOrderNumbers = string.Format("{0} {1}", Uniconta.ClientTools.Localization.lookup("OrderNumber"), string.Join(",", errors));
                        var message            = string.Format(Uniconta.ClientTools.Localization.lookup("FailedJoinOBJ"), failedOrderNumbers, selectedItem._OrderNumber);
                        UnicontaMessageBox.Show(message, Uniconta.ClientTools.Localization.lookup("Error"), MessageBoxButton.OK);
                    }
                    var propValpair = Uniconta.Common.PropValuePair.GenereteWhereElements("OrderNumber", typeof(int), Convert.ToString(selectedItem._OrderNumber));
                    dgJoinMultiOrderGrid.Filter(new Uniconta.Common.PropValuePair[] { propValpair });
                }
            };
            EraseYearWindowDialog.Show();
        }
Exemple #2
0
        private void JoinOrdersPerCustomer()
        {
            var ordersToBeJoined = dgJoinMultiOrderGrid.GetVisibleRows() as IEnumerable <DebtorOrderClient>;

            if (ordersToBeJoined == null || ordersToBeJoined.Count() == 0)
            {
                return;
            }
            var             allOrderList          = ordersToBeJoined.GroupBy(x => x.Account).Select(x => x.First()).ToList();
            EraseYearWindow EraseYearWindowDialog = new EraseYearWindow("", true);

            EraseYearWindowDialog.Closed += async delegate
            {
                if (EraseYearWindowDialog.DialogResult == true)
                {
                    var        ordersApi = new OrderAPI(api);
                    List <int> errors    = new List <int>();
                    List <int> orders    = new List <int>();
                    foreach (var order in allOrderList)
                    {
                        foreach (var customerOrder in ordersToBeJoined)
                        {
                            if (order.Account == customerOrder.Account)
                            {
                                if (order._OrderNumber == customerOrder._OrderNumber)
                                {
                                    continue;
                                }
                                var result = await ordersApi.JoinTwoOrders(customerOrder, order);

                                if (result != Uniconta.Common.ErrorCodes.Succes)
                                {
                                    errors.Add(customerOrder._OrderNumber);
                                    orders.Add(order._OrderNumber);
                                }
                            }
                        }
                    }
                    if (errors.Count > 0)
                    {
                        var failedOrderNumbers = string.Format("{0} {1}", Uniconta.ClientTools.Localization.lookup("OrderNumber"), string.Join(",", errors));
                        var message            = string.Format(Uniconta.ClientTools.Localization.lookup("FailedJoinOBJ"), failedOrderNumbers, string.Join(",", orders));
                        UnicontaMessageBox.Show(message, Uniconta.ClientTools.Localization.lookup("Error"), MessageBoxButton.OK);
                    }
                    InitQuery();
                }
            };
            EraseYearWindowDialog.Show();
        }
        void CallJoinTwoOrder(DCOrder fromOrder, DCOrder toOrder)
        {
            DeletePostedJournal delDialog = new DeletePostedJournal(true);

            delDialog.Closed += async delegate
            {
                if (delDialog.DialogResult == true)
                {
                    OrderAPI   orderApi = new OrderAPI(api);
                    ErrorCodes res      = await orderApi.JoinTwoOrders(fromOrder, toOrder);

                    if (res == ErrorCodes.Succes)
                    {
                        this.DialogResult = true;
                    }
                    UtilDisplay.ShowErrorCode(res);
                }
            };
            delDialog.Show();
        }