Пример #1
0
 public Vertex(Vertex obj)
 {
     PropertyInfo[] p = obj.GetType().GetProperties();                               // get entity properties
     for (int i = 0; i < (p.Length); i++)
     {
         if (!p[i].PropertyType.Name.Contains("list") && !p[i].Name.Contains("arg"))
             p[i].SetValue(this, p[i].GetValue(obj, null), null);                    // set entity's property values to obj properties
     }
 }
        // procedure fetches drawings given a component id
        private void FetchVertexList(int id, IDBManager dbmgr)
        {
            Vertex item = new Vertex();
            ArrayList list = new ArrayList();

            PropertyInfo[] p = item.GetType().GetProperties();
            string qryString = "SELECT DISTINCT c.FR_EQUIP_BD AS NAME, dbo.GET_LOCATION(cc.FR_EQUIP) AS LOCATION " +
                                "FROM viewCOMPCAB cc " +
                                "INNER JOIN CABLIST c ON c.CABLE_ID = cc.CABLE_ID " +
                                "WHERE cc.COMP_ID = @comp_id " +
                                "UNION " +
                                "SELECT DISTINCT c.TO_EQUIP_BD AS NAME, dbo.GET_LOCATION(cc.TO_EQUIP) AS LOCATION " +
                                "FROM viewCOMPCAB cc " +
                                "INNER JOIN CABLIST c ON c.CABLE_ID = cc.CABLE_ID " +
                                "WHERE cc.COMP_ID = @comp_id " +
                                "ORDER BY NAME";

            dbmgr.CreateParameters(1);
            dbmgr.AddParameters(0, "@comp_id", id);
            dbmgr.ExecuteReader(CommandType.Text, qryString);

            while (dbmgr.DataReader.Read())
            {
                item = new Vertex();
                item = (Vertex)FetchObject(item, p, dbmgr);
                list.Add(item);
            }

            dbmgr.CloseReader();
            _cabBlock.vertexlist = list;
        }