Example #1
0
        // fetches object and object items
        // user has option of passing object itself OR a string with id and type delimited by '|'
        public object Fetch(object obj)
        {
            int id;
            string type;
            string objtype = obj.GetType().ToString();

            if (objtype == "System.String")
            {
                string[] strTemp = ((string)obj).Split(new char[] { '|' });
                id = Convert.ToInt32(strTemp[0]);
                type = strTemp[1];
            }
            else
            {
                id = ((Component)obj).comp_id;
                type = "all";
            }

            // create new object and database connection
            _comp = new Component();
            _user = (User)System.Web.HttpContext.Current.Session[Constant.session.User];
            _dbmgr = new DBManager(_user.plantDBStr);
            _dbmgr.ConnectionString = _user.plantDBStr;

            try
            {
                _dbmgr.Open();

                // determine type
                switch (type)
                {
                    case "ra":
                        FetchRAList(id, _dbmgr);
                        return _comp.ralist;
                    default:
                        FetchComponent(id, _dbmgr);
                        FetchFACompDispList(id, _dbmgr);
                        FetchRAList(id, _dbmgr);
                        return _comp;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                _dbmgr.Dispose();
            }
        }
Example #2
0
        private void FetchComponent(int id, IDBManager dbmgr)
        {
            string qryLocal = "SELECT * FROM viewCOMPLIST WHERE COMP_ID=@id";

            dbmgr.CreateParameters(1);                                                      // create required parameters
            dbmgr.AddParameters(0, "@id", id);
            dbmgr.ExecuteReader(CommandType.Text, qryLocal);                                // execute reader
            if (dbmgr.DataReader.Read())
            {
                // get properties of object and fetch object
                PropertyInfo[] p = _comp.GetType().GetProperties();
                _comp = (Component)FetchObject(_comp, p, dbmgr);
            }

            dbmgr.CloseReader();
        }
Example #3
0
 public Component(Component oldobj)
 {
     PropertyInfo[] p = oldobj.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(oldobj, null), null);                 // set entity's property values to obj properties
     }
 }
        // fetches object and object items
        // user has option of passing object itself OR a string with id and type delimited by '|'
        public object Fetch(object obj)
        {
            int id = 0;
            string name = "";
            string type = "all";

            string objtype = obj.GetType().ToString();
            if (objtype == "System.String")
            {
                // if the object type is a string then extract the id and type
                string[] strTemp = ((string)obj).Split(new char[] { '|' });
                type = strTemp[1];
                if (type == "pricomp")
                    name = strTemp[0];
                else
                    id = Convert.ToInt32(strTemp[0]);
            }
            else
                id = ((Component)obj).comp_id;

            // create new object and database connection
            _comp = new Component();
            _user = (User)System.Web.HttpContext.Current.Session[Constant.session.User];
            _dbmgr = new DBManager(_user.plantDBStr);
            _dbmgr.ConnectionString = _user.plantDBStr;

            try
            {
                _dbmgr.Open();

                // determine type
                switch (type)
                {
                    case "drawing":
                        FetchDrawingList(id, _dbmgr);
                        return _comp.drawinglist;
                    case "power":
                        FetchPowerList(id, _dbmgr);
                        return _comp.powerlist;
                    case "subcomp":
                        FetchSubcompList(id, _dbmgr);
                        return _comp.subcomplist;
                    case "pricomp":
                        FetchPriCompList(name, _dbmgr);
                        return _comp.pricomplist;
                    case "interlock":
                        FetchIncomingIntlkList(id, _dbmgr);
                        return _comp.incomingintlklist;
                    case "cable":
                        FetchCableList(id, _dbmgr);
                        return _comp.cablelist;
                    case "be":
                        FetchBEList(id, _dbmgr);
                        return _comp.belist;
                    default:
                        FetchComponent(id, _dbmgr);
                        FetchDrawingList(id, _dbmgr);
                        FetchSubcompList(id, _dbmgr);
                        FetchPowerList(id, _dbmgr);
                        FetchLoadList(id, _dbmgr);
                        FetchIncomingIntlkList(id, _dbmgr);
                        FetchOutgoingIntlkList(id, _dbmgr);
                        FetchCableList(id, _dbmgr);
                        return _comp;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                _dbmgr.Dispose();
            }
        }
        private void UpdateStatus(IDBManager dbmgr, Component item, int statustype_id, string user_id, DateTime status_date)
        {
            if ((user_id == "N/A") || (user_id == ""))
            {
                // delete status
                dbmgr.CreateParameters(2);
                dbmgr.AddParameters(0, "@comp_id", item.comp_id);
                dbmgr.AddParameters(1, "@statustype_id", statustype_id);
                dbmgr.ExecuteNonQuery(CommandType.StoredProcedure, "dbo.COMPSTATUS_d");
            }
            else
            {

                if (status_date == Convert.ToDateTime(null))
                {
                    // update status
                    dbmgr.CreateParameters(3);
                    dbmgr.AddParameters(0, "@comp_id", item.comp_id);
                    dbmgr.AddParameters(1, "@statustype_id", statustype_id);
                    dbmgr.AddParameters(2, "@user_id", user_id);
                }
                else
                {
                    // update status
                    dbmgr.CreateParameters(4);
                    dbmgr.AddParameters(0, "@comp_id", item.comp_id);
                    dbmgr.AddParameters(1, "@statustype_id", statustype_id);
                    dbmgr.AddParameters(2, "@user_id", user_id);
                    dbmgr.AddParameters(3, "@status_date", status_date);
                }
                dbmgr.ExecuteNonQuery(CommandType.StoredProcedure, "dbo.COMPSTATUS_u");
            }
        }
 private void UpdateMasterDrawing(IDBManager dbmgr, Component item, int dwg_id, string dwg_ref, string dwg_rev, string dwg_cp, int dwg_type)
 {
     // if drawing ref is empty or N/A then delete
     if (dwg_ref == "")
     {
         dbmgr.CreateParameters(3);
         dbmgr.BeginTransaction();
         dbmgr.AddParameters(0, "@comp_id", item.comp_id);
         dbmgr.AddParameters(1, "@dwg_id", dwg_id);
         dbmgr.AddParameters(2, "@dwgtype_id", dwg_type);
         dbmgr.ExecuteNonQuery(CommandType.StoredProcedure, "dbo.COMPDWGS_d");
     }
     // otherwise update
     else
     {
         // add updated/new
         dbmgr.CreateParameters(5);
         dbmgr.AddParameters(0, "@comp_id", item.comp_id);
         dbmgr.AddParameters(1, "@dwg_id", dwg_id);
         dbmgr.AddParameters(2, "@dwgtype_id", dwg_type);
         dbmgr.AddParameters(3, "@dwg_rev", dwg_rev);
         dbmgr.AddParameters(4, "@dwg_cp", dwg_cp);
         dbmgr.ExecuteNonQuery(CommandType.StoredProcedure, "dbo.COMPDWGS_MASTER_u");
     }
 }