コード例 #1
0
        public MovimentoContabileEconomicoUI(TestataMovimentoContabileDTO testata, EsercizioDTO esercizio)
        {
            InitializeComponent();

            BusinessClass = new[] { (BaseDTOOfint)testata };
            _movimentoControl = new MovimentoContabileEconomicoUC(testata, esercizio, this);
            _movimentoControl.SetConfirmByParent(false);

            MainStandardForm_Fill_Panel.Controls.Add(_movimentoControl);
            _movimentoControl.AutoScroll = true;
            _movimentoControl.Dock = DockStyle.Fill;
            _movimentoControl.Location = new Point(0, 0);
            _movimentoControl.Name = "movimentoContabileUIControl";
            _movimentoControl.Size = new Size(987, 557);
            _movimentoControl.TabIndex = 0;

            _movimentoControl.AfterUpdate += movimentoControlAfterUpdate;
            _movimentoControl.FormClose += movimentoControlFormClose;

            _testata = testata;
        }
コード例 #2
0
        public TestataMovimentoContabileDTO[] GetAll()
        {
            try
            {
                var daoFactory = _windsorRepository.GetDaoFactory(_info.Azienda);
                var lista = daoFactory.GetTestataMovimentoContabileDao().GetAll();
                var testate = new TestataMovimentoContabileDTO[lista.Count];

                int index = 0;
                foreach (var testata in lista)
                {
                    testate[index] = setDto(testata);
                    index++;
                }

                return testate;
            }
            catch (Exception ex)
            {
                _log.ErrorFormat("Errore nel caricamento delle testate dei movimenti contabili - {0}", ex, Library.Utility.GetMethodDescription());
                throw;
            }
        }
コード例 #3
0
        private TestataMovimentoContabile manageTestataMovimento(TestataMovimentoContabileDTO testataDto)
        {
            TestataMovimentoContabile testata = null;
            bool result;

            // Controllo sullo stato U, D, I
            switch (testataDto.Stato.ToUpper())
            {
                case "U":
                    result = update(testataDto, out testata);

                    if (!result)
                        throw new Exception("Il dato sul database è più recente di quello utilizzato");
                    break;
                case "I":
                    result = insert(testataDto, out testata);

                    if (!result)
                        throw new Exception("Impossibile scrivere sul database");
                    break;
            }
            return testata;
        }
コード例 #4
0
        private bool insert(TestataMovimentoContabileDTO dto, out TestataMovimentoContabile item)
        {
            item = null;
            bool result;
            var daoFactory = _windsorRepository.GetDaoFactory(_info.Azienda);

            try
            {
                item = new TestataMovimentoContabile(daoFactory.GetEsercizioDao().GetById(dto.IdEsercizio.GetValueOrDefault(), false), dto.DataRegistrazione, Gipasoft.Sfera.Enums.TipoTestataMovimentoContabileEnum.Manuale, _logTransazione)
                {
                    IsAbilitataArchiviazioneOttica = dto.IsAbilitataArchiviazioneOttica,
                    Descrizione = dto.Descrizione,
                    DataInizioCompetenza = dto.DataInizioCompetenza,
                    DataFineCompetenza = dto.DataFineCompetenza,
                    Note = dto.Note
                };

                if (dto.IdSpesa > 0)
                    item.SpesaRiferimento = daoFactory.GetSpesaDao().GetById(dto.IdSpesa.GetValueOrDefault(), false);

                var movRep = new MovimentoContabileRepository(item, _info, _windsorRepository);
                foreach (var t in dto.Movimenti)
                {
                    if (t != null)
                        movRep.ManageDomainEntity(t);
                }
                daoFactory.GetTestataMovimentoContabileDao().SaveOrUpdate(item);
                result = true;
            }
            catch (Exception ex)
            {
                _log.ErrorFormat("Errore nel salvataggio della testata - {0} - testata:{1}", ex, Library.Utility.GetMethodDescription(), dto.ID);
                result = false;
            }

            return result;
        }
