상속: ChildWindow
예제 #1
0
        private void DeleteJournal(ProjectJournalPostedClient selectedItem)
        {
            if (selectedItem == null)
            {
                return;
            }
            var deleteDialog = new DeletePostedJournal();

            deleteDialog.Closed += async delegate
            {
                if (deleteDialog.DialogResult == true)
                {
                    var        pApi = new UnicontaAPI.Project.API.PostingAPI(api);
                    ErrorCodes res  = await pApi.DeletePostedJournal(selectedItem, deleteDialog.Comment);

                    if (res == ErrorCodes.Succes)
                    {
                        UnicontaMessageBox.Show(string.Format(Uniconta.ClientTools.Localization.lookup("Journaldeleted"), selectedItem.RowId), Uniconta.ClientTools.Localization.lookup("Message"));
                        dgProjectPostedJournal.UpdateItemSource(2, selectedItem);
                    }
                    else
                    {
                        UtilDisplay.ShowErrorCode(res);
                    }
                }
            };
            deleteDialog.Show();
        }
예제 #2
0
        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            var fromAccount = cmbFromAccount.SelectedItem as DCAccount;
            var toAccount   = cmbToAccount.SelectedItem as DCAccount;

            if (fromAccount == null)
            {
                UnicontaMessageBox.Show(string.Format(Uniconta.ClientTools.Localization.lookup("MandatoryField"), (Uniconta.ClientTools.Localization.lookup("FromAccount"))), Uniconta.ClientTools.Localization.lookup("Warning"));
                return;
            }
            if (toAccount == null)
            {
                UnicontaMessageBox.Show(string.Format(Uniconta.ClientTools.Localization.lookup("MandatoryField"), (Uniconta.ClientTools.Localization.lookup("ToAccount"))), Uniconta.ClientTools.Localization.lookup("Warning"));
                return;
            }
            DeletePostedJournal delDialog = new DeletePostedJournal(true);

            delDialog.Closed += async delegate
            {
                if (delDialog.DialogResult == true)
                {
                    CallJoinTwoAccount(fromAccount, toAccount);
                }
            };
            delDialog.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();
        }
        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            var fromAccount = cmbFromAccount.SelectedItem as GLAccount;
            var toAccount   = cmbToAccount.SelectedItem as GLAccount;

            if (fromAccount == null)
            {
                UnicontaMessageBox.Show(string.Format(Uniconta.ClientTools.Localization.lookup("MandatoryField"), (Uniconta.ClientTools.Localization.lookup("FromAccount"))), Uniconta.ClientTools.Localization.lookup("Error"));
                return;
            }
            if (toAccount == null)
            {
                UnicontaMessageBox.Show(string.Format(Uniconta.ClientTools.Localization.lookup("MandatoryField"), (Uniconta.ClientTools.Localization.lookup("ToAccount"))), Uniconta.ClientTools.Localization.lookup("Error"));
                return;
            }
            if ((fromAccount._AccountType >= (byte)GLAccountTypes.BalanceSheet && toAccount._AccountType < (byte)GLAccountTypes.BalanceSheet) ||
                (fromAccount._AccountType < (byte)GLAccountTypes.BalanceSheet && toAccount._AccountType >= (byte)GLAccountTypes.BalanceSheet))
            {
                var s1  = string.Format(Uniconta.ClientTools.Localization.lookup("AccountIsOfType"), fromAccount._Account, AppEnums.GLAccountTypes.ToString(fromAccount._AccountType));
                var s2  = string.Format(Uniconta.ClientTools.Localization.lookup("AccountIsOfType"), toAccount._Account, AppEnums.GLAccountTypes.ToString(toAccount._AccountType));
                var msg = string.Format("{0}\n{1}\n{2}", s1, s2, Uniconta.ClientTools.Localization.lookup("ProceedConfirmation"));

                if (UnicontaMessageBox.Show(msg, Uniconta.ClientTools.Localization.lookup("Warning"),
#if !SILVERLIGHT
                                            MessageBoxButton.YesNo) != MessageBoxResult.Yes)
#else
                                            MessageBoxButton.OKCancel) != MessageBoxResult.OK)
