Esempio n. 1
0
        public CWAccountingPeriod(CompanyFinanceYearClient accountYears, CompanyFinancePeriodClient[] accountPeriodClient, CrudAPI api)
        {
            this.DataContext = this;
            InitializeComponent();
#if !SILVERLIGHT
            this.Title = Uniconta.ClientTools.Localization.lookup("AccountingPeriod");
#endif
            API            = api;
            ModifiedRow    = accountYears;
            LoadedRow      = StreamingManager.Clone((UnicontaBaseEntity)ModifiedRow);
            accountPeriods = accountPeriodClient;
            dgAccountPeriod.ItemsSource = accountPeriods;
            this.Loaded += CW_Loaded;
        }
        private void RemovePrimo(CompanyFinanceYearClient financialYearClient)
        {
            var removePrimoWindowDialog = new EraseYearWindow(financialYearClient.BalanceName, false);

            removePrimoWindowDialog.Closed += async delegate
            {
                if (removePrimoWindowDialog.DialogResult == true)
                {
                    var financialYearApi = new FinancialYearAPI(api);
                    var result           = await financialYearApi.RemovePrimoTransactions(financialYearClient);

                    UtilDisplay.ShowErrorCode(result);
                }
            };
            removePrimoWindowDialog.Show();
        }
        async void SetDefault(CrudAPI crudapi)
        {
            if (LoadedRow == null)
            {
                frmRibbon.DisableButtons("Delete");
                editrow        = CreateNew() as CompanyFinanceYearClient;
                editrow._State = FinancePeriodeState.Open;
                var lst = await crudapi.Query(editrow, null, null);

                if (lst != null && lst.Length > 0)
                {
                    var p = lst[lst.Length - 1];
                    editrow.FromDate = p._ToDate.AddDays(1);
                    editrow.ToDate   = editrow._FromDate.AddYears(1).AddDays(-1);
                }
            }
        }
        public CWCreatePrimo(CrudAPI api, CompanyFinanceYearClient financeYearClient)
        {
            this.DataContext = this;
            InitializeComponent();


            lookupNumberserie.api = api;
#if !SILVERLIGHT
            this.Title = Uniconta.ClientTools.Localization.lookup("Primo");
#else
            Utility.SetThemeBehaviorOnChildWindow(this);
#endif
            txtBalance.Text      = financeYearClient.BalanceName;
            txtPL.Text           = financeYearClient.PLText;
            txtVoucher.Text      = Convert.ToString(financeYearClient.Voucher);
            this.BalanceName     = financeYearClient.BalanceName;
            this.PLText          = financeYearClient.PLText;
            this.NumberserieText = financeYearClient.NumberserieText;
            this.Voucher         = financeYearClient.Voucher;
            this.Loaded         += CW_Loaded;
        }
        private async void frmRibbon_OnItemClicked(string ActionType)
        {
            if (ActionType == "Save")
            {
                if (!ValidateState())
                {
                    return;
                }
                if (otherAccountOpen && accountYears != null && accountYears.Count > 0 && Validate())
                {
                    CompanyFinanceYearClient editrowUpdate = null;

                    foreach (var year in accountYears)
                    {
                        if (year._FromDate == editrow._FromDate && year._ToDate == editrow._ToDate)
                        {
                            editrowUpdate = year;
                        }
                        else if (year._Current)
                        {
                            year._Current = false;
                        }
                    }

                    if (editrowUpdate != null)
                    {
                        accountYears[accountYears.IndexOf(editrowUpdate)] = editrow;
                        accountYears.Sort(updateMainGrid.GridSorting.Compare);
                    }
                    else
                    {
                        var err3 = await api.Insert(editrow);

                        if (err3 != ErrorCodes.Succes)
                        {
                            UnicontaMessageBox.Show(err3.ToString(), Uniconta.ClientTools.Localization.lookup("Error"));
                        }
                        else
                        {
                            accountYears.Add(editrow);
                            accountYears.Sort(updateMainGrid.GridSorting.Compare);
                        }
                    }

                    var err = await api.Update(accountYears);

                    if (err != ErrorCodes.Succes)
                    {
                        UnicontaMessageBox.Show(err.ToString(), Uniconta.ClientTools.Localization.lookup("Error"));
                    }
                    else
                    {
                        if (updateMainGrid != null)
                        {
                            updateMainGrid.ItemsSource = accountYears;
                            var err2 = await updateMainGrid.SaveData();

                            if (err2 == ErrorCodes.Succes)
                            {
                                updateMainGrid.Visibility = Visibility.Visible;
                                CloseDockItem("FinanceYearPage2", null);
                            }
                            else
                            {
                                UnicontaMessageBox.Show(err2.ToString(), Uniconta.ClientTools.Localization.lookup("Error"));
                            }
                        }
                    }
                }
                else if (Validate())
                {
                    frmRibbon_BaseActions(ActionType);
                }
            }
            else
            {
                frmRibbon_BaseActions(ActionType);
            }
        }