コード例 #5
0
        private bool update(TestataMovimentoContabileDTO dto, out TestataMovimentoContabile item)
        {
            bool result = false;
            item = null;
            var daoFactory = _windsorRepository.GetDaoFactory(_info.Azienda);
            var testata = daoFactory.GetTestataMovimentoContabileDao().Find(dto.ID, false);
            if (testata != null)
            {
                var movRep = dto.ID == 0 ? new MovimentoContabileRepository(_info, _windsorRepository) : new MovimentoContabileRepository(testata, _info, _windsorRepository);

                try
                {
                    item = daoFactory.GetTestataMovimentoContabileDao().GetById(dto.ID, false);

                    // Condizione necessaria per il controllo del fatto che sul DB ho una versione uguale o più vecchia
                    if (dto.Version <= item.Version)
                    {
                        item.DataRegistrazione = dto.DataRegistrazione;
                        item.EsercizioRiferimento = daoFactory.GetEsercizioDao().GetById(dto.IdEsercizio.GetValueOrDefault(), false);
                        item.IsAbilitataArchiviazioneOttica = dto.IsAbilitataArchiviazioneOttica;
                        item.Descrizione = dto.Descrizione;
                        item.Note = dto.Note;
                        item.DataInizioCompetenza = dto.DataInizioCompetenza;
                        item.DataFineCompetenza = dto.DataFineCompetenza;

                        foreach (var t in dto.Movimenti)
                        {
                            if (t != null)
                                movRep.ManageDomainEntity(t);
                        }

                        result = true;
                    }
                    else
                    {
                        // Eccezione: Sul db c'è qualche cosa di più nuovo.
                        _log.ErrorFormat("Errore nel salvataggio della testata id:{0} - il dato sul db è più recente di quello che si vuole salvare", dto.ID);
                    }
                }
                catch (Exception ex)
                {
                    _log.ErrorFormat("Errore nel salvataggio della testata - {0} - id:{1}", ex, Library.Utility.GetMethodDescription(), dto.ID);
                    throw;
                }

                return result;
            }

            return true;
        }
コード例 #6
0
 public TestataMovimentoContabile ManageDomainEntity(TestataMovimentoContabileDTO testataDto)
 {
     try
     {
         return manageTestataMovimento(testataDto);
     }
     catch (Exception ex)
     {
         _log.ErrorFormat("Errore nella gestione delle testate dei movimenti contabili - {0} - testata:{1}", ex, Library.Utility.GetMethodDescription(), testataDto.ID);
         throw;
     }
 }
コード例 #7
0
        private TestataMovimentoContabileDTO setDto(TestataMovimentoContabile item)
        {
            try
            {
                TestataMovimentoContabileDTO dto = null;
                if (item != null)
                {
                    var movRep = new MovimentoContabileRepository(_info, _windsorRepository);
                    var archiviazioneService = _windsorRepository.GetContainer(_info.Azienda).Resolve<IArchiviazioneOtticaService>();

                    dto = new TestataMovimentoContabileDTO
                    {
                        DataRegistrazione = item.DataRegistrazione,
                        IdEsercizio = item.EsercizioRiferimento.ID,
                        ID = item.ID,
                        Tipo = item.Tipo,
                        NumeroProtocollo = item.NumeroProtocollo,
                        IsAbilitataArchiviazioneOttica = item.IsAbilitataArchiviazioneOttica,
                        Descrizione = item.Descrizione,
                        DataInizioCompetenza = item.DataInizioCompetenza,
                        DataFineCompetenza = item.DataFineCompetenza,
                        Note = item.Note
                    };
                    
                    if (item.ModelloRipartizione != null)
                        dto.IdModelloRipartizione = item.ModelloRipartizione.ID;
                    if (item.SpesaRiferimento != null)
                        dto.IdSpesa = item.SpesaRiferimento.ID;

                    string identificativoArchiviazione = string.Empty;
                    var movimenti = new List<MovimentoContabileDTO>(item.Movimenti.Count);
                    foreach (var movimento in item.Movimenti)
                    {
                        if (movimento.DettaglioRiferimento != null)
                            identificativoArchiviazione = archiviazioneService.GetIdentificativoArchiviazione(movimento.DettaglioRiferimento.SpesaRiferimento);

                        if (movimento.IsVisibileGestione)
                        {
                            var movDto = movRep.GetByDomainEntity(movimento, false, false);
                            movDto.IdTestata = dto.ID;
                            movimenti.Add(movDto);
                        }
                    }
                    dto.Movimenti = movimenti.ToArray();

                    if(string.IsNullOrEmpty(identificativoArchiviazione))
                        identificativoArchiviazione = archiviazioneService.GetIdentificativoArchiviazione(item);
                    dto.IdentificativoArchiviazioneOttica = identificativoArchiviazione;

                }

                return dto;
            }
            catch(Exception ex)
            {
                _log.ErrorFormat("Errore nel caricamento della Testata Contabile - {0} - testata:{1}", ex, Library.Utility.GetMethodDescription(), item != null ? item.ID.ToString() : "<NULL>");
                throw;
            }
        }
