public IList<INSTRUMENT> GetAllInstrumentsFromThreeTable()
        {
            SqlServerUtility sql = new SqlServerUtility();
            SqlDataReader reader = sql.ExecuteSPReader("usp_SelectAllInstrumentsFromTritables");

            IList<Core.Business.INSTRUMENT> iNSTRUMENTlist = new List<Core.Business.INSTRUMENT>();

            if (reader != null)
            {
                while (!reader.IsClosed && reader.Read())
                {
                    Core.Business.INSTRUMENT iNSTRUMENT = new Core.Business.INSTRUMENT();

                    if (!reader.IsDBNull(0)) iNSTRUMENT.Id = reader.GetGuid(0);
                    if (!reader.IsDBNull(1)) iNSTRUMENT.InstruCode = reader.GetString(1);
                    if (!reader.IsDBNull(2)) iNSTRUMENT.LaboratoryId = reader.GetGuid(2);
                    if (!reader.IsDBNull(3)) iNSTRUMENT.WorkingforUnitId = reader.GetGuid(3);
                    if (!reader.IsDBNull(4)) iNSTRUMENT.MachineGroupId = reader.GetGuid(4);
                    if (!reader.IsDBNull(5)) iNSTRUMENT.PERSONNELID = reader.GetGuid(5);
                    if (!reader.IsDBNull(6)) iNSTRUMENT.HNAME = reader.GetString(6);
                    if (!reader.IsDBNull(7)) iNSTRUMENT.ENAME = reader.GetString(7);
                    if (!reader.IsDBNull(8)) iNSTRUMENT.ALIAS = reader.GetString(8);
                    if (!reader.IsDBNull(9)) iNSTRUMENT.CLASSCODE = reader.GetString(9);
                    if (!reader.IsDBNull(10)) iNSTRUMENT.SITE = reader.GetGuid(10);
                    if (!reader.IsDBNull(11)) iNSTRUMENT.CITY = reader.GetGuid(11);
                    if (!reader.IsDBNull(12)) iNSTRUMENT.SPECTYPE = reader.GetString(12);
                    if (!reader.IsDBNull(13)) iNSTRUMENT.GETMODE = reader.GetGuid(13);
                    if (!reader.IsDBNull(14)) iNSTRUMENT.WorkState = reader.GetInt32(14);
                    if (!reader.IsDBNull(15)) iNSTRUMENT.UseState = reader.GetInt32(15);
                    if (!reader.IsDBNull(16)) iNSTRUMENT.MANUFACTURE = reader.GetString(16);
                    if (!reader.IsDBNull(17)) iNSTRUMENT.COUNTRYCODE = reader.GetGuid(17);
                    if (!reader.IsDBNull(18)) iNSTRUMENT.PRODUCINGAREA = reader.GetString(18);
                    if (!reader.IsDBNull(19)) iNSTRUMENT.PRODUCESORT = reader.GetGuid(19);
                    if (!reader.IsDBNull(20)) iNSTRUMENT.VALUERMB = reader.GetDecimal(20);
                    if (!reader.IsDBNull(21)) iNSTRUMENT.NATIONALPAY = reader.GetDecimal(21);
                    if (!reader.IsDBNull(22)) iNSTRUMENT.BUGETSOURCE = reader.GetGuid(22);
                    if (!reader.IsDBNull(23)) iNSTRUMENT.PRODUCEDATE = reader.GetDateTime(23);
                    if (!reader.IsDBNull(24)) iNSTRUMENT.PURCHASEDATE = reader.GetDateTime(24);
                    if (!reader.IsDBNull(25)) iNSTRUMENT.DISCARDTIME = reader.GetDateTime(25);
                    if (!reader.IsDBNull(26)) iNSTRUMENT.GUIDELINE = reader.GetString(26);
                    if (!reader.IsDBNull(27)) iNSTRUMENT.FUNCTIONFEATURES = reader.GetString(27);
                    if (!reader.IsDBNull(28)) iNSTRUMENT.EXAMINATION = reader.GetGuid(28);
                    if (!reader.IsDBNull(29)) iNSTRUMENT.HasCMA = reader.GetInt32(29);
                    if (!reader.IsDBNull(30)) iNSTRUMENT.IsSpecial = reader.GetInt32(30);
                    if (!reader.IsDBNull(31)) iNSTRUMENT.TOTALLY = reader.GetInt32(31);
                    if (!reader.IsDBNull(32)) iNSTRUMENT.ACCEPTMISSION = reader.GetInt32(32);
                    if (!reader.IsDBNull(33)) iNSTRUMENT.EXTERNALSERVICE = reader.GetInt32(33);
                    if (!reader.IsDBNull(34)) iNSTRUMENT.PICTURE = reader.GetInt32(34);
                    if (!reader.IsDBNull(35)) iNSTRUMENT.ATTACHMENT = reader.GetInt32(35);
                    if (!reader.IsDBNull(36)) iNSTRUMENT.MEDIA = reader.GetInt32(36);
                    if (!reader.IsDBNull(37)) iNSTRUMENT.PURPOSEID = reader.GetString(37);
                    if (!reader.IsDBNull(38)) iNSTRUMENT.REALMID = reader.GetString(38);
                    if (!reader.IsDBNull(39)) iNSTRUMENT.WRITEDATE = reader.GetDateTime(39);
                    if (!reader.IsDBNull(40)) iNSTRUMENT.UPDATEDATE = reader.GetDateTime(40);
                    if (!reader.IsDBNull(41)) iNSTRUMENT.REMARK = reader.GetString(41);
                    if (!reader.IsDBNull(42)) iNSTRUMENT.AUDITINGSTATE = reader.GetInt32(42);
                    if (!reader.IsDBNull(43)) iNSTRUMENT.ASSESSOR = reader.GetString(43);
                    if (!reader.IsDBNull(44)) iNSTRUMENT.AUDITINGDATE = reader.GetDateTime(44);

                    if (!reader.IsDBNull(45)) iNSTRUMENT.RollCall = reader.GetInt64(45);
                    if (!reader.IsDBNull(46)) iNSTRUMENT.OringalId = reader.GetInt32(46);
                    if (!reader.IsDBNull(47)) iNSTRUMENT.Gather = reader.GetInt32(47);

                    iNSTRUMENT.MarkOld();
                    iNSTRUMENTlist.Add(iNSTRUMENT);
                }

                reader.Close();
            }

            return iNSTRUMENTlist;
        }
        public Core.Business.INSTRUMENT Select(Guid id)
        {
            SqlServerUtility sql = new SqlServerUtility();

            sql.AddParameter("@Id", SqlDbType.UniqueIdentifier, id);
            SqlDataReader reader = sql.ExecuteSPReader("usp_SelectINSTRUMENT");

            if (reader != null && !reader.IsClosed && reader.Read())
            {
                Core.Business.INSTRUMENT instrument = new Core.Business.INSTRUMENT();

                if (!reader.IsDBNull(0)) instrument.Id = reader.GetGuid(0);
                if (!reader.IsDBNull(1)) instrument.InstruCode = reader.GetString(1);
                if (!reader.IsDBNull(2)) instrument.LaboratoryId = reader.GetGuid(2);
                if (!reader.IsDBNull(3)) instrument.WorkingforUnitId = reader.GetGuid(3);
                if (!reader.IsDBNull(4)) instrument.MachineGroupId = reader.GetGuid(4);
                if (!reader.IsDBNull(5)) instrument.PERSONNELID = reader.GetGuid(5);
                if (!reader.IsDBNull(6)) instrument.HNAME = reader.GetString(6);
                if (!reader.IsDBNull(7)) instrument.ENAME = reader.GetString(7);
                if (!reader.IsDBNull(8)) instrument.ALIAS = reader.GetString(8);
                if (!reader.IsDBNull(9)) instrument.CLASSCODE = reader.GetString(9);
                if (!reader.IsDBNull(10)) instrument.SITE = reader.GetGuid(10);
                if (!reader.IsDBNull(11)) instrument.CITY = reader.GetGuid(11);
                if (!reader.IsDBNull(12)) instrument.SPECTYPE = reader.GetString(12);
                if (!reader.IsDBNull(13)) instrument.GETMODE = reader.GetGuid(13);
                if (!reader.IsDBNull(14)) instrument.WorkState = reader.GetInt32(14);
                if (!reader.IsDBNull(15)) instrument.UseState = reader.GetInt32(15);
                if (!reader.IsDBNull(16)) instrument.MANUFACTURE = reader.GetString(16);
                if (!reader.IsDBNull(17)) instrument.COUNTRYCODE = reader.GetGuid(17);
                if (!reader.IsDBNull(18)) instrument.PRODUCINGAREA = reader.GetString(18);
                if (!reader.IsDBNull(19)) instrument.PRODUCESORT = reader.GetGuid(19);
                if (!reader.IsDBNull(20)) instrument.VALUERMB = reader.GetDecimal(20);
                if (!reader.IsDBNull(21)) instrument.NATIONALPAY = reader.GetDecimal(21);
                if (!reader.IsDBNull(22)) instrument.BUGETSOURCE = reader.GetGuid(22);
                if (!reader.IsDBNull(23)) instrument.PRODUCEDATE = reader.GetDateTime(23);
                if (!reader.IsDBNull(24)) instrument.PURCHASEDATE = reader.GetDateTime(24);
                if (!reader.IsDBNull(25)) instrument.DISCARDTIME = reader.GetDateTime(25);
                if (!reader.IsDBNull(26)) instrument.GUIDELINE = reader.GetString(26);
                if (!reader.IsDBNull(27)) instrument.FUNCTIONFEATURES = reader.GetString(27);
                if (!reader.IsDBNull(28)) instrument.EXAMINATION = reader.GetGuid(28);
                if (!reader.IsDBNull(29)) instrument.HasCMA = reader.GetInt32(29);
                if (!reader.IsDBNull(30)) instrument.IsSpecial = reader.GetInt32(30);
                if (!reader.IsDBNull(31)) instrument.TOTALLY = reader.GetInt32(31);
                if (!reader.IsDBNull(32)) instrument.ACCEPTMISSION = reader.GetInt32(32);
                if (!reader.IsDBNull(33)) instrument.EXTERNALSERVICE = reader.GetInt32(33);
                if (!reader.IsDBNull(34)) instrument.PICTURE = reader.GetInt32(34);
                if (!reader.IsDBNull(35)) instrument.ATTACHMENT = reader.GetInt32(35);
                if (!reader.IsDBNull(36)) instrument.MEDIA = reader.GetInt32(36);
                if (!reader.IsDBNull(37)) instrument.PURPOSEID = reader.GetString(37);
                if (!reader.IsDBNull(38)) instrument.REALMID = reader.GetString(38);
                if (!reader.IsDBNull(39)) instrument.WRITEDATE = reader.GetDateTime(39);
                if (!reader.IsDBNull(40)) instrument.UPDATEDATE = reader.GetDateTime(40);
                if (!reader.IsDBNull(41)) instrument.REMARK = reader.GetString(41);
                if (!reader.IsDBNull(42)) instrument.AUDITINGSTATE = reader.GetInt32(42);
                if (!reader.IsDBNull(43)) instrument.ASSESSOR = reader.GetString(43);
                if (!reader.IsDBNull(44)) instrument.AUDITINGDATE = reader.GetDateTime(44);

                if (!reader.IsDBNull(45)) instrument.RollCall = reader.GetInt64(45);
                if (!reader.IsDBNull(46)) instrument.OringalId = reader.GetInt32(46);
                if (!reader.IsDBNull(47)) instrument.Gather = reader.GetInt32(47);

                reader.Close();
                return instrument;
            }
            else
            {
                if (reader != null && !reader.IsClosed)
                    reader.Close();

                return null;
            }
        }