private Boolean Equals(BuildingComponent that)
        {
            if (that == null)
                return false;

            return this.Name.Equals(that.Name);
        }
Esempio n. 2
0
        public List<BuildingComponent> getDesignOptionComponents(DesignOption dOpt)
        {
            List<BuildingComponent> results = new List<BuildingComponent>();
            using (OleDbConnection conn = this.getConnection())
            {
                conn.Open();
                using (OleDbCommand comm = conn.CreateCommand())
                {
                    comm.CommandType = CommandType.Text;
                    comm.CommandText = "SELECT ComponentName, Description FROM BuildingComponent WHERE OptionID =" +
                                       " (SELECT id FROM DesignOption WHERE OptionName = ?);";
                    comm.Parameters.AddWithValue("@name", dOpt.Name);
                    using (OleDbDataReader reader = comm.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            BuildingComponent bComp = new BuildingComponent();
                            bComp.Name = reader["ComponentName"].ToString();
                            bComp.Description = reader["Description"].ToString();

                            results.Add(bComp);
                        }
                    }
                }
                conn.Close();
            }
            return results;
        }
Esempio n. 3
0
        public List<Assembly> getComponentAssemblies(BuildingComponent bComp)
        {
            List<Assembly> assemblies = new List<Assembly>();
            using (OleDbConnection conn = this.getConnection())
            {
                conn.Open();
                using (OleDbCommand comm = conn.CreateCommand())
                {
                    comm.CommandType = CommandType.Text;
                    comm.CommandText = "SELECT AssemName, Description, AssemblyCode " +
                                       "FROM Assembly WHERE " +
                                       "id in (select AssemblyID from comp_assem where componentID = " +
                                       "(select id from BuildingComponent where ComponentName = ?));";
                    comm.Parameters.AddWithValue("@name", bComp.Name);

                    using (OleDbDataReader reader = comm.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            Assembly a = new Assembly();
                            //Basic assembly information
                            a.AssemblyName = reader["AssemName"].ToString();
                            a.Description = reader["Description"].ToString();
                            a.AssemblyCode = reader["AssemblyCode"].ToString();
                            assemblies.Add(a);
                        }
                    }
                    foreach (Assembly a in assemblies)
                    {
                        a.Materials = getMaterialsByAssemblyName(a.AssemblyName);
                    }
                }
                conn.Close();
            }
            return assemblies;
        }
Esempio n. 4
0
 public List<Assembly> getComponentOptions(BuildingComponent bComp, int projID)
 {
     List<Assembly> assemblies = new List<Assembly>();
     using (OleDbConnection conn = this.getConnection())
     {
         conn.Open();
         using (OleDbCommand comm = conn.CreateCommand())
         {
             comm.CommandType = CommandType.Text;
             comm.CommandText = "SELECT AssemName, Description, AssemblyCode, Category FROM Assembly WHERE ID IN (SELECT AssemblyID from Comp_Assem WHERE ComponentID = (Select ID FROM BuildingComponent WHERE ComponentName = ? and ProjectID = ?));";
             comm.Parameters.AddWithValue("@name", bComp.Name);
             comm.Parameters.AddWithValue("@projID", projID);
             using (OleDbDataReader reader = comm.ExecuteReader())
             {
                 while (reader.Read())
                 {
                     Assembly assem = new Assembly();
                     assem.AssemblyName = reader["AssemName"].ToString();
                     assem.Description = reader["Description"].ToString();
                     assem.AssemblyCode = reader["AssemblyCode"].ToString();
                     assem.Category = reader["Category"].ToString();
                     assemblies.Add(assem);
                 }
             }
             foreach (Assembly a in assemblies)
             {
                 a.Materials = getMaterialsByAssemblyName(a.AssemblyName);
             }
         }
         conn.Close();
     }
     return assemblies;
 }
        private void calculateAreas_Volumes(List<Assembly> assemblies)
        {
            for(int i = 0; i < assemblies.Count(); i++)
            {
                Assembly assem = assemblies[i];
                String code = assem.AssemblyCode;
                if (areas.ContainsKey(code))
                {
                    double area = areas[assem.AssemblyCode];
                    areas[code] = area + assem.Area;
                }
                else
                {
                    areas.Add(code, assem.Area);
                    BuildingComponent bComp = new BuildingComponent();
                    bComp.Name = assem.AssemblyName;
                    bComp.Description = assem.Description;
                    bComp.Category = this.GeneralCategory;
                    Assemblies.Add(code, assem);
                    comps.Add(code, bComp);
                }

                if (volumes.ContainsKey(code))
                {
                    double volume = volumes[assem.AssemblyCode];
                    volumes[code] = volume + assem.Volume;
                }
                else
                    volumes.Add(code, assem.Volume);
            }
        }