public CompDwg(CompDwg 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 } }
private void FetchComponentList(int id, IDBManager dbmgr) { string qryString = "SELECT * FROM viewCOMPDWGS cd WHERE cd.DWG_ID = @dwg_id ORDER BY cd.COMP"; CompDwg item = new CompDwg(); // create new object type to be able to get property info ArrayList list = new ArrayList(); // create new ArrayList to house objects PropertyInfo[] p = item.GetType().GetProperties(); // get property info for item dbmgr.CreateParameters(1); // create parameters dbmgr.AddParameters(0, "@dwg_id", id); // drawing id dbmgr.ExecuteReader(CommandType.Text, qryString); // execute query while (dbmgr.DataReader.Read()) { item = new CompDwg(); // create new item item = (CompDwg)FetchObject(item, p, dbmgr); list.Add(item); // add item to the ArrayList } dbmgr.CloseReader(); _drawing.componentlist = list; // update object item list }
// procedure fetches drawings given a component id private void FetchDrawingList(int id, IDBManager dbmgr) { string qryString = "SELECT * FROM viewCOMPDWGS cd WHERE cd.COMP_ID = @comp_id AND cd.DWGTYPE_desc = 'Other' ORDER BY cd.DWG_REF, cd.DWG_REV"; //string qryString = "SELECT * FROM viewCOMPDWGS cd WHERE cd.COMP_ID = @comp_id AND DWGTYPE_ID <= 4 ORDER BY cd.DWGTYPE_ID, cd.DWG_REF, cd.DWG_REV"; CompDwg item = new CompDwg(); 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 CompDwg(); // create new item item = (CompDwg)FetchObject(item, p, dbmgr); list.Add(item); // add item to the ArrayList } dbmgr.CloseReader(); _comp.drawinglist = list; // update object item list }