public DialogResult OpenDialogFormInvioMessaggio(TipoMessaggio? tipoMessaggio, List<int> destinatari, ModelloLetteraDTO modelloLettera, string contattoMittente, ParametriStampaUnione parametriLettera)
        {

            DialogResult result;
            using (var form = new InvioMessaggioUI(tipoMessaggio, contattoMittente, parametriLettera))
            {
                if (destinatari != null && destinatari.Count > 0)
                    form.LoadPersone(destinatari);
                if (modelloLettera != null)
                    form.LoadModello(modelloLettera);

                if (!string.IsNullOrEmpty(_customText))
                    form.ShowInserisciTestoCustom(_customText);
                if (!string.IsNullOrEmpty(_userInfoText))
                    form.ShowInserisciUserInfo(_userInfoText);

                result = form.ShowDialog();
                if (result != DialogResult.Cancel)
                {
                    _contattiSelected = form.GetContattiSelected();
                    _contattoDaContattare = form.GetContattoDaContattare();
                    _personaDaContattare = form.GetPersonaDaContattare();
                    _modelloLettera = form.GetModelloLettera();
                    _emailRapportino = form.GetEmailRapportino();
                    _testoMessaggio = form.GetTestoMessaggio();
                    _oggettoMessaggio = form.GetOggettoMessaggio();
                    _invioVeloce = form.GetInvioVeloce();
                    _messageType = form.GetMessageType();
                    _colore = form.GetColore();
                    _apriFile = form.GetApriFile();
                    _aggregazione = form.GetAggregazioneDocumenti();
                    _formatoDocumento = form.GetFormatoDocumento();
                    _accodaMessaggio = form.GetAccodaMessaggio();
                    _numeraPagine = form.GetNumeraPagine();
                    _fronteRetro = form.GetFronteRetro();
                    _primaPaginaMittente = form.GetPrimaPaginaMittente();
                    _mittente = form.GetMittente();
                    _tipoMessaggio = form.GetTipoMessaggio();
                    _documenti = form.GetDocumenti();
                    _documentiNew = form.GetDocumentiNew();
                    _parametriInvioLettera = new ParametriInvioLettera { Tipo = form.GetMessageType() };
                    _aggiornaContatti = form.GetAggiornaContatti();                     
                }
                
                form.CloseForm();
            }

            Application.DoEvents();
            return result;
        }
Example #2
0
        public void AddOrUpdatePersona(PersonaListaDTO persona)
        {
            const string key = "AllPersone";
            IList<PersonaListaDTO> listaCache = GetAllPersone();

            var personeCache = listaCache.Where(item => item.ID == persona.ID).ToList();
            if (personeCache.Any())
            {
                if (personeCache.Count() > 1)
                {
                    _log.Warn("Errore inaspettato nell'aggiornamento della cache di Persona: Trovata più di una istanza dell'elemento: " + persona.ID + " - AllPersone: " + listaCache.Count + " - " + Utility.GetMethodDescription());
                }

                // Trovo l'indice del primo elemento
                PersonaListaDTO personaCache = personeCache.FirstOrDefault();
                int pos = listaCache.IndexOf(personaCache);

                // Rimuovo tutti gli elementi trovati
                foreach (PersonaListaDTO item in personeCache)
                    listaCache.Remove(item);

                // Inserisco il nuovo elemento con l'index corretto
                if (pos > -1)
                    listaCache.Insert(pos, persona);
                else
                    listaCache.Add(persona);
            }
            else
                listaCache.Add(persona);

            _cache.Add(key, listaCache.ToArray(), CacheItemPriority.Normal, new CollectionCacheRefreshAction(), new AbsoluteTime(DateTime.Now.AddMinutes(300)));
        }
Example #3
0
        public void Reset()
        {
            _personaSelected = null;
            OnSelectPersona(new DataSourceEventArgs<PersonaListaDTO>(SelectedPersona));

            _personaInitial = 0;
            ricercaPersone.Selected.Rows.Clear();
            ricercaPersone.DisplayLayout.Bands[0].ColumnFilters.ClearAllFilters();
            persona.Text = string.Empty;
        }