コード例 #8
0
        public MovimentoContabileEconomicoUC(TestataMovimentoContabileDTO testata, EsercizioDTO esercizio, UpdatableStandardForm formGestione)
        {
            try
            {
                InitializeComponent();

                _esercizio = esercizio;
                _testata = testata;
                _formGestione = formGestione;

                inizializza();

                if (_esercizio == null && testata.IdEsercizio != null && testata.IdEsercizio > 0)
                    _esercizio = getEsercizioService().GetById(testata.IdEsercizio.Value);

                _movimentiDare = getMovimentoContabileService().GetMovimentiLista(_testata);

                if (testata.Tipo == TipoTestataMovimentoContabileEnum.Automatica)
                {
                    groupDettaglioMovimento.Visible = false;
                    groupDettaglioMovimento.Enabled = false;
                    if (!_confirmByParent)
                        btnConferma.Visible = true;
                    btnRicevuta.Visible = true;
                }
                else
                {
                    groupDettaglioMovimento.Visible = true;
                    groupDettaglioMovimento.Enabled = true;
                }

                _movimentoAvere = getMovimentoContabileService().GetMovimentoSingolo(_testata);
                if (_movimentoAvere != null)
                {
                    _causale = _movimentoAvere.Causale;

                    int? idEsercizio = null;
                    if (_esercizio != null)
                        idEsercizio = _esercizio.ID;
                    _conto = getPianoContiService().GetById(_movimentoAvere.IdConto.GetValueOrDefault(), idEsercizio);

                    // Se il sottoconto è presente ed ha valore negativo trattasi di conto corrente bancario bugid#3754
                    if (_movimentoAvere.IdSottoConto != null)
                    {
                        if (_movimentoAvere.IdSottoConto.GetValueOrDefault() < 0)
                            _idContoBancario = _movimentoAvere.IdSottoConto.GetValueOrDefault()*-1;
                    }
                    
                    _importo = _movimentoAvere.Importo.GetValueOrDefault();
                    descrizioneDettaglio.Value = _movimentoAvere.Descrizione;
                    noteDettaglio.Value = _testata.Note;
                }

                numeroProtocollo.Value = testata.NumeroProtocollo;
                archiviazioneOttica.Checked = testata.IsAbilitataArchiviazioneOttica;
                dataRegistrazione.DateTime = testata.DataRegistrazione.GetValueOrDefault();

                dataInizioCompetenza.Value = null;
                dataFineCompetenza.Value = null;
                if (testata.DataInizioCompetenza != null)
                    dataInizioCompetenza.DateTime = testata.DataInizioCompetenza.GetValueOrDefault();
                if (testata.DataFineCompetenza != null)
                    dataFineCompetenza.DateTime = testata.DataFineCompetenza.GetValueOrDefault();

                sceltaEsercizioGroupBox.Enabled = false;
                sceltaCondominioCombo1.Enabled = false;
                esercizi.Enabled = false;

                btnRiparto.Enabled = false;
                btnConferma.Enabled = false;
                backgroundWorkerLoadDati.RunWorkerAsync(_movimentiDare);
            }
            catch (Exception ex)
            {
                var idStr = "<NULL>";
                if (testata != null)
                    idStr = testata.ID.ToString();

                var idEsercizioStr = "<NULL>";
                if (esercizio != null)
                    idEsercizioStr = esercizio.ID.ToString();

                var nomeForm = "<NULL>";
                if (formGestione != null)
                    nomeForm = formGestione.Name;

                _log.ErrorFormat("Errore insaspettato nel costruttore - {0} - testata:{1} - esercizio:{2} - formGestione:{3}", ex, Utility.GetMethodDescription(), idStr, idEsercizioStr, nomeForm);
                throw;
            }
        }