#endif
                { return; }
            }

            DeletePostedJournal delDialog = new DeletePostedJournal(true);
            delDialog.Closed += delegate
            {
                if (delDialog.DialogResult == true)
                {
                    CallJoinTwoAccount(fromAccount, toAccount);
                }
            };
            delDialog.Show();
        }
        void CallJoinTwoWareHouseOrLocation(InvWarehouse fromWareHouse = null, InvWarehouse copyToWareHouse = null, InvLocation fromLocation = null, InvLocation copyToLocation = null)
        {
            DeletePostedJournal delDialog = new DeletePostedJournal(true);

            delDialog.Closed += delegate
            {
                if (delDialog.DialogResult == true)
                {
                    var invApi = new InventoryAPI(crudApi);
                    if (isJoinWareHouse)
                    {
                        JoinResult = invApi.JoinTwoWarehouses(fromWareHouse, copyToWareHouse);
                    }
                    else
                    {
                        JoinResult = invApi.JoinTwoLocations(fromLocation, copyToWareHouse, copyToLocation);
                    }
                    this.DialogResult = true;
                }
            };
            delDialog.Show();
        }
예제 #6
0
        private void localMenu_OnItemClicked(string ActionType)
        {
            string header;
            var    selectedItem = dgAccountsTransGrid.SelectedItem as GLTransClient;

            switch (ActionType)
            {
            case "PostedTransaction":
                if (selectedItem == null)
                {
                    return;
                }
                header = string.Format("{0} / {1}", Uniconta.ClientTools.Localization.lookup("PostedTransactions"), selectedItem._JournalPostedId);
                AddDockItem(TabControls.PostedTransactions, selectedItem, header);
                break;

            case "ViewDownloadRow":
                if (selectedItem != null)
                {
                    DebtorTransactions.ShowVoucher(dgAccountsTransGrid.syncEntity, api, busyIndicator);
                }
                break;

            case "VoucherTransactions":
                if (selectedItem == null)
                {
                    return;
                }
                header = string.Format("{0} ({1})", Uniconta.ClientTools.Localization.lookup("VoucherTransactions"), selectedItem._Voucher);
                AddDockItem(TabControls.AccountsTransaction, dgAccountsTransGrid.syncEntity, header);
                break;

            case "AccountsTransaction":
                if (selectedItem != null)
                {
                    var glAccount = selectedItem.Master;
                    if (glAccount == null)
                    {
                        return;
                    }
                    string accHeader = string.Format("{0} ({1})", Uniconta.ClientTools.Localization.lookup("AccountsTransaction"), selectedItem._Account);
                    AddDockItem(TabControls.AccountsTransaction, glAccount, accHeader);
                }
                break;

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

            case "CancelVoucher":
                if (selectedItem == null)
                {
                    return;
                }
                CWCommentsDialogBox commentsDialog = new CWCommentsDialogBox(Uniconta.ClientTools.Localization.lookup("CancelVoucher"),
                                                                             true, selectedItem.Date);
#if !SILVERLIGHT
                commentsDialog.DialogTableId = 2000000035;
#endif
                commentsDialog.Closing += async delegate
                {
                    if (commentsDialog.DialogResult == true)
                    {
                        busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("SendingWait");
                        busyIndicator.IsBusy      = true;

                        var comments   = commentsDialog.Comments;
                        var date       = commentsDialog.Date;
                        var errorCodes = await postingApiInv.CancelVoucher(selectedItem, comments, date);

                        busyIndicator.IsBusy = false;

                        if (errorCodes != ErrorCodes.Succes)
                        {
                            UtilDisplay.ShowErrorCode(errorCodes);
                        }
                        else
                        {
                            UnicontaMessageBox.Show(Uniconta.ClientTools.Localization.lookup("TransCanceled"), Uniconta.ClientTools.Localization.lookup("Error"));
                            BindGrid();
                        }
                    }
                };
                commentsDialog.Show();
                break;

            case "DeleteVoucher":
                if (selectedItem == null)
                {
                    return;
                }
                var deleteDialog = new DeletePostedJournal();
                deleteDialog.Closed += async delegate
                {
                    if (deleteDialog.DialogResult == true)
                    {
                        PostingAPI pApi = new PostingAPI(api);
                        ErrorCodes res  = await pApi.DeletePostedVoucher(selectedItem, deleteDialog.Comment);

                        UtilDisplay.ShowErrorCode(res);
                        if (res == ErrorCodes.Succes)
                        {
                            dgAccountsTransGrid.ItemsSource = new GLTransClient[0];
                        }
                    }
                };
                deleteDialog.Show();
                break;

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

            case "RefVoucher":
                if (selectedItem == null)
                {
                    return;
                }

                var _refferedVouchers = new List <int>();
                var source            = (IList)dgAccountsTransGrid.ItemsSource;
                if (source != null)
                {
                    foreach (var statementLine in (IEnumerable <GLTrans>)source)
                    {
                        if (statementLine._DocumentRef != 0)
                        {
                            _refferedVouchers.Add(statementLine._DocumentRef);
                        }
                    }
                }
                CWAttachVouchers attachVouchersDialog = new CWAttachVouchers(api, _refferedVouchers);
                attachVouchersDialog.Closing += delegate
                {
                    if (attachVouchersDialog.DialogResult == true)
                    {
                        if (attachVouchersDialog.VoucherReference != 0 && selectedItem != null)
                        {
                            SaveAttachment(selectedItem, attachVouchersDialog.Voucher);
                        }
                    }
                };
                attachVouchersDialog.Show();
                break;

            case "RemoveVoucher":
                if (selectedItem == null || selectedItem._DocumentRef == 0)
                {
                    return;
                }
                if (UnicontaMessageBox.Show(Uniconta.ClientTools.Localization.lookup("AskRemoveDocument"), Uniconta.ClientTools.Localization.lookup("Confirmation"), MessageBoxButton.OKCancel) == MessageBoxResult.OK)
                {
                    postingApiInv.AddPhysicalVoucher(selectedItem, null, true);
                    selectedItem._DocumentRef = 0;
                }
                break;

            case "ChangeDimension":
                if (selectedItem != null)
                {
                    CWChangeDimension ChangeDimensionDialog = new CWChangeDimension(api, isChangeText: false);
                    ChangeDimensionDialog.Closing += delegate
                    {
                        if (ChangeDimensionDialog.DialogResult == true)
                        {
                            SetNewDim(selectedItem, ChangeDimensionDialog);
                        }
                    };
                    ChangeDimensionDialog.Show();
                }
                break;

            case "ChangeText":
                if (selectedItem != null)
                {
                    CWChangeDimension ChangeTextDialog = new CWChangeDimension(api, isChangeDimension: false);
                    ChangeTextDialog.Closing += delegate
                    {
                        if (ChangeTextDialog.DialogResult == true)
                        {
                            SetChangeText(selectedItem, ChangeTextDialog);
                        }
                    };
                    ChangeTextDialog.Show();
                }
                break;

            case "ChangeReference":
                if (selectedItem != null)
                {
                    CWChangeDimension updateReferenceDialog = new CWChangeDimension(api, isChangeDimension: false);
                    updateReferenceDialog.Closing += delegate
                    {
                        if (updateReferenceDialog.DialogResult == true)
                        {
                            SetChangeReference(selectedItem, updateReferenceDialog);
                        }
                    };
                    updateReferenceDialog.Show();
                }
                break;

            case "ChangeQuantity":
                if (selectedItem != null)
                {
                    CWChangeDimension ChangeQtyDialog = new CWChangeDimension(api, isChangeDimension: false, isChangeText: false);
                    ChangeQtyDialog.Closing += delegate
                    {
                        if (ChangeQtyDialog.DialogResult == true)
                        {
                            SetChangeQuantity(selectedItem, ChangeQtyDialog);
                        }
                    };
                    ChangeQtyDialog.Show();
                }
                break;

            case "AddEditNote":
                if (selectedItem != null)
                {
                    CWAddEditNote cwAddEditNote = new CWAddEditNote(api, null, selectedItem);
                    cwAddEditNote.Closed += delegate
                    {
                        if (cwAddEditNote.DialogResult == true)
                        {
                            if (cwAddEditNote.result == ErrorCodes.Succes)
                            {
                                BindGrid();
                            }
                        }
                    };
                    cwAddEditNote.Show();
                }
                break;

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

            case "ChangeDate":
                if (selectedItem == null)
                {
                    return;
                }
                var dateSelector = new CWDateSelector(selectedItem.Date, true);
#if !SILVERLIGHT
                dateSelector.DialogTableId = 2000000058;
#endif
                dateSelector.Closed += delegate
                {
                    if (dateSelector.DialogResult == true)
                    {
                        SetChangeDate(selectedItem, dateSelector.SelectedDate);
                    }
                };
                dateSelector.Show();
                break;

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

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

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

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

            case "ExportVouchers":
                var glTrans = ((IEnumerable <GLTransClient>)dgAccountsTransGrid.GetVisibleRows())?.Where(x => x._DocumentRef != 0);
                AddDockItem(TabControls.VoucherExportPage, new object[] { glTrans }, Uniconta.ClientTools.Localization.lookup("ExportVouchers"));
                break;

            default:
                gridRibbon_BaseActions(ActionType);
                break;
            }
        }