Example #4
0
        public List<ContoDTO> GetContiPartitarioByCondominio(int idCondominio)
        {
            try
            {
                var daoFactory = _windsorRepository.GetDaoFactory(_info.Azienda);
                var fornitori = daoFactory.GetFornitoreDao().GetIdNominativoByCondominio(idCondominio);
                var condomini = daoFactory.GetSoggettoCondominioDao().GetIdNominativoByCondominio(idCondominio);

                // ======================================
                // Elaboro lista Fornitori
                // ======================================
                var listaFornitori = new List<FornitoreListaDTO>(fornitori.Count);
                foreach (var nameValueDTO in fornitori)
                {
                    var nominativo = nameValueDTO.Name.Split('¥');
                    var fornitore = new FornitoreListaDTO {ID = nameValueDTO.Value};

                    var ragioneSociale = nominativo[2];
                    if (string.IsNullOrEmpty(ragioneSociale))
                    {
                        fornitore.Nome = nominativo[0];
                        fornitore.Cognome = nominativo[1];
                    }
                    else
                        fornitore.Cognome = ragioneSociale;

                    fornitore.DisplayName = fornitore.Nome;
                    if (!string.IsNullOrEmpty(fornitore.Nome))
                        fornitore.DisplayName += " ";
                    fornitore.DisplayName += fornitore.Cognome;
                    if (!string.IsNullOrEmpty(fornitore.DisplayName))
                        fornitore.DisplayName = fornitore.DisplayName.Trim();

                    listaFornitori.Add(fornitore);
                }
                listaFornitori = listaFornitori.OrderBy(item => item.DisplayName).ToList();

                // ======================================
                // Elaboro lista Condomini
                // ======================================
                var listaCondomini = new List<PersonaListaDTO>(condomini.Count);
                foreach (var nameValueDTO in condomini)
                {
                    var nominativo = nameValueDTO.Name.Split('¥');

                    var persona = new PersonaListaDTO{ ID = nameValueDTO.Value};

                    var ragioneSociale = nominativo[2];
                    if (string.IsNullOrEmpty(ragioneSociale))
                    {
                        persona.Nome = nominativo[0];
                        persona.Cognome = nominativo[1];
                    }
                    else
                        persona.Cognome = ragioneSociale;

                    persona.DisplayName = persona.Nome;
                    if (!string.IsNullOrEmpty(persona.Nome))
                        persona.DisplayName += " ";
                    persona.DisplayName += persona.Cognome;
                    if (!string.IsNullOrEmpty(persona.DisplayName))
                        persona.DisplayName = persona.DisplayName.Trim();

                    listaCondomini.Add(persona);
                }
                listaCondomini = listaCondomini.OrderBy(item => item.DisplayName).ToList();

                // ======================================
                // Recupero lista conti
                // ======================================
                var conti = GetContiByCondominio(idCondominio, false, listaFornitori, true);

                // ======================================
                // Aggiungo sottoconto condomini
                // ======================================
                var pianoContiService = _windsorRepository.GetContainer(_info.Azienda).Resolve<IPianoContiService>(); 
                foreach (var contoDTO in conti)
                {
                    if (contoDTO.Codice == pianoContiService.GetCodiceContoVersamentiCondomini())
                    {
                        foreach (var persona in listaCondomini)
                        {
                            var sottoconto = new SottoContoDTO
                            {
                                ID = persona.ID,
                                Codice = $"{contoDTO.Codice}.{persona.ID.ToString(CultureInfo.InvariantCulture).PadLeft(7, '0')}",
                                DisplayName = $"C{persona.ID}", 
                                Descrizione = persona.DisplayName
                            };
                            sottoconto.DescrizioneCompleta = $"{sottoconto.Codice} - {sottoconto.Descrizione}";

                            contoDTO.SottoConti.Add(sottoconto);
                        }
                    }
                    else if(contoDTO.SottoConti.Count > 0)
                    {
                        var sottoconto = new SottoContoDTO
                        {
                            Codice = $"{contoDTO.Codice}.000",
                            Descrizione = contoDTO.Descrizione
                        };
                        sottoconto.DescrizioneCompleta = $"{sottoconto.Codice} - {sottoconto.Descrizione}";

                        contoDTO.SottoConti.Insert(0, sottoconto);
                    }
                }

                return conti;
            }
            catch (Exception ex)
            {
                _log.ErrorFormat("Errore nel caricamento dei conti per partitario - {0} - condominio:{1}", ex, Utility.GetMethodDescription(), idCondominio);
                throw;
            }
        }