コード例 #9
0
        private void modelloRipartizioneSelectionChanged(object sender, EventArgs e)
        {
            try
            {
                // Se non ho scelto la causale non posso applicare il modello
                if (causale.Value == null)
                {
                    modelloRipartizione.SelectionChanged -= modelloRipartizioneSelectionChanged;
                    modelloRipartizione.Value = null;
                    modelloRipartizione.SelectionChanged += modelloRipartizioneSelectionChanged;
                }
                else
                    _causale = (CausaleContabileDTO)causale.SelectedItem.ListObject;

                if (modelloRipartizione.Value != null && modelloRipartizione.Value != DBNull.Value)
                {
                    TestataMovimentoContabileDTO testata = null;
                    if (_ripartizione != null)
                        testata = _ripartizione.Testata;
                    _ripartizione = getMovimentoContabileService().GetRipartizioneByModello(_esercizio.ID, testata, (int)modelloRipartizione.Value, _causale.ID, getImportoMovimento(), _tipoMovimento);
                    _testata = _ripartizione.Testata;

                    // -------------------------------------------------------------------------
                    //  Se siamo in inserimento prendo tutti i movimenti ...
                    //  ... altrimenti devo scartare quelli "avere"
                    // ------------------------------------------------------------------------
                    _movimentiDare = _isInserimento ? _ripartizione.Testata.Movimenti : getMovimentoContabileService().GetMovimentiLista(_ripartizione.Testata);
                    movimentoContabileBindingSource.DataSource = _movimentiDare;

                    // Gruppo soggetti
                    if(ripartizioneDettaglio.Rows.Count > 0)
                        ripartizioneDettaglio.ActiveRow = ripartizioneDettaglio.Rows[0];

                    foreach (var row in ripartizioneDettaglio.Rows)
                        setSottoContoValueList(row);

                    if (!_confirmByParent)
                        btnConferma.Visible = true;
                    btnRicevuta.Visible = true;

                    salvaModello.Enabled = false;
                    salvaModello.Checked = false;

                    setDettaglioResiduo();
                }
                else
                {
                    if (_ripartizione != null && _ripartizione.Testata != null)
                        _ripartizione.Testata.IdModelloRipartizione = null;
                }

            }
            catch (Exception ex)
            {
                _log.ErrorFormat("Errore inaspettato nella scelta del modello - {0} - modello:{1} - testata:{2} - esercizio:{3} - formGestione:{4}", ex, Utility.GetMethodDescription(), modelloRipartizione.Value, _testata != null ? _testata.ID.ToString() : "<NULL>", _esercizio != null ? _esercizio.ID.ToString() : "<NULL>", _formGestione != null ? _formGestione.Name : "<NULL>");
            }

        }
コード例 #10
0
 public IDettaglioSpesa GetGestioneMovimentoContabile(TestataMovimentoContabileDTO testata, EsercizioDTO esercizio)
 {
     _control = new MovimentoContabileEconomicoUI(testata, esercizio);
     return _control;
 }
コード例 #11
0
        public List<MovimentoContabileDTO> GetMovimentiLista(TestataMovimentoContabileDTO testata)
        {
            try
            {
                if (testata != null)
                {
                    var movimenti = from movimento in testata.Movimenti
                                    where movimento != GetMovimentoSingolo(testata)
                                    select movimento;

                    return new List<MovimentoContabileDTO>(movimenti.ToList());
                }
                return new List<MovimentoContabileDTO>();
            }
            catch (Exception ex)
            {
                var idStr = "<NULL>";
                if (testata != null)
                    idStr = testata.ID.ToString();

                _log.Error("Errore la lettura della lista dei movimenti economici - " + Utility.GetMethodDescription() + " - testata:" + idStr + " - azienda:" + Login.Instance.CurrentLogin().Azienda, ex);

                throw;
            }
        }
