public RegistryShareList GetRegistryShareList() { 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 = SQL.RegistryScripts.GetRegistryShareList; DataTable dt = new DataTable(); dbAdaptar.Fill(dt); RegistryShareList RSL = new RegistryShareList(); foreach (DataRow dr in dt.Rows) { RegistryShare RS = new RegistryShare(); foreach (var property in RS.GetType().GetProperties()) { property.SetValue(RS, dr.Field <object>(property.Name)); } RSL.Add(RS); } return(RSL); } } catch (MySqlException err) { throw new Exception(err.Message); } catch (Exception err) { throw new Exception(err.Message); } }
public RegistryShareList GetSharesByFirms(int[] id_aziende) { try { string where = ""; foreach (int x in id_aziende) { where += string.Format(" id_azienda = {0} OR ", x); } where = where.Remove(where.Length - 3, 3); 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.RegistryScripts.GetSharesByFirms, where); DataTable dt = new DataTable(); dbAdaptar.Fill(dt); RegistryShareList RSL = new RegistryShareList(); foreach (DataRow dr in dt.Rows) { RegistryShare RS = new RegistryShare(); foreach (var property in RS.GetType().GetProperties()) { property.SetValue(RS, dr.Field <object>(property.Name)); } RSL.Add(RS); } return(RSL); } } catch (MySqlException err) { throw new Exception(err.Message); } catch (Exception err) { throw new Exception(err.Message); } }