Example #5
0
        private void ricercaPersoneClick(object sender, EventArgs e)
        {
            try
            {
                //Cast the sender into an UltraGrid
                var grid = sender as UltraGrid;

                //Get the last element that the mouse entered
                if (grid != null && grid.DisplayLayout != null && grid.DisplayLayout.UIElement != null)
                {
                    var lastElementEntered = grid.DisplayLayout.UIElement.LastElementEntered;

                    //See if there's a RowUIElement in the chain.
                    RowUIElement rowElement = null;
                    if (lastElementEntered != null)
                    {
                        try
                        {
                            var element = lastElementEntered as RowUIElement;
                            if (element != null)
                                rowElement = element;
                            else
                                rowElement = (RowUIElement)lastElementEntered.GetAncestor(typeof(RowUIElement));
                        }
                        catch (Exception ex)
                        {
                            _log.FatalFormat("Errore inaspettato durante la ricerca di persone - LAST_ELEMENT_ENTERED - {0} - azienda:{1}", ex, Utility.GetMethodDescription(), Security.Login.Instance.CurrentLogin().Azienda);
                            throw;
                        }
                    }

                    if (rowElement == null) return;

                    //Try to get a row from the element
                    object rowObj;
                    try
                    {
                        rowObj = rowElement.GetContext(typeof(UltraGridRow));
                    }
                    catch (Exception ex)
                    {
                        _log.FatalFormat("Errore inaspettato durante la ricerca di persone - GETCONTEXT - {0} - azienda:{1}", ex, Utility.GetMethodDescription(), Security.Login.Instance.CurrentLogin().Azienda);
                        throw;
                    }

                    //If no row was returned, then the mouse is not over a row. 
                    if (rowObj == null)
                        return;

                    var row = (UltraGridRow) rowObj;

                    if (row.ListObject != null)
                    {
                        try
                        {
                            _personaSelected = (PersonaListaDTO)row.ListObject;
                            persona.Text = _personaSelected.DisplayName;
                            OnSelectPersona(new DataSourceEventArgs<PersonaListaDTO>(_personaSelected));
                            ((DropDownEditorButton)persona.ButtonsRight["SceltaPersona"]).CloseUp();
                        }
                        catch (Exception ex)
                        {
                            _log.FatalFormat("Errore inaspettato durante la ricerca di persone - ON SELECT PERSONA - {0} - azienda:{1}", ex, Utility.GetMethodDescription(), Security.Login.Instance.CurrentLogin().Azienda);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                _log.FatalFormat("Errore inaspettato durante la ricerca di persone - {0} - azienda:{1}", ex, Utility.GetMethodDescription(), Security.Login.Instance.CurrentLogin().Azienda);
            }
        }
Example #6
0
        public void SetPersonaInitial(int idPersona)
        {
            try
            {
                if (idPersona > 0)
                {
                    if (!_isLoaded)
                        sceltaPersonaComboLoad(null, EventArgs.Empty);

                    _personaInitial = idPersona;

                    ricercaPersone.BeginUpdate();
                    ricercaPersone.SuspendRowSynchronization();
                    try
                    {
                        foreach (var row in ricercaPersone.Rows)
                        {
                            _personaSelected = row.ListObject as PersonaListaDTO;
                            if (_personaSelected != null && _personaSelected.ID == _personaInitial)
                            {
                                row.Selected = true;
                                persona.Text = _personaSelected.DisplayName;
                                OnSelectPersona(new DataSourceEventArgs<PersonaListaDTO>(SelectedPersona));
                                break;
                            }
                        }
                    }
                    finally
                    {
                        ricercaPersone.ResumeRowSynchronization();
                        ricercaPersone.EndUpdate();
                    }
                }
            }
            catch (Exception ex)
            {
                _log.ErrorFormat("Errore nell'impostazione della persona - {0} - azienda:{1}", ex, Utility.GetMethodDescription(), Security.Login.Instance.CurrentLogin().Azienda);                
                throw;
            }

        }
Example #7
0
        private void ricercaPersonePreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
        {
            if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Tab)
            {
                if (ricercaPersone.ActiveRow.GetCellValue("Id") != null && ricercaPersone.ActiveRow.GetCellValue("Id") != DBNull.Value)
                {
                    _personaSelected = (PersonaListaDTO)ricercaPersone.ActiveRow.ListObject;
                    OnSelectPersona(new DataSourceEventArgs<PersonaListaDTO>(_personaSelected));
                    persona.Text = ricercaPersone.ActiveRow.GetCellValue("DisplayName").ToString();
                    ((DropDownEditorButton)persona.ButtonsRight["SceltaPersona"]).CloseUp();
                }
            }

            if (e.KeyCode >= Keys.A && e.KeyCode <= Keys.Z)
                persona.Text += e.KeyCode.ToString();
            else if (e.KeyCode >= Keys.D0 && e.KeyCode <= Keys.D9)
                persona.Text += e.KeyCode.ToString().Substring(1, 1);
            else if (e.KeyCode >= Keys.NumPad0 && e.KeyCode <= Keys.NumPad9)
                persona.Text += e.KeyCode.ToString().Substring(6, 1);
            else if (e.KeyCode == Keys.Back)
            {
                if (persona.Text.Length > 0)
                    persona.Text = persona.Text.Substring(0, persona.Text.Length - 1);
            }
        }
Example #8
0
        private void personaLeave(object sender, EventArgs e)
        {
            if (_personaSelected == null || string.IsNullOrEmpty(persona.Text))
            {
                persona.Text = null;
                _personaSelected = null;
            }
            else
                persona.Text = _personaSelected.DisplayName;

            ricercaPersone.DisplayLayout.Bands[0].ColumnFilters.ClearAllFilters();
        }
Example #9
0
 public void Insert(PersonaListaDTO personaLista)
 {
     if (personaLista != null)
     {
         var listaPersone = personeBindingSource.DataSource as IList<PersonaListaDTO>;
         if (listaPersone != null && listaPersone.All(item => item.ID != personaLista.ID))
         {
             personeBindingSource.Insert(0, personaLista);
         }
     }
 }
Example #10
0
        public PersonaListaDTO ConvertPersonaScelta(PersonaSceltaDTO persona)
        {
            var personaLista = new PersonaListaDTO
            {
                DisplayName = persona.Nominativo, 
                ID = persona.Id,
                Indirizzo = persona.Indirizzo,
                Tipo = persona.Tipo
            };

            return personaLista;
        }
Example #11
0
        public PersonaListaDTO ConvertPersona(PersonaDTO persona)
        {
            var personaLista = new PersonaListaDTO { Cognome = persona.Cognome, DisplayName = persona.DisplayName, ID = persona.ID, Nome = persona.Nome, Note = persona.Note, Tipo = persona.TipoPersona.ToString() };
            if (persona.IndirizzoResidenza != null)
                personaLista.Indirizzo = persona.IndirizzoResidenza.DisplayName;
            if (persona.Domicilio != null)
                personaLista.Domicilio = persona.Domicilio.DisplayName;

            string telefono = null;
            string fax = null;
            string cellulare = null;
            string email = null;
            foreach (var contatto in persona.Contatti)
            {
                if (telefono == null && contatto.TipoContatto == "Telefono")
                    telefono = contatto.Valore;

                if (cellulare == null && contatto.TipoContatto == "Cellulare")
                    cellulare = contatto.Valore;

                if (email == null && contatto.TipoContatto == "Email")
                    email = contatto.Valore;

                if (fax == null && contatto.TipoContatto == "Fax")
                    fax = contatto.Valore;
            }
            personaLista.Cellulare = cellulare;
            personaLista.Telefono = telefono;
            personaLista.Fax = fax;
            personaLista.Email = email;

            return personaLista;
        }