Example #1
0
 public CompPwr(CompPwr 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 power list
        private void FetchPowerList(int id, IDBManager dbmgr)
        {
            string qryString = "SELECT * FROM viewCOMPPWR cp WHERE cp.COMP_ID = @comp_id ORDER BY cp.POWER";

            CompPwr item = new CompPwr();
            ArrayList list = new ArrayList();

            PropertyInfo[] p = item.GetType().GetProperties();					            // get property info for item
            dbmgr.CreateParameters(1);											            // create parameters
            dbmgr.AddParameters(0, "@comp_id", id);								            // component id
            dbmgr.ExecuteReader(CommandType.Text, qryString);					            // execute query

            while (dbmgr.DataReader.Read())
            {
                item = new CompPwr();											            // create new item
                item = (CompPwr)FetchObject(item, p, dbmgr);
                list.Add(item);													            // add item to the ArrayList
            }

            dbmgr.CloseReader();
            _comp.powerlist = list;													        // update component item list
        }