Example #1
0
        private void CheckRegione(DTORendiconto r)
        {
            try
            {
                Regione reg = BilancioFenealgest.ServiceLayer.GeoElements.GeoHandlerProvider.Instance.Geo.GetGeoHandler().GetRegioneByName(_place);


                string regioneName = reg.Descrizione;


                //li confornto con i dati del rendiconto
                bool validated = true;



                if (!r.Regione.ToUpper().Equals(regioneName.ToUpper()))
                {
                    validated = false;
                }

                if (!validated)
                {
                    throw new Exception("Regione  non compatibile con l'utente loggato");
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Validazione compatibilitĂ  regione provincia non riuscita!" + Environment.NewLine + ex.Message);
            }
        }
Example #2
0
 public ExportBilancioServiceAgent(DTORendiconto rendiconto, string userName, string password, string place, bool forRlst)
 {
     _userName   = userName;
     _rendiconto = rendiconto;
     _password   = password;
     _place      = place;
     _forRlst    = forRlst;
 }
Example #3
0
        public void Export(BilancioFenealgest.DomainLayer.Rendiconto current, ExcelSearchCriteria criteria)
        {
            DTORendiconto r = null;

            if (_settings.DateToExport != null && _settings.DateToExport > DateTime.MinValue)
            {
                r = current.CreateDtoRendicontoWithSaldiInizialiBancaAtDate(_settings.DateToExport);
            }
            else
            {
                r = current.CreateDtoRendicontoWithSaldiInizialiBanca();
            }

            //lancio l'evento dfi inizio esportazione
            BeginExportBilancio(this, new EventArgs());

            ScriviBilancio(1, r, criteria);

            //////WriteWorkersWorkbook(1, "Lavoratori", list);


            if (_settings.StampaPreventivo)
            {
                //lancio l'evento dfi inizio esportazione
                BeginExportPreventivo(this, new EventArgs());

                ScriviBilancio(2, r, criteria);
            }


            if (_settings.StampaStatoPatrimoniale)
            {
                //lancio l'evento dfi inizio esportazione
                BeginExportStatoPatrimoniale(this, new EventArgs());



                ScriviStatoPatrimoniale(3, current.StatoPatrimoniale, r);
            }
        }
Example #4
0
        public void SendBilancio()
        {
            if (string.IsNullOrEmpty(_service.RendicontoSendableTag))
            {
                _view.GetSimpleMessageNotificator().Show("Esportazione non effettuata: " + Environment.NewLine + "Il rendiconto non è stato riconosciuto come un rendiconto Feneal o un rendiconto Rlst", "Errore", BilancioFenealgest.Middleware.MessageType.Error);
                return;
            }

            if ((_service.RendicontoSendableTag == "FENEAL" && _view.IsFeneal == false) || (_service.RendicontoSendableTag != "FENEAL" && _view.IsFeneal))
            {
                _view.GetSimpleMessageNotificator().Show("Esportazione non effettuata: " + Environment.NewLine + "Il rendiconto Feneal deve essere esportato dal programma del Rendiconto Feneal e non da quello RLST", "Errore", BilancioFenealgest.Middleware.MessageType.Error);
                return;
            }
            else if ((_service.RendicontoSendableTag == "RLST" && _view.IsRlst == false) || (_service.RendicontoSendableTag != "RLST" && _view.IsRlst))
            {
                _view.GetSimpleMessageNotificator().Show("Esportazione non effettuata: " + Environment.NewLine + "Il rendiconto RLST deve essere esportato dal programma del Rendiconto RLST e non da quello Feneal", "Errore", BilancioFenealgest.Middleware.MessageType.Error);
                return;
            }

            if ((_service.RendicontoSendableTag == "FENEAL" && _view.IsFeneal) || (_service.RendicontoSendableTag == "RLST" && _view.IsRlst))
            {
                try
                {
                    RendicontoHeaderDTO header = _service.RendicontoHeader;
                    string place;

                    if (header.IsRegionale)
                    {
                        place = header.Regione.ToUpper();
                    }
                    else
                    {
                        place = header.Provincia.ToUpper();
                    }


                    //Creo il file temporaneo
                    string path = CreateTemporaryFile();

                    //riprendio il file materializzato
                    DTORendicontoMappaer m = new DTORendicontoMappaer();

                    DTORendiconto r = m.LoadDTORendicontoByPath(path);

                    ExportBilancioServiceAgent a = new ExportBilancioServiceAgent(r, _view.UserName, _view.Password, place, _view.IsRlst);


                    //a.SendBilancio();

                    string result = a.SendBilancio();

                    if (string.IsNullOrEmpty(result))
                    {
                        _view.GetSimpleMessageNotificator().Show("Esportazione terminata con successo!", "Info", BilancioFenealgest.Middleware.MessageType.Information);
                    }
                    else
                    {
                        _view.GetSimpleMessageNotificator().Show("Esportazione non effettuata: " + Environment.NewLine + result, "Errore", BilancioFenealgest.Middleware.MessageType.Error);
                    }
                }
                catch (Exception ex)
                {
                    _view.GetSimpleMessageNotificator().Show("Esportazione non effettuata: " + Environment.NewLine + ex.Message, "Errore", BilancioFenealgest.Middleware.MessageType.Error);
                }
            }
        }
Example #5
0
        private void ScriviStatoPatrimoniale(int workBookindex, StatoPatrimoniale r, DTORendiconto rendiconto)
        {
            try
            {
                if (_handler.ExcelInstance == null)
                {    //'creo una nuova istanza di excel
                    _handler.OpenExcelApplication(true);
                }


                if (_handler.CurrentWorkbook == null)
                //'Aggiungo un nuovo documento ad excel
                {
                    _handler.AddDocumentToExcel(_model);
                    //'lo attivo
                    _handler.ActivateWorkBook();
                }

                //'seleziono lo sheet di interesse
                _handler.SelectSheetByIndex(workBookindex);



                _handler.FindReplaceCellValue(10, 10, "#prop#", rendiconto.Proprietario, false, OfficeExcelHandler.FindMode.Table);
                _handler.FindReplaceCellValue(10, 10, "#anno#", rendiconto.Anno.ToString(), false, OfficeExcelHandler.FindMode.Table);


                if (_settings.InventarioDisegnaOrizzontalmente)
                {
                    int currentRow = 1 + _settings.InventarioRigaIniziale;
                    int currentCol = 1;

                    WriteBeniImmobiliOrizzontalmente(r.Immobili, ref currentRow, ref currentCol);
                    WriteDepositiOrizzontalmente(r.Depositi, ref currentRow, ref currentCol);
                    WritePolizzeOrizzontalmente(r.Polizze, ref currentRow, ref currentCol);
                    WriteAutoOrizzontalmente(r.Autos, ref currentRow, ref currentCol);

                    WriteMobiliOrizzontalmente(r.Mobili, ref currentRow, ref currentCol);
                    WriteAccantonamentiTFROrizzontalmente(r.AccantonamentiTFR, ref currentRow, ref currentCol);
                    WriteChiusureOrizzontalmente(r.Chiusure, ref currentRow, ref currentCol);
                }
                else
                {
                    int currentRow = 1 + _settings.InventarioRigaIniziale;
                    int currentCol = 1 + _settings.InventarioColonnaIniziale;

                    WriteBeniImmobiliVerticalmente(r.Immobili, ref currentRow, currentCol);
                    WriteDepositiVerticalmente(r.Depositi, ref currentRow, currentCol);
                    WritePolizzeVerticalmente(r.Polizze, ref currentRow, currentCol);
                    WriteAutoVerticalmente(r.Autos, ref currentRow, currentCol);

                    WriteMobiliVerticalmente(r.Mobili, ref currentRow, currentCol);
                    WriteAccantonamentiTFRVerticalmente(r.AccantonamentiTFR, ref currentRow, currentCol);
                    WriteChiusureVerticalmente(r.Chiusure, ref currentRow, currentCol);
                }
            }
            catch (Exception)
            {
                _handler.Dispose();
                throw;
            }
        }
Example #6
0
        private void ScriviBilancio(int workBookindex, DTORendiconto r, ExcelSearchCriteria criteria)
        {
            try
            {
                if (_handler.ExcelInstance == null)
                {    //'creo una nuova istanza di excel
                    _handler.OpenExcelApplication(true);
                }



                if (_handler.CurrentWorkbook == null)
                //'Aggiungo un nuovo documento ad excel
                {
                    _handler.AddDocumentToExcel(_model);
                    //'lo attivo
                    _handler.ActivateWorkBook();
                }

                //'seleziono lo sheet di interesse
                _handler.SelectSheetByIndex(workBookindex);

                _handler.FindReplaceCellValue(3, 26, "#prop#", r.Proprietario, true, OfficeExcelHandler.FindMode.Table);
                _handler.FindReplaceCellValue(54, 26, "#prop#", r.Proprietario, true, OfficeExcelHandler.FindMode.LockRow);

                if (workBookindex == 2)
                {
                    _handler.FindReplaceCellValue(3, 26, "#anno#", (r.Anno + 1).ToString(), true, OfficeExcelHandler.FindMode.Table);
                    _handler.FindReplaceCellValue(54, 26, "#anno#", (r.Anno + 1).ToString(), true, OfficeExcelHandler.FindMode.LockRow);
                }
                else
                {
                    _handler.FindReplaceCellValue(3, 26, "#anno#", r.Anno.ToString(), true, OfficeExcelHandler.FindMode.Table);
                    _handler.FindReplaceCellValue(54, 26, "#anno#", r.Anno.ToString(), true, OfficeExcelHandler.FindMode.LockRow);
                }


                foreach (DTORendicontoItem item in r.Items)
                {
                    if (item.IdNodo != "")
                    {
                        if (workBookindex == 1)
                        {
                            // if (item.IdNodo.StartsWith("E") || item.IdNodo.StartsWith("P") || item.IdNodo.StartsWith("A"))
                            _handler.FindReplaceCellValue(criteria.MaxRowPrimaColonna, criteria.MaxColPrimaColonna, "#" + item.IdNodo + "#", item.ImportoBilancio.ToString("c"), false, criteria.FindMode);
                            // else
                            _handler.FindReplaceCellValue(criteria.MaxRowSecondaColonna, criteria.MaxColSecondaColonna, "#" + item.IdNodo + "#", item.ImportoBilancio.ToString("c"), false, criteria.FindMode);
                        }
                        else
                        {
                            // if (item.IdNodo.StartsWith("E") || item.IdNodo.StartsWith("P") || item.IdNodo.StartsWith("A"))
                            _handler.FindReplaceCellValue(criteria.MaxRowPrimaColonna, criteria.MaxColPrimaColonna, "#" + item.IdNodo + "#", item.ImportoPreventivo.ToString("c"), false, criteria.FindMode);
                            //  else
                            _handler.FindReplaceCellValue(criteria.MaxRowSecondaColonna, criteria.MaxColSecondaColonna, "#" + item.IdNodo + "#", item.ImportoPreventivo.ToString("c"), false, criteria.FindMode);
                        }
                    }
                }

                //_handler.FindReplaceCellValue(10, 3, "Quote", "PubblicitĂ ", false);

                //_handler.FillExcelCell(c.Row, c.Column, h);
            }
            catch (Exception)
            {
                _handler.Dispose();
                throw;
            }
        }