public AnalisiPortafoglio QuoteInvGeoSettori(IList <RegistryOwner> _selectedOwners)
        {
            string gestioni = "A.id_gestione = ";

            if (_selectedOwners.Count >= 1)
            {
                foreach (RegistryOwner item in _selectedOwners)
                {
                    gestioni += item.Id_gestione + " OR A.id_gestione = ";
                }
            }
            else
            {
                throw new Exception("ManagerReportService - Errore nel passaggio dei dati");
            }
            gestioni = gestioni.Substring(0, gestioni.Length - 20);
            try
            {
                using (MySqlDataAdapter dbAdaptar = new MySqlDataAdapter())
                {
                    dbAdaptar.SelectCommand             = new MySqlCommand();
                    dbAdaptar.SelectCommand.Connection  = new MySqlConnection(DAFconnection.GetConnectionType());
                    dbAdaptar.SelectCommand.CommandType = CommandType.Text;
                    dbAdaptar.SelectCommand.CommandText = string.Format(SQL.ReportScripts.QuoteInvGeoSettori, gestioni);
                    DataTable dt = new DataTable();
                    dbAdaptar.Fill(dt);
                    gestioni = "";
                    AnalisiPortafoglio RS = new AnalisiPortafoglio();
                    foreach (var property in RS.GetType().GetProperties())
                    {
                        if (property.Name != "id_titolo" && property.Name != "desc_titolo" &&
                            property.Name != "Isin" && property.Name != "data_modifica" &&
                            property.Name != "id_tipo_titolo" && property.Name != "id_azienda" &&
                            property.Name != "Nome")
                        {
                            property.SetValue(RS, dt.Rows[0].Field <object>(property.Name));
                        }
                        else if (property.Name == "Nome")
                        {
                            foreach (RegistryOwner item in _selectedOwners)
                            {
                                gestioni += item.Nome_Gestione + " + ";
                            }
                            gestioni = gestioni.Substring(0, gestioni.Length - 3);
                            property.SetValue(RS, gestioni);
                        }
                    }
                    return(RS);
                }
            }
            catch (MySqlException err)
            {
                throw new Exception(err.Message);
            }
            catch (Exception err)
            {
                throw new Exception(err.Message);
            }
        }
示例#2
0
 public AnalisiPortafoglioViewModel(AnalisiPortafoglio analisiPortafoglio)
 {
     ActualRecord = analisiPortafoglio;
     SetTitle();
 }