コード例 #12
0
        /// <summary>
        /// Restituisce il movimento relativo al conto patrimoniale, nella funzione di registrazione movimenti non compare nella lista dei movimenti ma nel dettaglio della registrazione.
        /// Per i movimenti generati automaticamente (es. Spese Bancarie) per trovarlo devo ricerca un conto patrimoniale non utilizzabile per le spese (es.Banca)
        /// </summary>
        /// <param name="testata">Testata del movimento</param>
        /// <returns>Movimento di conto patrimoniale restituito</returns>
        public MovimentoContabileDTO GetMovimentoSingolo(TestataMovimentoContabileDTO testata)
        {
            try
            {
                // Cerco il movimento patrimoniale trmiate il nuovo campo IsMovimentoEconomico bugid#9172
                var idMovimentoPatrimoniale = GetServiceClient().GetIdMovimentoPatrimoniale(testata.ID, GetUserInfo());
                if (idMovimentoPatrimoniale != null)
                {
                    var movimentoPatrimoniale = testata.Movimenti.FirstOrDefault(item => item.ID == idMovimentoPatrimoniale.Value);
                    if (movimentoPatrimoniale != null)
                        return movimentoPatrimoniale;
                }

                // Cerco un movimento di conto patrimoniale NON utilizzabile per la registrazione spese
                foreach (var movimentoContabileDTO in testata.Movimenti)
                {
                    var conto = _pianoContiService.GetById(movimentoContabileDTO.IdConto.GetValueOrDefault(), testata.IdEsercizio);
                    if (conto != null && conto.Tipo == TipoContoEconomicoEnum.Patrimoniale && !conto.UtilizzabileRegistrazioneSpese)
                        return movimentoContabileDTO;
                }

                // Se non lo trovo ritorno il movimento con numero di riga: 1
                return (testata.Movimenti.Where(movimento => movimento.NumeroRiga == 1)).FirstOrDefault();
            }
            catch (Exception ex)
            {
                _log.ErrorFormat("Errore la lettura della lista del conto patrimoniale di un movimento economico - {0} - testata:{1} - azienda:{2}", ex, Utility.GetMethodDescription(), testata != null ? testata.ID.ToString() : "<NULL>", Login.Instance.CurrentLogin().Azienda);
                throw;
            }
        }
コード例 #13
0
        public RipartizioneSpeseDTO GetRipartizioneByModello(int idEsercizio, TestataMovimentoContabileDTO testata, int idModello, int idCausale, decimal importo, TipoMovimentoEnum tipo)
        {
            try
            {
                var idTestata = 0;
                if (testata != null)
                    idTestata = testata.ID;

                var result = GetServiceClient().GetRipartizioneByModello(idEsercizio, idTestata, idModello, idCausale, importo, tipo, GetUserInfo());
                CloseService();
                return result;
            }
            catch (CommunicationObjectAbortedException ex)
            {
                _log.DebugFormat("Errore nella chiamata al servizio - {0} - azienda:{1}", ex, Utility.GetMethodDescription(), Login.Instance.CurrentLogin().Azienda);
            }
            catch (CommunicationObjectFaultedException ex)
            {
                _log.DebugFormat("Errore nella chiamata al servizio - {0} - azienda:{1}", ex, Utility.GetMethodDescription(), Login.Instance.CurrentLogin().Azienda);
            }
            catch (IOException ex)
            {
                _log.DebugFormat("Errore nella chiamata al servizio - {0} - azienda:{1}", ex, Utility.GetMethodDescription(), Login.Instance.CurrentLogin().Azienda);
            }
            catch (ObjectDisposedException ex)
            {
                _log.DebugFormat("Errore nella chiamata al servizio - {0} - azienda:{1}", ex, Utility.GetMethodDescription(), Login.Instance.CurrentLogin().Azienda);
            }
            catch (Exception ex)
            {
                _log.ErrorFormat("Errore nella chiamata al servizio - {0} - azienda:{1}", ex, Utility.GetMethodDescription(), Login.Instance.CurrentLogin().Azienda);
                throw;
            }

            return new RipartizioneSpeseDTO();
        }
コード例 #14
0
        public RipartizioneSpeseDTO GetRipartizioneByTestata(TestataMovimentoContabileDTO testata)
        {
            var esercizio = _esercizioService.GetById(testata.IdEsercizio.GetValueOrDefault());
            var movimenti = GetMovimentiLista(testata);
            RipartizioneSpeseDTO ripartizioneDTO = null;

            foreach (var movimento in movimenti)
            {
                ripartizioneDTO = GetRipartizioneByMovimentoEsistente(movimento, esercizio, ripartizioneDTO, null);

                // TODO: Per ora serve perchè la testata deve contenere i soli movimenti visualizzati relativi allo specifico dettaglio.
                ripartizioneDTO.Testata.Movimenti.Clear();
            }

            return ripartizioneDTO;
        }