Example #1
0
 public CabDwg(CabDwg 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 FetchCableList(int id, IDBManager dbmgr)
        {
            string qryString;

            switch (_user.plant)
            {
                case "ANO":
                    qryString = "SELECT cd.COMP_ID,  " +
                        " COMP = CASE WHEN c.CHKD_DATE IS NULL AND c.CABLE_CODE LIKE '%YES%' THEN 'R' ELSE '-' END, " +
                        " cd.CABLE_ID, cd.CABLE, cd.DWG_ID, cd.DWG_REF, cd.DWG_REV, cd.DWGTYPE_ID " +
                        " FROM viewCOMPCABDWGS AS cd " +
                        " LEFT OUTER JOIN viewCABLIST c ON c.CABLE_ID = cd.CABLE_ID " +
                        " WHERE cd.DWG_ID = @dwg_id " +
                        " ORDER BY cd.CABLE";
                    break;
                default:
                    qryString = "SELECT cd.*, '' AS COMP FROM viewCABDWGS AS cd " +
                        "INNER JOIN viewCABLIST_USED AS c ON c.CABLE_ID = cd.CABLE_ID " +
                        "WHERE cd.DWG_ID = @dwg_id ORDER BY cd.CABLE";
                    break;
            }

            CabDwg item = new CabDwg();											            // 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 CabDwg();											            // create new item
                item = (CabDwg)FetchObject(item, p, dbmgr);
                list.Add(item);													            // add item to the ArrayList
            }

            dbmgr.CloseReader();
            _drawing.cablelist = list;												        // update object item list
        }
Example #3
0
        private void FetchDrawingList(int id, IDBManager dbmgr)
        {
            string qryString;

            switch (_user.plant)
            {
                case "ANO":
                    qryString = "SELECT * FROM viewCOMPCABDWGS cd WHERE cd.CABLE_ID = @cable_id ORDER BY DWG_REF";
                    break;
                default:
                    qryString = "SELECT * FROM viewCOMPCABDWGS cd WHERE cd.CABLE_ID = @cable_id AND cd.DWGTYPE_DESC = 'Other' ORDER BY cd.DWG_REF, cd.DWG_REV";
                    break;
            }

            CabDwg item = new CabDwg();											            // create new object type to be able to get property info
            ArrayList list = new ArrayList();										        // create new ArrayList to house objects
            try
            {
                PropertyInfo[] p = item.GetType().GetProperties();					        // get property info for item
                dbmgr.Open();														        // open database manager
                dbmgr.CreateParameters(1);											        // create parameters
                dbmgr.AddParameters(0, "@cable_id", id);								    // cable id
                dbmgr.ExecuteReader(CommandType.Text, qryString);					        // execute query

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

            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                dbmgr.Dispose();
            }
            _cable.drawinglist = list;												        // update item list
        }